summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]scripts/mkmakefile36
1 files changed, 26 insertions, 10 deletions
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index 7f9d544f9b..84af27bf0f 100644..100755
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -11,7 +11,15 @@
test ! -r $2/Makefile -o -O $2/Makefile || exit 0
-echo " GEN $2/Makefile"
+# Only overwrite automatically generated Makefiles
+# (so we do not overwrite kernel Makefile)
+if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
+then
+ exit 0
+fi
+if [ "${quiet}" != "silent_" ]; then
+ echo " GEN $2/Makefile"
+fi
cat << EOF > $2/Makefile
# Automatically generated by $0: don't edit
@@ -19,18 +27,26 @@ cat << EOF > $2/Makefile
VERSION = $3
PATCHLEVEL = $4
-KERNELSRC := $1
-KERNELOUTPUT := $2
+lastword = \$(word \$(words \$(1)),\$(1))
+makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
-MAKEFLAGS += --no-print-directory
+ifeq ("\$(origin V)", "command line")
+VERBOSE := \$(V)
+endif
+ifneq (\$(VERBOSE),1)
+Q := @
+endif
+
+MAKEARGS := -C $1
+MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
-.PHONY: all \$(MAKECMDGOALS)
+MAKEFLAGS += --no-print-directory
-all:
- \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
+.PHONY: __sub-make \$(MAKECMDGOALS)
-Makefile:;
+__sub-make:
+ \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS)
-\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/:
- \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
+ @:
EOF