michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ifndef .PYMAKE michael@0: ifeq (,$(MAKE_VERSION)) michael@0: $(error GNU Make is required) michael@0: endif michael@0: make_min_ver := 3.81 michael@0: ifneq ($(make_min_ver),$(firstword $(sort $(make_min_ver) $(MAKE_VERSION)))) michael@0: $(error GNU Make $(make_min_ver) or higher is required) michael@0: endif michael@0: endif michael@0: michael@0: export TOPLEVEL_BUILD := 1 michael@0: michael@0: default:: michael@0: michael@0: ifdef MOZ_BUILD_APP michael@0: include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk michael@0: endif michael@0: michael@0: include $(topsrcdir)/config/config.mk michael@0: michael@0: GARBAGE_DIRS += dist _javagen _profile staticlib michael@0: DIST_GARBAGE = config.cache config.log config.status* config-defs.h \ michael@0: config/autoconf.mk \ michael@0: mozilla-config.h \ michael@0: netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \ michael@0: .mozconfig.mk michael@0: michael@0: ifdef JS_STANDALONE michael@0: configure_dir = $(topsrcdir)/js/src michael@0: else michael@0: configure_dir = $(topsrcdir) michael@0: endif michael@0: michael@0: ifndef MOZ_PROFILE_USE michael@0: # We need to explicitly put backend.RecursiveMakeBackend here michael@0: # otherwise the rule in rules.mk doesn't run early enough. michael@0: libs binaries export tools:: CLOBBER $(configure_dir)/configure config.status backend.RecursiveMakeBackend michael@0: ifndef JS_STANDALONE michael@0: ifndef LIBXUL_SDK michael@0: libs binaries export tools:: $(topsrcdir)/js/src/configure js/src/config.status michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifdef JS_STANDALONE michael@0: .PHONY: CLOBBER michael@0: CLOBBER: michael@0: else michael@0: CLOBBER: $(topsrcdir)/CLOBBER michael@0: @echo 'STOP! The CLOBBER file has changed.' michael@0: @echo 'Please run the build through a sanctioned build wrapper, such as' michael@0: @echo '"mach build" or client.mk.' michael@0: @exit 1 michael@0: endif michael@0: michael@0: $(topsrcdir)/configure: $(topsrcdir)/configure.in michael@0: $(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in michael@0: $(topsrcdir)/configure $(topsrcdir)/js/src/configure: michael@0: @echo 'STOP! $^ has changed, and your configure is out of date.' michael@0: @echo 'Please rerun autoconf and re-configure your build directory.' michael@0: @echo 'To ignore this message, touch "$@",' michael@0: @echo 'but your build might not succeed.' michael@0: @exit 1 michael@0: michael@0: config.status: $(configure_dir)/configure michael@0: js/src/config.status: $(topsrcdir)/js/src/configure michael@0: config.status js/src/config.status: michael@0: @echo 'STOP! $^ has changed and needs to be run again.' michael@0: @echo 'Please rerun it.' michael@0: @echo 'To ignore this message, touch "$(CURDIR)/$@",' michael@0: @echo 'but your build might not succeed.' michael@0: @exit 1 michael@0: michael@0: # Regenerate the build backend if it is out of date. We only have this rule in michael@0: # this main make file because having it in rules.mk and applied to partial tree michael@0: # builds resulted in a world of hurt. Gory details are in bug 877308. michael@0: # michael@0: # The mach build driver will ensure the backend is up to date for partial tree michael@0: # builds. This cleanly avoids most of the pain. michael@0: michael@0: backend.RecursiveMakeBackend: michael@0: @echo 'Build configuration changed. Regenerating backend.' michael@0: $(PYTHON) config.status michael@0: michael@0: Makefile: backend.RecursiveMakeBackend michael@0: @$(TOUCH) $@ michael@0: michael@0: include backend.RecursiveMakeBackend.pp michael@0: michael@0: default:: backend.RecursiveMakeBackend michael@0: michael@0: install_manifests := bin idl include public private sdk michael@0: install_manifest_depends = \ michael@0: CLOBBER \ michael@0: $(configure_dir)/configure \ michael@0: config.status \ michael@0: backend.RecursiveMakeBackend \ michael@0: $(NULL) michael@0: michael@0: ifndef JS_STANDALONE michael@0: ifndef LIBXUL_SDK michael@0: install_manifest_depends += \ michael@0: $(topsrcdir)/js/src/configure \ michael@0: js/src/config.status \ michael@0: $(NULL) michael@0: endif michael@0: endif michael@0: michael@0: .PHONY: install-manifests michael@0: install-manifests: $(addprefix install-dist-,$(install_manifests)) michael@0: michael@0: # process_install_manifest needs to be invoked with --no-remove when building michael@0: # js as standalone because automated builds are building nspr separately and michael@0: # that would remove the resulting files. michael@0: # Eventually, a standalone js build would just be able to build nspr itself, michael@0: # removing the need for the former. michael@0: ifdef JS_STANDALONE michael@0: NO_REMOVE=1 michael@0: endif michael@0: michael@0: .PHONY: $(addprefix install-dist-,$(install_manifests)) michael@0: $(addprefix install-dist-,$(install_manifests)): install-dist-%: $(install_manifest_depends) michael@0: $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$*) michael@0: michael@0: .PHONY: install-tests michael@0: install-manifests: install-tests michael@0: install-tests: $(install_manifest_depends) michael@0: $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/tests) michael@0: michael@0: include $(topsrcdir)/build/moz-automation.mk michael@0: michael@0: # _tests should be purged during cleaning. However, we don't want it purged michael@0: # during PGO builds because it contains some auto-generated files. michael@0: ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),) michael@0: GARBAGE_DIRS += _tests michael@0: endif michael@0: michael@0: # Windows PGO builds don't perform a clean before the 2nd pass. So, we want michael@0: # to preserve content for the 2nd pass on Windows. Everywhere else, we always michael@0: # process the install manifests as part of export. michael@0: ifdef MOZ_PROFILE_USE michael@0: ifndef NO_PROFILE_GUIDED_OPTIMIZE michael@0: ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) michael@0: export:: install-manifests michael@0: binaries:: michael@0: @$(MAKE) install-manifests NO_REMOVE=1 michael@0: endif michael@0: endif michael@0: else # !MOZ_PROFILE_USE (normal build) michael@0: export:: install-manifests michael@0: binaries:: michael@0: @$(MAKE) install-manifests NO_REMOVE=1 michael@0: endif michael@0: michael@0: # For historical reasons that are unknown, $(DIST)/sdk is always blown away michael@0: # with no regard for PGO passes. This decision could probably be revisited. michael@0: export:: install-dist-sdk michael@0: michael@0: ifndef JS_STANDALONE michael@0: ifdef ENABLE_TESTS michael@0: # Additional makefile targets to call automated test suites michael@0: include $(topsrcdir)/testing/testsuite-targets.mk michael@0: endif michael@0: endif michael@0: michael@0: default all:: michael@0: $(call BUILDSTATUS,TIERS export $(if $(COMPILE_ENVIRONMENT),$(if $(MOZ_PSEUDO_DERECURSE),compile ))libs tools $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS))) michael@0: michael@0: include $(topsrcdir)/config/rules.mk michael@0: michael@0: distclean:: michael@0: $(RM) $(DIST_GARBAGE) michael@0: michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: # we want to copy PDB files on Windows michael@0: MAKE_SYM_STORE_ARGS := -c --vcs-info michael@0: ifdef PDBSTR_PATH michael@0: MAKE_SYM_STORE_ARGS += -i michael@0: endif michael@0: DUMP_SYMS_BIN ?= $(topsrcdir)/toolkit/crashreporter/tools/win32/dump_syms_vc$(_MSC_VER).exe michael@0: # PDB files don't get moved to dist, so we need to scan the whole objdir michael@0: MAKE_SYM_STORE_PATH := . michael@0: endif michael@0: ifeq ($(OS_ARCH),Darwin) michael@0: # need to pass arch flags for universal builds michael@0: ifdef UNIVERSAL_BINARY michael@0: MAKE_SYM_STORE_ARGS := -c -a 'i386 x86_64' --vcs-info michael@0: MAKE_SYM_STORE_PATH := $(DIST)/universal michael@0: else michael@0: MAKE_SYM_STORE_ARGS := -c -a $(OS_TEST) --vcs-info michael@0: MAKE_SYM_STORE_PATH := $(DIST)/bin michael@0: endif michael@0: DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms michael@0: endif michael@0: ifeq (,$(filter-out Linux SunOS,$(OS_ARCH))) michael@0: MAKE_SYM_STORE_ARGS := -c --vcs-info michael@0: DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms michael@0: MAKE_SYM_STORE_PATH := $(DIST)/bin michael@0: endif michael@0: michael@0: SYM_STORE_SOURCE_DIRS := $(topsrcdir) michael@0: michael@0: ifndef JS_STANDALONE michael@0: include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk michael@0: michael@0: ifdef MOZ_SYMBOLS_EXTRA_BUILDID michael@0: EXTRA_BUILDID := -$(MOZ_SYMBOLS_EXTRA_BUILDID) michael@0: endif michael@0: michael@0: SYMBOL_INDEX_NAME = \ michael@0: $(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_TARGET)-$(BUILDID)-$(CPU_ARCH)$(EXTRA_BUILDID)-symbols.txt michael@0: michael@0: buildsymbols: michael@0: ifdef MOZ_CRASHREPORTER michael@0: echo building symbol store michael@0: $(RM) -r $(DIST)/crashreporter-symbols michael@0: $(RM) '$(DIST)/$(SYMBOL_ARCHIVE_BASENAME).zip' michael@0: $(RM) '$(DIST)/$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' michael@0: $(NSINSTALL) -D $(DIST)/crashreporter-symbols michael@0: OBJCOPY='$(OBJCOPY)' \ michael@0: $(PYTHON) $(topsrcdir)/toolkit/crashreporter/tools/symbolstore.py \ michael@0: $(MAKE_SYM_STORE_ARGS) \ michael@0: $(foreach dir,$(SYM_STORE_SOURCE_DIRS),-s $(dir)) \ michael@0: $(DUMP_SYMS_BIN) \ michael@0: $(DIST)/crashreporter-symbols \ michael@0: $(MAKE_SYM_STORE_PATH) | grep -iv test > \ michael@0: $(DIST)/crashreporter-symbols/$(SYMBOL_INDEX_NAME) michael@0: echo packing symbols michael@0: $(NSINSTALL) -D $(DIST)/$(PKG_PATH) michael@0: cd $(DIST)/crashreporter-symbols && \ michael@0: zip -r9D '../$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' . -x '*test*' -x '*Test*' michael@0: cd $(DIST)/crashreporter-symbols && \ michael@0: grep 'sym' $(SYMBOL_INDEX_NAME) > $(SYMBOL_INDEX_NAME).tmp && \ michael@0: mv $(SYMBOL_INDEX_NAME).tmp $(SYMBOL_INDEX_NAME) michael@0: cd $(DIST)/crashreporter-symbols && \ michael@0: zip -r9D '../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' . -i '*.sym' -i '*.txt' -x '*test*' -x '*Test*' michael@0: endif # MOZ_CRASHREPORTER michael@0: michael@0: uploadsymbols: michael@0: ifdef MOZ_CRASHREPORTER michael@0: $(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' michael@0: endif michael@0: michael@0: # MOZ_SOURCE_STAMP is defined in package-name.mk with a deferred assignment. michael@0: # exporting it makes make run its $(shell) command for each invoked submake, michael@0: # so transform it to an immediate assignment. michael@0: MOZ_SOURCE_STAMP := $(MOZ_SOURCE_STAMP) michael@0: export MOZ_SOURCE_STAMP michael@0: endif michael@0: michael@0: .PHONY: update-packaging michael@0: update-packaging: michael@0: $(MAKE) -C tools/update-packaging michael@0: michael@0: .PHONY: pretty-package michael@0: pretty-package: michael@0: unset MOZ_SIGN_CMD && $(MAKE) package MOZ_PKG_PRETTYNAMES=1 michael@0: michael@0: .PHONY: pretty-package-tests michael@0: pretty-package-tests: michael@0: unset MOZ_SIGN_CMD && $(MAKE) package-tests MOZ_PKG_PRETTYNAMES=1 michael@0: michael@0: .PHONY: pretty-l10n-check michael@0: pretty-l10n-check: michael@0: unset MOZ_SIGN_CMD && $(MAKE) l10n-check MOZ_PKG_PRETTYNAMES=1 michael@0: michael@0: .PHONY: pretty-update-packaging michael@0: pretty-update-packaging: michael@0: unset MOZ_SIGN_CMD && $(MAKE) -C tools/update-packaging MOZ_PKG_PRETTYNAMES=1 michael@0: michael@0: .PHONY: pretty-installer michael@0: pretty-installer: michael@0: unset MOZ_SIGN_CMD && $(MAKE) installer MOZ_PKG_PRETTYNAMES=1 michael@0: michael@0: #XXX: this is a hack, since we don't want to clobber for MSVC michael@0: # PGO support, but we can't do this test in client.mk michael@0: ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) michael@0: # No point in clobbering if PGO has been explicitly disabled. michael@0: ifndef NO_PROFILE_GUIDED_OPTIMIZE michael@0: maybe_clobber_profiledbuild: clean michael@0: else michael@0: maybe_clobber_profiledbuild: michael@0: endif michael@0: else michael@0: maybe_clobber_profiledbuild: michael@0: $(RM) $(DIST)/bin/*.pgc michael@0: find $(DIST)/$(MOZ_APP_NAME) -name '*.pgc' -exec mv {} $(DIST)/bin \; michael@0: endif michael@0: michael@0: .PHONY: maybe_clobber_profiledbuild michael@0: michael@0: # Look for R_386_PC32 relocations in shared libs, these michael@0: # break x86_64 builds and SELinux users. michael@0: ifeq ($(OS_TARGET)_$(TARGET_XPCOM_ABI),Linux_x86-gcc3) michael@0: check:: michael@0: @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 michael@0: endif michael@0: michael@0: ifdef JS_STANDALONE michael@0: # Delegate js-specific rules to js michael@0: check-%: michael@0: $(MAKE) -C js/src $@ michael@0: michael@0: source-package install: michael@0: $(MAKE) -C js/src $@ michael@0: michael@0: # Every export rule depends on config/export, but the rule for config/export michael@0: # doesn't exist when building js non-standalone. michael@0: .PHONY: config/export michael@0: config/export: michael@0: michael@0: endif michael@0: michael@0: ifdef MOZ_PSEUDO_DERECURSE michael@0: # Interdependencies for parallel export. michael@0: js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export michael@0: accessible/src/xpcom/export: xpcom/xpidl/export michael@0: js/src/export: mfbt/export michael@0: ifdef ENABLE_CLANG_PLUGIN michael@0: js/src/export config/export: build/clang-plugin/export michael@0: endif michael@0: endif