Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 1 | #!/bin/sh |
Tom Rini | 473fc27 | 2021-06-17 18:07:25 -0400 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0 |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 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 |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 9 | |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 10 | # Only overwrite automatically generated Makefiles |
| 11 | # (so we do not overwrite kernel Makefile) |
Tom Rini | 473fc27 | 2021-06-17 18:07:25 -0400 | [diff] [blame] | 12 | if test -e Makefile && ! grep -q Automatically Makefile |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 13 | then |
| 14 | exit 0 |
| 15 | fi |
| 16 | if [ "${quiet}" != "silent_" ]; then |
Tom Rini | 473fc27 | 2021-06-17 18:07:25 -0400 | [diff] [blame] | 17 | echo " GEN Makefile" |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 18 | fi |
| 19 | |
Tom Rini | 473fc27 | 2021-06-17 18:07:25 -0400 | [diff] [blame] | 20 | cat << EOF > Makefile |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 21 | # Automatically generated by $0: don't edit |
| 22 | |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 23 | ifeq ("\$(origin V)", "command line") |
| 24 | VERBOSE := \$(V) |
| 25 | endif |
| 26 | ifneq (\$(VERBOSE),1) |
| 27 | Q := @ |
| 28 | endif |
| 29 | |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 30 | MAKEFLAGS += --no-print-directory |
| 31 | |
Masahiro Yamada | e773440 | 2014-08-05 15:56:44 +0900 | [diff] [blame] | 32 | .PHONY: __sub-make \$(MAKECMDGOALS) |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 33 | |
Masahiro Yamada | e773440 | 2014-08-05 15:56:44 +0900 | [diff] [blame] | 34 | __sub-make: |
Tom Rini | 473fc27 | 2021-06-17 18:07:25 -0400 | [diff] [blame] | 35 | \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS) |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 36 | |
Masahiro Yamada | e773440 | 2014-08-05 15:56:44 +0900 | [diff] [blame] | 37 | \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make |
Masahiro Yamada | 22433fc | 2014-02-04 17:24:27 +0900 | [diff] [blame] | 38 | @: |
| 39 | EOF |