mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* (no subject)
@ 2006-07-04 21:57 Milton Miller
  2006-07-05  7:01 ` [KBUILD] optionally print cause of rebuild (#2) Milton Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Milton Miller @ 2006-07-04 21:57 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel, Sam Ravnborg

Al wanted to see why Kbuild wanted to build files, to help debug
Makefiles or dependency chains.

Here is a first draft.   It always does if_changed_dep $^ processing,
and it has a few whitepace issues, but the paths other than not in
targets passes a basic test.

export KBUILLD_PRINTDEPS=1 and you wil get lines beginning with DEPS:

Signed-off-by: Milton Miller <miltonm@bga.com>

--- linux-2.6.17/scripts/Kbuild.include.orig	2006-07-04 16:02:55.000000000 -0400
+++ linux-2.6.17/scripts/Kbuild.include	2006-07-04 17:40:31.000000000 -0400
@@ -112,6 +112,18 @@ ifneq ($(KBUILD_NOCMDDEP),1)
 arg-check = $(strip $(filter-out $(1), $(2)) $(filter-out $(2), $(1)) )
 endif
 
+ifeq ($(KBUILD_PRINTDEPS),1)
+deps-cmd = $(if 1,echo 'DEPS: $@ built because' 			\
+	'$(call escsq,$(if $(wildcard $@),				\
+		$(if $(filter $@, $(targets)),				\
+			$(if $(call arg-check, $(cmd_$(1)), $(cmd_$@)),	\
+				command $(if $(cmd_$@),changed,was missing) \
+				,of $(sort $(filter-out $(PHONY),$?) 	\
+				$(filter-out FORCE $(wildcard $^),$^)))	\
+		,it was not a target)					\
+	,it was missing))';)
+endif
+
 # echo command. Short version is $(quiet) equals quiet, otherwise full command
 echo-cmd = $(if $($(quiet)cmd_$(1)), \
 	echo '  $(call escsq,$($(quiet)cmd_$(1)))';)
@@ -125,7 +137,7 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$
 if_changed = $(if $(strip $(filter-out $(PHONY),$?)          \
 		$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
 	@set -e; \
-	$(echo-cmd) $(cmd_$(1)); \
+	$(deps-cmd) $(echo-cmd) $(cmd_$(1)); \
 	echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
 
 # execute the command and also postprocess generated .d dependencies
@@ -134,7 +146,7 @@ if_changed_dep = $(if $(strip $(filter-o
 		$(filter-out FORCE $(wildcard $^),$^)    \
 	$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),     \
 	@set -e; \
-	$(echo-cmd) $(cmd_$(1)); \
+	$(deps-cmd) $(echo-cmd) $(cmd_$(1)); \
 	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
 	rm -f $(depfile); \
 	mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
@@ -145,4 +157,4 @@ if_changed_dep = $(if $(strip $(filter-o
 if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?)            \
 			$(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
 			@set -e; \
-			$(rule_$(1)))
+			$(deps-cmd) $(rule_$(1)))

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-05 17:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-04 21:57 Milton Miller
2006-07-05  7:01 ` [KBUILD] optionally print cause of rebuild (#2) Milton Miller
2006-07-05  9:30   ` Sam Ravnborg
2006-07-05 17:20     ` Milton Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome