Bug 1609564 [wpt PR 21209] - Update wpt metadata, a=testonly
[gecko.git] / config / config.mk
blob5acbfcbe2354a9a206752a89a4247c67fb88fb8f
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/.
7 # config.mk
9 # Determines the platform and builds the macros needed to load the
10 # appropriate platform-specific .mk file, then defines all (most?)
11 # of the generic macros.
14 # Define an include-at-most-once flag
15 ifdef INCLUDED_CONFIG_MK
16 $(error Do not include config.mk twice!)
17 endif
18 INCLUDED_CONFIG_MK = 1
20 EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
22 ifndef topsrcdir
23 topsrcdir = $(DEPTH)
24 endif
26 ifndef INCLUDED_AUTOCONF_MK
27 include $(DEPTH)/config/autoconf.mk
28 endif
30 -include $(DEPTH)/.mozconfig.mk
32 # MDDEPDIR is the subdirectory where dependency files are stored
33 MDDEPDIR := .deps
35 ifndef EXTERNALLY_MANAGED_MAKE_FILE
36 # Import the automatically generated backend file. If this file doesn't exist,
37 # the backend hasn't been properly configured. We want this to be a fatal
38 # error, hence not using "-include".
39 ifndef STANDALONE_MAKEFILE
40 GLOBAL_DEPS += backend.mk
41 include backend.mk
42 endif
44 endif
46 space = $(NULL) $(NULL)
48 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
49 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
50 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
51 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
52 # These defs.mk files are used to define variables in a directory
53 # and all its subdirectories, recursively.
54 __depth := $(subst /, ,$(DEPTH))
55 ifeq (.,$(__depth))
56 __depth :=
57 endif
58 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
60 COMMA = ,
62 # Sanity check some variables
63 CHECK_VARS := \
64 XPI_NAME \
65 LIBRARY_NAME \
66 MODULE \
67 DEPTH \
68 XPI_PKGNAME \
69 INSTALL_EXTENSION_ID \
70 SHARED_LIBRARY_NAME \
71 SONAME \
72 STATIC_LIBRARY_NAME \
73 $(NULL)
75 # checks for internal spaces or trailing spaces in the variable
76 # named by $x
77 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
79 $(foreach x,$(CHECK_VARS),$(check-variable))
81 ifndef INCLUDED_FUNCTIONS_MK
82 include $(MOZILLA_DIR)/config/makefiles/functions.mk
83 endif
85 RM = rm -f
87 # FINAL_TARGET specifies the location into which we copy end-user-shipped
88 # build products (typelibs, components, chrome). It may already be specified by
89 # a moz.build file.
91 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
92 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
93 # shipped to a $(DIST_SUBDIR) subdirectory.
94 FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
95 # Override the stored value for the check to make sure that the variable is not
96 # redefined in the Makefile.in value.
97 FINAL_TARGET_FROZEN := '$(FINAL_TARGET)'
99 ifdef XPI_NAME
100 ACDEFINES += -DXPI_NAME=$(XPI_NAME)
101 endif
103 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
104 VERSION_NUMBER = 50
106 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
107 AUTOCONF_TOOLS = $(MOZILLA_DIR)/build/autoconf
109 CC := $(CC_WRAPPER) $(CC)
110 CXX := $(CXX_WRAPPER) $(CXX)
111 MKDIR ?= mkdir
112 SLEEP ?= sleep
113 TOUCH ?= touch
115 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
118 # Build using PIC by default
120 _ENABLE_PIC=1
122 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
123 # and we don't have the same build logic to re-link them in the second pass.
124 ifdef SIMPLE_PROGRAMS
125 NO_PROFILE_GUIDED_OPTIMIZE = 1
126 endif
128 # No sense in profiling unit tests
129 ifdef CPP_UNIT_TESTS
130 NO_PROFILE_GUIDED_OPTIMIZE = 1
131 endif
133 # Enable profile-based feedback
134 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
135 ifdef MOZ_PROFILE_GENERATE
136 PGO_CFLAGS += -DNS_FREE_PERMANENT_DATA=1
137 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
138 PGO_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
139 ifeq (WINNT,$(OS_ARCH))
140 AR_FLAGS += -LTCG
141 endif
142 endif # MOZ_PROFILE_GENERATE
144 ifdef MOZ_PROFILE_USE
145 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
146 PGO_LDFLAGS += $(PROFILE_USE_LDFLAGS)
147 ifeq (WINNT,$(OS_ARCH))
148 AR_FLAGS += -LTCG
149 endif
150 endif # MOZ_PROFILE_USE
151 endif # NO_PROFILE_GUIDED_OPTIMIZE
153 LOCALE_TOPDIR ?= $(topsrcdir)
154 MAKE_JARS_FLAGS = \
155 -t $(LOCALE_TOPDIR) \
156 -f $(MOZ_JAR_MAKER_FILE_FORMAT) \
157 $(NULL)
159 ifdef USE_EXTENSION_MANIFEST
160 MAKE_JARS_FLAGS += -e
161 endif
163 TAR_CREATE_FLAGS = -chf
166 # Default command macros; can be overridden in <arch>.mk.
168 CCC = $(CXX)
170 INCLUDES = \
171 -I$(srcdir) \
172 -I$(CURDIR) \
173 $(LOCAL_INCLUDES) \
174 -I$(ABS_DIST)/include \
175 $(NULL)
177 include $(MOZILLA_DIR)/config/static-checking-config.mk
179 ifndef MOZ_LTO
180 MOZ_LTO_CFLAGS :=
181 MOZ_LTO_LDFLAGS :=
182 endif
184 LDFLAGS = $(MOZ_LTO_LDFLAGS) $(COMPUTED_LDFLAGS) $(PGO_LDFLAGS) $(MK_LDFLAGS)
186 COMPILE_CFLAGS = $(MOZ_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
187 COMPILE_CXXFLAGS = $(MOZ_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
188 COMPILE_CMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
189 COMPILE_CMMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
190 ASFLAGS = $(COMPUTED_ASFLAGS)
191 SFLAGS = $(COMPUTED_SFLAGS)
193 HOST_CFLAGS = $(COMPUTED_HOST_CFLAGS) $(_HOST_DEPEND_CFLAGS)
194 HOST_CXXFLAGS = $(COMPUTED_HOST_CXXFLAGS) $(_HOST_DEPEND_CFLAGS)
195 HOST_C_LDFLAGS = $(COMPUTED_HOST_C_LDFLAGS)
196 HOST_CXX_LDFLAGS = $(COMPUTED_HOST_CXX_LDFLAGS)
198 WASM_CFLAGS = $(COMPUTED_WASM_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
199 WASM_CXXFLAGS = $(COMPUTED_WASM_CXXFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
200 WASM_LDFLAGS = $(COMPUTED_WASM_LDFLAGS)
202 ifdef MOZ_LTO
203 ifeq (Darwin,$(OS_TARGET))
204 # When linking on macOS, debug info is not linked along with the final binary,
205 # and the dwarf data stays in object files until they are "linked" with the
206 # dsymutil tool.
207 # With LTO, object files are temporary, and are not kept around, which
208 # means there's no object file for dsymutil to do its job. Consequently,
209 # there is no debug info for LTOed compilation units.
210 # The macOS linker has however an option to explicitly keep those object
211 # files, which dsymutil will then find.
212 # The catch is that the linker uses sequential numbers for those object
213 # files, and doesn't avoid conflicts from multiple linkers running at
214 # the same time. So in directories with multiple binaries, object files
215 # from the first linked binaries would be overwritten by those of the
216 # last linked binary. So we use a subdirectory containing the name of the
217 # linked binary.
218 LDFLAGS += -Wl,-object_path_lto,$(@F).lto.o/
219 endif
220 endif
222 # We only add color flags if neither the flag to disable color
223 # (e.g. "-fno-color-diagnostics" nor a flag to control color
224 # (e.g. "-fcolor-diagnostics=never") is present.
225 define colorize_flags
226 ifeq (,$(filter $(COLOR_CFLAGS:-f%=-fno-%),$$(1))$(findstring $(COLOR_CFLAGS),$$(1)))
227 $(1) += $(COLOR_CFLAGS)
228 endif
229 endef
231 color_flags_vars := \
232 COMPILE_CFLAGS \
233 COMPILE_CXXFLAGS \
234 COMPILE_CMFLAGS \
235 COMPILE_CMMFLAGS \
236 LDFLAGS \
237 WASM_LDFLAGS \
238 WASM_CFLAGS \
239 WASM_CXXFLAGS \
240 $(NULL)
242 ifdef MACH_STDOUT_ISATTY
243 ifdef COLOR_CFLAGS
244 # TODO Bug 1319166 - iTerm2 interprets some bytes sequences as a
245 # request to show a print dialog. Don't enable color on iTerm2 until
246 # a workaround is in place.
247 ifneq ($(TERM_PROGRAM),iTerm.app)
248 $(foreach var,$(color_flags_vars),$(eval $(call colorize_flags,$(var))))
249 endif
250 endif
251 endif
254 # Name of the binary code directories
256 # Override defaults
258 DEPENDENCIES = .md
260 ifdef MACOSX_DEPLOYMENT_TARGET
261 export MACOSX_DEPLOYMENT_TARGET
262 endif # MACOSX_DEPLOYMENT_TARGET
264 # Export to propagate to cl and submake for third-party code.
265 # Eventually, we'll want to just use -I.
266 ifdef INCLUDE
267 export INCLUDE
268 endif
270 # Export to propagate to link.exe and submake for third-party code.
271 # Eventually, we'll want to just use -LIBPATH.
272 ifdef LIB
273 export LIB
274 endif
276 ifdef MOZ_USING_CCACHE
277 ifdef CLANG_CXX
278 export CCACHE_CPP2=1
279 endif
280 endif
282 ifdef CCACHE_PREFIX
283 export CCACHE_PREFIX
284 endif
286 # Set link flags according to whether we want a console.
287 ifeq ($(OS_ARCH),WINNT)
288 ifdef MOZ_WINCONSOLE
289 ifeq ($(MOZ_WINCONSOLE),1)
290 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
291 else # MOZ_WINCONSOLE
292 WIN32_EXE_LDFLAGS += $(WIN32_GUI_EXE_LDFLAGS)
293 endif
294 else
295 # For setting subsystem version
296 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
297 endif
298 endif # WINNT
300 ifeq ($(OS_ARCH),WINNT)
301 ifneq (,$(filter msvc clang-cl,$(CC_TYPE)))
302 ifneq ($(CPU_ARCH),x86)
303 # Normal operation on 64-bit Windows needs 2 MB of stack. (Bug 582910)
304 # ASAN requires 6 MB of stack.
305 # Setting the stack to 8 MB to match the capability of other systems
306 # to deal with frame construction for unreasonably deep DOM trees
307 # with worst-case styling. This uses address space unnecessarily for
308 # non-main threads, but that should be tolerable on 64-bit systems.
309 # (Bug 256180)
310 WIN32_EXE_LDFLAGS += -STACK:8388608
311 else
312 # Since this setting affects the default stack size for non-main
313 # threads, too, to avoid burning the address space, increase only
314 # 512 KB over the default. Just enough to be able to deal with
315 # reasonable styling applied to DOM trees whose depth is near what
316 # Blink's HTML parser can output, esp.
317 # layout/base/crashtests/507119.html (Bug 256180)
318 WIN32_EXE_LDFLAGS += -STACK:1572864
319 endif
320 else
321 ifneq ($(CPU_ARCH),x86)
322 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:8388608
323 else
324 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:1572864
325 endif
326 endif
327 endif
329 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
331 ######################################################################
333 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
335 ifeq ($(OS_ARCH),Darwin)
336 ifndef NSDISTMODE
337 NSDISTMODE=absolute_symlink
338 endif
339 PWD := $(CURDIR)
340 endif
342 NSINSTALL_PY := $(PYTHON) $(abspath $(MOZILLA_DIR)/config/nsinstall.py)
343 ifneq (,$(or $(filter WINNT,$(HOST_OS_ARCH)),$(if $(COMPILE_ENVIRONMENT),,1)))
344 NSINSTALL = $(NSINSTALL_PY)
345 else
346 NSINSTALL = $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)
347 endif # WINNT
350 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
351 INSTALL = $(NSINSTALL) -t
353 else
355 # This isn't laid out as conditional directives so that NSDISTMODE can be
356 # target-specific.
357 INSTALL = $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R)
359 endif # WINNT
361 # The default for install_cmd is simply INSTALL
362 install_cmd ?= $(INSTALL) $(1)
364 # Use nsinstall in copy mode to install files on the system
365 SYSINSTALL = $(NSINSTALL) -t
366 # This isn't necessarily true, just here
367 sysinstall_cmd = install_cmd
370 # Localization build automation
373 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
374 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
375 # overridden by the command line. (Besides, AB_CD is prettier).
376 AB_CD = $(MOZ_UI_LOCALE)
378 include $(MOZILLA_DIR)/config/AB_rCD.mk
380 # Many locales directories want this definition.
381 ACDEFINES += -DAB_CD=$(AB_CD)
383 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(LOCALE_TOPDIR)/$(1)/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/$(subst /locales,,$(1)))
385 ifdef relativesrcdir
386 LOCALE_RELATIVEDIR ?= $(relativesrcdir)
387 endif
389 ifdef LOCALE_RELATIVEDIR
390 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(LOCALE_RELATIVEDIR))
391 endif
393 ifdef relativesrcdir
394 MAKE_JARS_FLAGS += --relativesrcdir=$(LOCALE_RELATIVEDIR)
395 ifneq (en-US,$(AB_CD))
396 ifdef IS_LANGUAGE_REPACK
397 MAKE_JARS_FLAGS += --locale-mergedir=$(REAL_LOCALE_MERGEDIR)
398 endif
399 ifdef IS_LANGUAGE_REPACK
400 MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD)
401 endif
402 else
403 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
404 endif # en-US
405 else
406 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
407 endif # ! relativesrcdir
409 ifdef IS_LANGUAGE_REPACK
410 MERGE_FILE = $(firstword \
411 $(wildcard $(REAL_LOCALE_MERGEDIR)/$(subst /locales,,$(LOCALE_RELATIVEDIR))/$(1)) \
412 $(wildcard $(LOCALE_SRCDIR)/$(1)) \
413 $(srcdir)/en-US/$(1) )
414 # Like MERGE_FILE, but with the specified relative source directory
415 # $(2) replacing $(srcdir). It's expected that $(2) will include
416 # '/locales' but not '/locales/en-US'.
418 # MERGE_RELATIVE_FILE and MERGE_FILE could be -- ahem -- merged by
419 # making the second argument optional, but that expression makes for
420 # difficult to read Make.
421 MERGE_RELATIVE_FILE = $(firstword \
422 $(wildcard $(REAL_LOCALE_MERGEDIR)/$(subst /locales,,$(2))/$(1)) \
423 $(wildcard $(call EXPAND_LOCALE_SRCDIR,$(2))/$(1)) \
424 $(topsrcdir)/$(2)/en-US/$(1) )
425 else
426 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
427 MERGE_RELATIVE_FILE = $(call EXPAND_LOCALE_SRCDIR,$(2))/$(1)
428 endif
430 ifneq (WINNT,$(OS_ARCH))
431 RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
432 endif # ! WINNT
434 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
435 # this file
436 OBJ_SUFFIX := $(_OBJ_SUFFIX)
438 PLY_INCLUDE = -I$(MOZILLA_DIR)/other-licenses/ply
440 # Enable verbose logs when not using `make -s`
441 ifeq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
442 BUILD_VERBOSE_LOG = 1
443 endif