Bug 1452182 [wpt PR 9921] - [css-grid] Minimum width items should include margins...
[gecko.git] / client.mk
blob27db6b93f2d99ee3dab82a2a48392f758ad2eb1b
1 # -*- makefile -*-
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.
12 # Options:
13 # MOZ_OBJDIR - Destination object directory
14 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
16 #######################################################################
17 # Defines
19 ifdef MACH
20 ifndef NO_BUILDSTATUS_MESSAGES
21 define BUILDSTATUS
22 @echo 'BUILDSTATUS $1'
24 endef
25 endif
26 endif
29 CWD := $(CURDIR)
31 ifeq "$(CWD)" "/"
32 CWD := /.
33 endif
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)
45 endif
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)
51 endif
53 ifdef MOZ_AUTOMATION
54 ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION))))
55 MOZ_MAKE_FLAGS += --output-sync=line
56 endif
57 endif
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 #######################################################################
66 # Rules
68 # The default rule is build
69 build::
71 ifndef MACH
72 $(error client.mk must be used via `mach`. Try running \
73 `./mach $(firstword $(MAKECMDGOALS) $(.DEFAULT_GOAL))`)
74 endif
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
79 build::
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
86 endif
88 ####################################
89 # Configure
91 MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
92 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
94 EXTRA_CONFIG_DEPS := \
95 $(TOPSRCDIR)/aclocal.m4 \
96 $(TOPSRCDIR)/old-configure.in \
97 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
98 $(TOPSRCDIR)/js/src/aclocal.m4 \
99 $(TOPSRCDIR)/js/src/old-configure.in \
100 $(NULL)
102 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
103 @echo Generating $@
104 cp -f $< $@
105 chmod +x $@
107 CONFIG_STATUS_DEPS := \
108 $(wildcard $(TOPSRCDIR)/*/confvars.sh) \
109 $(CONFIGURES) \
110 $(TOPSRCDIR)/nsprpub/configure \
111 $(TOPSRCDIR)/config/milestone.txt \
112 $(TOPSRCDIR)/browser/config/version.txt \
113 $(TOPSRCDIR)/browser/config/version_display.txt \
114 $(TOPSRCDIR)/build/virtualenv_packages.txt \
115 $(TOPSRCDIR)/python/mozbuild/mozbuild/virtualenv.py \
116 $(TOPSRCDIR)/testing/mozbase/packages.txt \
117 $(OBJDIR)/.mozconfig.json \
118 $(NULL)
120 # Include a dep file emitted by configure to track Python files that
121 # may influence the result of configure.
122 -include $(OBJDIR)/configure.d
124 CONFIGURE_ENV_ARGS += \
125 MAKE='$(MAKE)' \
126 $(NULL)
128 # configure uses the program name to determine @srcdir@. Calling it without
129 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
130 # path of $(TOPSRCDIR).
131 ifeq ($(TOPSRCDIR),$(OBJDIR))
132 CONFIGURE = ./configure
133 else
134 CONFIGURE = $(TOPSRCDIR)/configure
135 endif
137 configure-files: $(CONFIGURES)
139 configure-preqs = \
140 configure-files \
141 $(OBJDIR)/.mozconfig.json \
142 $(NULL)
144 configure:: $(configure-preqs)
145 $(call BUILDSTATUS,TIERS configure)
146 $(call BUILDSTATUS,TIER_START configure)
147 @echo cd $(OBJDIR);
148 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
149 @cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
150 || ( echo '*** Fix above errors and then restart with\
151 "$(MAKE) -f client.mk build"' && exit 1 )
152 @touch $(OBJDIR)/Makefile
153 $(call BUILDSTATUS,TIER_FINISH configure)
155 ifneq (,$(MAKEFILE))
156 $(OBJDIR)/Makefile: $(OBJDIR)/config.status
158 $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
159 else
160 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
161 endif
162 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
164 ####################################
165 # Build it
167 build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
168 +$(MOZ_MAKE)
170 ifdef MOZ_AUTOMATION
171 build::
172 +$(MOZ_MAKE) automation/build
173 endif
175 ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
176 build::
177 # Terminate sccache server. This prints sccache stats.
178 -$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server
179 endif
181 # This makefile doesn't support parallel execution. It does pass
182 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
183 # in parallel.
184 .NOTPARALLEL:
186 .PHONY: \
187 build \
188 configure