[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Use -MMD -MF in tools/* rather than -Wp,-M...



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@xxxxxxxxxxxxx>

diff -r b999142bca8c tools/Rules.mk
--- a/tools/Rules.mk    Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/Rules.mk    Thu Jan 08 15:16:38 2009 +0000
@@ -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-instal
 
 subdir-all-% subdir-clean-% subdir-install-%: .phony
        $(MAKE) -C $* $(patsubst subdir-%-$*,%,$@)
-
diff -r b999142bca8c tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/blktap/drivers/Makefile     Thu Jan 08 15:35:33 2009 +0000
@@ -12,10 +12,6 @@ CFLAGS   += $(CFLAGS_libxenstore)
 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
diff -r b999142bca8c tools/console/Makefile
--- a/tools/console/Makefile    Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/console/Makefile    Thu Jan 08 17:18:53 2009 +0000
@@ -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)
diff -r b999142bca8c tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/firmware/hvmloader/Makefile Thu Jan 08 17:22:21 2009 +0000
@@ -58,4 +58,6 @@ roms.h: ../rombios/BIOS-bochs-latest ../
 .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)
diff -r b999142bca8c tools/firmware/hvmloader/acpi/Makefile
--- a/tools/firmware/hvmloader/acpi/Makefile    Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/firmware/hvmloader/acpi/Makefile    Thu Jan 08 17:22:54 2009 +0000
@@ -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)
diff -r b999142bca8c tools/firmware/rombios/32bit/Makefile
--- a/tools/firmware/rombios/32bit/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/firmware/rombios/32bit/Makefile     Thu Jan 08 17:22:21 2009 +0000
@@ -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 @@ clean: subdirs-clean
            exit 11;                                         \
          } || :
        sh mkhex highbios_array 32bitbios_all.o > $@
+
+-include $(DEPS)
diff -r b999142bca8c tools/firmware/rombios/32bit/tcgbios/Makefile
--- a/tools/firmware/rombios/32bit/tcgbios/Makefile     Fri Jan 09 16:56:54 
2009 +0000
+++ b/tools/firmware/rombios/32bit/tcgbios/Makefile     Thu Jan 08 17:22:21 
2009 +0000
@@ -12,7 +12,10 @@ all: $(TARGET)
 all: $(TARGET)
 
 clean:
-       rm -rf *.o $(TARGET)
+       rm -rf *.o $(TARGET) $(DEPS)
 
 $(TARGET): $(OBJECTS)
        $(LD) $(LDFLAGS_DIRECT) -r $^ -o $@
+
+-include $(DEPS)
+
diff -r b999142bca8c tools/firmware/rombios/Makefile
--- a/tools/firmware/rombios/Makefile   Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/firmware/rombios/Makefile   Thu Jan 08 17:22:21 2009 +0000
@@ -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 @@ biossums: biossums.c
 biossums: biossums.c
        gcc -o biossums biossums.c
 
+-include $(DEPS)
diff -r b999142bca8c tools/flask/libflask/Makefile
--- a/tools/flask/libflask/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/flask/libflask/Makefile     Thu Jan 08 15:35:36 2009 +0000
@@ -16,7 +16,6 @@ CFLAGS   += $(INCLUDES) -I./include -I$(
 # 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))
diff -r b999142bca8c tools/flask/loadpolicy/Makefile
--- a/tools/flask/loadpolicy/Makefile   Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/flask/loadpolicy/Makefile   Thu Jan 08 15:35:36 2009 +0000
@@ -7,9 +7,6 @@ LIBFLASK_ROOT = $(XEN_ROOT)/tools/flask/
 
 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 @@ clean:
 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:
diff -r b999142bca8c tools/fs-back/Makefile
--- a/tools/fs-back/Makefile    Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/fs-back/Makefile    Thu Jan 08 15:35:36 2009 +0000
@@ -12,10 +12,6 @@ CFLAGS   += $(CFLAGS_libxenstore)
 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)
diff -r b999142bca8c tools/libfsimage/Rules.mk
--- a/tools/libfsimage/Rules.mk Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/libfsimage/Rules.mk Thu Jan 08 15:35:36 2009 +0000
@@ -1,8 +1,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 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))
diff -r b999142bca8c tools/libfsimage/common/Makefile
--- a/tools/libfsimage/common/Makefile  Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/libfsimage/common/Makefile  Thu Jan 08 15:35:36 2009 +0000
@@ -3,9 +3,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
diff -r b999142bca8c tools/libxc/Makefile
--- a/tools/libxc/Makefile      Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/libxc/Makefile      Thu Jan 08 15:35:36 2009 +0000
@@ -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))
diff -r b999142bca8c tools/misc/Makefile
--- a/tools/misc/Makefile       Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/misc/Makefile       Thu Jan 08 17:19:08 2009 +0000
@@ -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)
diff -r b999142bca8c tools/pygrub/Makefile
--- a/tools/pygrub/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/pygrub/Makefile     Thu Jan 08 17:19:40 2009 +0000
@@ -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)
diff -r b999142bca8c tools/python/Makefile
--- a/tools/python/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/python/Makefile     Thu Jan 08 17:18:57 2009 +0000
@@ -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)
diff -r b999142bca8c tools/vnet/libxutil/Makefile
--- a/tools/vnet/libxutil/Makefile      Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/vnet/libxutil/Makefile      Thu Jan 08 15:35:36 2009 +0000
@@ -27,10 +27,6 @@ CFLAGS   += -Werror -fno-strict-aliasing
 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
diff -r b999142bca8c tools/vtpm/Rules.mk
--- a/tools/vtpm/Rules.mk       Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/vtpm/Rules.mk       Thu Jan 08 15:35:36 2009 +0000
@@ -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 @@ OBJS  = $(patsubst %.c,%.o,$(SRCS))
 
 $(OBJS): $(SRCS)
 
--include $(DEP_FILES)
+-include $(DEPS)
 
 BUILD_EMULATOR = y
 
diff -r b999142bca8c tools/vtpm_manager/Rules.mk
--- a/tools/vtpm_manager/Rules.mk       Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/vtpm_manager/Rules.mk       Thu Jan 08 15:35:36 2009 +0000
@@ -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 @@ OBJS  = $(patsubst %.c,%.o,$(SRCS))
 
 $(OBJS): $(SRCS)
 
--include $(DEP_FILES)
+-include $(FILES)
 
 # Make sure these are just rules
 .PHONY : all build install clean
diff -r b999142bca8c tools/xcutils/Makefile
--- a/tools/xcutils/Makefile    Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xcutils/Makefile    Thu Jan 08 17:22:21 2009 +0000
@@ -13,10 +13,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
 
@@ -40,6 +36,6 @@ install: build
 .PHONY: clean
 clean:
        $(RM) *.o $(PROGRAMS)
-       $(RM) $(PROG_DEP)
+       $(RM) $(DEPS)
 
--include $(PROG_DEP)
+-include $(DEPS)
diff -r b999142bca8c tools/xenmon/Makefile
--- a/tools/xenmon/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xenmon/Makefile     Thu Jan 08 17:19:13 2009 +0000
@@ -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)
diff -r b999142bca8c tools/xenpmd/Makefile
--- a/tools/xenpmd/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xenpmd/Makefile     Thu Jan 08 17:19:10 2009 +0000
@@ -17,4 +17,6 @@ install: all
 
 .PHONY: clean
 clean:
-       $(RM) -f $(BIN)
+       $(RM) -f $(BIN) $(DEPS)
+
+-include $(DEPS)
diff -r b999142bca8c tools/xenstat/libxenstat/Makefile
--- a/tools/xenstat/libxenstat/Makefile Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xenstat/libxenstat/Makefile Thu Jan 08 17:19:04 2009 +0000
@@ -155,4 +155,6 @@ endif
 .PHONY: clean
 clean:
        rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
-             $(BINDINGS) $(BINDINGSRC)
+             $(BINDINGS) $(BINDINGSRC) $(DEPS)
+
+-include $(DEPS)
diff -r b999142bca8c tools/xenstat/xentop/Makefile
--- a/tools/xenstat/xentop/Makefile     Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xenstat/xentop/Makefile     Thu Jan 08 17:19:01 2009 +0000
@@ -37,4 +37,6 @@ endif
 
 .PHONY: clean
 clean:
-       rm -f xentop xentop.o
+       rm -f xentop xentop.o $(DEPS)
+
+-include $(DEPS)
diff -r b999142bca8c tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xenstore/Makefile   Thu Jan 08 15:35:36 2009 +0000
@@ -7,10 +7,6 @@ CFLAGS += -Werror
 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:
diff -r b999142bca8c tools/xentrace/Makefile
--- a/tools/xentrace/Makefile   Fri Jan 09 16:56:54 2009 +0000
+++ b/tools/xentrace/Makefile   Thu Jan 08 17:22:21 2009 +0000
@@ -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)
+
diff -r b999142bca8c xen/arch/ia64/tools/p2m_foreign/Makefile
--- a/xen/arch/ia64/tools/p2m_foreign/Makefile  Fri Jan 09 16:56:54 2009 +0000
+++ b/xen/arch/ia64/tools/p2m_foreign/Makefile  Thu Jan 08 16:03:54 2009 +0000
@@ -24,10 +24,6 @@ CFLAGS += -Werror -ggdb3
 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
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.