summaryrefslogtreecommitdiffstats
path: root/support/scripts/mkmakefile
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2011-08-31 23:35:02 +0200
committerPeter Korsgaard <jacmet@sunsite.dk>2011-09-17 08:14:11 +0200
commitf082c7c5cf72296566dcf92bba4fcb4c95f2186f (patch)
tree755b968c86505d8746ba179a2e3751d0f0415703 /support/scripts/mkmakefile
parent3e304db0f0ef583efb250a19663259bb6dc60c93 (diff)
downloadbuildroot-novena-f082c7c5cf72296566dcf92bba4fcb4c95f2186f.tar.gz
buildroot-novena-f082c7c5cf72296566dcf92bba4fcb4c95f2186f.zip
support: move scripts/ to a new support/ directory
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'support/scripts/mkmakefile')
-rwxr-xr-xsupport/scripts/mkmakefile47
1 files changed, 47 insertions, 0 deletions
diff --git a/support/scripts/mkmakefile b/support/scripts/mkmakefile
new file mode 100755
index 000000000..cef2ec707
--- /dev/null
+++ b/support/scripts/mkmakefile
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Generates a small Makefile used in the root of the output
+# directory, to allow make to be started from there.
+# The Makefile also allow for more convenient build of external modules
+
+# Usage
+# $1 - Kernel src directory
+# $2 - Output directory
+
+
+test ! -r $2/Makefile -o -O $2/Makefile || exit 0
+# Only overwrite automatically generated Makefiles
+# (so we do not overwrite buildroot 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
+
+lastword = \$(word \$(words \$(1)),\$(1))
+makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
+
+MAKEARGS := -C $1
+MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
+
+MAKEFLAGS += --no-print-directory
+
+.PHONY: all \$(MAKECMDGOALS)
+
+all := \$(filter-out all Makefile,\$(MAKECMDGOALS))
+
+all:
+ \$(MAKE) \$(MAKEARGS) \$(all)
+
+Makefile:;
+
+\$(all): all
+ @:
+
+%/: all
+ @:
+EOF