kbuild: remove VERSION and PATCHLEVEL from $(objtree)/Makefile
[linux-2.6-block.git] / scripts / mkmakefile
CommitLineData
1da177e4 1#!/bin/sh
b2441318 2# SPDX-License-Identifier: GPL-2.0
1da177e4
LT
3# Generates a small Makefile used in the root of the output
4# directory, to allow make to be started from there.
5# The Makefile also allow for more convinient build of external modules
6
7# Usage
8# $1 - Kernel src directory
9# $2 - Output directory
1da177e4 10
fd5f0cd6 11test ! -r $2/Makefile -o -O $2/Makefile || exit 0
18c32dac
SR
12# Only overwrite automatically generated Makefiles
13# (so we do not overwrite kernel Makefile)
971edcfc 14if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
18c32dac
SR
15then
16 exit 0
17fi
d2301249
SR
18if [ "${quiet}" != "silent_" ]; then
19 echo " GEN $2/Makefile"
20fi
fd5f0cd6
JB
21
22cat << EOF > $2/Makefile
1da177e4
LT
23# Automatically generated by $0: don't edit
24
1d3b3bfa
JB
25lastword = \$(word \$(words \$(1)),\$(1))
26makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
27
0ff35771
PF
28ifeq ("\$(origin V)", "command line")
29VERBOSE := \$(V)
30endif
31ifneq (\$(VERBOSE),1)
32Q := @
33endif
34
1d3b3bfa
JB
35MAKEARGS := -C $1
36MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
1da177e4
LT
37
38MAKEFLAGS += --no-print-directory
39
9319f453 40.PHONY: __sub-make \$(MAKECMDGOALS)
96678281 41
9319f453
MY
42__sub-make:
43 \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS)
0b35786d 44
9319f453 45\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
3c955b40 46 @:
1da177e4 47EOF