From c2b7d77784beeae5f86f19e33ba3da5ddce55898 Mon Sep 17 00:00:00 2001 From: Sam James Date: Tue, 18 Jan 2022 13:30:14 +0000 Subject: build: respect environment options more (#1392) * build: update m4/ax_pthread.m4 from serial 23 -> serial 31 Update ax_pthread.m4 to the latest version from the autoconf-archive project. Signed-off-by: Sam James * build: properly detect AR, CC, RANLIB It's necessary to be able to override choice of AR/CC/RANLIB and other toolchain variables/tools for cross-compilation, testing with other toolchains, and to ensure the compiler chosen by the user is actually used for the build. Previously, GNU_PREFIX was kind-of used for this but this isn't a standard variable (at all) and it wasn't applied consistently anyway. We now use the standard autoconf mechanisms for finding these tools. (RANLIB is already covered by LT_INIT.) Signed-off-by: Sam James * build: use $(MAKE) This ensures that parallel make works correctly, as otherwise, a fresh make job will be started without the jobserver fd, and hence not know about its parent, forcing -j1. * build: respect CPPFLAGS, LDFLAGS - CPPFLAGS is for the C preprocessor (usually for setting defines) - LDFLAGS should be placed before objects for certain flags to work (e.g. -Wl,--as-needed) Signed-off-by: Sam James Co-authored-by: Luca Deri --- src/lib/Makefile.in | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 56b9628c0..e3a3f9a9a 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -5,17 +5,18 @@ # cd src/lib # make Makefile # - +AR = @AR@ +CC = @CC@ +RANLIB = @RANLIB@ # # Installation directories # prefix = @prefix@ libdir = ${prefix}/lib includedir = ${prefix}/include/ndpi -CC = @GNU_PREFIX@@CC@ CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@ -LDFLAGS = @LDFLAGS@ @ADDITIONAL_LIBS@ @LIBS@ -RANLIB = @GNU_PREFIX@ranlib +LDFLAGS = @LDFLAGS@ +LIBS = @ADDITIONAL_LIBS@ @LIBS@ OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) $(patsubst ./%.c, ./%.o, $(wildcard ./*.c)) HEADERS = $(wildcard ../include/*.h) @@ -47,16 +48,16 @@ all: $(NDPI_LIBS) ndpi_main.c: ndpi_content_match.c.inc $(NDPI_LIB_STATIC): $(OBJECTS) - @GNU_PREFIX@ar rc $@ $(OBJECTS) + $(AR) rc $@ $(OBJECTS) $(RANLIB) $@ $(NDPI_LIB_SHARED): $(OBJECTS) - $(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(OBJECTS) $(LDFLAGS) + $(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(LDFLAGS) $(OBJECTS) $(LIBS) ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE) ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) %.o: %.c $(HEADERS) Makefile - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ clean: /bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo libndpi.so* -- cgit v1.2.3