ia64/xen-unstable

changeset 19667:241607f414c8

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>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 28 10:02:57 2009 +0100 (2009-05-28)
parents 8bf58f09e45a
children 56d00bbc21e2
files tools/blktap2/Makefile tools/blktap2/daemon/Makefile tools/blktap2/daemon/lib/Makefile tools/blktap2/drivers/Makefile tools/blktap2/lvm/Makefile tools/blktap2/vhd/Makefile tools/blktap2/vhd/lib/Makefile
line diff
     1.1 --- a/tools/blktap2/Makefile	Thu May 28 10:00:55 2009 +0100
     1.2 +++ b/tools/blktap2/Makefile	Thu May 28 10:02:57 2009 +0100
     1.3 @@ -11,24 +11,8 @@ SUBDIRS-y += vhd
     1.4  SUBDIRS-y += drivers
     1.5  SUBDIRS-y += daemon
     1.6  
     1.7 -.PHONY: all
     1.8 -all: build
     1.9 -
    1.10 -.PHONY: build
    1.11 -build:
    1.12 -	@set -e; for subdir in $(SUBDIRS-y); do \
    1.13 -	$(MAKE) -C $$subdir all;       \
    1.14 -		done
    1.15 -
    1.16 -.PHONY: install
    1.17 -install:
    1.18 -	@set -e; for subdir in $(SUBDIRS-y); do \
    1.19 -		$(MAKE) -C $$subdir install; \
    1.20 -	done
    1.21 -
    1.22 -.PHONY: clean
    1.23  clean:
    1.24  	rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) TAGS
    1.25 -	@set -e; for subdir in $(SUBDIRS-y); do \
    1.26 -	$(MAKE) -C $$subdir clean;       \
    1.27 -		done
    1.28 +
    1.29 +.PHONY: all clean install
    1.30 +all clean install: %: subdirs-%
     2.1 --- a/tools/blktap2/daemon/Makefile	Thu May 28 10:00:55 2009 +0100
     2.2 +++ b/tools/blktap2/daemon/Makefile	Thu May 28 10:02:57 2009 +0100
     2.3 @@ -2,11 +2,12 @@ XEN_ROOT=../../../
     2.4  BLKTAP_ROOT := ..
     2.5  include $(XEN_ROOT)/tools/Rules.mk
     2.6  
     2.7 +SUBDIRS-y    :=
     2.8 +SUBDIRS-y    += lib
     2.9 +
    2.10  IBIN          = blktapctrl
    2.11  INST_DIR      = $(SBINDIR)
    2.12  
    2.13 -LIBDIR        = lib
    2.14 -
    2.15  LIBS         := -lxenstore
    2.16  LIBS         += -Llib
    2.17  LIBS         += -lblktap
    2.18 @@ -31,25 +32,20 @@ CFLAGS       += -g
    2.19  CFLAGS       += -Wp,-MD,.$(@F).d
    2.20  DEPS          = .*.d
    2.21  
    2.22 -all: libblktap $(IBIN)
    2.23 +all: $(IBIN)
    2.24  
    2.25 -blktapctrl: tapdisk-daemon.c $(OBJS)
    2.26 -	$(CC) $(CFLAGS) -o blktapctrl tapdisk-daemon.c $(LIBS) $(OBJS)
    2.27 -
    2.28 -libblktap:
    2.29 -	@set -e
    2.30 -	$(MAKE) -C $(LIBDIR) all
    2.31 +blktapctrl: tapdisk-daemon.c $(OBJS) subdir-all-lib
    2.32 +	$(CC) $(CFLAGS) -o blktapctrl tapdisk-daemon.c $(LDFLAGS) $(LIBS) $(OBJS)
    2.33  
    2.34  install: all
    2.35 -	$(MAKE) -C $(LIBDIR) install
    2.36  	$(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
    2.37  	$(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR)
    2.38  
    2.39  clean:
    2.40 -	$(MAKE) -C $(LIBDIR) clean
    2.41  	rm -rf *.o *~ $(IBIN) $(DEPS) xen TAGS
    2.42  
    2.43 -.PHONY: all clean install blktapctrl libblktap
    2.44 +.PHONY: all clean install blktapctrl
    2.45 +all clean install: %: subdirs-%
    2.46  
    2.47  -include $(DEPS)
    2.48  
     3.1 --- a/tools/blktap2/daemon/lib/Makefile	Thu May 28 10:00:55 2009 +0100
     3.2 +++ b/tools/blktap2/daemon/lib/Makefile	Thu May 28 10:02:57 2009 +0100
     3.3 @@ -55,7 +55,7 @@ clean:
     3.4  
     3.5  libblktap.a: $(OBJS) 
     3.6  	$(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,$(SONAME) $(SHLIB_CFLAGS) \
     3.7 -	      -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS)
     3.8 +	      $(LDFLAGS) -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS)
     3.9  	ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR)
    3.10  	ln -sf libblktap.so.$(MAJOR) libblktap.so
    3.11  	$(AR) rc $@ libblktap.so
     4.1 --- a/tools/blktap2/drivers/Makefile	Thu May 28 10:00:55 2009 +0100
     4.2 +++ b/tools/blktap2/drivers/Makefile	Thu May 28 10:02:57 2009 +0100
     4.3 @@ -72,28 +72,28 @@ BLK-OBJS-y  += aes.o
     4.4  all: $(IBIN) lock-util qcow-util
     4.5  
     4.6  tapdisk: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk.c
     4.7 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS)  $(LDFLAGS_img)
     4.8 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS)  $(LDFLAGS_img)
     4.9  
    4.10  tapdisk2: $(TAP-OBJS-y) $(BLK-OBJS-y) $(MISC-OBJS-y) tapdisk2.c
    4.11 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img)
    4.12 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img)
    4.13  
    4.14  tapdisk-client: tapdisk-client.o
    4.15 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)  $(LDFLAGS_img)
    4.16 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LDFLAGS_img)
    4.17  
    4.18  tapdisk-stream tapdisk-diff: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
    4.19 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS)  $(LDFLAGS_img)
    4.20 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS)  $(LDFLAGS_img)
    4.21  
    4.22  td-util: td.o tapdisk-utils.o tapdisk-log.o
    4.23 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)  $(LDFLAGS_img)
    4.24 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)  $(LDFLAGS_img)
    4.25  
    4.26  lock-util: lock.c
    4.27 -	$(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LIBS)
    4.28 +	$(CC) $(CFLAGS) -DUTIL -o lock-util lock.c $(LDFLAGS) $(LIBS)
    4.29  
    4.30  .PHONY: qcow-util
    4.31  qcow-util: img2qcow qcow2raw qcow-create
    4.32  
    4.33  img2qcow qcow2raw qcow-create: %: %.o $(TAP-OBJS-y) $(BLK-OBJS-y)
    4.34 -	$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(AIOLIBS) $(LDFLAGS_img)
    4.35 +	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(AIOLIBS) $(LDFLAGS_img)
    4.36  
    4.37  install: all
    4.38  	$(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
     5.1 --- a/tools/blktap2/lvm/Makefile	Thu May 28 10:00:55 2009 +0100
     5.2 +++ b/tools/blktap2/lvm/Makefile	Thu May 28 10:02:57 2009 +0100
     5.3 @@ -28,7 +28,7 @@ build: $(TEST) $(LVM-OBJS)
     5.4  install: all
     5.5  
     5.6  lvm-util: lvm-util.o
     5.7 -	$(CC) $(CFLAGS) -DLVM_UTIL -o lvm-util lvm-util.c
     5.8 +	$(CC) $(CFLAGS) -DLVM_UTIL $(LDFLAGS) -o lvm-util lvm-util.c
     5.9  
    5.10  clean:
    5.11  	rm -rf *.o *~ $(DEPS) $(IBIN)
     6.1 --- a/tools/blktap2/vhd/Makefile	Thu May 28 10:00:55 2009 +0100
     6.2 +++ b/tools/blktap2/vhd/Makefile	Thu May 28 10:02:57 2009 +0100
     6.3 @@ -2,11 +2,12 @@ XEN_ROOT=../../../
     6.4  BLKTAP_ROOT := ../
     6.5  include $(XEN_ROOT)/tools/Rules.mk
     6.6  
     6.7 +SUBDIRS-y         :=
     6.8 +SUBDIRS-y         += lib
     6.9 +
    6.10  IBIN               = vhd-util vhd-update
    6.11  INST_DIR           = $(SBINDIR)
    6.12  
    6.13 -LIBDIR             = lib
    6.14 -
    6.15  CFLAGS            += -Werror
    6.16  CFLAGS            += -Wno-unused
    6.17  CFLAGS            += -I../include
    6.18 @@ -20,7 +21,7 @@ ifeq ($(VHD_STATIC),y)
    6.19  CFLAGS            += -static
    6.20  endif
    6.21  
    6.22 -LIBS              := -L$(LIBDIR) -lvhd
    6.23 +LIBS              := -Llib -lvhd
    6.24  LIBS              += -luuid
    6.25  
    6.26  # Get gcc to generate the dependencies for us.
    6.27 @@ -29,27 +30,22 @@ DEPS               = .*.d
    6.28  
    6.29  all: build
    6.30  
    6.31 -build: libvhd $(IBIN)
    6.32 +build: $(IBIN)
    6.33  
    6.34 -libvhd:
    6.35 -	@set -e
    6.36 -	$(MAKE) -C $(LIBDIR) all
    6.37 +vhd-util: vhd-util.o subdir-all-lib
    6.38 +	$(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LDFLAGS) $(LIBS)
    6.39  
    6.40 -vhd-util: vhd-util.o
    6.41 -	$(CC) $(CFLAGS) -o vhd-util vhd-util.o $(LIBS)
    6.42 -
    6.43 -vhd-update: vhd-update.o
    6.44 -	$(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LIBS)
    6.45 +vhd-update: vhd-update.o subdir-all-lib
    6.46 +	$(CC) $(CFLAGS) -o vhd-update vhd-update.o $(LDFLAGS) $(LIBS)
    6.47  
    6.48  install: all
    6.49 -	$(MAKE) -C $(LIBDIR) install
    6.50  	$(INSTALL_DIR) -p $(DESTDIR)$(INST_DIR)
    6.51  	$(INSTALL_PROG) $(IBIN) $(DESTDIR)$(INST_DIR)
    6.52  
    6.53  clean:
    6.54 -	$(MAKE) -C $(LIBDIR) clean
    6.55  	rm -rf *.o *~ $(DEPS) $(IBIN)
    6.56  
    6.57 -.PHONY: all build clean install libvhd vhd-util vhd-update
    6.58 +.PHONY: all build clean install vhd-util vhd-update
    6.59 +all clean install: %: subdirs-%
    6.60  
    6.61  -include $(DEPS)
     7.1 --- a/tools/blktap2/vhd/lib/Makefile	Thu May 28 10:00:55 2009 +0100
     7.2 +++ b/tools/blktap2/vhd/lib/Makefile	Thu May 28 10:02:57 2009 +0100
     7.3 @@ -54,7 +54,7 @@ build: $(LIBVHD-BUILD)
     7.4  
     7.5  libvhd.a: $(LIB-OBJS)
     7.6  	$(CC) $(CFLAGS) -Wl,$(SONAME_LDFLAG),$(LIBVHD-SONAME) $(SHLIB_CFLAGS) \
     7.7 -		-o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) $^
     7.8 +		$(LDFLAGS) -o libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) $(LIBS) $^
     7.9  	ln -sf libvhd.so.$(LIBVHD-MAJOR).$(LIBVHD-MINOR) libvhd.so.$(LIBVHD-MAJOR)
    7.10  	ln -sf libvhd.so.$(LIBVHD-MAJOR) libvhd.so
    7.11  	$(AR) rc $@ $^