1# -*- mode: makefile;-*- 2# 3# Copyright (C) 1999-2012 Apple Inc. All rights reserved. 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): 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_%,%,$$@)/) \ 37 OBJPATH=$${OBJPATH} \ 38 $(1); 39 40.PHONY: $(1) 41 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} \ 49 SOURCE=$$(SOURCE) \ 50 RELATIVE_SOURCE_PATH=$$(RELATIVE_SOURCE_PATH) \ 51 TARGET=$$(TARGET) \ 52 OBJPATH=$${OBJPATH} \ 53 $(3); 54endef 55 56# 57# Setup pass for all architectures for all Configuration/Architecture options 58# 59$(eval $(call RECURSIVE_BUILD_RULES_template,build_setup,$(SETUP_SUBDIRS),do_build_setup,)) 60 61# 62# Install machine independent kernel header files 63# 64$(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_mi,$(INSTINC_SUBDIRS),do_installhdrs_mi,)) 65 66# 67# Install machine dependent kernel header files 68# 69$(eval $(call RECURSIVE_BUILD_RULES_template,build_installhdrs_md,$(INSTINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_installhdrs_md,)) 70 71# 72# Install machine independent kernel header files 73# 74$(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_mi,$(EXPINC_SUBDIRS),do_exporthdrs_mi,)) 75 76# 77# Install machine dependent kernel header files 78# 79$(eval $(call RECURSIVE_BUILD_RULES_template,build_exporthdrs_md,$(EXPINC_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_exporthdrs_md,)) 80 81# 82# Build all architectures for all Configuration/Architecture options 83# 84$(eval $(call RECURSIVE_BUILD_RULES_template,build_all,$(COMP_SUBDIRS) $(COMP_SUBDIRS_$(CURRENT_ARCH_CONFIG)),do_build_all,1)) 85 86# 87# Post-process build results 88# 89$(eval $(call RECURSIVE_BUILD_RULES_template,config_all,$(CONFIG_SUBDIRS),do_config_all,1)) 90 91# 92# Install for all architectures for all Configuration/Architecture options 93# 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)) 97 98# 99# Install text files 100# 101$(eval $(call RECURSIVE_BUILD_RULES_template,textfiles_install,$(INSTTEXTFILES_SUBDIRS),do_textfiles_install,)) 102 103# vim: set ft=make: 104