[lvm-devel] master - makefiles: protect CFLAGS

Zdenek Kabelac zkabelac at fedoraproject.org
Wed May 13 22:20:06 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6fb2552ef47200af1e9b1a987cb3edfdc8f3ee66
Commit:        6fb2552ef47200af1e9b1a987cb3edfdc8f3ee66
Parent:        a2c9ede6b38f2a454e1a18fc4cac9dd06af04972
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Wed May 13 23:43:50 2015 +0200
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Thu May 14 00:19:33 2015 +0200

makefiles: protect CFLAGS

When CFLAGS and LDFLAGS are passed into - protect them,
and avoid even recursive subdir 'extension' of them.
---
 make.tmpl.in |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/make.tmpl.in b/make.tmpl.in
index 1aae6a2..7ff61fd 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -46,11 +46,11 @@ LIBS = @LIBS@
 STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
 DEFS += @DEFS@
 # FIXME set this only where it's needed, not globally?
-CFLAGS += @CFLAGS@
+CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
+LDFLAGS ?= @COPTIMISE_FLAG@ @LDFLAGS@
 CLDFLAGS += @CLDFLAGS@
 ELDFLAGS += @ELDFLAGS@
 LDDEPS += @LDDEPS@
-LDFLAGS += @LDFLAGS@
 LIB_SUFFIX = @LIB_SUFFIX@
 LVMINTERNAL_LIBS = -llvm-internal $(DAEMON_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
 DL_LIBS = @DL_LIBS@
@@ -204,8 +204,13 @@ endif
 #WFLAGS += -pedantic -std=gnu99
 #DEFS += -DDEBUG_CRC32
 
-CFLAGS += -fPIC  @COPTIMISE_FLAG@
-LDFLAGS += @COPTIMISE_FLAG@
+#
+# Avoid recursive extension of CFLAGS
+# by checking whether CFLAGS already has fPIC string
+#
+ifeq (,$(findstring fPIC,$(CFLAGS)))
+
+CFLAGS += -fPIC
 
 ifeq ("@DEBUG@", "yes")
   CFLAGS += -g -fno-omit-frame-pointer
@@ -216,6 +221,10 @@ ifeq ("@DEBUG@", "yes")
   endif
 endif
 
+# end of fPIC protection
+endif
+
+
 ifeq ("@INTL@", "yes")
   DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
 endif




More information about the lvm-devel mailing list