WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] blktap2: fix makefile of vhd for parallel make

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] [PATCH] blktap2: fix makefile of vhd for parallel make
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Thu, 28 May 2009 14:14:15 +0900
Cc: dmeyer@xxxxxxxxx, Christoph.Egger@xxxxxxx, jake.wires@xxxxxxxxxx
Delivery-date: Wed, 27 May 2009 22:14:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090528035121.GL15873%yamahata@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090528035121.GL15873%yamahata@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6i
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@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>