]> git.saurik.com Git - apple/xnu.git/blame - makedefs/MakeInc.dir
xnu-6153.141.1.tar.gz
[apple/xnu.git] / makedefs / MakeInc.dir
CommitLineData
39236c6e
A
1# -*- mode: makefile;-*-
2#
39037602 3# Copyright (C) 1999-2016 Apple Inc. All rights reserved.
39236c6e
A
4#
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.
11#
12
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
21define RECURSIVE_BUILD_RULES_template
22$(1)_recurse_target_list = $$(addprefix $(1)_recurse_into_,$(2))
23
24.PHONY: $$($(1)_recurse_target_list)
25
26$$($(1)_recurse_target_list):
39037602
A
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" \
39236c6e
A
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} \
39037602
A
34 SOURCE="$$(SOURCE)$$(patsubst $(1)_recurse_into_%,%,$$@)/" \
35 RELATIVE_SOURCE_PATH="$$(RELATIVE_SOURCE_PATH)/$$(patsubst $(1)_recurse_into_%,%,$$@)" \
39236c6e 36 TARGET=$(if $(4),$${OBJPATH}/$$(COMPONENT),$$(TARGET)$$(patsubst $(1)_recurse_into_%,%,$$@)/) \
39037602 37 OBJPATH=$${OBJPATH} \
39236c6e
A
38 $(1);
39
40.PHONY: $(1)
41
42$(1): $$($(1)_recurse_target_list)
39037602 43 $$(_v)$${MAKE} -C "$$(CURDIR)" \
39236c6e
A
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} \
49 SOURCE=$$(SOURCE) \
50 RELATIVE_SOURCE_PATH=$$(RELATIVE_SOURCE_PATH) \
51 TARGET=$$(TARGET) \
39037602 52 OBJPATH=$${OBJPATH} \
39236c6e
A
53 $(3);
54endef
316670eb 55
1c79356b 56#
39236c6e 57# Setup pass for all architectures for all Configuration/Architecture options
1c79356b 58#
39236c6e 59$(eval $(call RECURSIVE_BUILD_RULES_template,build_setup,$(SETUP_SUBDIRS),do_build_setup,))
1c79356b
A
60
61#
39037602 62# Install machine independent kernel header files
1c79356b 63#
39236c6e 64$(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_mi,$(INSTINC_SUBDIRS),do_installhdrs_mi,))
1c79356b
A
65
66#
39037602 67# Install machine dependent kernel header files
1c79356b 68#
39236c6e 69$(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_md,$(INSTINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_installhdrs_md,))
1c79356b
A
70
71#
39037602 72# Install machine independent kernel header files
1c79356b 73#
39236c6e 74$(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_mi,$(EXPINC_SUBDIRS),do_exporthdrs_mi,))
1c79356b
A
75
76#
39037602 77# Install machine dependent kernel header files
1c79356b 78#
39236c6e 79$(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_md,$(EXPINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_exporthdrs_md,))
316670eb 80
1c79356b
A
81#
82# Build all architectures for all Configuration/Architecture options
83#
39236c6e 84$(eval $(call RECURSIVE_BUILD_RULES_template,build_all,$(COMP_SUBDIRS) $(COMP_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_build_all,1))
1c79356b
A
85
86#
39236c6e 87# Post-process build results
2d21ac55 88#
39236c6e 89$(eval $(call RECURSIVE_BUILD_RULES_template,config_all,$(CONFIG_SUBDIRS),do_config_all,1))
1c79356b
A
90
91#
92# Install for all architectures for all Configuration/Architecture options
93#
39236c6e
A
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))
fe8ab488 96$(eval $(call RECURSIVE_BUILD_RULES_template,config_install,$(CONFIG_SUBDIRS),do_config_install,1))
1c79356b 97
9bccf70c 98#
fe8ab488 99# Install text files
9bccf70c 100#
fe8ab488 101$(eval $(call RECURSIVE_BUILD_RULES_template,textfiles_install,$(INSTTEXTFILES_SUBDIRS),do_textfiles_install,))
2d21ac55
A
102
103# vim: set ft=make: