Bug 1577282 - Part 1: Move the requires before the constants and format the markup...
[gecko.git] / Makefile.in
blob407e373573fb20b573b5cddf35a5616ef417484b
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 ifeq (,$(MAKE_VERSION))
7 $(error GNU Make is required)
8 endif
9 make_min_ver := 3.81
10 ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION))))
11 $(error GNU Make $(make_min_ver) or higher is required)
12 endif
14 export TOPLEVEL_BUILD := 1
16 default::
18 ifndef TEST_MOZBUILD
19 ifdef MOZ_BUILD_APP
20 include $(wildcard $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk)
21 endif
22 endif
24 include $(topsrcdir)/config/config.mk
26 GARBAGE_DIRS += _javagen _profile staticlib
27 # To share compilation of dependencies, Rust libraries all set their
28 # CARGO_TARGET_DIR as a subdirectory of topobjdir. Normally, we would add
29 # RUST*TARGET to GARBAGE_DIRS for those directories building Rust libraries.
30 # But the directories building Rust libraries don't actually have
31 # subdirectories to remove. So we add to GARBAGE_DIRS once here, globally,
32 # for it to have the desired effect.
33 GARBAGE_DIRS += $(RUST_TARGET)
34 DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
35 config/autoconf.mk \
36 mozilla-config.h \
37 netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
38 .mozconfig.mk
40 ifndef MOZ_PROFILE_USE
41 ifneq (mobile/android,$(MOZ_BUILD_APP))
42 $(MDDEPDIR)/buildid.h.stub $(MDDEPDIR)/source-repo.h.stub: FORCE
43 endif
44 source-repo.h: $(MDDEPDIR)/source-repo.h.stub
45 buildid.h: $(MDDEPDIR)/buildid.h.stub
46 endif
48 BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
50 ifndef TEST_MOZBUILD
51 ifndef MOZ_PROFILE_USE
52 # We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in
53 # rules.mk doesn't run early enough.
54 $(RUNNABLE_TIERS) binaries:: CLOBBER $(BUILD_BACKEND_FILES)
55 endif
56 endif
58 ifdef JS_STANDALONE
59 .PHONY: CLOBBER
60 CLOBBER:
61 else
62 CLOBBER: $(topsrcdir)/CLOBBER
63 @echo 'STOP! The CLOBBER file has changed.'
64 @echo 'Please run the build through "mach build".'
65 @exit 1
66 endif
68 install_manifests := \
69 $(addprefix dist/,branding include public private xpi-stage) \
70 _tests \
71 $(NULL)
72 # Skip the dist/bin install manifest when using the hybrid
73 # FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves
74 # xpidl handling to FasterMake in that case, mechanically making the dist/bin
75 # install manifest non-existent (non-existent manifests being skipped)
76 ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
77 install_manifests += dist/bin
78 endif
79 install_manifest_depends = \
80 CLOBBER \
81 $(BUILD_BACKEND_FILES) \
82 $(NULL)
84 .PHONY: install-manifests
85 install-manifests: $(addprefix install-,$(install_manifests))
87 # If we're using the hybrid FasterMake/RecursiveMake backend, we want
88 # to recurse in the faster/ directory in parallel of install manifests.
89 ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
90 install-manifests: faster
91 .PHONY: faster
92 faster:
93 $(MAKE) -C faster FASTER_RECURSIVE_MAKE=1
94 endif
96 .PHONY: $(addprefix install-,$(install_manifests))
97 $(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends)
98 ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS)))
99 @# If we're using the hybrid FasterMake/RecursiveMake backend, we want
100 @# to ensure the FasterMake end doesn't have install manifests for the
101 @# same directory, because that would blow up
102 $(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*)))
103 endif
104 $(addprefix $(call py_action,process_install_manifest,--track install_$(subst /,_,$*).track $*) ,$(wildcard _build_manifests/install/$(subst /,_,$*)))
106 # Dummy wrapper rule to allow the faster backend to piggy back
107 $(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ;
109 .PHONY: install-tests
110 install-tests: install-test-files
112 .PHONY: install-test-files
113 install-test-files:
114 $(call py_action,process_install_manifest,--track install__test_files.track _tests _build_manifests/install/_test_files)
116 include $(topsrcdir)/build/moz-automation.mk
118 # dist and _tests should be purged during cleaning. However, we don't want them
119 # purged during PGO builds because they contain some auto-generated files.
120 ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),)
121 GARBAGE_DIRS += dist _tests
122 endif
124 # Dummy rule for the cases below where we don't depend on dist/include
125 recurse_pre-export::
127 # Windows PGO builds don't perform a clean before the 2nd pass. So, we want
128 # to preserve content for the 2nd pass on Windows. Everywhere else, we always
129 # process the install manifests as part of export.
130 # For the binaries rule, not all the install manifests matter, so force only
131 # the interesting ones to be done.
132 ifdef MOZ_1TIER_PGO
133 ifndef NO_PROFILE_GUIDED_OPTIMIZE
134 ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
135 recurse_pre-export:: install-manifests
136 binaries::
137 @$(MAKE) install-manifests install_manifests=dist/include
138 endif
139 endif
140 else # !MOZ_1TIER_PGO (normal build)
141 recurse_pre-export:: install-manifests
142 binaries::
143 @$(MAKE) install-manifests install_manifests=dist/include
144 endif
146 # Host binaries are not produced for macOS consumers: that is, there's
147 # no macOS-hosted job to produce them at this time. Therefore we
148 # enable --host-bins only for automation builds, which only require Linux and
149 # Windows host binaries.
150 recurse_artifact:
151 $(topsrcdir)/mach --log-no-times artifact install$(if $(MOZ_ARTIFACT_BUILD_SYMBOLS), --symbols$(addprefix =,$(filter full,$(MOZ_ARTIFACT_BUILD_SYMBOLS))))$(if $(MOZ_AUTOMATION), --host-bins)
153 ifdef MOZ_EME_WIN32_ARTIFACT
154 recurse_win32-artifact:
155 rm -rf $(DIST)/i686
156 $(topsrcdir)/mach --log-no-times artifact install --job $(if $(MOZ_PGO),win32-pgo,win32-opt) --no-tests --distdir $(DIST)/i686
157 mv $(DIST)/i686/bin/* $(DIST)/i686
158 endif
160 ifdef MOZ_ANDROID_FAT_AAR_ARCHITECTURES
161 recurse_android-fat-aar-artifact:
162 $(call py_action,fat_aar,\
163 $(addprefix --armeabi-v7a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARMEABI_V7A)) \
164 $(addprefix --arm64-v8a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARM64_V8A)) \
165 $(addprefix --x86 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86)) \
166 $(addprefix --x86-64 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86_64)) \
167 --distdir $(abspath $(DIST)/fat-aar))
168 endif
170 ifeq ($(MOZ_BUILD_APP),mobile/android)
172 recurse_android-stage-package: stage-package
174 recurse_android-archive-geckoview:
175 GRADLE_INVOKED_WITHIN_MACH_BUILD=1 $(topsrcdir)/mach --log-no-times android archive-geckoview
176 endif
178 ifdef MOZ_WIDGET_TOOLKIT
179 ifdef ENABLE_TESTS
180 # Additional makefile targets to call automated test suites
181 include $(topsrcdir)/testing/testsuite-targets.mk
182 endif
183 endif
185 default all::
186 $(call BUILDSTATUS,TIERS $(TIERS) $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS)))
188 # PGO build target.
189 profiledbuild::
190 $(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use)
191 $(call BUILDSTATUS,TIER_START pgo_profile_generate)
192 $(MAKE) default MOZ_PROFILE_GENERATE=1 MOZ_LTO=
193 $(call BUILDSTATUS,TIER_FINISH pgo_profile_generate)
194 $(call BUILDSTATUS,TIER_START pgo_package)
195 $(MAKE) package MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
196 rm -f jarlog/en-US.log
197 $(call BUILDSTATUS,TIER_FINISH pgo_package)
198 $(call BUILDSTATUS,TIER_START pgo_profile)
199 JARLOG_FILE=jarlog/en-US.log $(PYTHON) $(topsrcdir)/build/pgo/profileserver.py
200 $(call BUILDSTATUS,TIER_FINISH pgo_profile)
201 $(call BUILDSTATUS,TIER_START pgo_clobber)
202 $(MAKE) maybe_clobber_profiledbuild
203 $(call BUILDSTATUS,TIER_FINISH pgo_clobber)
204 $(call BUILDSTATUS,TIER_START pgo_profile_use)
205 $(MAKE) default MOZ_PROFILE_USE=1 MOZ_1TIER_PGO=1
206 $(call BUILDSTATUS,TIER_FINISH pgo_profile_use)
208 # Change default target to PGO build if PGO is enabled.
209 ifdef MOZ_PGO
210 ifdef COMPILE_ENVIRONMENT
211 # If one of these is already set in addition to PGO we are doing a single phase
212 # of PGO in isolation, so don't override the default target.
213 ifeq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
214 OVERRIDE_DEFAULT_GOAL := profiledbuild
215 endif
216 endif
217 endif
219 include $(topsrcdir)/config/rules.mk
221 ifdef SCCACHE_VERBOSE_STATS
222 default::
223 -$(CCACHE) --show-stats --stats-format=json > sccache-stats.json
224 @echo "===SCCACHE STATS==="
225 -$(CCACHE) --show-stats
226 @echo "==================="
227 endif
229 distclean::
230 $(RM) $(DIST_GARBAGE)
232 ifdef MOZ_CRASHREPORTER
233 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
235 endif
237 .PHONY: prepsymbolsarchive
238 prepsymbolsarchive:
239 echo packing symbols
240 $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
242 ifndef MOZ_AUTOMATION
243 prepsymbolsarchive: recurse_syms
244 endif
246 .PHONY: symbolsfullarchive
247 symbolsfullarchive: prepsymbolsarchive
248 $(RM) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
249 $(call py_action,symbols_archive,'$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' \
250 $(abspath $(DIST)/crashreporter-symbols) \
251 --full-archive)
253 .PHONY: symbolsarchive
254 symbolsarchive: prepsymbolsarchive
255 $(RM) '$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip'
256 $(call py_action,symbols_archive,'$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' \
257 $(abspath $(DIST)/crashreporter-symbols))
259 ifdef MOZ_CRASHREPORTER
260 # Set MOZ_DISABLE_FULL_SYMBOLS to disable generation and upload of the full
261 # crashreporter symbols archives
262 ifdef MOZ_DISABLE_FULL_SYMBOLS
263 buildsymbols: symbolsarchive
264 else
265 buildsymbols: symbolsfullarchive symbolsarchive
266 endif # MOZ_DISABLE_FULL_SYMBOLS
267 else
268 buildsymbols:
269 endif
271 uploadsymbols:
272 ifdef MOZ_CRASHREPORTER
273 $(PYTHON) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
274 endif
276 .PHONY: update-packaging
277 update-packaging:
278 $(MAKE) -C tools/update-packaging
280 .PHONY: package-generated-sources
281 package-generated-sources:
282 $(call py_action,package_generated_sources,'$(DIST)/$(PKG_PATH)$(GENERATED_SOURCE_FILE_PACKAGE)')
284 # PGO support, but we can't do this test in client.mk
285 # No point in clobbering if PGO has been explicitly disabled.
286 ifdef NO_PROFILE_GUIDED_OPTIMIZE
287 maybe_clobber_profiledbuild:
288 else
289 maybe_clobber_profiledbuild: clean
290 ifneq (,$(findstring clang,$(CC_TYPE)))
291 $(LLVM_PROFDATA) merge -o $(DEPTH)/merged.profdata $(DEPTH)/*.profraw
292 endif
293 endif # NO_PROFILE_GUIDED_OPTIMIZE
295 .PHONY: maybe_clobber_profiledbuild
297 ifdef JS_STANDALONE
298 # Delegate js-specific rules to js
299 check-%:
300 $(MAKE) -C js/src $@
302 source-package install:
303 $(MAKE) -C js/src $@
305 # Every export rule depends on config/export, but the rule for config/export
306 # doesn't exist when building js non-standalone.
307 .PHONY: config/export
308 config/export:
310 endif
312 # There used to be build interdependencies here. They are now in config/recurse.mk