Moved regex library to a makefile of its own to solve the issues with compiler warnings.
authorHenning Rogge <hrogge@googlemail.com>
Fri, 19 Oct 2012 14:16:18 +0000 (16:16 +0200)
committerHenning Rogge <hrogge@googlemail.com>
Fri, 19 Oct 2012 14:16:18 +0000 (16:16 +0200)
Makefile
android/regex/Makefile [new file with mode: 0644]
lib/nameservice/Makefile
make/Makefile.android

index dc59b69..31fde33 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -191,7 +191,6 @@ libs:
 
 libs_clean clean_libs:
                -for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) clean;rm -f lib/$$dir/*.so lib/$$dir/*.dll;done
-               -rm -f $(REGEX_OBJS)
 
 libs_install install_libs:
                @set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) install;done
@@ -307,7 +306,7 @@ mdns_uninstall:
 # nameserver uses regex, which was only recently added to Android.  On
 # Android, $(REGEX_OBJS) will have all of the files needed, on all
 # other platforms, it'll be empty and therefore ignored.
-nameservice: $(REGEX_OBJS)
+nameservice:
                @$(MAKECMD) -C lib/nameservice clean
                @$(MAKECMD) -C lib/nameservice
 
diff --git a/android/regex/Makefile b/android/regex/Makefile
new file mode 100644 (file)
index 0000000..74c7315
--- /dev/null
@@ -0,0 +1,22 @@
+SRC = regcomp.c regerror.c regexec.c regfree.c 
+OBJ = $(SRC:.c=.o)
+INCLUDES = -I. -I..
+
+CFLAGS := -O2 -D_FORTIFY_SOURCE=2
+CFLAGS += -fPIC
+
+all: $(REGEX_LIB)
+
+.c.o:
+ifeq ($(VERBOSE),0)
+       @echo "[CC] $<"
+       @$(CC) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+else
+       $(CC) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+endif
+
+$(REGEX_LIB): $(OBJ)
+       $(AR) rcs $(REGEX_LIB) $(OBJ)
+
+clean:
+       rm -f $(OBJ) $(REGEX_LIB)
index 9ba270a..3abc369 100644 (file)
@@ -51,8 +51,7 @@ ifeq ($(OS),android)
 # On Android Google forgot to include regex engine code for Froyo version (but also there was
 # no support in older versions for it) so we have here this missing code.
 # http://groups.google.com/group/android-ndk/browse_thread/thread/5ea6f0650f0e3fc
-SRCS +=     $(wildcard $(TOPDIR)/android/regex/reg*.c)
-HDRS +=     $(wildcard $(TOPDIR)/android/regex/*.h)
+OBJS +=     $(REGEX_LIB)
 CFLAGS += -D__POSIX_VISIBLE
 endif
 
@@ -69,6 +68,6 @@ install:      $(PLUGIN_FULLNAME)
 uninstall:
                $(UNINSTALL_LIB)
 
-clean:
+clean:         $(REGEX_CLEAN)
                rm -f $(OBJS) $(SRCS:%.c=%.d) $(PLUGIN_FULLNAME)
 endif
index dc56b84..340f411 100644 (file)
@@ -44,14 +44,6 @@ SHAREDIR = $(DESTDIR)$(datarootdir)
 SRCS += $(wildcard src/unix/*.c src/linux/*.c)
 HDRS += $(wildcard src/unix/*.h src/linux/*.h)
 
-# Android didn't add regex until android-8 so include this one
-REGEX_SRCS = \
-       android/regex/regcomp.c \
-       android/regex/regerror.c \
-       android/regex/regexec.c \
-       android/regex/regfree.c
-REGEX_OBJS = $(REGEX_SRCS:.c=.o)
-
 CPPFLAGS +=    -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
 # bionic libc: missing declarations
 CPPFLAGS +=    -DINET_ADDRSTRLEN=16
@@ -116,18 +108,20 @@ ifeq ($(DEBUG),0)
 STRIP = $(CROSS_COMPILE)strip
 endif
 
-
-# The Android NDK didn't add proper regex support until android-8
-# (2.2), so we include the Android files here, and build with
-# -DPOSIX_MISTAKE like Android does.
-$(REGEX_OBJS): $(REGEX_SRCS)
-       @echo "[CC] $<"
-       @$(CC) $(CFLAGS) $(CPPFLAGS) -DPOSIX_MISTAKE -c -o $@ $<
-
-regex: $(REGEX_OBJS)
-
-regex_clean:
-       rm -f $(REGEX_OBJS)
+# Android didn't add regex until android-8 so include this one
+REGEX_LIB = $(TOPDIR)/android/regex/libregex.a
+REGEX_CLEAN = regex_clean
+$(REGEX_LIB):
+       @$(MAKE) -C $(TOPDIR)/android/regex/ REGEX_LIB=$(REGEX_LIB) VERBOSE=$(VERBOSE) \
+               NDK_TOOLCHAIN_BASE="$(NDK_TOOLCHAIN_BASE)" \
+               NDK_PLATFORM_VERSION="$(NDK_PLATFORM_VERSION)" \
+               NDK_SYSROOT="$(NDK_SYSROOT)" \
+               CROSS_COMPILE="$(CROSS_COMPILE)" \
+               CC="$(CC)" LD="$(LD)" AR="$(AR)" STRIP="$(STRIP)" \
+               CPPFLAGS="$(CPPFLAGS)"
+
+$(REGEX_CLEAN):
+       @$(MAKE) -C $(TOPDIR)/android/regex/ clean REGEX_LIB=$(REGEX_LIB)
 
 # Local Variables:
 # mode: makefile