use compiler determined by configure instead of hard-coded ones
Subsystems (2)
PATCH 1/7 use compiler determined by configure instead of hard-coded ones
From: "Lan Yixun (dlan)" <[email protected]>
the logic here is:
if user pass compiler variable, then use it, otherwise fallback to default value
this will provide most flexibility, so user can set this variable it would be even useful for cross-compile environment.
--- Makefile.conf.in | 3 +++ Makefile.rules | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-)
Makefile.conf.in +3 -0
@@ -109,3 +109,6 @@ initdir = @initdir@ # Location of systemd unit files systemddir = @systemddir@ + +# Use the compiler determined by configure instead of hard-coded ones +CC := @CC@
Makefile.rules +4 -4
@@ -38,10 +38,10 @@ STRIP = strip --strip-debug endif endif -CC = gcc -CXX = g++ -CXXFLAGS = $(CFLAGS) -LD = ld +CC ?= gcc +CXX ?= g++ +CXXFLAGS ?= $(CFLAGS) +LD ?= ld SOLDFLAGS = -shared CFLAGS += -D_REENTRANT -D_FILE_OFFSET_BITS=64
Signature · 1 line
1.8.3.2
PATCH 2/7 remove hard-coded CFLAGS, LDFLAGS
From: "Lan Yixun (dlan)" <[email protected]>
according to autoconf manual[1], build script should allow user override the CFLAGS, LDFLAGS varible (passed via ./configure). And actually, we should not directly use CFLAGS, LDFLAGS, but have to create another one (eg. AUTOFS_CFLAGS). FYI, see section "Variable: CFLAGS", the last paragraph.
Here, I slightly modify the code so that we can still fallback to the default one.
--- Makefile.rules | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Makefile.rules +6 -6
@@ -24,17 +24,17 @@ endif ifdef DEBUG CFLAGS ?= -g -Wall -DDEBUG -LDFLAGS = -g -STRIP = : +LDFLAGS ?= -g +STRIP ?= : else ifdef DONTSTRIP CFLAGS ?= -O2 -g -LDFLAGS = -g -STRIP = : +LDFLAGS ?= -g +STRIP ?= : else CFLAGS ?= -O2 -Wall -LDFLAGS = -s -STRIP = strip --strip-debug +LDFLAGS ?= -s +STRIP ?= strip --strip-debug endif endif
Signature · 1 line
1.8.3.2
PATCH 3/7 variable "-lpthread" should put into LIBS, not LDFLAGS
In reply to Lan Yixun (dlan)From: "Lan Yixun (dlan)" <[email protected]>
quote:
"Don't use this variable to pass library names (-l) to the linker; use LIBS instead."
see the section "Variable: LDFLAGS"
--- Makefile.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.rules +1 -1
@@ -45,7 +45,7 @@ LD ?= ld SOLDFLAGS = -shared CFLAGS += -D_REENTRANT -D_FILE_OFFSET_BITS=64 -LDFLAGS += -lpthread +LIBS += -lpthread ifdef TIRPCLIB CFLAGS += -I/usr/include/tirpc
Signature · 1 line
1.8.3.2
PATCH 4/7 library should pass via variable $(LIBS), not $(LDFLAGS)
In reply to Lan Yixun (dlan)From: "Lan Yixun (dlan)" <[email protected]>
--- Makefile.rules | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Makefile.rules +5 -3
@@ -49,13 +49,15 @@ LIBS += -lpthread ifdef TIRPCLIB CFLAGS += -I/usr/include/tirpc -LDFLAGS += $(TIRPCLIB) +LIBS += $(TIRPCLIB) endif ifdef DMALLOCLIB -LDFLAGS += $(DMALLOCLIB) +LIBS += $(DMALLOCLIB) endif +LIBS += $(LIBNSL) + # Standard rules .SUFFIXES: .c .o .s .so
@@ -67,5 +69,5 @@ endif $(CC) $(CFLAGS) -S $< .c.so: - $(CC) $(SOLDFLAGS) $(CFLAGS) -o $*.so $< $(AUTOFS_LIB) $(DMALLOCLIB) $(LIBNSL) + $(CC) $(SOLDFLAGS) $(CFLAGS) -o $*.so $< $(AUTOFS_LIB) $(LIBS) $(STRIP) $*.so
Signature · 1 line
1.8.3.2
PATCH 5/7 use += to accumulate the LIBS, otherwise we may lost early set
In reply to Lan Yixun (dlan)From: "Lan Yixun (dlan)" <[email protected]>
--- daemon/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
daemon/Makefile +1 -1
@@ -20,7 +20,7 @@ CFLAGS += -DAUTOFS_FIFO_DIR=\"$(autofsfifodir)\" CFLAGS += -DAUTOFS_FLAG_DIR=\"$(autofsflagdir)\" CFLAGS += -DVERSION_STRING=\"$(version)\" LDFLAGS += -rdynamic -LIBS = -ldl +LIBS += -ldl ifeq ($(LDAP), 1) CFLAGS += $(XML_FLAGS)
Signature · 1 line
1.8.3.2
PATCH 6/7 allow user to pass LDFLAGS via ./configure
In reply to Lan Yixun (dlan)From: "Lan Yixun (dlan)" <[email protected]>
--- Makefile.rules | 2 +- modules/Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
Makefile.rules +1 -1
@@ -69,5 +69,5 @@ LIBS += $(LIBNSL) $(CC) $(CFLAGS) -S $< .c.so: - $(CC) $(SOLDFLAGS) $(CFLAGS) -o $*.so $< $(AUTOFS_LIB) $(LIBS) + $(CC) $(LDFLAGS) $(SOLDFLAGS) $(CFLAGS) -o $*.so $< $(AUTOFS_LIB) $(LIBS) $(STRIP) $*.so
modules/Makefile +3 -3
@@ -98,7 +98,7 @@ endif # Ad hoc compilation rules for modules which need auxilliary libraries # lookup_hesiod.so: lookup_hesiod.c - $(CC) $(SOLDFLAGS) $(CFLAGS) $(HESIOD_FLAGS) -o lookup_hesiod.so \ + $(CC) $(LDFLAGS) $(SOLDFLAGS) $(CFLAGS) $(HESIOD_FLAGS) -o lookup_hesiod.so \ lookup_hesiod.c $(AUTOFS_LIB) $(LIBHESIOD) $(LIBRESOLV) $(STRIP) lookup_hesiod.so
@@ -109,13 +109,13 @@ cyrus-sasl-extern.o: cyrus-sasl-extern.c $(CC) $(CFLAGS) $(LDAP_FLAGS) -c $< lookup_ldap.so: lookup_ldap.c dclist.o base64.o $(SASL_OBJ) - $(CC) $(SOLDFLAGS) $(CFLAGS) $(LDAP_FLAGS) -o lookup_ldap.so \ + $(CC) $(LDFLAGS) $(SOLDFLAGS) $(CFLAGS) $(LDAP_FLAGS) -o lookup_ldap.so \ lookup_ldap.c dclist.o base64.o $(SASL_OBJ) \ $(AUTOFS_LIB) $(LIBLDAP) $(LIBRESOLV) $(STRIP) lookup_ldap.so mount_nfs.so: mount_nfs.c replicated.o - $(CC) $(SOLDFLAGS) $(CFLAGS) -o mount_nfs.so \ + $(CC) $(LDFLAGS) $(SOLDFLAGS) $(CFLAGS) -o mount_nfs.so \ mount_nfs.c replicated.o $(AUTOFS_LIB) $(LIBNSL) $(TIRPCLIB) $(STRIP) mount_nfs.so
Signature · 1 line
1.8.3.2
PATCH 7/7 unbundle NOTSTRIP from DEBUG, so they won't depend on each other
In reply to Lan Yixun (dlan)From: "Lan Yixun (dlan)" <[email protected]>
gentoo build system expects unstripped elf image from the build system, seperate this, will allow us to better control the strip operation.
--- Makefile.rules | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Makefile.rules +4 -6
@@ -25,18 +25,16 @@ endif ifdef DEBUG CFLAGS ?= -g -Wall -DDEBUG LDFLAGS ?= -g -STRIP ?= : else +CFLAGS ?= -O2 -Wall +LDFLAGS ?= -s +endif + ifdef DONTSTRIP -CFLAGS ?= -O2 -g -LDFLAGS ?= -g STRIP ?= : else -CFLAGS ?= -O2 -Wall -LDFLAGS ?= -s STRIP ?= strip --strip-debug endif -endif CC ?= gcc CXX ?= g++
Signature · 1 line
1.8.3.2