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 # Main rules (export, compile, libs and tools) call recurse_* rules.
34 # This wrapping is only really useful for build status.
36 $(call BUILDSTATUS
,TIER_START
$@
)
38 $(call BUILDSTATUS
,TIER_FINISH
$@
)
40 # Special rule that does install-manifests (cf. Makefile.in) + compile
42 +$(MAKE
) recurse_compile
44 # Carefully avoid $(eval) type of rule generation, which makes pymake slower
46 # Get current tier and corresponding subtiers from the data in root.mk.
47 CURRENT_TIER
:= $(filter $(foreach tier
,$(TIERS
),recurse_
$(tier
) $(tier
)-deps
),$(MAKECMDGOALS
))
48 ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER
))))
49 $(error
$(CURRENT_TIER
) not supported on the same make command line
)
51 CURRENT_TIER
:= $(subst recurse_
,,$(CURRENT_TIER
:-deps
=))
53 # The rules here are doing directory traversal, so we don't want further
54 # recursion to happen when running make -C subdir $tier. But some make files
55 # further call make -C something else, and sometimes expect recursion to
56 # happen in that case (see browser/metro/locales/Makefile.in for example).
57 # Conveniently, every invocation of make increases MAKELEVEL, so only stop
58 # recursion from happening at current MAKELEVEL + 1.
61 export NO_RECURSE_MAKELEVEL
=1
63 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)
67 # Use the $(*_dirs) variables available in root.mk
68 CURRENT_DIRS
:= $($(CURRENT_TIER
)_dirs
)
70 # Need a list of compile targets because we can't use pattern rules:
71 # https://savannah.gnu.org/bugs/index.php?42833
72 .PHONY
: $(compile_targets
)
74 $(call SUBMAKE
,$(@F
),$(@D
))
76 # The compile tier has different rules from other tiers.
77 ifneq ($(CURRENT_TIER
),compile
)
79 # Recursion rule for all directories traversed for all subtiers in the
81 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): %/$(CURRENT_TIER
):
82 $(call SUBMAKE
,$(CURRENT_TIER
),$*)
84 .PHONY
: $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
))
86 # Dummy rules for possibly inexisting dependencies for the above tier targets
87 $(addsuffix /Makefile
,$(CURRENT_DIRS
)) $(addsuffix /backend.mk
,$(CURRENT_DIRS
)):
89 ifeq ($(CURRENT_TIER
),export)
90 # At least build/export requires config/export for buildid, but who knows what
91 # else, so keep this global dependency to make config/export first for now.
92 $(addsuffix /$(CURRENT_TIER
),$(filter-out config
,$(CURRENT_DIRS
))): config
/$(CURRENT_TIER
)
94 # The export tier requires nsinstall, which is built from config. So every
95 # subdirectory traversal needs to happen after building nsinstall in config, which
96 # is done with the config/host target. Note the config/host target only exists if
97 # nsinstall is actually built, which it is not on Windows, because we use
99 ifneq (,$(filter config
/host
, $(compile_targets
)))
100 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): config
/host
104 endif # ifeq ($(CURRENT_TIER),compile)
108 # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
109 ifeq ($(NO_RECURSE_MAKELEVEL
),$(MAKELEVEL
))
114 #########################
115 # Tier traversal handling
116 #########################
118 define CREATE_SUBTIER_TRAVERSAL_RULE
121 $(1):: $$(SUBMAKEFILES
)
126 $(foreach subtier
,$(filter-out compile
,$(TIERS
)),$(eval
$(call CREATE_SUBTIER_TRAVERSAL_RULE
,$(subtier
))))
128 ifndef TOPLEVEL_BUILD
132 endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
134 endif # ifeq (.,$(DEPTH))
141 # Interdependencies for parallel export.
142 js
/xpconnect
/src
/export: dom
/bindings
/export xpcom
/xpidl
/export
143 accessible
/xpcom
/export: xpcom
/xpidl
/export
145 # The widget binding generator code is part of the annotationProcessors.
146 widget
/android
/bindings
/export: build
/annotationProcessors
/export
148 ifdef ENABLE_CLANG_PLUGIN
149 $(filter-out build
/clang-plugin
/%,$(compile_targets
)): build
/clang-plugin
/target build
/clang-plugin
/tests
/target
150 build
/clang-plugin
/tests
/target
: build
/clang-plugin
/target
153 # Interdependencies that moz.build world don't know about yet for compilation.
154 # Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
155 ifeq ($(MOZ_WIDGET_TOOLKIT
),gtk3
)
156 toolkit
/library
/target
: widget
/gtk
/mozgtk
/gtk3
/target
159 ldap
/target
: config
/external
/nss
/target mozglue
/build
/target
160 toolkit
/library
/target
: ldap
/target
162 ifeq ($(MOZ_REPLACE_MALLOC_LINKAGE
),dummy library
)
163 mozglue
/build
/target memory
/replace
/logalloc
/replay
/target
: memory
/replace
/dummy
/target
166 mozglue
/crt
/target
: mozglue
/build
/target
168 # js/src/target can end up invoking js/src/host rules (through object files
169 # depending on jsautokw.h, which depends on host_jskwgen, and that can't
170 # happen at the same time (bug #1146738)
171 js
/src
/target
: js
/src
/host