2 # vim:set ts=8 sw=8 sts=8 noet:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Defines main targets for driving the Firefox build system.
9 # This make file should not be invoked directly. Instead, use
10 # `mach` (likely `mach build`) for invoking the build system.
13 # MOZ_OBJDIR - Destination object directory
14 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
16 #######################################################################
20 ifndef NO_BUILDSTATUS_MESSAGES
22 @echo
'BUILDSTATUS $1'
35 PYTHON ?
= $(shell which python2.7
> /dev
/null
2>&1 && echo python2.7 || echo python
)
37 ####################################
38 # Load mozconfig Options
40 include $(OBJDIR
)/.mozconfig-client-mk
42 ifdef MOZ_PARALLEL_BUILD
43 MOZ_MAKE_FLAGS
:= $(filter-out -j
%,$(MOZ_MAKE_FLAGS
))
44 MOZ_MAKE_FLAGS
+= -j
$(MOZ_PARALLEL_BUILD
)
47 # Automatically add -jN to make flags if not defined. N defaults to number of cores.
48 ifeq (,$(findstring -j
,$(MOZ_MAKE_FLAGS
)))
49 cores
=$(shell $(PYTHON
) -c
'import multiprocessing; print(multiprocessing.cpu_count())')
50 MOZ_MAKE_FLAGS
+= -j
$(cores
)
54 ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION
))))
55 MOZ_MAKE_FLAGS
+= --output-sync
=line
59 MOZ_MAKE
= $(MAKE
) $(MOZ_MAKE_FLAGS
) -C
$(OBJDIR
)
61 # 'configure' scripts generated by autoconf.
62 CONFIGURES
:= $(TOPSRCDIR
)/configure
63 CONFIGURES
+= $(TOPSRCDIR
)/js
/src
/configure
65 #######################################################################
68 # The default rule is build
72 $(error client.mk must be used via
`mach`. Try running \
73 `./mach $(firstword $(MAKECMDGOALS) $(.DEFAULT_GOAL))`)
76 # In automation, manage an sccache daemon. The starting of the server
77 # needs to be in a make file so sccache inherits the jobserver.
78 ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
80 # Terminate any sccache server that might still be around.
81 -$(MOZBUILD_MANAGE_SCCACHE_DAEMON
) --stop-server
> /dev
/null
2>&1
82 # Start a new server, ensuring it gets the jobserver file descriptors
83 # from make (but don't use the + prefix when make -n is used, so that
84 # the command doesn't run in that case)
85 $(if
$(findstring n
,$(filter-out --%, $(MAKEFLAGS
))),,+)env RUST_LOG
=sccache
::compiler
=debug SCCACHE_ERROR_LOG
=$(OBJDIR
)/dist/sccache.log
$(MOZBUILD_MANAGE_SCCACHE_DAEMON
) --start-server
88 ####################################
91 MAKEFILE
= $(wildcard $(OBJDIR
)/Makefile
)
92 CONFIG_STATUS
= $(wildcard $(OBJDIR
)/config.status
)
94 # Include deps for configure written by configure itself.
95 CONFIG_STATUS_DEPS
:= $(if
$(wildcard $(OBJDIR
)/config_status_deps.in
),$(shell cat
$(OBJDIR
)/config_status_deps.in
),)
97 $(CONFIGURES
): %: %.in
102 CONFIGURE_ENV_ARGS
+= \
106 # configure uses the program name to determine @srcdir@. Calling it without
107 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
108 # path of $(TOPSRCDIR).
109 ifeq ($(TOPSRCDIR
),$(OBJDIR
))
110 CONFIGURE
= .
/configure
112 CONFIGURE
= $(TOPSRCDIR
)/configure
115 configure-files
: $(CONFIGURES
)
119 $(OBJDIR
)/.mozconfig.json \
122 configure
:: $(configure-preqs
)
123 $(call BUILDSTATUS
,TIERS configure
)
124 $(call BUILDSTATUS
,TIER_START configure
)
126 @echo
$(CONFIGURE
) $(CONFIGURE_ARGS
)
127 @cd
$(OBJDIR
) && $(CONFIGURE_ENV_ARGS
) $(CONFIGURE
) $(CONFIGURE_ARGS
) \
128 ||
( echo
'*** Fix above errors and then restart with\
129 "$(MAKE) -f client.mk build"' && exit
1 )
130 @touch
$(OBJDIR
)/Makefile
131 $(call BUILDSTATUS
,TIER_FINISH configure
)
134 $(OBJDIR
)/Makefile
: $(OBJDIR
)/config.status
140 $(OBJDIR
)/config.status
: $(CONFIG_STATUS_DEPS
)
142 $(OBJDIR
)/Makefile
: $(CONFIG_STATUS_DEPS
)
144 @
$(MAKE
) -f
$(TOPSRCDIR
)/client.mk configure
146 ####################################
149 build
:: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status
154 +$(MOZ_MAKE
) automation
/build
157 ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
159 # Terminate sccache server. This prints sccache stats.
160 -$(MOZBUILD_MANAGE_SCCACHE_DAEMON
) --stop-server
163 # This makefile doesn't support parallel execution. It does pass
164 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute