Use -MMD -MF in tools/* rather than -Wp,-M...
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Jan 2009 10:16:05 +0000 (10:16 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 12 Jan 2009 10:16:05 +0000 (10:16 +0000)
If you use -MMD -MF then the correct .o filename is written to the
.*.d file as the compiler driver arranges everything.  This was done
in 19010:275abe1c5d24 for the hypervisor.

In this patch we do the same elsewhere in the xen-unstable tree,
particularly tools/.  Specifically:
 * Change tools/Rules.mk to add -MMD -MF ... to CFLAGS and set DEPS.
 * Remove -Wp,-MD... from every other Makefile
 * Remove setting of DEPS from every other Makefile
 * Ensure that every Makefile says -include $(DEPS)
 * Ensure that every Makefile's clean target removes $(DEPS)

Some Makefiles were already halfway there, but often for a different
variable name eg PROG_DEP.  The variable name is now standardised in
Rules.mk as DEPS.

I have done a test build with this change, on Debian etch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
28 files changed:
tools/Rules.mk
tools/blktap/drivers/Makefile
tools/console/Makefile
tools/firmware/hvmloader/Makefile
tools/firmware/hvmloader/acpi/Makefile
tools/firmware/rombios/32bit/Makefile
tools/firmware/rombios/32bit/tcgbios/Makefile
tools/firmware/rombios/Makefile
tools/flask/libflask/Makefile
tools/flask/loadpolicy/Makefile
tools/fs-back/Makefile
tools/libfsimage/Rules.mk
tools/libfsimage/common/Makefile
tools/libxc/Makefile
tools/misc/Makefile
tools/pygrub/Makefile
tools/python/Makefile
tools/vnet/libxutil/Makefile
tools/vtpm/Rules.mk
tools/vtpm_manager/Rules.mk
tools/xcutils/Makefile
tools/xenmon/Makefile
tools/xenpmd/Makefile
tools/xenstat/libxenstat/Makefile
tools/xenstat/xentop/Makefile
tools/xenstore/Makefile
tools/xentrace/Makefile
xen/arch/ia64/tools/p2m_foreign/Makefile

index a477c8253b9db257e8485bcc62868daad1b46518..fbd69ea215c995cefb2311ec77d0d03f7301b780 100644 (file)
@@ -29,6 +29,10 @@ X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR)
 
 CFLAGS += -D__XEN_TOOLS__
 
+# Get gcc to generate the dependencies for us.
+CFLAGS += -MMD -MF .$(@F).d
+DEPS = .*.d
+
 # Enable implicit LFS support *and* explicit LFS names.
 CFLAGS  += $(shell getconf LFS_CFLAGS)
 CFLAGS  += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
@@ -59,4 +63,3 @@ subdirs-all subdirs-clean subdirs-install: .phony
 
 subdir-all-% subdir-clean-% subdir-install-%: .phony
        $(MAKE) -C $* $(patsubst subdir-%-$*,%,$@)
-
index 7c3e088bf101e88f2023e472041a81bbf27c7bab..36af03fa2c67962d526fad74e05c4e02c5c37320 100644 (file)
@@ -13,10 +13,6 @@ CFLAGS   += $(CFLAGS_libxenstore)
 CFLAGS   += -I $(LIBAIO_DIR)
 CFLAGS   += -D_GNU_SOURCE
 
-# Get gcc to generate the dependencies for us.
-CFLAGS   += -Wp,-MD,.$(@F).d
-DEPS      = .*.d
-
 ifeq ($(shell . ./check_gcrypt),"yes")
 CFLAGS += -DUSE_GCRYPT
 CRYPT_LIB := -lgcrypt
index 10e909a0b621572096317c02c6afaae3b76dc3f3..7339e9e064d026db8a18da3bca46e649c71a343d 100644 (file)
@@ -16,7 +16,7 @@ all: $(BIN)
 
 .PHONY: clean
 clean:
-       $(RM) *.a *.so *.o *.rpm $(BIN)
+       $(RM) *.a *.so *.o *.rpm $(BIN) $(DEPS)
        $(RM) client/*.o daemon/*.o
 
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
@@ -33,3 +33,5 @@ install: $(BIN)
        $(INSTALL_PROG) xenconsoled $(DESTDIR)/$(SBINDIR)
        $(INSTALL_DIR) $(DESTDIR)$(PRIVATE_BINDIR)
        $(INSTALL_PROG) xenconsole $(DESTDIR)$(PRIVATE_BINDIR)
+
+-include $(DEPS)
index 79f641d9a22ee7fd21542289d9e23fb36a963bee..6d89269fe2de77f571254ae858726f2750be9b19 100644 (file)
@@ -58,4 +58,6 @@ roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \
 .PHONY: clean
 clean: subdirs-clean
        rm -f roms.h acpi.h
-       rm -f hvmloader hvmloader.tmp *.o
+       rm -f hvmloader hvmloader.tmp *.o $(DEPS)
+
+-include $(DEPS)
index 49245aa0890697ce02fabe131dff0f8749a01b14..e4dc4cb53f3ad93e3cf008185cd4de4949db98ea 100644 (file)
@@ -63,6 +63,8 @@ acpi.a: $(OBJS)
        $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
 
 clean:
-       rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz
+       rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
 
 install: all
+
+-include $(DEPS)
index cdad7561b9c338e760a1dbef3009a46c759bb5e3..ec8ff2c60c4cd2389ccaf6974e1c934325c77178 100644 (file)
@@ -16,7 +16,7 @@ all: subdirs-all
 
 .PHONY: clean
 clean: subdirs-clean
-       rm -rf *.o $(TARGET)
+       rm -rf *.o $(TARGET) $(DEPS)
 
 $(TARGET): 32bitbios.o $(MODULES) util.o
        $(LD) $(LDFLAGS_DIRECT) -s -r $^ -o 32bitbios_all.o
@@ -27,3 +27,5 @@ $(TARGET): 32bitbios.o $(MODULES) util.o
            exit 11;                                         \
          } || :
        sh mkhex highbios_array 32bitbios_all.o > $@
+
+-include $(DEPS)
index 1b3cf2b94a3496aead65fef88adea833042e5f81..68509c7f027d45111a85f97ec6f7b898606e7cab 100644 (file)
@@ -12,7 +12,10 @@ CFLAGS += $(CFLAGS_include) -I.. -I../.. -DGCC_PROTOS
 all: $(TARGET)
 
 clean:
-       rm -rf *.o $(TARGET)
+       rm -rf *.o $(TARGET) $(DEPS)
 
 $(TARGET): $(OBJECTS)
        $(LD) $(LDFLAGS_DIRECT) -r $^ -o $@
+
+-include $(DEPS)
+
index 8ea8cb756025454b985024459e7c87cfe8369116..8321eadd8519bb62b7eeb31875e61b6258b3d751 100644 (file)
@@ -13,6 +13,7 @@ clean: subdirs-clean
        rm -f  as86-sym.txt ld86-sym.txt 
        rm -f  rombios*.txt rombios*.sym usage biossums
        rm -f  BIOS-bochs-*
+       rm -f  $(DEPS)
 
 BIOS-bochs-latest: rombios.c biossums 32bitgateway.c tcgbios.c
        gcc -DBX_SMP_PROCESSORS=1 -E -P $< > _rombios_.c
@@ -27,3 +28,4 @@ BIOS-bochs-latest: rombios.c biossums 32bitgateway.c tcgbios.c
 biossums: biossums.c
        gcc -o biossums biossums.c
 
+-include $(DEPS)
index 8c085b929b8dc495dd5a875c65ca67ad8757975d..c03fc8aca84b0b57660a1745f828cbf949a27e62 100644 (file)
@@ -16,7 +16,6 @@ CFLAGS   += $(INCLUDES) -I./include -I$(XEN_LIBXC) -I$(XEN_INCLUDE)
 # Get gcc to generate the dependencies for us.
 CFLAGS   += -Wp,-MD,.$(@F).d
 LDFLAGS  += -L.
-DEPS     = .*.d
 
 LIB_OBJS := $(patsubst %.c,%.o,$(SRCS))
 PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
index 7c38525ba87b64987d628e88a7ce9fe64fbfbca4..8b404214c242a996d1499256113d862ba85d1774 100644 (file)
@@ -7,9 +7,6 @@ LIBFLASK_ROOT = $(XEN_ROOT)/tools/flask/libflask
 
 PROFILE=#-pg
 BASECFLAGS=-Wall -g -Werror
-# Make gcc generate dependencies.
-BASECFLAGS += -Wp,-MD,.$(@F).d
-PROG_DEP = .*.d
 BASECFLAGS+= $(PROFILE)
 #BASECFLAGS+= -I$(XEN_ROOT)/tools
 BASECFLAGS+= $(CFLAGS_libxenctrl)
@@ -39,7 +36,7 @@ $(CLIENTS_OBJS): $(CLIENTS_SRCS)
 clean: 
        rm -f *.o *.opic *.so
        rm -f $(CLIENTS)
-       $(RM) $(PROG_DEP)
+       $(RM) $(DEPS)
 
 .PHONY: print-dir
 print-dir:
@@ -54,7 +51,7 @@ install: all
        $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
        $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(SBINDIR)
 
--include $(PROG_DEP)
+-include $(DEPS)
 
 # never delete any intermediate files.
 .SECONDARY:
index dc5fc446ce1254b1e4be2666c74d6fb520faadd7..431a192067e735f0602a1b8286b76b87d237d0e7 100644 (file)
@@ -13,10 +13,6 @@ CFLAGS   += $(CFLAGS_libxenstore)
 CFLAGS   += $(INCLUDES) -I.
 CFLAGS   += -D_GNU_SOURCE
 
-# Get gcc to generate the dependencies for us.
-CFLAGS   += -Wp,-MD,.$(@F).d
-DEPS      = .*.d
-
 LIBS      := -L. -L.. -L../lib
 LIBS      += $(LDFLAGS_libxenctrl)
 LIBS      += $(LDFLAGS_libxenstore)
index afc08bdaab727f4c4011b9e930b852de213360b9..accbafef15a65915526f2a171f1e9411d070e26a 100644 (file)
@@ -1,8 +1,6 @@
 include $(XEN_ROOT)/tools/Rules.mk
 
-DEPS = .*.d
-
-CFLAGS += -I$(XEN_ROOT)/tools/libfsimage/common/ -Werror -Wp,-MD,.$(@F).d
+CFLAGS += -I$(XEN_ROOT)/tools/libfsimage/common/ -Werror
 LDFLAGS += -L../common/
 
 PIC_OBJS := $(patsubst %.c,%.opic,$(LIB_SRCS-y))
index 641bca53b3a7945784e5111275ca78da1b73fe50..48851acfa6719cacb7e12312ffd15720e9b56e41 100644 (file)
@@ -4,9 +4,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 MAJOR = 1.0
 MINOR = 0
 
-CFLAGS += -Werror -Wp,-MD,.$(@F).d
-DEPS = .*.d
-
 LDFLAGS-$(CONFIG_SunOS) = -Wl,-M -Wl,mapfile-SunOS
 LDFLAGS-$(CONFIG_Linux) = -Wl,mapfile-GNU
 LDFLAGS = $(LDFLAGS-y)
index 4ec156c1d828ec6ba1bb292a788502322ac53361..6f839463d7b63c32015bc5e43f42237a97992c18 100644 (file)
@@ -62,10 +62,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
 # libraries.
 #CFLAGS   += -DVALGRIND -O0 -ggdb3
 
-# Get gcc to generate the dependencies for us.
-CFLAGS   += -Wp,-MD,.$(@F).d
 LDFLAGS  += -L.
-DEPS     = .*.d
 
 CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y))
 CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
index 40e7bbfca378525471c10292ad673689e495fd89..12c599cd75f3333e5a5c39060afa9747d842750b 100644 (file)
@@ -47,7 +47,7 @@ install: build
 
 .PHONY: clean
 clean:
-       $(RM) *.o $(TARGETS) *~
+       $(RM) *.o $(TARGETS) *~ $(DEPS)
        set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d clean; done
 
 %.o: %.c $(HDRS) Makefile
@@ -55,3 +55,5 @@ clean:
 
 xenperf xenpm: %: %.o Makefile
        $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDFLAGS_libxenctrl)
+
+-include $(DEPS)
index 3629d897423035494112217490e151f69a2766da..03c8ed9530c12571b8eb5acb762e790819beaa3c 100644 (file)
@@ -22,4 +22,6 @@ endif
 
 .PHONY: clean
 clean:
-       rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
+       rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out $(DEPS)
+
+-include $(DEPS)
index c2e5c9c3189732259551b9ccb900a5cbaa629be3..4ae0a2d777a23b7b8149c5edcbc2c1308aaac9fd 100644 (file)
@@ -85,3 +85,6 @@ test:
 .PHONY: clean
 clean:
        rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
+       rm -f $(DEPS)
+
+-include $(DEPS)
index 0c8ef6bb73ef09015b7c6c0af62c115f3929d408..889c55c32f4634975b9725b836bd9d52a693d1c5 100644 (file)
@@ -28,10 +28,6 @@ CFLAGS   += -Werror -fno-strict-aliasing $(call cc-option,$(CC),-fgnu89-inline,)
 CFLAGS   += -O3
 #CFLAGS   += -g
 
-# Get gcc to generate the dependencies for us.
-CFLAGS   += -Wp,-MD,.$(@F).d
-DEPS     = .*.d
-
 MAJOR    := 3.0
 MINOR    := 0
 LIB      := libxutil.so 
index 8eb1a3c343402b28bbcb0c20fdd981815b3b8aac..c6a7487fbf9ad9634b599a5ab212675c769cca7a 100644 (file)
@@ -11,11 +11,6 @@ TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin
 # General compiler flags
 CFLAGS   = -Werror -g3 -I.
 
-# For generating dependencies
-CFLAGS += -Wp,-MD,.$(@F).d
-
-DEP_FILES      = .*.d
-
 # Generic project files
 HDRS   = $(wildcard *.h)
 SRCS   = $(wildcard *.c)
@@ -26,7 +21,7 @@ $(SRCS): Makefile $(XEN_ROOT)/tools/Rules.mk $(XEN_ROOT)/tools/vtpm/Rules.mk
 
 $(OBJS): $(SRCS)
 
--include $(DEP_FILES)
+-include $(DEPS)
 
 BUILD_EMULATOR = y
 
index 3d48870288661cc0f387ed40edb81f7c7dda67a9..461e13bf2849623d821b7e73f72c8c6d5930077d 100644 (file)
@@ -11,11 +11,6 @@ TOOLS_INSTALL_DIR = $(DESTDIR)/usr/bin
 # General compiler flags
 CFLAGS = -Werror -g3 -I.
 
-# For generating dependencies
-CFLAGS += -Wp,-MD,.$(@F).d
-
-DEP_FILES      = .*.d
-
 # Generic project files
 HDRS   = $(wildcard *.h)
 SRCS   = $(wildcard *.c)
@@ -26,7 +21,7 @@ $(SRCS): Makefile $(XEN_ROOT)/tools/Rules.mk $(XEN_ROOT)/tools/vtpm_manager/Rule
 
 $(OBJS): $(SRCS)
 
--include $(DEP_FILES)
+-include $(FILES)
 
 # Make sure these are just rules
 .PHONY : all build install clean
index 15c0c9758ef698a160edef05257fd4647a4951e3..a8029086b28a61d53b98fbbfe793af74d9ac703c 100644 (file)
@@ -14,10 +14,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror
 CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore)
 
-# Make gcc generate dependencies.
-CFLAGS += -Wp,-MD,.$(@F).d
-PROG_DEP = .*.d
-
 PROGRAMS = xc_restore xc_save readnotes lsevtchn
 
 LDLIBS   = $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenguest) $(LDFLAGS_libxenstore)
@@ -40,6 +36,6 @@ install: build
 .PHONY: clean
 clean:
        $(RM) *.o $(PROGRAMS)
-       $(RM) $(PROG_DEP)
+       $(RM) $(DEPS)
 
--include $(PROG_DEP)
+-include $(DEPS)
index 8ad42665673653d43754f8e758b21f7ac94eb03a..276a8e9886c4d475b7d6c96e5353f47bc2cd04d3 100644 (file)
@@ -38,10 +38,12 @@ install: build
 
 .PHONY: clean
 clean:
-       rm -f $(BIN)
+       rm -f $(BIN) $(DEPS)
 
 
 %: %.c Makefile
        $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
 xentrace_%: %.c Makefile
        $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
+
+-include $(DEPS)
index 6fc31a46b41ce9e10d7d57fb3bb3098326677b61..7e9353bfb09eb336b6d5dd8909d1286c3fadb26a 100644 (file)
@@ -17,4 +17,6 @@ install: all
 
 .PHONY: clean
 clean:
-       $(RM) -f $(BIN)
+       $(RM) -f $(BIN) $(DEPS)
+
+-include $(DEPS)
index 1177b55ac06c9b184eec701b7b6aaaf5a4821dfb..b40992959fe8c315c4692f2c926b353aafcf479f 100644 (file)
@@ -155,4 +155,6 @@ endif
 .PHONY: clean
 clean:
        rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
-             $(BINDINGS) $(BINDINGSRC)
+             $(BINDINGS) $(BINDINGSRC) $(DEPS)
+
+-include $(DEPS)
index 4b862a4ec55e793af6b054c816c91398803744a3..15daa39c598d48a94471e5c082f4e321bd8041a0 100644 (file)
@@ -37,4 +37,6 @@ endif
 
 .PHONY: clean
 clean:
-       rm -f xentop xentop.o
+       rm -f xentop xentop.o $(DEPS)
+
+-include $(DEPS)
index 9b7e9e89c627e69acc13ddf8f7c916c08563d0bd..c84505cc3c983a5aa1431a9ae3330e6c296027fe 100644 (file)
@@ -8,10 +8,6 @@ CFLAGS += -Werror
 CFLAGS += -I.
 CFLAGS += $(CFLAGS_libxenctrl)
 
-# Make gcc generate dependencies.
-CFLAGS += -Wp,-MD,.$(@F).d
-DEP    = .*.d
-
 CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod
 CLIENTS += xenstore-write xenstore-ls
 
@@ -82,7 +78,7 @@ clean:
        rm -f xenstored xs_random xs_stress xs_crashme
        rm -f xs_tdb_dump xenstore-control
        rm -f xenstore $(CLIENTS)
-       $(RM) $(DEP)
+       $(RM) $(DEPS)
 
 .PHONY: TAGS
 TAGS:
@@ -113,7 +109,7 @@ install: all
        $(INSTALL_DATA) xs.h $(DESTDIR)$(INCLUDEDIR)
        $(INSTALL_DATA) xs_lib.h $(DESTDIR)$(INCLUDEDIR)
 
--include $(DEP)
+-include $(DEPS)
 
 # never delete any intermediate files.
 .SECONDARY:
index 336ee007e79288cb7d26f47eb635c0b9728bfc2e..f540b420530837f3ffca5b8d54f2a0c01a81b167 100644 (file)
@@ -46,9 +46,12 @@ install: build
 
 .PHONY: clean
 clean:
-       $(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN)
+       $(RM) *.a *.so *.o *.rpm $(BIN) $(LIBBIN) $(DEPS)
 
 %: %.c $(HDRS) Makefile
        $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
 xentrace_%: %.c $(HDRS) Makefile
        $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
+
+-include $(DEPS)
+
index 2fa62322a5599415f250bb28ef17c6f2381e2eea..716d6750ec2431b9a82a125654ce1775c79ee686 100644 (file)
@@ -24,10 +24,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 CFLAGS += -Werror -ggdb3
 CFLAGS += -I$(XEN_LIBXC) -I$(XEN_XENSTORE)
 
-# Make gcc generate dependencies.
-CFLAGS += -Wp,-MD,.$(@F).d
-DEPS = .*.d
-
 PROGRAMS = p2m_foreign
 LDLIBS   = -L$(XEN_LIBXC) -L$(XEN_XENSTORE) -lxenguest -lxenctrl