blob: 412f13fdff52f502056f27b95edc7e540ee2dd2d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#!/bin/sh
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07003# 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
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Sam Ravnborg18c32da2007-12-09 08:55:13 +010010# Only overwrite automatically generated Makefiles
11# (so we do not overwrite kernel Makefile)
Masahiro Yamada4fd61272018-09-18 17:45:53 +090012if test -e Makefile && ! grep -q Automatically Makefile
Sam Ravnborg18c32da2007-12-09 08:55:13 +010013then
14 exit 0
15fi
Sam Ravnborgd2301242008-11-21 23:00:12 +010016if [ "${quiet}" != "silent_" ]; then
Masahiro Yamada4fd61272018-09-18 17:45:53 +090017 echo " GEN Makefile"
Sam Ravnborgd2301242008-11-21 23:00:12 +010018fi
Jan Beulichfd5f0cd2006-05-02 12:33:20 +020019
Masahiro Yamada4fd61272018-09-18 17:45:53 +090020cat << EOF > Makefile
Linus Torvalds1da177e2005-04-16 15:20:36 -070021# Automatically generated by $0: don't edit
22
Peter Foley0ff35772011-07-04 18:55:23 -040023ifeq ("\$(origin V)", "command line")
24VERBOSE := \$(V)
25endif
26ifneq (\$(VERBOSE),1)
27Q := @
28endif
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030MAKEFLAGS += --no-print-directory
31
Masahiro Yamada9319f452014-04-09 15:51:35 +090032.PHONY: __sub-make \$(MAKECMDGOALS)
Jan Beulich96678282006-01-30 10:05:09 +010033
Masahiro Yamada9319f452014-04-09 15:51:35 +090034__sub-make:
Masahiro Yamada80d0dda2018-09-18 17:45:54 +090035 \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS)
Milton Miller0b357862007-09-21 18:09:02 -050036
Masahiro Yamada9319f452014-04-09 15:51:35 +090037\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
Jan Beulich3c955b42010-08-16 11:58:58 +010038 @:
Linus Torvalds1da177e2005-04-16 15:20:36 -070039EOF