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>
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
subdir-all-% subdir-clean-% subdir-install-%: .phony
$(MAKE) -C $* $(patsubst subdir-%-$*,%,$@)
-
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
.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))
$(INSTALL_PROG) xenconsoled $(DESTDIR)/$(SBINDIR)
$(INSTALL_DIR) $(DESTDIR)$(PRIVATE_BINDIR)
$(INSTALL_PROG) xenconsole $(DESTDIR)$(PRIVATE_BINDIR)
+
+-include $(DEPS)
.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)
$(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)
.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
exit 11; \
} || :
sh mkhex highbios_array 32bitbios_all.o > $@
+
+-include $(DEPS)
all: $(TARGET)
clean:
- rm -rf *.o $(TARGET)
+ rm -rf *.o $(TARGET) $(DEPS)
$(TARGET): $(OBJECTS)
$(LD) $(LDFLAGS_DIRECT) -r $^ -o $@
+
+-include $(DEPS)
+
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
biossums: biossums.c
gcc -o biossums biossums.c
+-include $(DEPS)
# 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))
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)
clean:
rm -f *.o *.opic *.so
rm -f $(CLIENTS)
- $(RM) $(PROG_DEP)
+ $(RM) $(DEPS)
.PHONY: print-dir
print-dir:
$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
$(INSTALL_PROG) $(CLIENTS) $(DESTDIR)$(SBINDIR)
--include $(PROG_DEP)
+-include $(DEPS)
# never delete any intermediate files.
.SECONDARY:
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)
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))
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)
# 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))
.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
xenperf xenpm: %: %.o Makefile
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDFLAGS_libxenctrl)
+
+-include $(DEPS)
.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)
.PHONY: clean
clean:
rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
+ rm -f $(DEPS)
+
+-include $(DEPS)
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
# 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)
$(OBJS): $(SRCS)
--include $(DEP_FILES)
+-include $(DEPS)
BUILD_EMULATOR = y
# 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)
$(OBJS): $(SRCS)
--include $(DEP_FILES)
+-include $(FILES)
# Make sure these are just rules
.PHONY : all build install clean
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)
.PHONY: clean
clean:
$(RM) *.o $(PROGRAMS)
- $(RM) $(PROG_DEP)
+ $(RM) $(DEPS)
--include $(PROG_DEP)
+-include $(DEPS)
.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)
.PHONY: clean
clean:
- $(RM) -f $(BIN)
+ $(RM) -f $(BIN) $(DEPS)
+
+-include $(DEPS)
.PHONY: clean
clean:
rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
- $(BINDINGS) $(BINDINGSRC)
+ $(BINDINGS) $(BINDINGSRC) $(DEPS)
+
+-include $(DEPS)
.PHONY: clean
clean:
- rm -f xentop xentop.o
+ rm -f xentop xentop.o $(DEPS)
+
+-include $(DEPS)
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
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:
$(INSTALL_DATA) xs.h $(DESTDIR)$(INCLUDEDIR)
$(INSTALL_DATA) xs_lib.h $(DESTDIR)$(INCLUDEDIR)
--include $(DEP)
+-include $(DEPS)
# never delete any intermediate files.
.SECONDARY:
.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)
+
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