2019-03-11 03:26:37 -07:00
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
i f e q ( , $( MAKE_VERSION ) )
$( error GNU Make is required )
e n d i f
make_min_ver := 3.81
i f n e q ( $( make_min_ver ) , $( firstword $ ( sort $ ( make_min_ver ) $ ( MAKE_VERSION ) ) ) )
$( error GNU Make $ ( make_min_ver ) or higher is required )
e n d i f
export TOPLEVEL_BUILD := 1
default ::
i f n d e f T E S T _ M O Z B U I L D
i f d e f M O Z _ B U I L D _ A P P
i n c l u d e $( wildcard $ ( topsrcdir ) /$ ( MOZ_BUILD_APP ) /build .mk )
e n d i f
e n d i f
i n c l u d e $( topsrcdir ) / c o n f i g / c o n f i g . m k
GARBAGE_DIRS += _javagen _profile staticlib
DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
config/autoconf.mk \
mozilla-config.h \
netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
.mozconfig.mk
i f n d e f M O Z _ P R O F I L E _ U S E
buildid.h source-repo.h : FORCE
e n d i f
i f d e f J S _ S T A N D A L O N E
configure_dir = $( topsrcdir) /js/src
e l s e
configure_dir = $( topsrcdir)
e n d i f
BUILD_BACKEND_FILES := $( addprefix backend.,$( addsuffix Backend,$( BUILD_BACKENDS) ) )
i f n d e f T E S T _ M O Z B U I L D
i f n d e f M O Z _ P R O F I L E _ U S E
# We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in
# rules.mk doesn't run early enough.
$(TIERS) binaries :: CLOBBER $( configure_dir ) /configure config .status $( BUILD_BACKEND_FILES )
2020-05-07 04:44:57 -07:00
# While our mozbuild backend has some kind of crazy install_manfests junk to
# try and make this not have to happen, we actually want dist/bin to be
# completely removed regardless.
default alldep all ::
2020-05-07 04:45:16 -07:00
@$( RM) -r $( DIST) /bin
2019-03-11 03:26:37 -07:00
i f n d e f J S _ S T A N D A L O N E
i f d e f C O M P I L E _ E N V I R O N M E N T
$(TIERS) binaries :: $( topsrcdir ) /js /src /configure js /src /config .status
e n d i f
e n d i f
e n d i f
e n d i f
i f d e f J S _ S T A N D A L O N E
.PHONY : CLOBBER
CLOBBER :
e l s e
CLOBBER : $( topsrcdir ) /CLOBBER
@echo 'STOP! The CLOBBER file has changed.'
@echo 'Please run the build through a sanctioned build wrapper, such as'
@echo '"mach build" or client.mk.'
@exit 1
e n d i f
$(topsrcdir)/configure : $( topsrcdir ) /configure .in $( topsrcdir ) /old -configure .in
$(topsrcdir)/js/src/configure : $( topsrcdir ) /js /src /configure .in $( topsrcdir ) /js /src /old -configure .in
$(topsrcdir)/configure $(topsrcdir)/js/src/configure :
@echo 'STOP! $? has changed, and your configure is out of date.'
@echo 'Please rerun autoconf and re-configure your build directory.'
@echo 'To ignore this message, touch "$@",'
@echo 'but your build might not succeed.'
@exit 1
config.status : $( configure_dir ) /configure $( configure_dir ) /old -configure
js/src/config.status : $( topsrcdir ) /js /src /configure $( topsrcdir ) /js /src /old -configure
config.status js/src/config.status :
@echo 'STOP! $? has changed and needs to be run again.'
@echo 'Please rerun it.'
@echo 'To ignore this message, touch "$(CURDIR)/$@",'
@echo 'but your build might not succeed.'
@exit 1
# Regenerate the build backend if it is out of date. We only have this rule in
# this main make file because having it in rules.mk and applied to partial tree
# builds resulted in a world of hurt. Gory details are in bug 877308.
#
# The mach build driver will ensure the backend is up to date for partial tree
# builds. This cleanly avoids most of the pain.
i f n d e f T E S T _ M O Z B U I L D
.PHONY : backend
backend : $( BUILD_BACKEND_FILES )
# A traditional rule would look like this:
# backend.%:
# @echo do stuff
#
# But with -j<n>, and multiple items in BUILD_BACKEND_FILES, the command would
# run multiple times in parallel.
#
# "Fortunately", make has some weird semantics for pattern rules: if there are
# multiple targets in a pattern rule and each of them is matched at most once,
# the command will only run once. So:
# backend%RecursiveMakeBackend backend%FasterMakeBackend:
# @echo do stuff
# backend: backend.RecursiveMakeBackend backend.FasterMakeBackend
# would only execute the command once.
#
# Credit where due: http://stackoverflow.com/questions/2973445/gnu-makefile-rule-generating-a-few-targets-from-a-single-source-file/3077254#3077254
$(subst .,%,$(BUILD_BACKEND_FILES)) :
@echo 'Build configuration changed. Regenerating backend.'
$( PYTHON) config.status
Makefile : $( BUILD_BACKEND_FILES )
@$( TOUCH) $@
d e f i n e b u i l d _ b a c k e n d _ r u l e
$(1)_files := $$ ( shell cat $( 1) .in)
$(1) : $$( $ ( 1) _files )
$$ ($(1)_files) :
e n d e f
$( foreach file ,$ ( BUILD_BACKEND_FILES ) ,$ ( eval $ ( call build_backend_rule ,$ ( file ) ) ) )
default :: $( BUILD_BACKEND_FILES )
e n d i f
install_manifests := \
$( addprefix dist/,branding idl include public private sdk xpi-stage) \
_tests \
$( NULL)
# Skip the dist/bin install manifest when using the hybrid
# FasterMake/RecursiveMake backend. This is a hack until bug 1241744 moves
# xpidl handling to FasterMake in that case, mechanically making the dist/bin
# install manifest non-existent (non-existent manifests being skipped)
i f e q ( , $( filter FasterMake +RecursiveMake ,$ ( BUILD_BACKENDS ) ) )
install_manifests += dist/bin
e n d i f
install_manifest_depends = \
CLOBBER \
$( configure_dir) /configure \
config.status \
$( BUILD_BACKEND_FILES) \
$( NULL)
i f n d e f J S _ S T A N D A L O N E
i f d e f C O M P I L E _ E N V I R O N M E N T
install_manifest_depends += \
$( topsrcdir) /js/src/configure \
js/src/config.status \
$( NULL)
e n d i f
e n d i f
.PHONY : install -manifests
install-manifests : $( addprefix install -,$ ( install_manifests ) )
# If we're using the hybrid FasterMake/RecursiveMake backend, we want
# to recurse in the faster/ directory in parallel of install manifests.
# But dist/idl needs to happen before (cf. dependencies in
# config/faster/rules.mk)
i f n e q ( , $( filter FasterMake +RecursiveMake ,$ ( BUILD_BACKENDS ) ) )
install-manifests : faster
.PHONY : faster
faster : install -dist /idl
$( MAKE) -C faster FASTER_RECURSIVE_MAKE = 1
e n d i f
.PHONY : tup
tup :
$( call BUILDSTATUS,TIERS make tup)
$( call BUILDSTATUS,TIER_START make)
$( MAKE) install-manifests buildid.h source-repo.h
$( call BUILDSTATUS,TIER_FINISH make)
$( call BUILDSTATUS,TIER_START tup)
@$( TUP) $( if $( findstring s,$( filter-out --%,$( MAKEFLAGS) ) ) ,,--verbose)
$( call BUILDSTATUS,TIER_FINISH tup)
# process_install_manifest needs to be invoked with --no-remove when building
# js as standalone because automated builds are building nspr separately and
# that would remove the resulting files.
# Eventually, a standalone js build would just be able to build nspr itself,
# removing the need for the former.
i f d e f J S _ S T A N D A L O N E
NO_REMOVE = 1
e n d i f
.PHONY : $( addprefix install -,$ ( subst /,_ ,$ ( install_manifests ) ) )
$(addprefix install-,$(install_manifests)) : install -%: $( install_manifest_depends )
i f n e q ( , $( filter FasterMake +RecursiveMake ,$ ( BUILD_BACKENDS ) ) )
@# If we' re using the hybrid FasterMake/RecursiveMake backend, we want
@# to ensure the FasterMake end doesn' t have install manifests for the
@# same directory, because that would blow up
$( if $( wildcard _build_manifests/install/$( subst /,_,$* ) ) ,$( if $( wildcard faster/install_$( subst /,_,$* ) *) ,$( error FasterMake and RecursiveMake ends of the hybrid build system want to handle $* ) ) )
e n d i f
$( addprefix $( call py_action,process_install_manifest,$( if $( NO_REMOVE) ,--no-remove ) $* ) ,$( wildcard _build_manifests/install/$( subst /,_,$* ) ) )
# Dummy wrapper rule to allow the faster backend to piggy back
$(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))) : install -dist_ %: install -dist /% ;
.PHONY : install -tests
install-tests : install -test -files
# We no longer run "make install-tests" directly before running tests, but we still
# want to depend on things like config.status, hence this target.
.PHONY : run -tests -deps
run-tests-deps : $( install_manifest_depends )
# Force --no-remove, because $objdir/_tests is handled by multiple manifests.
.PHONY : install -test -files
install-test-files :
$( call py_action,process_install_manifest,--no-remove _tests _build_manifests/install/_test_files)
i n c l u d e $( topsrcdir ) / b u i l d / m o z - a u t o m a t i o n . m k
# dist and _tests should be purged during cleaning. However, we don't want them
# purged during PGO builds because they contain some auto-generated files.
i f n e q ( $( filter -out maybe_clobber_profiledbuild ,$ ( MAKECMDGOALS ) ) , )
GARBAGE_DIRS += dist _tests
e n d i f
# Windows PGO builds don't perform a clean before the 2nd pass. So, we want
# to preserve content for the 2nd pass on Windows. Everywhere else, we always
# process the install manifests as part of export.
# For the binaries rule, not all the install manifests matter, so force only
# the interesting ones to be done.
i f d e f M O Z _ P R O F I L E _ U S E
i f n d e f N O _ P R O F I L E _ G U I D E D _ O P T I M I Z E
i f n e q ( $( OS_ARCH ) _ $( GNU_CC ) , W I N N T _ )
recurse_pre-export :: install -manifests
binaries ::
@$( MAKE) install-manifests NO_REMOVE = 1 install_manifests = dist/include
e n d i f
e n d i f
e l s e # !MOZ_PROFILE_USE (normal build)
recurse_pre-export :: install -manifests
binaries ::
@$( MAKE) install-manifests NO_REMOVE = 1 install_manifests = dist/include
e n d i f
# For historical reasons that are unknown, $(DIST)/sdk is always blown away
# with no regard for PGO passes. This decision could probably be revisited.
recurse_pre-export :: install -dist /sdk
recurse_artifact :
$( topsrcdir) /mach --log-no-times artifact install
i f n d e f J S _ S T A N D A L O N E
i f d e f E N A B L E _ T E S T S
# Additional makefile targets to call automated test suites
i n c l u d e $( topsrcdir ) / t e s t i n g / t e s t s u i t e - t a r g e t s . m k
e n d i f
e n d i f
default all ::
$( call BUILDSTATUS,TIERS $( TIERS) $( if $( MOZ_AUTOMATION) ,$( MOZ_AUTOMATION_TIERS) ) )
i n c l u d e $( topsrcdir ) / c o n f i g / r u l e s . m k
distclean ::
$( RM) $( DIST_GARBAGE)
i f e q ( $( OS_ARCH ) , W I N N T )
# we want to copy PDB files on Windows
MAKE_SYM_STORE_ARGS := -c --vcs-info
i f d e f P D B S T R _ P A T H
MAKE_SYM_STORE_ARGS += -i
e n d i f
i f d e f M S V C _ H A S _ D I A _ S D K
DUMP_SYMS_BIN ?= $( DIST) /host/bin/dump_syms.exe
e l s e
DUMP_SYMS_BIN ?= $( topsrcdir) /toolkit/crashreporter/tools/win32/dump_syms_vc$( _MSC_VER) .exe
e n d i f
# PDB files don't get moved to dist, so we need to scan the whole objdir
MAKE_SYM_STORE_PATH := .
e n d i f
i f e q ( $( OS_ARCH ) , D a r w i n )
# need to pass arch flags for universal builds
i f d e f U N I V E R S A L _ B I N A R Y
MAKE_SYM_STORE_ARGS := -c --vcs-info
MAKE_SYM_STORE_PATH := $( DIST) /bin $( UNIFY_DIST) /bin
e l s e
MAKE_SYM_STORE_ARGS := -c -a $( OS_TEST) --vcs-info
MAKE_SYM_STORE_PATH := $( DIST) /bin
e n d i f
DUMP_SYMS_BIN ?= $( DIST) /host/bin/dump_syms
e n d i f
2019-12-25 04:43:27 -08:00
i f e q ( , $( filter -out Linux SunOS ,$ ( OS_ARCH ) ) )
2019-03-11 03:26:37 -07:00
MAKE_SYM_STORE_ARGS := -c --vcs-info
DUMP_SYMS_BIN ?= $( DIST) /host/bin/dump_syms
MAKE_SYM_STORE_PATH := $( DIST) /bin
e n d i f
MAKE_SYM_STORE_ARGS += --install-manifest= $( DEPTH) /_build_manifests/install/dist_include,$( DIST) /include
SYM_STORE_SOURCE_DIRS := $( topsrcdir)
.PHONY : generatesymbols
generatesymbols :
echo building symbol store
$( RM) -r $( DIST) /crashreporter-symbols
$( RM) '$(DIST)/$(SYMBOL_ARCHIVE_BASENAME).zip'
$( RM) '$(DIST)/$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
$( NSINSTALL) -D $( DIST) /crashreporter-symbols
OBJCOPY = '$(OBJCOPY)' \
$( PYTHON) $( topsrcdir) /toolkit/crashreporter/tools/symbolstore.py \
$( MAKE_SYM_STORE_ARGS) \
$( foreach dir,$( SYM_STORE_SOURCE_DIRS) ,-s $( dir) ) \
$( DUMP_SYMS_BIN) \
$( DIST) /crashreporter-symbols \
$( MAKE_SYM_STORE_PATH) | grep -iv test > \
$( DIST) /crashreporter-symbols/$( SYMBOL_INDEX_NAME)
echo packing symbols
$( NSINSTALL) -D $( DIST) /$( PKG_PATH)
.PHONY : symbolsfullarchive
symbolsfullarchive : generatesymbols
cd $( DIST) /crashreporter-symbols && \
zip -r5D '../$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip' . -x '*test*' -x '*Test*'
.PHONY : symbolsarchive
symbolsarchive : generatesymbols
cd $( DIST) /crashreporter-symbols && \
grep 'sym' $( SYMBOL_INDEX_NAME) > $( SYMBOL_INDEX_NAME) .tmp && \
mv $( SYMBOL_INDEX_NAME) .tmp $( SYMBOL_INDEX_NAME)
cd $( DIST) /crashreporter-symbols && \
zip -r5D '../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' . -i '*.sym' -i '*.txt'
buildsymbols :
uploadsymbols :
.PHONY : update -packaging
update-packaging :
$( MAKE) -C tools/update-packaging
.PHONY : pretty -package
pretty-package :
unset MOZ_SIGN_CMD && $( MAKE) package MOZ_PKG_PRETTYNAMES = 1
.PHONY : pretty -package -tests
pretty-package-tests :
unset MOZ_SIGN_CMD && $( MAKE) package-tests MOZ_PKG_PRETTYNAMES = 1
.PHONY : pretty -l 10n -check
pretty-l10n-check :
unset MOZ_SIGN_CMD && $( MAKE) l10n-check MOZ_PKG_PRETTYNAMES = 1
.PHONY : pretty -update -packaging
pretty-update-packaging :
unset MOZ_SIGN_CMD && $( MAKE) -C tools/update-packaging MOZ_PKG_PRETTYNAMES = 1
.PHONY : pretty -installer
pretty-installer :
unset MOZ_SIGN_CMD && $( MAKE) installer MOZ_PKG_PRETTYNAMES = 1
#XXX: this is a hack, since we don't want to clobber for MSVC
# PGO support, but we can't do this test in client.mk
i f n e q ( $( OS_ARCH ) _ $( GNU_CC ) , W I N N T _ )
# No point in clobbering if PGO has been explicitly disabled.
i f n d e f N O _ P R O F I L E _ G U I D E D _ O P T I M I Z E
maybe_clobber_profiledbuild : clean
e l s e
maybe_clobber_profiledbuild :
e n d i f
e l s e
maybe_clobber_profiledbuild :
$( RM) $( DIST) /bin/*.pgc
find $( DIST) /$( MOZ_APP_NAME) -name '*.pgc' -exec mv { } $( DIST) /bin \;
e n d i f
.PHONY : maybe_clobber_profiledbuild
# Look for R_386_PC32 relocations in shared libs, these
# break x86_64 builds and SELinux users.
i f e q ( $( OS_TARGET ) _ $( TARGET_XPCOM_ABI ) , L i n u x _ x 8 6 - g c c 3 )
check ::
@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
e n d i f
i f d e f J S _ S T A N D A L O N E
# Delegate js-specific rules to js
check-% :
$( MAKE) -C js/src $@
source-package install :
$( MAKE) -C js/src $@
# Every export rule depends on config/export, but the rule for config/export
# doesn't exist when building js non-standalone.
.PHONY : config /export
config/export :
e n d i f
# There used to be build interdependencies here. They are now in config/recurse.mk