From 8a5f846f83556370f8c69b8573ebd7ceb01653f7 Mon Sep 17 00:00:00 2001 From: Niranjan Pendharkar Date: Fri, 8 Feb 2013 14:09:13 -0800 Subject: brctl: Add Android makefiles to build on Android This patch adds makefiles to build this open source tool on Android. This patch also addresses some compatibilty issues between GNU C and bionic C implementation. Change-Id: Ic35ab4f98d5f252d53e92c6cde43f0673cef9d4a --- Android.mk | 1 + brctl/Android.mk | 25 ++++++++++++++ brctl/brctl.c | 7 ++-- libbridge/Android.mk | 17 +++++++++ libbridge/config.h | 80 +++++++++++++++++++++++++++++++++++++++++++ libbridge/libbridge.h | 4 ++- libbridge/libbridge_devif.c | 5 ++- libbridge/libbridge_if.c | 4 +++ libbridge/libbridge_private.h | 2 -- 9 files changed, 137 insertions(+), 8 deletions(-) create mode 100644 Android.mk create mode 100644 brctl/Android.mk create mode 100644 libbridge/Android.mk create mode 100644 libbridge/config.h diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..5053e7d --- /dev/null +++ b/Android.mk @@ -0,0 +1 @@ +include $(call all-subdir-makefiles) diff --git a/brctl/Android.mk b/brctl/Android.mk new file mode 100644 index 0000000..04897a2 --- /dev/null +++ b/brctl/Android.mk @@ -0,0 +1,25 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:=\ + brctl_cmd.c \ + brctl_disp.c \ + brctl.c + +LOCAL_CFLAGS := -O2 -g -Wno-ignored-qualifiers +LOCAL_CFLAGS += -Wno-sign-compare -Wno-missing-field-initializers +LOCAL_CFLAGS += -DHAVE_CONFIG_H -D_U_="__attribute__((unused))" +LOCAL_CFLAGS += -DFEATURE_ANDROID + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/../libbridge/ + +LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils + +LOCAL_MODULE_TAGS := debug + +LOCAL_STATIC_LIBRARIES += libbridge + +LOCAL_MODULE := brctl + +include $(BUILD_EXECUTABLE) diff --git a/brctl/brctl.c b/brctl/brctl.c index 46ca352..87af143 100644 --- a/brctl/brctl.c +++ b/brctl/brctl.c @@ -24,7 +24,6 @@ #include "libbridge.h" #include "config.h" - #include "brctl.h" static void help() @@ -39,9 +38,9 @@ int main(int argc, char *const* argv) const struct command *cmd; int f; static const struct option options[] = { - { .name = "help", .val = 'h' }, - { .name = "version", .val = 'V' }, - { 0 } + { .name = "help", .has_arg = '0', .flag = 0, .val = 'h' }, + { .name = "version", .has_arg = '0', .flag = 0, .val = 'V' }, + { 0,0,0,0 } }; while ((f = getopt_long(argc, argv, "Vh", options, NULL)) != EOF) diff --git a/libbridge/Android.mk b/libbridge/Android.mk new file mode 100644 index 0000000..7f73ab2 --- /dev/null +++ b/libbridge/Android.mk @@ -0,0 +1,17 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:=\ + libbridge_devif.c \ + libbridge_if.c \ + libbridge_init.c \ + libbridge_misc.c + +LOCAL_CFLAGS:= -Wall -O2 -g +LOCAL_CFLAGS += -DFEATURE_ANDROID + +LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils +LOCAL_MODULE:= libbridge +LOCAL_MODULE_TAGS := optional + +include $(BUILD_STATIC_LIBRARY) diff --git a/libbridge/config.h b/libbridge/config.h new file mode 100644 index 0000000..774b9e7 --- /dev/null +++ b/libbridge/config.h @@ -0,0 +1,80 @@ +/* libbridge/config.h. Generated from config.h.in by configure. */ +/* libbridge/config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the `gethostname' function. */ +#define HAVE_GETHOSTNAME 1 + +/* Define to 1 if you have the `if_indextoname' function. */ +#define HAVE_IF_INDEXTONAME 1 + +/* Define to 1 if you have the `if_nametoindex' function. */ +#define HAVE_IF_NAMETOINDEX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "bridge-utils" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "bridge-utils 1.5" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "bridge-utils" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.5" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ diff --git a/libbridge/libbridge.h b/libbridge/libbridge.h index 39964f2..e7506e0 100644 --- a/libbridge/libbridge.h +++ b/libbridge/libbridge.h @@ -22,7 +22,9 @@ #include #include #include - +#ifdef FEATURE_ANDROID +#include +#endif /* defined in net/if.h but that conflicts with linux/if.h... */ extern unsigned int if_nametoindex (const char *__ifname); extern char *if_indextoname (unsigned int __ifindex, char *__ifname); diff --git a/libbridge/libbridge_devif.c b/libbridge/libbridge_devif.c index 1e83925..99a0de0 100644 --- a/libbridge/libbridge_devif.c +++ b/libbridge/libbridge_devif.c @@ -23,8 +23,11 @@ #include #include #include +#ifndef FEATURE_ANDROID #include - +#else +#include +#endif #include "libbridge.h" #include "libbridge_private.h" diff --git a/libbridge/libbridge_if.c b/libbridge/libbridge_if.c index 77d3f8a..3df9fd7 100644 --- a/libbridge/libbridge_if.c +++ b/libbridge/libbridge_if.c @@ -20,7 +20,11 @@ #include #include #include +#ifndef FEATURE_ANDROID #include +#else +#include +#endif #include #include "libbridge.h" diff --git a/libbridge/libbridge_private.h b/libbridge/libbridge_private.h index 99a511d..f0fe394 100644 --- a/libbridge/libbridge_private.h +++ b/libbridge/libbridge_private.h @@ -18,9 +18,7 @@ #ifndef _LIBBRIDGE_PRIVATE_H #define _LIBBRIDGE_PRIVATE_H - #include "config.h" - #include #include #include -- cgit v1.2.3