1# 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/. 5 6ifeq (,$(MAKE_VERSION)) 7$(error GNU Make is required) 8endif 9make_min_ver := 3.81 10ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION)))) 11$(error GNU Make $(make_min_ver) or higher is required) 12endif 13 14export TOPLEVEL_BUILD := 1 15 16default:: 17 18ifndef TEST_MOZBUILD 19ifdef MOZ_BUILD_APP 20include $(wildcard $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk) 21endif 22endif 23 24include $(topsrcdir)/config/config.mk 25 26GARBAGE_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. 33GARBAGE_DIRS += $(RUST_TARGET) 34GARBAGE_DIRS += config.statusd 35DIST_GARBAGE = config.cache config.log config.status config-defs.h \ 36 config/autoconf.mk \ 37 mozilla-config.h \ 38 xpcom/xpcom-config.h xpcom/xpcom-private.h \ 39 .mozconfig.mk 40 41ifneq (mobile/android,$(MOZ_BUILD_APP)) 42$(MDDEPDIR)/buildid.h.stub $(MDDEPDIR)/source-repo.h.stub: FORCE 43endif 44source-repo.h: $(MDDEPDIR)/source-repo.h.stub 45buildid.h: $(MDDEPDIR)/buildid.h.stub 46 47BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS))) 48 49ifndef TEST_MOZBUILD 50# We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in 51# rules.mk doesn't run early enough. 52$(RUNNABLE_TIERS) binaries:: CLOBBER $(BUILD_BACKEND_FILES) 53endif 54 55ifdef JS_STANDALONE 56.PHONY: CLOBBER 57CLOBBER: 58else 59CLOBBER: $(topsrcdir)/CLOBBER 60 @echo 'STOP! The CLOBBER file has changed.' 61 @echo 'Please run the build through "mach build".' 62 @exit 1 63endif 64 65install_manifests := \ 66 $(addprefix dist/,branding include public private xpi-stage) \ 67 _tests \ 68 $(NULL) 69# Skip the dist/bin install manifest when using the hybrid 70# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves 71# xpidl handling to FasterMake in that case, mechanically making the dist/bin 72# install manifest non-existent (non-existent manifests being skipped) 73ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 74install_manifests += dist/bin 75endif 76install_manifest_depends = \ 77 CLOBBER \ 78 $(BUILD_BACKEND_FILES) \ 79 $(NULL) 80 81.PHONY: install-manifests 82install-manifests: $(addprefix install-,$(install_manifests)) 83 84# If we're using the hybrid FasterMake/RecursiveMake backend, we want 85# to recurse in the faster/ directory in parallel of install manifests. 86ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 87install-manifests: faster 88.PHONY: faster 89faster: 90 $(MAKE) -C faster FASTER_RECURSIVE_MAKE=1 91endif 92 93.PHONY: $(addprefix install-,$(install_manifests)) 94$(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends) 95ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 96 @# If we're using the hybrid FasterMake/RecursiveMake backend, we want 97 @# to ensure the FasterMake end doesn't have install manifests for the 98 @# same directory, because that would blow up 99 $(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*))) 100endif 101 $(addprefix $(call py_action,process_install_manifest,--track install_$(subst /,_,$*).track $*) ,$(wildcard _build_manifests/install/$(subst /,_,$*))) 102 103# Dummy wrapper rule to allow the faster backend to piggy back 104$(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ; 105 106.PHONY: install-tests 107install-tests: install-test-files 108 109.PHONY: install-test-files 110install-test-files: 111 $(call py_action,process_install_manifest,--track install__test_files.track _tests _build_manifests/install/_test_files) 112 113include $(topsrcdir)/build/moz-automation.mk 114 115# dist and _tests should be purged during cleaning. 116GARBAGE_DIRS += dist _tests 117 118# Dummy rule for the cases below where we don't depend on dist/include 119recurse_pre-export:: 120 121# For the binaries rule, not all the install manifests matter, so force only 122# the interesting ones to be done. 123recurse_pre-export:: install-manifests 124binaries:: 125 @$(MAKE) install-manifests install_manifests=dist/include 126 127# Host binaries are not produced for macOS consumers: that is, there's 128# no macOS-hosted job to produce them at this time. Therefore we 129# enable --host-bins only for automation builds, which only require Linux and 130# Windows host binaries. 131recurse_artifact: 132 $(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) 133 134ifdef MOZ_EME_WIN32_ARTIFACT 135recurse_win32-artifact: 136 rm -rf $(DIST)/i686 137 $(topsrcdir)/mach --log-no-times artifact install --job $(if $(MOZ_PGO),win32-pgo,win32-opt) --no-tests --distdir $(DIST)/i686 138 mv $(DIST)/i686/bin/* $(DIST)/i686 139endif 140 141ifdef MOZ_ANDROID_FAT_AAR_ARCHITECTURES 142recurse_android-fat-aar-artifact: 143 $(call py_action,fat_aar,\ 144 $(addprefix --armeabi-v7a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARMEABI_V7A)) \ 145 $(addprefix --arm64-v8a $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_ARM64_V8A)) \ 146 $(addprefix --x86 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86)) \ 147 $(addprefix --x86-64 $(MOZ_FETCHES_DIR)/,$(MOZ_ANDROID_FAT_AAR_X86_64)) \ 148 --distdir $(abspath $(DIST)/fat-aar)) 149endif 150 151ifeq ($(MOZ_BUILD_APP),mobile/android) 152 153recurse_android-stage-package: stage-package 154 155recurse_android-archive-geckoview: 156 GRADLE_INVOKED_WITHIN_MACH_BUILD=1 $(topsrcdir)/mach --log-no-times android archive-geckoview 157endif 158 159ifdef MOZ_WIDGET_TOOLKIT 160ifdef ENABLE_TESTS 161# Additional makefile targets to call automated test suites 162include $(topsrcdir)/testing/testsuite-targets.mk 163endif 164endif 165 166default all:: 167 $(call BUILDSTATUS,TIERS $(TIERS) $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS))) 168 169include $(topsrcdir)/config/rules.mk 170 171ifdef SCCACHE_VERBOSE_STATS 172default:: 173 -$(CCACHE) --show-stats --stats-format=json > sccache-stats.json 174 @echo "===SCCACHE STATS===" 175 -$(CCACHE) --show-stats 176 @echo "===================" 177endif 178 179distclean:: 180 $(RM) $(DIST_GARBAGE) 181 182ifdef MOZ_CRASHREPORTER 183include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk 184 185endif 186 187.PHONY: prepsymbolsarchive 188prepsymbolsarchive: 189 echo packing symbols 190 $(NSINSTALL) -D $(DIST)/$(PKG_PATH) 191 192ifndef MOZ_AUTOMATION 193prepsymbolsarchive: recurse_syms 194endif 195 196.PHONY: symbolsfullarchive 197symbolsfullarchive: prepsymbolsarchive 198 $(RM) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' 199 $(call py_action,symbols_archive,'$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' \ 200 $(abspath $(DIST)/crashreporter-symbols) \ 201 --full-archive) 202 203.PHONY: symbolsarchive 204symbolsarchive: prepsymbolsarchive 205 $(RM) '$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' 206 $(call py_action,symbols_archive,'$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' \ 207 $(abspath $(DIST)/crashreporter-symbols)) 208 209ifdef MOZ_CRASHREPORTER 210# Set MOZ_DISABLE_FULL_SYMBOLS to disable generation and upload of the full 211# crashreporter symbols archives 212ifdef MOZ_DISABLE_FULL_SYMBOLS 213buildsymbols: symbolsarchive 214else 215buildsymbols: symbolsfullarchive symbolsarchive 216endif # MOZ_DISABLE_FULL_SYMBOLS 217else 218buildsymbols: 219endif 220 221uploadsymbols: 222ifdef MOZ_CRASHREPORTER 223 $(PYTHON3) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' 224endif 225 226.PHONY: update-packaging 227update-packaging: 228 $(MAKE) -C tools/update-packaging 229 230.PHONY: package-generated-sources 231package-generated-sources: 232 $(call py_action,package_generated_sources,'$(DIST)/$(PKG_PATH)$(GENERATED_SOURCE_FILE_PACKAGE)') 233 234ifdef JS_STANDALONE 235# Delegate js-specific rules to js 236check-%: 237 $(MAKE) -C js/src $@ 238 239source-package install: 240 $(MAKE) -C js/src $@ 241 242# Every export rule depends on config/export, but the rule for config/export 243# doesn't exist when building js non-standalone. 244.PHONY: config/export 245config/export: 246 247endif 248 249# There used to be build interdependencies here. They are now in config/recurse.mk 250