1 # -*- mode: makefile;-*-
3 # Copyright (C) 1999-2012 Apple Inc. All rights reserved.
5 # MakeInc.dir contains the recursion rules for the build system.
6 # For instance, the "build_installhdrs_md" target is auto-generated
7 # such that make(1) recurses into a specified set of subdirectories
8 # (building "build_installhdrs_md" in turn at each level) before
9 # building the special "do_installhdrs_md" target at the current
10 # level. "do_installhdrs_md" is defined in MakeInc.rule.
13 # $(1) is the name of the target to produce that will perform the
14 # recursive behavior via dependencies
15 # $(2) is a list of subdirectories to recurse into
16 # $(3) is the target to build with a sub-make after
17 # the subdirectories have been recursed into
18 # $(4) should be "1" if TARGET should be pinned to the per-arch
19 # build COMPONENT directory, or empty if it should recurse
20 # in lockstep with the source recursion
21 define RECURSIVE_BUILD_RULES_template
22 $(1)_recurse_target_list = $$(addprefix $(1)_recurse_into_,$(2))
24 .PHONY: $$($(1)_recurse_target_list)
26 $$($(1)_recurse_target_list):
27 $$(_v)$$(MKDIR) $$(CURDIR)/$$(patsubst $(1)_recurse_into_%,%,$$@)
28 $$(_v)$${MAKE} -C $$(CURDIR)/$$(patsubst $(1)_recurse_into_%,%,$$@) \
29 -f $$(SOURCE)$$(patsubst $(1)_recurse_into_%,%,$$@)/Makefile \
30 CURRENT_KERNEL_CONFIG=$${CURRENT_KERNEL_CONFIG} \
31 CURRENT_ARCH_CONFIG=$${CURRENT_ARCH_CONFIG} \
32 CURRENT_MACHINE_CONFIG=$${CURRENT_MACHINE_CONFIG} \
33 CURRENT_BUILD_CONFIG=$${CURRENT_BUILD_CONFIG} \
34 SOURCE=$$(SOURCE)$$(patsubst $(1)_recurse_into_%,%,$$@)/ \
35 RELATIVE_SOURCE_PATH=$$(RELATIVE_SOURCE_PATH)/$$(patsubst $(1)_recurse_into_%,%,$$@) \
36 TARGET=$(if $(4),$${OBJPATH}/$$(COMPONENT),$$(TARGET)$$(patsubst $(1)_recurse_into_%,%,$$@)/) \
42 $(1): $$($(1)_recurse_target_list)
43 $$(_v)$${MAKE} -C $$(CURDIR) \
44 -f $$(firstword $$(MAKEFILE_LIST)) \
45 CURRENT_KERNEL_CONFIG=$${CURRENT_KERNEL_CONFIG} \
46 CURRENT_ARCH_CONFIG=$${CURRENT_ARCH_CONFIG} \
47 CURRENT_MACHINE_CONFIG=$${CURRENT_MACHINE_CONFIG} \
48 CURRENT_BUILD_CONFIG=$${CURRENT_BUILD_CONFIG} \
50 RELATIVE_SOURCE_PATH=$$(RELATIVE_SOURCE_PATH) \
57 # Setup pass for all architectures for all Configuration/Architecture options
59 $(eval $(call RECURSIVE_BUILD_RULES_template,build_setup,$(SETUP_SUBDIRS),do_build_setup,))
62 # Install machine independent kernel header files
64 $(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_mi,$(INSTINC_SUBDIRS),do_installhdrs_mi,))
67 # Install machine dependent kernel header files
69 $(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_md,$(INSTINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_installhdrs_md,))
72 # Install machine independent kernel header files
74 $(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_mi,$(EXPINC_SUBDIRS),do_exporthdrs_mi,))
77 # Install machine dependent kernel header files
79 $(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_md,$(EXPINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_exporthdrs_md,))
82 # Build all architectures for all Configuration/Architecture options
84 $(eval $(call RECURSIVE_BUILD_RULES_template,build_all,$(COMP_SUBDIRS) $(COMP_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_build_all,1))
87 # Post-process build results
89 $(eval $(call RECURSIVE_BUILD_RULES_template,config_all,$(CONFIG_SUBDIRS),do_config_all,1))
92 # Install for all architectures for all Configuration/Architecture options
94 $(eval $(call RECURSIVE_BUILD_RULES_template,build_install_primary,$(INST_SUBDIRS),do_build_install_primary,1))
95 $(eval $(call RECURSIVE_BUILD_RULES_template,build_install_non_primary,$(INST_SUBDIRS),do_build_install_non_primary,1))
96 $(eval $(call RECURSIVE_BUILD_RULES_template,config_install,$(CONFIG_SUBDIRS),do_config_install,1))
101 $(eval $(call RECURSIVE_BUILD_RULES_template,textfiles_install,$(INSTTEXTFILES_SUBDIRS),do_textfiles_install,))