blob: 412f13fdff52f502056f27b95edc7e540ee2dd2d [file] [log] [blame]
Masahiro Yamada22433fc2014-02-04 17:24:27 +09001#!/bin/sh
Tom Rini473fc272021-06-17 18:07:25 -04002# SPDX-License-Identifier: GPL-2.0
Masahiro Yamada22433fc2014-02-04 17:24:27 +09003# 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
Masahiro Yamada22433fc2014-02-04 17:24:27 +09009
Masahiro Yamada22433fc2014-02-04 17:24:27 +090010# Only overwrite automatically generated Makefiles
11# (so we do not overwrite kernel Makefile)
Tom Rini473fc272021-06-17 18:07:25 -040012if test -e Makefile && ! grep -q Automatically Makefile
Masahiro Yamada22433fc2014-02-04 17:24:27 +090013then
14 exit 0
15fi
16if [ "${quiet}" != "silent_" ]; then
Tom Rini473fc272021-06-17 18:07:25 -040017 echo " GEN Makefile"
Masahiro Yamada22433fc2014-02-04 17:24:27 +090018fi
19
Tom Rini473fc272021-06-17 18:07:25 -040020cat << EOF > Makefile
Masahiro Yamada22433fc2014-02-04 17:24:27 +090021# Automatically generated by $0: don't edit
22
Masahiro Yamada22433fc2014-02-04 17:24:27 +090023ifeq ("\$(origin V)", "command line")
24VERBOSE := \$(V)
25endif
26ifneq (\$(VERBOSE),1)
27Q := @
28endif
29
Masahiro Yamada22433fc2014-02-04 17:24:27 +090030MAKEFLAGS += --no-print-directory
31
Masahiro Yamadae7734402014-08-05 15:56:44 +090032.PHONY: __sub-make \$(MAKECMDGOALS)
Masahiro Yamada22433fc2014-02-04 17:24:27 +090033
Masahiro Yamadae7734402014-08-05 15:56:44 +090034__sub-make:
Tom Rini473fc272021-06-17 18:07:25 -040035 \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS)
Masahiro Yamada22433fc2014-02-04 17:24:27 +090036
Masahiro Yamadae7734402014-08-05 15:56:44 +090037\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
Masahiro Yamada22433fc2014-02-04 17:24:27 +090038 @:
39EOF