From 29abba378520a270c3a9385724c8ef5df66497b1 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 4 Jun 2018 13:22:14 +0100 Subject: [PATCH] build: get separate builddir working again --- Makefile.in | 2 +- device_mapper/Makefile | 10 +++++----- device_mapper/datastruct/bitset.c | 2 +- device_mapper/datastruct/hash.c | 2 +- device_mapper/datastruct/list.c | 2 +- device_mapper/ioctl/libdm-iface.c | 10 +++++----- device_mapper/mm/dbg_malloc.c | 2 +- device_mapper/mm/pool-fast.c | 2 +- device_mapper/mm/pool.c | 2 +- device_mapper/regex/matcher.c | 2 +- device_mapper/regex/parse_rx.c | 2 +- device_mapper/regex/ttree.c | 2 +- libdm/make.tmpl.in | 29 ++++++++++++++++++++--------- make.tmpl.in | 19 +++++++++++++------ 14 files changed, 53 insertions(+), 35 deletions(-) diff --git a/Makefile.in b/Makefile.in index 00b4f1e99..851447ec0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -213,7 +213,7 @@ endif endif include test/unit/Makefile -include device_mapper/Makefile +include $(top_srcdir)/device_mapper/Makefile ifneq ($(shell which ctags),) .PHONY: tags diff --git a/device_mapper/Makefile b/device_mapper/Makefile index 999c3babf..b246f828d 100644 --- a/device_mapper/Makefile +++ b/device_mapper/Makefile @@ -30,17 +30,17 @@ DEVICE_MAPPER_SOURCE=\ device_mapper/regex/ttree.c \ device_mapper/ioctl/libdm-iface.c -DEVICE_MAPPER_DEPENDS=$(subst .c,.d,$(DEVICE_MAPPER_SOURCE)) -DEVICE_MAPPER_OBJECTS=$(subst .c,.o,$(DEVICE_MAPPER_SOURCE)) +DEVICE_MAPPER_DEPENDS=$(addprefix $(top_builddir)/,$(subst .c,.d,$(DEVICE_MAPPER_SOURCE))) +DEVICE_MAPPER_OBJECTS=$(addprefix $(top_builddir)/,$(subst .c,.o,$(DEVICE_MAPPER_SOURCE))) CLEAN_TARGETS+=$(DEVICE_MAPPER_DEPENDS) $(DEVICE_MAPPER_OBJECTS) -include $(DEVICE_MAPPER_DEPENDS) -$(DEVICE_MAPPER_OBJECTS): INCLUDES+=-Idevice_mapper/ +$(DEVICE_MAPPER_OBJECTS): INCLUDES+=-I$(top_srcdir)/device_mapper/ -device_mapper/libdevice-mapper.a: $(DEVICE_MAPPER_OBJECTS) +$(top_builddir)/device_mapper/libdevice-mapper.a: $(DEVICE_MAPPER_OBJECTS) @echo " [AR] $@" $(Q) $(RM) $@ $(Q) $(AR) rsv $@ $(DEVICE_MAPPER_OBJECTS) > /dev/null -CLEAN_TARGETS+=device_mapper/libdevice-mapper.a +CLEAN_TARGETS+=$(top_builddir)/device_mapper/libdevice-mapper.a diff --git a/device_mapper/datastruct/bitset.c b/device_mapper/datastruct/bitset.c index 6ae99d3de..f093ac0cb 100644 --- a/device_mapper/datastruct/bitset.c +++ b/device_mapper/datastruct/bitset.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include diff --git a/device_mapper/datastruct/hash.c b/device_mapper/datastruct/hash.c index 9b9c939f4..59e719baa 100644 --- a/device_mapper/datastruct/hash.c +++ b/device_mapper/datastruct/hash.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" struct dm_hash_node { struct dm_hash_node *next; diff --git a/device_mapper/datastruct/list.c b/device_mapper/datastruct/list.c index 86c3e4ef8..bda802770 100644 --- a/device_mapper/datastruct/list.c +++ b/device_mapper/datastruct/list.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include /* diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index 4825f1d17..3e1b445a4 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -13,9 +13,9 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" -#include "libdm-targets.h" -#include "libdm-common.h" +#include "device_mapper/misc/dmlib.h" +#include "device_mapper/ioctl/libdm-targets.h" +#include "device_mapper/libdm-common.h" #include #include @@ -26,7 +26,7 @@ #include #ifdef __linux__ -# include "misc/kdev_t.h" +# include "device_mapper/misc/kdev_t.h" # include #else # define MAJOR(x) major((x)) @@ -34,7 +34,7 @@ # define MKDEV(x,y) makedev((x),(y)) #endif -#include "misc/dm-ioctl.h" +#include "device_mapper/misc/dm-ioctl.h" /* * Ensure build compatibility. diff --git a/device_mapper/mm/dbg_malloc.c b/device_mapper/mm/dbg_malloc.c index a17203c48..b169f8b26 100644 --- a/device_mapper/mm/dbg_malloc.c +++ b/device_mapper/mm/dbg_malloc.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #ifdef VALGRIND_POOL #include "memcheck.h" diff --git a/device_mapper/mm/pool-fast.c b/device_mapper/mm/pool-fast.c index 895872e4b..b83c693b9 100644 --- a/device_mapper/mm/pool-fast.c +++ b/device_mapper/mm/pool-fast.c @@ -17,7 +17,7 @@ #include "memcheck.h" #endif -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include /* For musl libc */ #include diff --git a/device_mapper/mm/pool.c b/device_mapper/mm/pool.c index a710704ae..20d7fd931 100644 --- a/device_mapper/mm/pool.c +++ b/device_mapper/mm/pool.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include #include diff --git a/device_mapper/regex/matcher.c b/device_mapper/regex/matcher.c index 375c1abdc..b3870e0f6 100644 --- a/device_mapper/regex/matcher.c +++ b/device_mapper/regex/matcher.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include "parse_rx.h" #include "ttree.h" #include "assert.h" diff --git a/device_mapper/regex/parse_rx.c b/device_mapper/regex/parse_rx.c index cc83bfe35..563d2ae1d 100644 --- a/device_mapper/regex/parse_rx.c +++ b/device_mapper/regex/parse_rx.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include "parse_rx.h" #ifdef DEBUG diff --git a/device_mapper/regex/ttree.c b/device_mapper/regex/ttree.c index 62c5bf786..27b775e0a 100644 --- a/device_mapper/regex/ttree.c +++ b/device_mapper/regex/ttree.c @@ -13,7 +13,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "misc/dmlib.h" +#include "device_mapper/misc/dmlib.h" #include "ttree.h" struct node { diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in index 7e3f4a481..b9672dc4a 100644 --- a/libdm/make.tmpl.in +++ b/libdm/make.tmpl.in @@ -58,6 +58,7 @@ PYTHON3 = @PYTHON3@ PYCOMPILE = $(top_srcdir)/autoconf/py-compile LIBS = @LIBS@ +LIBS += $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS) $(RT_LIBS) -lm # Extra libraries always linked with static binaries STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS) DEFS += @DEFS@ @@ -68,7 +69,9 @@ CLDFLAGS += @CLDFLAGS@ ELDFLAGS += @ELDFLAGS@ LDDEPS += @LDDEPS@ LIB_SUFFIX = @LIB_SUFFIX@ -LVMINTERNAL_LIBS = -llvm-internal $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS) +LVMINTERNAL_LIBS=\ + -llvm-internal \ + $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS) DL_LIBS = @DL_LIBS@ RT_LIBS = @RT_LIBS@ M_LIBS = @M_LIBS@ @@ -308,6 +311,7 @@ LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_s INCLUDES += -I$(top_srcdir) -I$(srcdir) -I$(top_builddir)/include + DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \ $(top_builddir)/Makefile @@ -338,7 +342,7 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean) TARGETS += $(LIB_SHARED) $(LIB_STATIC) -all: $(SUBDIRS) $(TARGETS) +all: $(top_builddir)/device_mapper/libdevice-mapper.a $(SUBDIRS) $(TARGETS) install: all $(SUBDIRS.install) install_cluster: all $(SUBDIRS.install_cluster) @@ -347,7 +351,7 @@ install_lvm2: $(SUBDIRS.install_lvm2) install_ocf: $(SUBDIRS.install_ocf) cflow: $(SUBDIRS.cflow) -$(SUBDIRS): $(SUBDIRS.device-mapper) +$(SUBDIRS): $(SUBDIRS.device-mapper) $(top_builddir)/device_mapper/libdevice-mapper.a $(MAKE) -C $@ $(SUBDIRS.device-mapper): @@ -440,14 +444,12 @@ endif .LIBPATTERNS = lib%.so lib%.a -DEPFLAGS=-MT $@ -MMD -MP -MF $*.d - # still needed in 2018 for 32bit builds DEFS+=-D_FILE_OFFSET_BITS=64 %.o: %.c @echo " [CC] $<" - $(Q) $(CC) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@ + $(Q) $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@ %.o: %.cpp @echo " [CXX] $<" @@ -507,9 +509,18 @@ $(LIB_STATIC): $(OBJECTS) $(Q) $(RM) $@ $(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null -%.d: -.PRECIOUS: %.d - +%.d: %.c + @echo " [DEP] $<" + $(Q) $(MKDIR_P) $(dir $@); \ + set -e; \ + FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \ + DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \ + $(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:/' >> $@; \ + [ -s $@ ] || $(RM) $@ + %.mo: %.po @echo " [MSGFMT] $<" $(Q) $(MSGFMT) -o $@ $< diff --git a/make.tmpl.in b/make.tmpl.in index 16a857121..b9672dc4a 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -444,14 +444,12 @@ endif .LIBPATTERNS = lib%.so lib%.a -DEPFLAGS=-MT $@ -MMD -MP -MF $*.d - # still needed in 2018 for 32bit builds DEFS+=-D_FILE_OFFSET_BITS=64 %.o: %.c @echo " [CC] $<" - $(Q) $(CC) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@ + $(Q) $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@ %.o: %.cpp @echo " [CXX] $<" @@ -511,9 +509,18 @@ $(LIB_STATIC): $(OBJECTS) $(Q) $(RM) $@ $(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null -%.d: -.PRECIOUS: %.d - +%.d: %.c + @echo " [DEP] $<" + $(Q) $(MKDIR_P) $(dir $@); \ + set -e; \ + FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \ + DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \ + $(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:/' >> $@; \ + [ -s $@ ] || $(RM) $@ + %.mo: %.po @echo " [MSGFMT] $<" $(Q) $(MSGFMT) -o $@ $< -- 2.43.5