kbuild: do not pass $(objtree) to scripts/mkmakefile
[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
1da177e4 9
18c32dac
SR
10# Only overwrite automatically generated Makefiles
11# (so we do not overwrite kernel Makefile)
4fd61277 12if test -e Makefile && ! grep -q Automatically Makefile
18c32dac
SR
13then
14 exit 0
15fi
d2301249 16if [ "${quiet}" != "silent_" ]; then
4fd61277 17 echo " GEN Makefile"
d2301249 18fi
fd5f0cd6 19
4fd61277 20cat << EOF > Makefile
1da177e4
LT
21# Automatically generated by $0: don't edit
22
1d3b3bfa
JB
23lastword = \$(word \$(words \$(1)),\$(1))
24makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
25
0ff35771
PF
26ifeq ("\$(origin V)", "command line")
27VERBOSE := \$(V)
28endif
29ifneq (\$(VERBOSE),1)
30Q := @
31endif
32
1d3b3bfa
JB
33MAKEARGS := -C $1
34MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
1da177e4
LT
35
36MAKEFLAGS += --no-print-directory
37
9319f453 38.PHONY: __sub-make \$(MAKECMDGOALS)
96678281 39
9319f453
MY
40__sub-make:
41 \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS)
0b35786d 42
9319f453 43\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
3c955b40 44 @:
1da177e4 45EOF