kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: will.deacon@arm.com
Cc: kvm@vger.kernel.org
Subject: [PATCH] Remove visible dependency files
Date: Fri, 29 May 2015 15:20:17 +0100	[thread overview]
Message-ID: <20150529142017.GA32617@rmk-PC.arm.linux.org.uk> (raw)

After building, there is a lot of clutter from the dependency system.
Let's clean this up by using dir/.file.d style dependencies, similar
to those used in the Linux kernel.

In order to support this, rearrange the dependency generation to
create the dependency files as we build rather than as a separate
step, and have make clean remove them.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>
---
 Makefile | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 4bd86ee..c07fd8e 100644
--- a/Makefile
+++ b/Makefile
@@ -288,7 +288,13 @@ LIBS	+= -lpthread
 LIBS	+= -lutil
 
 
-DEPS	:= $(patsubst %.o,%.d,$(OBJS))
+comma = ,
+
+# The dependency file for the current target
+depfile = $(subst $(comma),_,$(dir $@).$(notdir $@).d)
+
+DEPS	:= $(foreach obj,$(OBJS),\
+		$(subst $(comma),_,$(dir $(obj)).$(notdir $(obj)).d))
 
 DEFINES	+= -D_FILE_OFFSET_BITS=64
 DEFINES	+= -D_GNU_SOURCE
@@ -327,6 +333,10 @@ all: arch_support_check $(PROGRAM) $(PROGRAM_ALIAS) $(GUEST_INIT)
 arch_support_check:
 	$(UNSUPP_ERR)
 
+# CFLAGS used when building objects
+# This is intentionally not assigned using :=
+c_flags	= -Wp,-MD,$(depfile) $(CFLAGS)
+
 # When building -static all objects are built with appropriate flags, which
 # may differ between static & dynamic .o.  The objects are separated into
 # .o and .static.o.  See the %.o: %.c rules below.
@@ -336,11 +346,11 @@ arch_support_check:
 STATIC_OBJS = $(patsubst %.o,%.static.o,$(OBJS) $(OBJS_STATOPT))
 GUEST_OBJS = guest/guest_init.o
 
-$(PROGRAM)-static:  $(DEPS) $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT)
+$(PROGRAM)-static:  $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_INIT)
 	$(E) "  LINK    " $@
 	$(Q) $(CC) -static $(CFLAGS) $(STATIC_OBJS) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_STATOPT) -o $@
 
-$(PROGRAM): $(DEPS) $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT)
+$(PROGRAM): $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_INIT)
 	$(E) "  LINK    " $@
 	$(Q) $(CC) $(CFLAGS) $(OBJS) $(OBJS_DYNOPT) $(OTHEROBJS) $(GUEST_OBJS) $(LIBS) $(LIBS_DYNOPT) -o $@
 
@@ -353,19 +363,11 @@ $(GUEST_INIT): guest/init.c
 	$(Q) $(CC) -static guest/init.c -o $@
 	$(Q) $(LD) $(LDFLAGS) -r -b binary -o guest/guest_init.o $(GUEST_INIT)
 
-$(DEPS):
-
-util/rbtree.d: util/rbtree.c
-	$(Q) $(CC) -M -MT util/rbtree.o $(CFLAGS) $< -o $@
-
-%.d: %.c
-	$(Q) $(CC) -M -MT $(patsubst %.d,%.o,$@) $(CFLAGS) $< -o $@
-
 %.s: %.c
 	$(Q) $(CC) -o $@ -S $(CFLAGS) -fverbose-asm $<
 
 # The header file common-cmds.h is needed for compilation of builtin-help.c.
-builtin-help.d: $(KVM_INCLUDE)/common-cmds.h
+builtin-help.o: $(KVM_INCLUDE)/common-cmds.h
 
 $(OBJS):
 
@@ -375,7 +377,7 @@ ifeq ($(C),1)
 	$(Q) $(CHECK) -c $(CFLAGS) $< -o $@
 endif
 	$(E) "  CC      " $@
-	$(Q) $(CC) -c $(CFLAGS) $< -o $@
+	$(Q) $(CC) -c $(c_flags) $< -o $@
 
 %.static.o: %.c
 ifeq ($(C),1)
@@ -383,7 +385,7 @@ ifeq ($(C),1)
 	$(Q) $(CHECK) -c $(CFLAGS) $(CFLAGS_STATOPT) $< -o $@
 endif
 	$(E) "  CC      " $@
-	$(Q) $(CC) -c $(CFLAGS) $(CFLAGS_STATOPT)  $< -o $@
+	$(Q) $(CC) -c $(c_flags) $(CFLAGS_STATOPT)  $< -o $@
 
 %.o: %.c
 ifeq ($(C),1)
@@ -391,7 +393,7 @@ ifeq ($(C),1)
 	$(Q) $(CHECK) -c $(CFLAGS) $(CFLAGS_DYNOPT) $< -o $@
 endif
 	$(E) "  CC      " $@
-	$(Q) $(CC) -c $(CFLAGS) $(CFLAGS_DYNOPT) $< -o $@
+	$(Q) $(CC) -c $(c_flags) $(CFLAGS_DYNOPT) $< -o $@
 
 
 $(KVM_INCLUDE)/common-cmds.h: util/generate-cmdlist.sh command-list.txt
-- 
2.1.0


                 reply	other threads:[~2015-05-29 14:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150529142017.GA32617@rmk-PC.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=kvm@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).