Commit e321b2ec authored by Sam Ravnborg's avatar Sam Ravnborg

kbuild: Create Makefile in output directory if != kernel tree

When building a kernel using the O= syntax to save output
files in a separate output directory now create a small Makefile in
that same dir.
This Makefile allow one to use make in the output directory without
the hassle of going back to the kernel source tree.
The O= option is added by this Makefile stub.
Please note that the Makefile silently overwrite an old one, so changes
will be lost if modified.
If there is a need to tweak a Makefile in the output directory it is recommended
to use the filename 'makefile', which GNU Make will try first.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 56978bc2
...@@ -631,14 +631,24 @@ $(vmlinux-dirs): prepare-all scripts ...@@ -631,14 +631,24 @@ $(vmlinux-dirs): prepare-all scripts
# A multi level approach is used. prepare1 is updated first, then prepare0. # A multi level approach is used. prepare1 is updated first, then prepare0.
# prepare-all is the collection point for the prepare targets. # prepare-all is the collection point for the prepare targets.
.PHONY: prepare-all prepare prepare0 prepare1 .PHONY: prepare-all prepare prepare0 prepare1 prepare2
# prepare 2 generate Makefile to be placed in output directory, if
# using a seperate output directory. This allows convinient use
# of make in output directory
prepare2:
$(Q)if [ ! $(srctree) -ef $(objtree) ]; then \
$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) \
> $(objtree)/Makefile; \
fi
# prepare1 is used to check if we are building in a separate output directory, # prepare1 is used to check if we are building in a separate output directory,
# and if so do: # and if so do:
# 1) Check that make has not been executed in the kernel src $(srctree) # 1) Check that make has not been executed in the kernel src $(srctree)
# 2) Create the include2 directory, used for the second asm symlink # 2) Create the include2 directory, used for the second asm symlink
prepare1: prepare1: prepare2
ifneq ($(KBUILD_SRC),) ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel' @echo ' Using $(srctree) as source for kernel'
$(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \ $(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
......
#!/bin/sh
# Generates a small Makefile used in the root of the output
# directory, to allow make to be started from there.
# The Makefile also allow for more convinient build of external modules
# Usage
# $1 - Kernel src directory
# $2 - Output directory
# $3 - version
# $4 - patchlevel
cat << EOF
# Automatically generated by $0: don't edit
VERSION = $3
PATCHLEVEL = $4
KERNELSRC := $1
KERNELOUTPUT := $2
MAKEFLAGS += --no-print-directory
all:
\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
%::
\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
EOF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment