@@ -1,25 +1,18 @@
-include $(XEN_ROOT)/tools/Rules.mk
-
-CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
-CFLAGS += -Werror -D_GNU_SOURCE
-LDFLAGS += -L../common/
-
-PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
-
-FSDIR = $(libdir)/xenfsimage
+include $(XEN_ROOT)/tools/libfsimage/common.mk
FSLIB = fsimage.so
+TARGETS += $(FSLIB)
-.PHONY: fs-all
-fs-all: $(FSLIB)
+.PHONY: all
+all: $(TARGETS)
-.PHONY: fs-install
-fs-install: fs-all
+.PHONY: install
+install: all
$(INSTALL_DIR) $(DESTDIR)$(FSDIR)/$(FS)
$(INSTALL_PROG) $(FSLIB) $(DESTDIR)$(FSDIR)/$(FS)
-.PHONY: fs-uninstall
-fs-uninstall:
+.PHONY: uninstall
+uninstall:
rm -f $(addprefix $(DESTDIR)$(FSDIR)/$(FS)/, $(FSLIB))
if [ -d $(DESTDIR)$(FSDIR)/$(FS) ]; then \
rmdir $(DESTDIR)$(FSDIR)/$(FS); \
@@ -28,7 +21,4 @@ fs-uninstall:
$(FSLIB): $(PIC_OBJS)
$(CC) $(LDFLAGS) $(SHLIB_LDFLAGS) -o $@ $^ -lxenfsimage $(FS_LIBDEPS) $(APPEND_LDFLAGS)
-clean distclean::
- rm -f $(PIC_OBJS) $(FSLIB) $(DEPS_RM)
-
-include $(DEPS_INCLUDE)
new file mode 100644
@@ -0,0 +1,11 @@
+include $(XEN_ROOT)/tools/Rules.mk
+
+FSDIR := $(libdir)/xenfsimage
+CFLAGS += -Wno-unknown-pragmas -I$(XEN_ROOT)/tools/libfsimage/common/ -DFSIMAGE_FSDIR=\"$(FSDIR)\"
+CFLAGS += -Werror -D_GNU_SOURCE
+LDFLAGS += -L../common/
+
+PIC_OBJS = $(patsubst %.c,%.opic,$(LIB_SRCS-y))
+
+clean distclean::
+ rm -f $(PIC_OBJS) $(TARGETS) $(DEPS_RM)
@@ -1,5 +1,5 @@
XEN_ROOT = $(CURDIR)/../../..
-include $(XEN_ROOT)/tools/libfsimage/Rules.mk
+include $(XEN_ROOT)/tools/libfsimage/common.mk
MAJOR = 4.16
MINOR = 0
@@ -13,12 +13,10 @@ LDFLAGS += $(PTHREAD_LDFLAGS)
LIB_SRCS-y = fsimage.c fsimage_plugin.c fsimage_grub.c
-PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
-
-LIB = libxenfsimage.so libxenfsimage.so.$(MAJOR) libxenfsimage.so.$(MAJOR).$(MINOR)
+TARGETS = libxenfsimage.so libxenfsimage.so.$(MAJOR) libxenfsimage.so.$(MAJOR).$(MINOR)
.PHONY: all
-all: $(LIB)
+all: $(TARGETS)
.PHONY: install
install: all
@@ -40,9 +38,6 @@ uninstall:
rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR)
rm -f $(DESTDIR)$(libdir)/libxenfsimage.so.$(MAJOR).$(MINOR)
-clean distclean::
- rm -f $(LIB)
-
libxenfsimage.so: libxenfsimage.so.$(MAJOR)
ln -sf $< $@
libxenfsimage.so.$(MAJOR): libxenfsimage.so.$(MAJOR).$(MINOR)
@@ -9,13 +9,4 @@ FS_LIBDEPS = $(EXTFS_LIBS)
# Include configure output (config.h)
CFLAGS += -include $(XEN_ROOT)/tools/config.h
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_ext2fs.c
FS = ext2fs
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_fat.c
FS = fat
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,15 +4,4 @@ LIB_SRCS-y = fsys_iso9660.c
FS = iso9660
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
-fsys_iso9660.c: iso9660.h
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_reiserfs.c
FS = reiserfs
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_ufs.c
FS = ufs
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -4,13 +4,4 @@ LIB_SRCS-y = fsys_xfs.c
FS = xfs
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
@@ -28,13 +28,4 @@ LIB_SRCS-y = zfs_lzjb.c zfs_sha256.c zfs_fletcher.c fsi_zfs.c fsys_zfs.c
FS = zfs
-.PHONY: all
-all: fs-all
-
-.PHONY: install
-install: fs-install
-
-.PHONY: uninstall
-uninstall: fs-uninstall
-
include $(XEN_ROOT)/tools/libfsimage/Rules.mk
Remove the need for "fs-*" targets by creating a "common.mk" which have flags that are common to libfsimage/common/ and the other libfsimages/*/ directories. In common.mk, make $(PIC_OBJS) a recursively expanded variable so it doesn't matter where $(LIB_SRCS-y) is defined, and remove the extra $(PIC_OBJS) from libfsimage/common/Makefile. Use a $(TARGETS) variable to list things to be built. And $(TARGETS) can be use in the clean target in common.mk. iso9660/: Remove the explicit dependency between fsys_iso9660.c and iso9660.h, this is handled automaticaly by the .*.d dependency files, and iso9660.h already exist. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- tools/libfsimage/Rules.mk | 26 ++++++++------------------ tools/libfsimage/common.mk | 11 +++++++++++ tools/libfsimage/common/Makefile | 11 +++-------- tools/libfsimage/ext2fs-lib/Makefile | 9 --------- tools/libfsimage/ext2fs/Makefile | 9 --------- tools/libfsimage/fat/Makefile | 9 --------- tools/libfsimage/iso9660/Makefile | 11 ----------- tools/libfsimage/reiserfs/Makefile | 9 --------- tools/libfsimage/ufs/Makefile | 9 --------- tools/libfsimage/xfs/Makefile | 9 --------- tools/libfsimage/zfs/Makefile | 9 --------- 11 files changed, 22 insertions(+), 100 deletions(-) create mode 100644 tools/libfsimage/common.mk