Commit 3341bfecb522bc407ecc8add154704e9d8b62a9c
Committed by
Tom Rini
1 parent
53bca5ab6a
Exists in
master
and in
49 other branches
kbuild: check clean source and generate Makefile for out-of-tree build
For out-of-tree build - Check if the source tree is clean - Create a Makefile in the output directory Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Showing 1 changed file with 55 additions and 6 deletions Side-by-side Diff
Makefile
... | ... | @@ -392,6 +392,17 @@ |
392 | 392 | # To avoid any implicit rule to kick in, define an empty command. |
393 | 393 | scripts/basic/%: scripts_basic ; |
394 | 394 | |
395 | +PHONY += outputmakefile | |
396 | +# outputmakefile generates a Makefile in the output directory, if using a | |
397 | +# separate output directory. This allows convenient use of make in the | |
398 | +# output directory. | |
399 | +outputmakefile: | |
400 | +ifneq ($(KBUILD_SRC),) | |
401 | + $(Q)ln -fsn $(srctree) source | |
402 | + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ | |
403 | + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) | |
404 | +endif | |
405 | + | |
395 | 406 | # To make sure we do not include .config for any of the *config targets |
396 | 407 | # catch them early, and hand them over to scripts/kconfig/Makefile |
397 | 408 | # It is allowed to specify more targets when calling make, including |
... | ... | @@ -449,7 +460,7 @@ |
449 | 460 | # KBUILD_DEFCONFIG may point out an alternative default configuration |
450 | 461 | # used for 'make defconfig' |
451 | 462 | |
452 | -%_config:: | |
463 | +%_config:: outputmakefile | |
453 | 464 | @$(MKCONFIG) -A $(@:_config=) |
454 | 465 | |
455 | 466 | else |
... | ... | @@ -928,7 +939,7 @@ |
928 | 939 | # Error messages still appears in the original language |
929 | 940 | |
930 | 941 | PHONY += $(u-boot-dirs) |
931 | -$(u-boot-dirs): depend scripts_basic | |
942 | +$(u-boot-dirs): depend prepare scripts | |
932 | 943 | $(Q)$(MAKE) $(build)=$@ |
933 | 944 | |
934 | 945 | tools: $(TIMESTAMP_FILE) $(VERSION_FILE) |
935 | 946 | |
... | ... | @@ -938,7 +949,42 @@ |
938 | 949 | # is "yes"), so compile examples after U-Boot is compiled. |
939 | 950 | examples: $(filter-out examples, $(u-boot-dirs)) |
940 | 951 | |
952 | +# Things we need to do before we recursively start building the kernel | |
953 | +# or the modules are listed in "prepare". | |
954 | +# A multi level approach is used. prepareN is processed before prepareN-1. | |
955 | +# archprepare is used in arch Makefiles and when processed asm symlink, | |
956 | +# version.h and scripts_basic is processed / created. | |
941 | 957 | |
958 | +# Listed in dependency order | |
959 | +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 | |
960 | + | |
961 | +# prepare3 is used to check if we are building in a separate output directory, | |
962 | +# and if so do: | |
963 | +# 1) Check that make has not been executed in the kernel src $(srctree) | |
964 | +prepare3: | |
965 | +ifneq ($(KBUILD_SRC),) | |
966 | + @$(kecho) ' Using $(srctree) as source for u-boot' | |
967 | + $(Q)if [ -f $(srctree)/include/config.mk ]; then \ | |
968 | + echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ | |
969 | + echo >&2 " in the '$(srctree)' directory.";\ | |
970 | + /bin/false; \ | |
971 | + fi; | |
972 | +endif | |
973 | + | |
974 | +# prepare2 creates a makefile if using a separate output directory | |
975 | +prepare2: prepare3 outputmakefile | |
976 | + | |
977 | +prepare1: prepare2 | |
978 | + @: | |
979 | + | |
980 | +archprepare: prepare1 scripts_basic | |
981 | + | |
982 | +prepare0: archprepare FORCE | |
983 | + @: | |
984 | + | |
985 | +# All the preparing.. | |
986 | +prepare: prepare0 | |
987 | + | |
942 | 988 | # |
943 | 989 | # Auto-generate the autoconf.mk file (which is included by all makefiles) |
944 | 990 | # |
945 | 991 | |
946 | 992 | |
... | ... | @@ -965,16 +1011,16 @@ |
965 | 1011 | u-boot.lds: $(LDSCRIPT) depend |
966 | 1012 | $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@ |
967 | 1013 | |
968 | -nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic | |
1014 | +nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend prepare | |
969 | 1015 | $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all |
970 | 1016 | |
971 | 1017 | u-boot-nand.bin: nand_spl u-boot.bin |
972 | 1018 | cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin |
973 | 1019 | |
974 | -spl/u-boot-spl.bin: tools depend scripts_basic | |
1020 | +spl/u-boot-spl.bin: tools depend prepare | |
975 | 1021 | $(MAKE) obj=spl -f $(srctree)/spl/Makefile all |
976 | 1022 | |
977 | -tpl/u-boot-tpl.bin: tools depend scripts_basic | |
1023 | +tpl/u-boot-tpl.bin: tools depend prepare | |
978 | 1024 | $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y |
979 | 1025 | |
980 | 1026 | # Explicitly make _depend in subdirs containing multiple targets to prevent |
... | ... | @@ -1213,7 +1259,10 @@ |
1213 | 1259 | F=`basename $(TOPDIR)` ; cd .. ; \ |
1214 | 1260 | gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F |
1215 | 1261 | |
1216 | -######################################################################### | |
1262 | +# Dummies... | |
1263 | +PHONY += prepare scripts | |
1264 | +prepare: ; | |
1265 | +scripts: ; | |
1217 | 1266 | |
1218 | 1267 | endif #ifeq ($(config-targets),1) |
1219 | 1268 | endif #ifeq ($(mixed-targets),1) |