summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2002-06-17 05:18:31 -0500
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2002-06-17 05:18:31 -0500
commita95ca5a96f8248754487dd53fbbcbc58ea753aa9 (patch)
treeca2f390002952b7dbac5dc6354e18670dd7eaef2
parent5c4498f1064e82c73a1e5c5464c34fb61dfe83e4 (diff)
kbuild: Improve output and error behavior when making modversions.
Reduce the amount of output in verbose (default) mode and stop immediately on error. (Sam Ravnborg/me)
-rw-r--r--Rules.make41
-rw-r--r--scripts/fixdep.c8
2 files changed, 41 insertions, 8 deletions
diff --git a/Rules.make b/Rules.make
index 7db5301ea7db..e6bd353619b8 100644
--- a/Rules.make
+++ b/Rules.make
@@ -131,6 +131,10 @@ else
genksyms_smp_prefix :=
endif
+# Don't include modversions.h, we're just about to generate it here.
+
+CFLAGS_MODULE := $(filter-out -include $(HPATH)/linux/modversions.h,$(CFLAGS_MODULE))
+
$(addprefix $(MODVERDIR)/,$(real-objs-y:.o=.ver)): modkern_cflags := $(CFLAGS_KERNEL)
$(addprefix $(MODVERDIR)/,$(real-objs-m:.o=.ver)): modkern_cflags := $(CFLAGS_MODULE)
$(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)): export_flags := -D__GENKSYMS__
@@ -145,18 +149,34 @@ c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
# files changes
quiet_cmd_cc_ver_c = MKVER include/linux/modules/$(RELDIR)/$*.ver
-define cmd_cc_ver_c
- mkdir -p $(dir $@); \
- $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \
- -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp; \
+cmd_cc_ver_c = $(CPP) $(c_flags) $< | $(GENKSYMS) $(genksyms_smp_prefix) \
+ -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp
+
+# Okay, let's explain what's happening in rule_make_cc_ver_c:
+# o echo the command
+# o execute the command
+# o If the $(CPP) fails, we won't notice because it's output is piped
+# to $(GENKSYMS) which does not fail. We recognize this case by
+# looking if the generated $(depfile) exists, though.
+# o If the .ver file changed, touch modversions.h, which is our maker
+# of any changed .ver files.
+# o Move command line and deps into their normal .*.cmd place.
+
+define rule_cc_ver_c
+ $(if $($(quiet)cmd_cc_ver_c),echo ' $($(quiet)cmd_cc_ver_c)';) \
+ $(cmd_cc_ver_c); \
+ if [ ! -r $(depfile) ]; then exit 1; fi; \
+ $(TOPDIR)/scripts/fixdep $(depfile) $@ $(TOPDIR) '$(cmd_cc_ver_c)' > $(@D)/.$(@F).tmp; \
+ rm -f $(depfile); \
if [ ! -r $@ ] || cmp -s $@ $@.tmp; then \
touch $(TOPDIR)/include/linux/modversions.h; \
fi; \
mv -f $@.tmp $@
+ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
endef
$(MODVERDIR)/%.ver: %.c FORCE
- @$(call if_changed_dep,cc_ver_c)
+ @$(call if_changed_rule,cc_ver_c)
targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
@@ -456,6 +476,17 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
rm -f $(depfile); \
mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
+# Usage: $(call if_changed_rule,foo)
+# will check if $(cmd_foo) changed, or any of the prequisites changed,
+# and if so will execute $(rule_foo)
+
+if_changed_rule = $(if $(strip $? \
+ $(filter-out $(cmd_$(1)),$(cmd_$@))\
+ $(filter-out $(cmd_$@),$(cmd_$(1)))),\
+ @set -e; \
+ mkdir -p $(dir $@); \
+ $(rule_$(1)))
+
# If quiet is set, only print short version of command
cmd = @$(if $($(quiet)$(1)),echo ' $($(quiet)$(1))' &&) $($(1))
diff --git a/scripts/fixdep.c b/scripts/fixdep.c
index db45bd1888c0..1e9ffda8473b 100644
--- a/scripts/fixdep.c
+++ b/scripts/fixdep.c
@@ -143,7 +143,7 @@ void grow_config(int len)
size_config = 2048;
str_config = realloc(str_config, size_config *= 2);
if (str_config == NULL)
- { perror("malloc"); exit(1); }
+ { perror("fixdep:malloc"); exit(1); }
}
}
@@ -259,6 +259,7 @@ void do_config_file(char *filename)
fd = open(filename, O_RDONLY);
if (fd < 0) {
+ fprintf(stderr, "fixdep: ");
perror(filename);
exit(2);
}
@@ -269,7 +270,7 @@ void do_config_file(char *filename)
}
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if ((long) map == -1) {
- perror("mmap");
+ perror("fixdep: mmap");
close(fd);
return;
}
@@ -326,6 +327,7 @@ void print_deps(void)
fd = open(depfile, O_RDONLY);
if (fd < 0) {
+ fprintf(stderr, "fixdep: ");
perror(depfile);
exit(2);
}
@@ -337,7 +339,7 @@ void print_deps(void)
}
map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if ((long) map == -1) {
- perror("mmap");
+ perror("fixdep: mmap");
close(fd);
return;
}