Isaku Yamahata
2009-May-28 03:51 UTC
[Xen-devel] [PATCH] blktap2: fix makefile of vhd for parallel make
blktap2: fix makefile of vhd for parallel make With parallel make, libvhd might not be created before link resulting in link error. This patch guarantees it. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> diff --git a/tools/blktap2/vhd/Makefile b/tools/blktap2/vhd/Makefile --- a/tools/blktap2/vhd/Makefile +++ b/tools/blktap2/vhd/Makefile @@ -12,6 +12,9 @@ CFLAGS += -Wno-unused CFLAGS += -I../include CFLAGS += -D_GNU_SOURCE +SUBDIRS-y :+SUBDIRS-y += $(LIBDIR) + ifeq ($(CONFIG_X86_64),y) CFLAGS += -fPIC endif @@ -29,27 +32,22 @@ DEPS = .*.d all: build -build: libvhd $(IBIN) +build: $(IBIN) -libvhd: - @set -e - $(MAKE) -C $(LIBDIR) all - -vhd-util: vhd-util.o +vhd-util: vhd-util.o subdir-all-lib $(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LIBS) -vhd-update: vhd-update.o +vhd-update: vhd-update.o subdir-all-lib $(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LIBS) install: all - $(MAKE) -C $(LIBDIR) install $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR) $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR) clean: - $(MAKE) -C $(LIBDIR) clean rm -rf *.o *~ $(DEPS) $(IBIN) -.PHONY: all build clean install libvhd vhd-util vhd-update +.PHONY: all build clean install vhd-util vhd-update +all clean install: %: subdirs-% -include $(DEPS) -- yamahata _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Isaku Yamahata
2009-May-28 05:14 UTC
Re: [Xen-devel] [PATCH] blktap2: fix makefile of vhd for parallel make
Please discard the previous one. I sent the patch too early. blktap2: fix makefile of blktap2 - clean up to use SUBDIRS-y - With parallel make, libvhd might not be created before link. guarantee it. - use LDFLAGS for link which is set by upper level makefiles. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> diff --git a/tools/blktap2/Makefile b/tools/blktap2/Makefile --- a/tools/blktap2/Makefile +++ b/tools/blktap2/Makefile @@ -11,24 +11,8 @@ SUBDIRS-y += vhd SUBDIRS-y += drivers SUBDIRS-y += daemon -.PHONY: all -all: build - -.PHONY: build -build: - @set -e; for subdir in $(SUBDIRS-y); do \ - $(MAKE) -C $$subdir all; \ - done - -.PHONY: install -install: - @set -e; for subdir in $(SUBDIRS-y); do \ - $(MAKE) -C $$subdir install; \ - done - -.PHONY: clean clean: rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) TAGS - @set -e; for subdir in $(SUBDIRS-y); do \ - $(MAKE) -C $$subdir clean; \ - done + +.PHONY: all clean install +all clean install: %: subdirs-% diff --git a/tools/blktap2/daemon/Makefile b/tools/blktap2/daemon/Makefile --- a/tools/blktap2/daemon/Makefile +++ b/tools/blktap2/daemon/Makefile @@ -2,11 +2,12 @@ XEN_ROOT=../../../ BLKTAP_ROOT := .. include $(XEN_ROOT)/tools/Rules.mk +SUBDIRS-y :+SUBDIRS-y += lib + IBIN = blktapctrl INST_DIR = $(SBINDIR) -LIBDIR = lib - LIBS := -lxenstore LIBS += -Llib LIBS += -lblktap @@ -31,25 +32,20 @@ CFLAGS += -g CFLAGS += -Wp,-MD,.$(@F).d DEPS = .*.d -all: libblktap $(IBIN) +all: $(IBIN) -blktapctrl: tapdisk-daemon.c $(OBJS) - $(CC) $(CFLAGS) -o blktapctrl tapdisk-daemon.c $(LIBS) $(OBJS) - -libblktap: - @set -e - $(MAKE) -C $(LIBDIR) all +blktapctrl: tapdisk-daemon.c $(OBJS) subdir-all-lib + $(CC) $(CFLAGS) -o blktapctrl tapdisk-daemon.c $(LDFLAGS) $(LIBS) $(OBJS) install: all - $(MAKE) -C $(LIBDIR) install $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR) $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR) clean: - $(MAKE) -C $(LIBDIR) clean rm -rf *.o *~ $(IBIN) $(DEPS) xen TAGS -.PHONY: all clean install blktapctrl libblktap +.PHONY: all clean install blktapctrl +all clean install: %: subdirs-% -include $(DEPS) diff --git a/tools/blktap2/daemon/lib/Makefile b/tools/blktap2/daemon/lib/Makefile --- a/tools/blktap2/daemon/lib/Makefile +++ b/tools/blktap2/daemon/lib/Makefile @@ -55,7 +55,7 @@ clean: libblktap.a: $(OBJS) $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_CFLAGS) \ - -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS) + $(LDFLAGS) -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS) ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR) ln -sf libblktap.so.$(MAJOR) libblktap.so $(AR) rc $@ libblktap.so diff --git a/tools/blktap2/drivers/Makefile b/tools/blktap2/drivers/Makefile --- a/tools/blktap2/drivers/Makefile +++ b/tools/blktap2/drivers/Makefile @@ -72,28 +72,28 @@ BLK-OBJS-y += aes.o all: $(IBIN) lock-util qcow-util tapdisk: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk.c - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img) tapdisk2: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk2.c - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img) tapdisk-client: tapdisk-client.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LDFLAGS_img) tapdisk-stream tapdisk-diff: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y) - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img) td-util: td.o tapdisk-utils.o tapdisk-log.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LDFLAGS_img) lock-util: lock.c - $(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LIBS) + $(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LDFLAGS) $(LIBS) .PHONY: qcow-util qcow-util: img2qcow qcow2raw qcow-create img2qcow qcow2raw qcow-create: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y) - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img) install: all $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR) diff --git a/tools/blktap2/lvm/Makefile b/tools/blktap2/lvm/Makefile --- a/tools/blktap2/lvm/Makefile +++ b/tools/blktap2/lvm/Makefile @@ -28,7 +28,7 @@ build: $(TEST) $(LVM-OBJS) install: all lvm-util: lvm-util.o - $(CC) $(CFLAGS) -DLVM_UTIL -o lvm-util lvm-util.c + $(CC) $(CFLAGS) -DLVM_UTIL $(LDFLAGS) -o lvm-util lvm-util.c clean: rm -rf *.o *~ $(DEPS) $(IBIN) diff --git a/tools/blktap2/vhd/Makefile b/tools/blktap2/vhd/Makefile --- a/tools/blktap2/vhd/Makefile +++ b/tools/blktap2/vhd/Makefile @@ -2,11 +2,12 @@ XEN_ROOT=../../../ BLKTAP_ROOT := ../ include $(XEN_ROOT)/tools/Rules.mk +SUBDIRS-y :+SUBDIRS-y += lib + IBIN = vhd-util vhd-update INST_DIR = $(SBINDIR) -LIBDIR = lib - CFLAGS += -Werror CFLAGS += -Wno-unused CFLAGS += -I../include @@ -20,7 +21,7 @@ ifeq ($(VHD_STATIC),y) CFLAGS += -static endif -LIBS := -L$(LIBDIR) -lvhd +LIBS := -Llib -lvhd LIBS += -luuid # Get gcc to generate the dependencies for us. @@ -29,27 +30,22 @@ DEPS = .*.d all: build -build: libvhd $(IBIN) +build: $(IBIN) -libvhd: - @set -e - $(MAKE) -C $(LIBDIR) all +vhd-util: vhd-util.o subdir-all-lib + $(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LDFLAGS) $(LIBS) -vhd-util: vhd-util.o - $(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LIBS) - -vhd-update: vhd-update.o - $(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LIBS) +vhd-update: vhd-update.o subdir-all-lib + $(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LDFLAGS) $(LIBS) install: all - $(MAKE) -C $(LIBDIR) install $(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR) $(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR) clean: - $(MAKE) -C $(LIBDIR) clean rm -rf *.o *~ $(DEPS) $(IBIN) -.PHONY: all build clean install libvhd vhd-util vhd-update +.PHONY: all build clean install vhd-util vhd-update +all clean install: %: subdirs-% -include $(DEPS) diff --git a/tools/blktap2/vhd/lib/Makefile b/tools/blktap2/vhd/lib/Makefile --- a/tools/blktap2/vhd/lib/Makefile +++ b/tools/blktap2/vhd/lib/Makefile @@ -54,7 +54,7 @@ build: $(LIBVHD-BUILD) libvhd.a: $(LIB-OBJS) $(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_CFLAGS) \ - -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) $^ + $(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) $^ ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) libvhd.so.$(LIBVHD-MAJOR) ln -sf libvhd.so.$(LIBVHD-MAJOR) libvhd.so $(AR) rc $@ $^ -- yamahata _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Reasonably Related Threads
- [PATCH 00 of 18] [v2] tools: fix bugs and build errors triggered by -O2 -Wall -Werror
- [PATCH] tools: do not link against unused libraries
- [PATCH 0 of 8] blktap3/libvhd: Introduce VHD library.
- [PATCH] vhd-util create: add -C|nocow option
- BLKTAPCTRL[2375]: blktapctrl_linux.c:86: blktap0 open failed