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 27DIST_GARBAGE = config.cache config.log config.status* config-defs.h \ 28 config/autoconf.mk \ 29 mozilla-config.h \ 30 netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \ 31 .mozconfig.mk 32 33ifndef MOZ_PROFILE_USE 34buildid.h source-repo.h: FORCE 35endif 36 37ifdef JS_STANDALONE 38configure_dir = $(topsrcdir)/js/src 39else 40configure_dir = $(topsrcdir) 41endif 42 43BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS))) 44 45ifndef TEST_MOZBUILD 46ifndef MOZ_PROFILE_USE 47# We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in 48# rules.mk doesn't run early enough. 49$(TIERS) binaries:: CLOBBER $(configure_dir)/configure config.status $(BUILD_BACKEND_FILES) 50ifndef JS_STANDALONE 51ifdef COMPILE_ENVIRONMENT 52$(TIERS) binaries:: $(topsrcdir)/js/src/configure js/src/config.status 53endif 54endif 55endif 56endif 57 58ifdef JS_STANDALONE 59.PHONY: CLOBBER 60CLOBBER: 61else 62CLOBBER: $(topsrcdir)/CLOBBER 63 @echo 'STOP! The CLOBBER file has changed.' 64 @echo 'Please run the build through a sanctioned build wrapper, such as' 65 @echo '"mach build" or client.mk.' 66 @exit 1 67endif 68 69$(topsrcdir)/configure: $(topsrcdir)/configure.in $(topsrcdir)/old-configure.in 70$(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in $(topsrcdir)/js/src/old-configure.in 71$(topsrcdir)/configure $(topsrcdir)/js/src/configure: 72 @echo 'STOP! $? has changed, and your configure is out of date.' 73 @echo 'Please rerun autoconf and re-configure your build directory.' 74 @echo 'To ignore this message, touch "$@",' 75 @echo 'but your build might not succeed.' 76 @exit 1 77 78config.status: $(configure_dir)/configure $(configure_dir)/old-configure 79js/src/config.status: $(topsrcdir)/js/src/configure $(topsrcdir)/js/src/old-configure 80config.status js/src/config.status: 81 @echo 'STOP! $? has changed and needs to be run again.' 82 @echo 'Please rerun it.' 83 @echo 'To ignore this message, touch "$(CURDIR)/$@",' 84 @echo 'but your build might not succeed.' 85 @exit 1 86 87# Regenerate the build backend if it is out of date. We only have this rule in 88# this main make file because having it in rules.mk and applied to partial tree 89# builds resulted in a world of hurt. Gory details are in bug 877308. 90# 91# The mach build driver will ensure the backend is up to date for partial tree 92# builds. This cleanly avoids most of the pain. 93 94ifndef TEST_MOZBUILD 95 96.PHONY: backend 97backend: $(BUILD_BACKEND_FILES) 98 99# A traditional rule would look like this: 100# backend.%: 101# @echo do stuff 102# 103# But with -j<n>, and multiple items in BUILD_BACKEND_FILES, the command would 104# run multiple times in parallel. 105# 106# "Fortunately", make has some weird semantics for pattern rules: if there are 107# multiple targets in a pattern rule and each of them is matched at most once, 108# the command will only run once. So: 109# backend%RecursiveMakeBackend backend%FasterMakeBackend: 110# @echo do stuff 111# backend: backend.RecursiveMakeBackend backend.FasterMakeBackend 112# would only execute the command once. 113# 114# Credit where due: http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file/3077254#3077254 115$(subst .,%,$(BUILD_BACKEND_FILES)): 116 @echo 'Build configuration changed. Regenerating backend.' 117 $(PYTHON) config.status 118 119Makefile: $(BUILD_BACKEND_FILES) 120 @$(TOUCH) $@ 121 122define build_backend_rule 123$(1)_files := $$(shell cat $(1).in) 124$(1): $$($(1)_files) 125$$($(1)_files): 126 127endef 128$(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file)))) 129 130default:: $(BUILD_BACKEND_FILES) 131endif 132 133install_manifests := \ 134 $(addprefix dist/,branding idl include public private sdk xpi-stage) \ 135 _tests \ 136 $(NULL) 137# Skip the dist/bin install manifest when using the hybrid 138# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves 139# xpidl handling to FasterMake in that case, mechanically making the dist/bin 140# install manifest non-existent (non-existent manifests being skipped) 141ifeq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 142install_manifests += dist/bin 143endif 144install_manifest_depends = \ 145 CLOBBER \ 146 $(configure_dir)/configure \ 147 config.status \ 148 $(BUILD_BACKEND_FILES) \ 149 $(NULL) 150 151ifndef JS_STANDALONE 152ifdef COMPILE_ENVIRONMENT 153install_manifest_depends += \ 154 $(topsrcdir)/js/src/configure \ 155 js/src/config.status \ 156 $(NULL) 157endif 158endif 159 160.PHONY: install-manifests 161install-manifests: $(addprefix install-,$(install_manifests)) 162 163# If we're using the hybrid FasterMake/RecursiveMake backend, we want 164# to recurse in the faster/ directory in parallel of install manifests. 165# But dist/idl needs to happen before (cf. dependencies in 166# config/faster/rules.mk) 167ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 168install-manifests: faster 169.PHONY: faster 170faster: install-dist/idl 171 $(MAKE) -C faster FASTER_RECURSIVE_MAKE=1 172endif 173 174.PHONY: tup 175tup: 176 $(call BUILDSTATUS,TIERS make tup) 177 $(call BUILDSTATUS,TIER_START make) 178 $(MAKE) install-manifests buildid.h source-repo.h 179 $(call BUILDSTATUS,TIER_FINISH make) 180 $(call BUILDSTATUS,TIER_START tup) 181 @$(TUP) $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),,--verbose) 182 $(call BUILDSTATUS,TIER_FINISH tup) 183 184# process_install_manifest needs to be invoked with --no-remove when building 185# js as standalone because automated builds are building nspr separately and 186# that would remove the resulting files. 187# Eventually, a standalone js build would just be able to build nspr itself, 188# removing the need for the former. 189ifdef JS_STANDALONE 190NO_REMOVE=1 191endif 192 193.PHONY: $(addprefix install-,$(subst /,_,$(install_manifests))) 194$(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends) 195ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) 196 @# If we're using the hybrid FasterMake/RecursiveMake backend, we want 197 @# to ensure the FasterMake end doesn't have install manifests for the 198 @# same directory, because that would blow up 199 $(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*))) 200endif 201 $(addprefix $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$*) ,$(wildcard _build_manifests/install/$(subst /,_,$*))) 202 203# Dummy wrapper rule to allow the faster backend to piggy back 204$(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ; 205 206.PHONY: install-tests 207install-tests: install-test-files 208 209# We no longer run "make install-tests" directly before running tests, but we still 210# want to depend on things like config.status, hence this target. 211.PHONY: run-tests-deps 212run-tests-deps: $(install_manifest_depends) 213 214# Force --no-remove, because $objdir/_tests is handled by multiple manifests. 215.PHONY: install-test-files 216install-test-files: 217 $(call py_action,process_install_manifest,--no-remove _tests _build_manifests/install/_test_files) 218 219include $(topsrcdir)/build/moz-automation.mk 220 221# dist and _tests should be purged during cleaning. However, we don't want them 222# purged during PGO builds because they contain some auto-generated files. 223ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),) 224GARBAGE_DIRS += dist _tests 225endif 226 227# Windows PGO builds don't perform a clean before the 2nd pass. So, we want 228# to preserve content for the 2nd pass on Windows. Everywhere else, we always 229# process the install manifests as part of export. 230# For the binaries rule, not all the install manifests matter, so force only 231# the interesting ones to be done. 232ifdef MOZ_PROFILE_USE 233ifndef NO_PROFILE_GUIDED_OPTIMIZE 234ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) 235recurse_pre-export:: install-manifests 236binaries:: 237 @$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include 238endif 239endif 240else # !MOZ_PROFILE_USE (normal build) 241recurse_pre-export:: install-manifests 242binaries:: 243 @$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include 244endif 245 246# For historical reasons that are unknown, $(DIST)/sdk is always blown away 247# with no regard for PGO passes. This decision could probably be revisited. 248recurse_pre-export:: install-dist/sdk 249 250recurse_artifact: 251 $(topsrcdir)/mach --log-no-times artifact install 252 253ifndef JS_STANDALONE 254ifdef ENABLE_TESTS 255# Additional makefile targets to call automated test suites 256include $(topsrcdir)/testing/testsuite-targets.mk 257endif 258endif 259 260default all:: 261 $(call BUILDSTATUS,TIERS $(TIERS) $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS))) 262 263include $(topsrcdir)/config/rules.mk 264 265distclean:: 266 $(RM) $(DIST_GARBAGE) 267 268ifeq ($(OS_ARCH),WINNT) 269# we want to copy PDB files on Windows 270MAKE_SYM_STORE_ARGS := -c --vcs-info 271ifdef PDBSTR_PATH 272MAKE_SYM_STORE_ARGS += -i 273endif 274ifdef MSVC_HAS_DIA_SDK 275DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms.exe 276else 277DUMP_SYMS_BIN ?= $(topsrcdir)/toolkit/crashreporter/tools/win32/dump_syms_vc$(_MSC_VER).exe 278endif 279# PDB files don't get moved to dist, so we need to scan the whole objdir 280MAKE_SYM_STORE_PATH := . 281endif 282ifeq ($(OS_ARCH),Darwin) 283# need to pass arch flags for universal builds 284ifdef UNIVERSAL_BINARY 285MAKE_SYM_STORE_ARGS := -c --vcs-info 286MAKE_SYM_STORE_PATH := $(DIST)/bin $(UNIFY_DIST)/bin 287else 288MAKE_SYM_STORE_ARGS := -c -a $(OS_TEST) --vcs-info 289MAKE_SYM_STORE_PATH := $(DIST)/bin 290endif 291DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms 292endif 293ifeq (,$(filter-out Linux SunOS,$(OS_ARCH))) 294MAKE_SYM_STORE_ARGS := -c --vcs-info 295DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms 296MAKE_SYM_STORE_PATH := $(DIST)/bin 297endif 298MAKE_SYM_STORE_ARGS += --install-manifest=$(DEPTH)/_build_manifests/install/dist_include,$(DIST)/include 299 300SYM_STORE_SOURCE_DIRS := $(topsrcdir) 301 302ifdef MOZ_CRASHREPORTER 303include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk 304 305SYMBOL_INDEX_NAME = \ 306 $(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_TARGET)-$(BUILDID)-$(CPU_ARCH)-symbols.txt 307endif 308 309.PHONY: generatesymbols 310generatesymbols: 311 echo building symbol store 312 $(RM) -r $(DIST)/crashreporter-symbols 313 $(RM) '$(DIST)/$(SYMBOL_ARCHIVE_BASENAME).zip' 314 $(RM) '$(DIST)/$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' 315 $(NSINSTALL) -D $(DIST)/crashreporter-symbols 316 OBJCOPY='$(OBJCOPY)' \ 317 $(PYTHON) $(topsrcdir)/toolkit/crashreporter/tools/symbolstore.py \ 318 $(MAKE_SYM_STORE_ARGS) \ 319 $(foreach dir,$(SYM_STORE_SOURCE_DIRS),-s $(dir)) \ 320 $(DUMP_SYMS_BIN) \ 321 $(DIST)/crashreporter-symbols \ 322 $(MAKE_SYM_STORE_PATH) | grep -iv test > \ 323 $(DIST)/crashreporter-symbols/$(SYMBOL_INDEX_NAME) 324 echo packing symbols 325 $(NSINSTALL) -D $(DIST)/$(PKG_PATH) 326 327.PHONY: symbolsfullarchive 328symbolsfullarchive: generatesymbols 329 cd $(DIST)/crashreporter-symbols && \ 330 zip -r5D '../$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' . -x '*test*' -x '*Test*' 331 332.PHONY: symbolsarchive 333symbolsarchive: generatesymbols 334 cd $(DIST)/crashreporter-symbols && \ 335 grep 'sym' $(SYMBOL_INDEX_NAME) > $(SYMBOL_INDEX_NAME).tmp && \ 336 mv $(SYMBOL_INDEX_NAME).tmp $(SYMBOL_INDEX_NAME) 337 cd $(DIST)/crashreporter-symbols && \ 338 zip -r5D '../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' . -i '*.sym' -i '*.txt' 339 340ifdef MOZ_CRASHREPORTER 341buildsymbols: symbolsfullarchive symbolsarchive 342else 343buildsymbols: 344endif 345 346uploadsymbols: 347ifdef MOZ_CRASHREPORTER 348ifdef SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE 349 $(PYTHON) -u $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' 350endif 351endif 352 353.PHONY: update-packaging 354update-packaging: 355 $(MAKE) -C tools/update-packaging 356 357.PHONY: pretty-package 358pretty-package: 359 unset MOZ_SIGN_CMD && $(MAKE) package MOZ_PKG_PRETTYNAMES=1 360 361.PHONY: pretty-package-tests 362pretty-package-tests: 363 unset MOZ_SIGN_CMD && $(MAKE) package-tests MOZ_PKG_PRETTYNAMES=1 364 365.PHONY: pretty-l10n-check 366pretty-l10n-check: 367 unset MOZ_SIGN_CMD && $(MAKE) l10n-check MOZ_PKG_PRETTYNAMES=1 368 369.PHONY: pretty-update-packaging 370pretty-update-packaging: 371 unset MOZ_SIGN_CMD && $(MAKE) -C tools/update-packaging MOZ_PKG_PRETTYNAMES=1 372 373.PHONY: pretty-installer 374pretty-installer: 375 unset MOZ_SIGN_CMD && $(MAKE) installer MOZ_PKG_PRETTYNAMES=1 376 377#XXX: this is a hack, since we don't want to clobber for MSVC 378# PGO support, but we can't do this test in client.mk 379ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) 380# No point in clobbering if PGO has been explicitly disabled. 381ifndef NO_PROFILE_GUIDED_OPTIMIZE 382maybe_clobber_profiledbuild: clean 383else 384maybe_clobber_profiledbuild: 385endif 386else 387maybe_clobber_profiledbuild: 388 $(RM) $(DIST)/bin/*.pgc 389 find $(DIST)/$(MOZ_APP_NAME) -name '*.pgc' -exec mv {} $(DIST)/bin \; 390endif 391 392.PHONY: maybe_clobber_profiledbuild 393 394# Look for R_386_PC32 relocations in shared libs, these 395# break x86_64 builds and SELinux users. 396ifeq ($(OS_TARGET)_$(TARGET_XPCOM_ABI),Linux_x86-gcc3) 397check:: 398 @relcount=`find $(DIST)/bin -name '*.so' | xargs objdump -R | grep R_386_PC32 | wc -l` && if test $$relcount -gt 0; then echo 'FAILED: R_386_PC32 relocations detected in a shared library. Did you use a system header without adding it to config/system-headers?'; exit 1; else echo 'PASSED'; fi 399endif 400 401ifdef JS_STANDALONE 402# Delegate js-specific rules to js 403check-%: 404 $(MAKE) -C js/src $@ 405 406source-package install: 407 $(MAKE) -C js/src $@ 408 409# Every export rule depends on config/export, but the rule for config/export 410# doesn't exist when building js non-standalone. 411.PHONY: config/export 412config/export: 413 414endif 415 416# There used to be build interdependencies here. They are now in config/recurse.mk 417