summaryrefslogtreecommitdiff
path: root/make.tmpl.in
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-08-01 00:01:07 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2017-08-01 11:53:30 +0200
commit2232e82d25382f499adf83cbc7525b281f4f8b92 (patch)
tree4a7d7a8bc5f6ead08758e6030f7fda49dd69ce49 /make.tmpl.in
parent918e867abe6a455a401346744820d9e54a977749 (diff)
downloadlvm2-2232e82d25382f499adf83cbc7525b281f4f8b92.tar.gz
makefiles: fixing linking
Avoid adding -g more then once for debug builds. Avoid enabling DEBUG_MEM when we build multithreaded tools. Link executables with -fPIE -pie and --export-dynamic LDFLAGS Introduce PROGS_FLAGS to add option to pass flags for external libs. Link lvm2 internally library only when really used. Link DAEMON_LIBS with daemons. Pass VALGRIND_CFLAGS internally Set shell failure mode on couple places.
Diffstat (limited to 'make.tmpl.in')
-rw-r--r--make.tmpl.in29
1 files changed, 21 insertions, 8 deletions
diff --git a/make.tmpl.in b/make.tmpl.in
index 102079ef4..3a09a10c6 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -57,12 +57,12 @@ STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
DEFS += @DEFS@
# FIXME set this only where it's needed, not globally?
CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
-LDFLAGS ?= @COPTIMISE_FLAG@ @LDFLAGS@
+LDFLAGS ?= @LDFLAGS@
CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
LIB_SUFFIX = @LIB_SUFFIX@
-LVMINTERNAL_LIBS = -llvm-internal $(DAEMON_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
+LVMINTERNAL_LIBS = -llvm-internal $(DMEVENT_LIBS) $(DAEMON_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
DL_LIBS = @DL_LIBS@
M_LIBS = @M_LIBS@
PTHREAD_LIBS = @PTHREAD_LIBS@
@@ -235,12 +235,25 @@ ifeq (,$(findstring fPIC,$(CFLAGS)))
CFLAGS += -fPIC
ifeq ("@DEBUG@", "yes")
- CFLAGS += -g -fno-omit-frame-pointer
+ifeq (,$(findstring -g,$(CFLAGS)))
+ CFLAGS += -g
+endif
+ CFLAGS += -fno-omit-frame-pointer
DEFS += -DDEBUG
# memory debugging is not thread-safe yet
ifneq ("@DMEVENTD@", "yes")
+ ifneq ("@DMFILEMAPD@", "yes")
+ ifneq ("@LVMLOCKD@", "yes")
+ ifneq ("@LVMPOLLD@", "yes")
+ ifneq ("@LVMETAD@", "yes")
+ ifneq ("@CLVMD@", "yes")
DEFS += -DDEBUG_MEM
endif
+ endif
+ endif
+ endif
+ endif
+ endif
endif
# end of fPIC protection
@@ -254,6 +267,7 @@ LDFLAGS += -L$(top_builddir)/libdaemon/client
CLDFLAGS += -L$(top_builddir)/libdaemon/client
ifeq ("@DMEVENTD@", "yes")
+ DMEVENT_LIBS = -ldevmapper-event
LDFLAGS += -L$(top_builddir)/daemons/dmeventd
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd
endif
@@ -420,14 +434,13 @@ endif
.LIBPATTERNS = lib%.so lib%.a
%.o: %.c
- $(CC) -c $(INCLUDES) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
+ $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
%.o: %.cpp
- $(CXX) -c $(INCLUDES) $(DEFS) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@
+ $(CXX) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(DEFS) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@
%.pot: %.c Makefile
- $(CC) -E $(INCLUDES) $(BLKID_CFLAGS) $(VALGRIND_CFLAGS) $(UDEV_CFLAGS) -include $(top_builddir)/include/pogen.h \
- $(DEFS) $(WFLAGS) $(CFLAGS) $< > $@
+ $(CC) -E $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) -include $(top_builddir)/include/pogen.h $(DEFS) $(WFLAGS) $(CFLAGS) $< >$@
%.so: %.o
$(CC) -c $(CFLAGS) $(CLDFLAGS) $< $(LIBS) -o $@
@@ -477,7 +490,7 @@ $(LIB_STATIC): $(OBJECTS)
set -e; \
FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
- $(CC) -MM $(INCLUDES) $(BLKID_CFLAGS) $(VALGRIND_CFLAGS) $(UDEV_CFLAGS) $(DEFS) -o $@ $<; \
+ $(CC) -MM $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) -o $@ $<; \
sed -i "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" $@; \
DEPLIST=`sed 's/ \\\\//;s/.*://;' < $@`; \
echo $$DEPLIST | fmt -1 | sed 's/ //g;s/\(.*\)/\1:/' >> $@; \