Commit 5bb78269 authored by Sam Ravnborg's avatar Sam Ravnborg

kbuild: rename prepare to archprepare to fix dependency chain

When introducing the generic asm-offsets.h support the dependency
chain for the prepare targets was changed. All build scripts expecting
include/asm/asm-offsets.h to be made when using the prepare target would broke.
With the limited number of prepare targets left in arch Makefiles
the trivial solution was to introduce a new arch specific target: archprepare

The dependency chain looks like this now:

prepare
  |
  +--> prepare0
         |
         +--> archprepare
                |
		+--> scripts_basic
                +--> prepare1
                       |
                       +---> prepare2
                               |
                               +--> prepare3

So prepare 3 is processed before prepare2 etc.
This guaantees that the asm symlink, version.h, scripts_basic
are all updated before archprepare is processed.

prepare0 which build the asm-offsets.h file will need the
actions performed by archprepare.

The head target is now named prepare, because users scripts will most
likely use that target, but prepare-all has been kept for compatibility.
Updated Documentation/kbuild/makefiles.txt.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 9fe66dfd
...@@ -31,7 +31,7 @@ This document describes the Linux kernel Makefiles. ...@@ -31,7 +31,7 @@ This document describes the Linux kernel Makefiles.
=== 6 Architecture Makefiles === 6 Architecture Makefiles
--- 6.1 Set variables to tweak the build to the architecture --- 6.1 Set variables to tweak the build to the architecture
--- 6.2 Add prerequisites to prepare: --- 6.2 Add prerequisites to archprepare:
--- 6.3 List directories to visit when descending --- 6.3 List directories to visit when descending
--- 6.4 Architecture specific boot images --- 6.4 Architecture specific boot images
--- 6.5 Building non-kbuild targets --- 6.5 Building non-kbuild targets
...@@ -734,18 +734,18 @@ When kbuild executes the following steps are followed (roughly): ...@@ -734,18 +734,18 @@ When kbuild executes the following steps are followed (roughly):
for loadable kernel modules. for loadable kernel modules.
--- 6.2 Add prerequisites to prepare: --- 6.2 Add prerequisites to archprepare:
The prepare: rule is used to list prerequisites that needs to be The archprepare: rule is used to list prerequisites that needs to be
built before starting to descend down in the subdirectories. built before starting to descend down in the subdirectories.
This is usual header files containing assembler constants. This is usual header files containing assembler constants.
Example: Example:
#arch/s390/Makefile #arch/arm/Makefile
prepare: include/asm-$(ARCH)/offsets.h archprepare: maketools
In this example the file include/asm-$(ARCH)/offsets.h will In this example the file target maketools will be processed
be built before descending down in the subdirectories. before descending down in the subdirectories.
See also chapter XXX-TODO that describe how kbuild supports See also chapter XXX-TODO that describe how kbuild supports
generating offset header files. generating offset header files.
......
...@@ -776,15 +776,20 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; ...@@ -776,15 +776,20 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
# Error messages still appears in the original language # Error messages still appears in the original language
.PHONY: $(vmlinux-dirs) .PHONY: $(vmlinux-dirs)
$(vmlinux-dirs): prepare-all scripts $(vmlinux-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@ $(Q)$(MAKE) $(build)=$@
# Things we need to do before we recursively start building the kernel # Things we need to do before we recursively start building the kernel
# or the modules are listed in "prepare-all". # or the modules are listed in "prepare".
# A multi level approach is used. prepare1 is updated first, then prepare0. # A multi level approach is used. prepareN is processed before prepareN-1.
# prepare-all is the collection point for the prepare targets. # archprepare is used in arch Makefiles and when processed asm symlink,
# version.h and scripts_basic is processed / created.
.PHONY: prepare-all prepare prepare0 prepare1 prepare2 prepare3 # Listed in dependency order
.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3
# prepare-all is deprecated, use prepare as valid replacement
.PHONY: prepare-all
# prepare3 is used to check if we are building in a separate output directory, # prepare3 is used to check if we are building in a separate output directory,
# and if so do: # and if so do:
...@@ -813,11 +818,13 @@ ifneq ($(KBUILD_MODULES),) ...@@ -813,11 +818,13 @@ ifneq ($(KBUILD_MODULES),)
$(Q)mkdir -p $(MODVERDIR) $(Q)mkdir -p $(MODVERDIR)
endif endif
prepare0: prepare prepare1 FORCE archprepare: prepare1 scripts_basic
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=. $(Q)$(MAKE) $(build)=.
# All the preparing.. # All the preparing..
prepare-all: prepare0 prepare prepare-all: prepare0
# Leave this as default for preprocessing vmlinux.lds.S, which is now # Leave this as default for preprocessing vmlinux.lds.S, which is now
# done in arch/$(ARCH)/kernel/Makefile # done in arch/$(ARCH)/kernel/Makefile
...@@ -908,7 +915,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) ...@@ -908,7 +915,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
# Target to prepare building external modules # Target to prepare building external modules
.PHONY: modules_prepare .PHONY: modules_prepare
modules_prepare: prepare-all scripts modules_prepare: prepare scripts
# Target to install modules # Target to install modules
.PHONY: modules_install .PHONY: modules_install
......
...@@ -175,7 +175,7 @@ else ...@@ -175,7 +175,7 @@ else
endif endif
@touch $@ @touch $@
prepare: maketools include/asm-arm/.arch archprepare: maketools include/asm-arm/.arch
.PHONY: maketools FORCE .PHONY: maketools FORCE
maketools: include/linux/version.h FORCE maketools: include/linux/version.h FORCE
......
...@@ -107,7 +107,7 @@ archclean: ...@@ -107,7 +107,7 @@ archclean:
rm -f timage vmlinux.bin decompress.bin rescue.bin cramfs.img rm -f timage vmlinux.bin decompress.bin rescue.bin cramfs.img
rm -rf $(LD_SCRIPT).tmp rm -rf $(LD_SCRIPT).tmp
prepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch archprepare: $(SRC_ARCH)/.links $(srctree)/include/asm-$(ARCH)/.arch
# Create some links to make all tools happy # Create some links to make all tools happy
$(SRC_ARCH)/.links: $(SRC_ARCH)/.links:
......
...@@ -82,7 +82,7 @@ unwcheck: vmlinux ...@@ -82,7 +82,7 @@ unwcheck: vmlinux
archclean: archclean:
$(Q)$(MAKE) $(clean)=$(boot) $(Q)$(MAKE) $(clean)=$(boot)
prepare: include/asm-ia64/.offsets.h.stamp archprepare: include/asm-ia64/.offsets.h.stamp
include/asm-ia64/.offsets.h.stamp: include/asm-ia64/.offsets.h.stamp:
mkdir -p include/asm-ia64 mkdir -p include/asm-ia64
......
...@@ -107,7 +107,7 @@ archclean: ...@@ -107,7 +107,7 @@ archclean:
# Temporary hack until we have migrated to asm-powerpc # Temporary hack until we have migrated to asm-powerpc
$(Q)rm -rf arch/$(ARCH)/include $(Q)rm -rf arch/$(ARCH)/include
prepare: checkbin archprepare: checkbin
# Temporary hack until we have migrated to asm-powerpc # Temporary hack until we have migrated to asm-powerpc
include/asm: arch/$(ARCH)/include/asm include/asm: arch/$(ARCH)/include/asm
......
...@@ -152,7 +152,7 @@ endif ...@@ -152,7 +152,7 @@ endif
@touch $@ @touch $@
prepare: maketools include/asm-sh/.cpu include/asm-sh/.mach archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
.PHONY: maketools FORCE .PHONY: maketools FORCE
maketools: include/linux/version.h FORCE maketools: include/linux/version.h FORCE
......
...@@ -73,7 +73,7 @@ compressed: zImage ...@@ -73,7 +73,7 @@ compressed: zImage
archclean: archclean:
$(Q)$(MAKE) $(clean)=$(boot) $(Q)$(MAKE) $(clean)=$(boot)
prepare: arch/$(ARCH)/lib/syscalltab.h archprepare: arch/$(ARCH)/lib/syscalltab.h
define filechk_gen-syscalltab define filechk_gen-syscalltab
(set -e; \ (set -e; \
......
...@@ -107,7 +107,7 @@ else ...@@ -107,7 +107,7 @@ else
$(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
endif endif
prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
......
...@@ -66,7 +66,7 @@ boot := arch/xtensa/boot ...@@ -66,7 +66,7 @@ boot := arch/xtensa/boot
archinc := include/asm-xtensa archinc := include/asm-xtensa
prepare: $(archinc)/.platform archprepare: $(archinc)/.platform
# Update machine cpu and platform symlinks if something which affects # Update machine cpu and platform symlinks if something which affects
# them changed. # them changed.
......
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