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 # The traditional model of directory traversal with make is as follows:
19 # Pseudo derecurse transforms the above into:
29 # Main rules (export, compile, libs and tools) call recurse_* rules.
30 # This wrapping is only really useful for build status.
32 $(if
$(filter $@
,$(MAKECMDGOALS
)),$(call BUILDSTATUS
,TIERS
$@
),)
33 $(call BUILDSTATUS
,TIER_START
$@
)
35 $(call BUILDSTATUS
,TIER_FINISH
$@
)
37 # Special rule that does install-manifests (cf. Makefile.in) + compile
39 +$(MAKE
) recurse_compile
41 # Carefully avoid $(eval) type of rule generation, which makes pymake slower
43 # Get current tier and corresponding subtiers from the data in root.mk.
44 CURRENT_TIER
:= $(filter $(foreach tier
,$(TIERS
) $(non_default_tiers
),recurse_
$(tier
) $(tier
)-deps
),$(MAKECMDGOALS
))
45 ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER
))))
46 $(error
$(CURRENT_TIER
) not supported on the same make command line
)
48 CURRENT_TIER
:= $(subst recurse_
,,$(CURRENT_TIER
:-deps
=))
50 # The rules here are doing directory traversal, so we don't want further
51 # recursion to happen when running make -C subdir $tier. But some make files
52 # further call make -C something else, and sometimes expect recursion to
53 # happen in that case.
54 # Conveniently, every invocation of make increases MAKELEVEL, so only stop
55 # recursion from happening at current MAKELEVEL + 1.
58 export NO_RECURSE_MAKELEVEL
=1
60 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)
64 RECURSE
= $(if
$(RECURSE_TRACE_ONLY
),@echo
$2/$1,$(call SUBMAKE
,$1,$2))
66 # Use the $(*_dirs) variables available in root.mk
67 CURRENT_DIRS
:= $($(CURRENT_TIER
)_dirs
)
69 # Need a list of compile targets because we can't use pattern rules:
70 # https://savannah.gnu.org/bugs/index.php?42833
71 # Only recurse the paths starting with RECURSE_BASE_DIR when provided.
72 .PHONY
: $(compile_targets
) $(syms_targets
)
73 $(compile_targets
) $(syms_targets
):
74 $(if
$(filter $(RECURSE_BASE_DIR
)%,$@
),$(call RECURSE
,$(@F
),$(@D
)))
76 $(syms_targets
): %/syms
: %/target
78 # Only hook symbols targets into the main compile graph in automation.
80 ifeq (1,$(MOZ_AUTOMATION_BUILD_SYMBOLS
))
81 recurse_compile
: $(syms_targets
)
85 # Create a separate rule that depends on every 'syms' target so that
86 # symbols can be dumped on demand locally.
88 recurse_syms
: $(syms_targets
)
90 # Ensure dump_syms gets built before any syms targets, all of which depend on it.
91 ifneq (,$(filter toolkit
/crashreporter
/google-breakpad
/src
/tools
/%/dump_syms
/host
,$(compile_targets
)))
92 $(syms_targets
): $(filter toolkit
/crashreporter
/google-breakpad
/src
/tools
/%/dump_syms
/host
,$(compile_targets
))
95 # The compile tier has different rules from other tiers.
96 ifneq ($(CURRENT_TIER
),compile
)
98 # Recursion rule for all directories traversed for all subtiers in the
100 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): %/$(CURRENT_TIER
):
101 $(call RECURSE
,$(CURRENT_TIER
),$*)
103 .PHONY
: $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
))
105 # Dummy rules for possibly inexisting dependencies for the above tier targets
106 $(addsuffix /Makefile
,$(CURRENT_DIRS
)) $(addsuffix /backend.mk
,$(CURRENT_DIRS
)):
108 ifeq ($(CURRENT_TIER
),export)
109 # At least build/export requires config/export for buildid, but who knows what
110 # else, so keep this global dependency to make config/export first for now.
111 $(addsuffix /$(CURRENT_TIER
),$(filter-out config
,$(CURRENT_DIRS
))): config
/$(CURRENT_TIER
)
113 # The export tier requires nsinstall, which is built from config. So every
114 # subdirectory traversal needs to happen after building nsinstall in config, which
115 # is done with the config/host target. Note the config/host target only exists if
116 # nsinstall is actually built, which it is not on Windows, because we use
117 # nsinstall.py there.
118 ifdef COMPILE_ENVIRONMENT
119 ifneq (,$(filter config
/host
, $(compile_targets
)))
120 $(addsuffix /$(CURRENT_TIER
),$(CURRENT_DIRS
)): config
/host
125 endif # ifeq ($(CURRENT_TIER),compile)
129 # Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
130 ifeq ($(NO_RECURSE_MAKELEVEL
),$(MAKELEVEL
))
135 #########################
136 # Tier traversal handling
137 #########################
139 define CREATE_SUBTIER_TRAVERSAL_RULE
142 $(1):: $$(SUBMAKEFILES
)
147 $(foreach subtier
,$(filter-out compile
,$(TIERS
)),$(eval
$(call CREATE_SUBTIER_TRAVERSAL_RULE
,$(subtier
))))
149 ifndef TOPLEVEL_BUILD
150 ifdef COMPILE_ENVIRONMENT
152 @
$(MAKE
) -C
$(DEPTH
) compile RECURSE_BASE_DIR
=$(relativesrcdir
)/
153 endif # COMPILE_ENVIRONMENT
156 endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
158 endif # ifeq (.,$(DEPTH))
165 # Interdependencies for parallel export.
166 js
/xpconnect
/src
/export: dom
/bindings
/export xpcom
/xpidl
/export
167 accessible
/xpcom
/export: xpcom
/xpidl
/export
169 # The Android SDK bindings needs to build the Java generator code
170 # source code in order to write the SDK bindings.
171 widget
/android
/bindings
/export: mobile
/android
/base
/export
173 # The widget JNI wrapper generator code needs to build the GeckoView
174 # and Fennec source code in order to find JNI wrapper annotations.
175 widget
/android
/fennec
/export: mobile
/android
/base
/export
176 widget
/android
/export: mobile
/android
/base
/export
178 # .xpt generation needs the xpidl lex/yacc files
179 xpcom
/xpidl
/export: xpcom
/idl-parser
/xpidl
/export
181 # CSS2Properties.webidl needs ServoCSSPropList.py from layout/style
182 dom
/bindings
/export: layout
/style
/export
184 ifdef ENABLE_CLANG_PLUGIN
185 $(filter-out config
/host build
/unix
/stdc
++compat
/% build
/clang-plugin
/%,$(compile_targets
)): build
/clang-plugin
/host build
/clang-plugin
/tests
/target
186 build
/clang-plugin
/tests
/target
: build
/clang-plugin
/host
189 # Interdependencies that moz.build world don't know about yet for compilation.
190 # Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
191 ifeq ($(MOZ_WIDGET_TOOLKIT
),gtk3
)
192 toolkit
/library
/target
: widget
/gtk
/mozgtk
/gtk3
/target
195 ldap
/target
: security
/target mozglue
/build
/target
196 toolkit
/library
/target
: ldap
/target
199 # Most things are built during compile (target/host), but some things happen during export
200 # Those need to depend on config/export for system wrappers.
201 $(addprefix build
/unix
/stdc
++compat
/,target host
) build
/clang-plugin
/host
: config
/export