1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
5 ifndef INCLUDED_RULES_MK
6 include $(topsrcdir
)/config
/rules.mk
9 # Make sure that anything that needs to be defined in moz.build wasn't
10 # overwritten after including rules.mk.
11 _eval_for_side_effects
:= $(CHECK_MOZBUILD_VARIABLES
)
13 # The traditional model of directory traversal with make is as follows:
23 # Pseudo derecurse transforms the above into:
33 # Disable build status for mach in top directories without TIERS.
34 # In practice this disables it when recursing under js/src, which confuses mach.
39 # Main rules (export, compile, libs and tools) call recurse_* rules.
40 # This wrapping is only really useful for build status.
41 compile libs
export tools
::
42 $(call BUILDSTATUS
,TIER_START
$@
)
44 $(call BUILDSTATUS
,TIER_FINISH
$@
)
46 # Special rule that does install-manifests (cf. Makefile.in) + compile
48 +$(MAKE
) recurse_compile
50 # Carefully avoid $(eval) type of rule generation, which makes pymake slower
52 # Get current tier and corresponding subtiers from the data in root.mk.
53 CURRENT_TIER
:= $(filter $(foreach tier
,compile libs
export tools
,recurse_
$(tier
) $(tier
)-deps
),$(MAKECMDGOALS
))
54 ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER
))))
55 $(error
$(CURRENT_TIER
) not supported on the same make command line
)
57 CURRENT_TIER
:= $(subst recurse_
,,$(CURRENT_TIER
:-deps
=))
59 # The rules here are doing directory traversal, so we don't want further
60 # recursion to happen when running make -C subdir $tier. But some make files
61 # further call make -C something else, and sometimes expect recursion to
62 # happen in that case (see browser/metro/locales/Makefile.in for example).
63 # Conveniently, every invocation of make increases MAKELEVEL, so only stop
64 # recursion from happening at current MAKELEVEL + 1.
67 export NO_RECURSE_MAKELEVEL
=1
69 export NO_RECURSE_MAKELEVEL
=$(word $(MAKELEVEL
),2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
73 # Get all directories traversed for all subtiers in the current tier, or use
74 # directly the $(*_dirs) variables available in root.mk when there is no
75 # TIERS (like for js/src).
76 CURRENT_DIRS
:= $($(CURRENT_TIER
)_dirs
)
78 # The compile tier has different rules from other tiers.
79 ifeq ($(CURRENT_TIER
),compile
)
81 # Need a list of compile targets because we can't use pattern rules:
82 # https://savannah.gnu.org/bugs/index.php?42833
83 .PHONY
: $(compile_targets
)
85 $(call SUBMAKE
,$(@F
),$(@D
))
89 # Recursion rule for all directories traversed for all subtiers in the
91 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): %/$(CURRENT_TIER
):
92 $(call SUBMAKE
,$(CURRENT_TIER
),$*)
94 .PHONY
: $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
))
96 # Dummy rules for possibly inexisting dependencies for the above tier targets
97 $(addsuffix /Makefile
,$(CURRENT_DIRS
)) $(addsuffix /backend.mk
,$(CURRENT_DIRS
)):
99 ifeq ($(CURRENT_TIER
),export)
100 # At least build/export requires config/export for buildid, but who knows what
101 # else, so keep this global dependency to make config/export first for now.
102 $(addsuffix /$(CURRENT_TIER
),$(filter-out config
,$(CURRENT_DIRS
))): config
/$(CURRENT_TIER
)
104 # The export tier requires nsinstall, which is built from config. So every
105 # subdirectory traversal needs to happen after building nsinstall in config, which
106 # is done with the config/host target. Note the config/host target only exists if
107 # nsinstall is actually built, which it is not on Windows, because we use
108 # nsinstall.py there.
109 ifneq (,$(filter config
/host
, $(compile_targets
)))
110 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): config
/host
112 # Ensure rules for config/host and its possible dependencies.
113 .PHONY
: $(filter %/host
, $(compile_targets
))
114 $(filter %/host
, $(compile_targets
)):
115 $(call SUBMAKE
,host
,$(@D
))
119 endif # ifeq ($(CURRENT_TIER),compile)
123 # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
124 ifeq ($(NO_RECURSE_MAKELEVEL
),$(MAKELEVEL
))
126 compile libs
export tools
::
129 #########################
130 # Tier traversal handling
131 #########################
136 $(call BUILDSTATUS
,TIER_START
$@
)
137 $(foreach tier
,$(TIERS
), $(if
$(filter-out libs_precompile tools_precompile
,$@_
$(tier
)), \
138 $(foreach dir, $(tier_
$(tier
)_dirs
), $(call TIER_DIR_SUBMAKE
,$@
,$(tier
),$(dir),$@
))))
139 $(call BUILDSTATUS
,TIER_FINISH
$@
)
143 define CREATE_SUBTIER_TRAVERSAL_RULE
146 $(1):: $$(SUBMAKEFILES
)
151 $(foreach subtier
,export libs tools
,$(eval
$(call CREATE_SUBTIER_TRAVERSAL_RULE
,$(subtier
))))
153 ifndef TOPLEVEL_BUILD
159 endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
161 endif # ifeq (.,$(DEPTH))