Bug 1669129 - [devtools] Enable devtools.overflow.debugging.enabled. r=jdescottes
[gecko.git] / config / config.mk
blob47b9f6ec62576be0ac4fe1c14222224c03e24a82
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 varize = $(subst -,_,$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))))
16 # Define an include-at-most-once flag
17 ifdef INCLUDED_CONFIG_MK
18 $(error Do not include config.mk twice!)
19 endif
20 INCLUDED_CONFIG_MK = 1
22 EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
24 ifndef topsrcdir
25 topsrcdir = $(DEPTH)
26 endif
28 ifndef INCLUDED_AUTOCONF_MK
29 include $(DEPTH)/config/autoconf.mk
30 endif
32 -include $(DEPTH)/.mozconfig.mk
34 # MDDEPDIR is the subdirectory where dependency files are stored
35 MDDEPDIR := .deps
37 ifndef EXTERNALLY_MANAGED_MAKE_FILE
38 # Import the automatically generated backend file. If this file doesn't exist,
39 # the backend hasn't been properly configured. We want this to be a fatal
40 # error, hence not using "-include".
41 ifndef STANDALONE_MAKEFILE
42 GLOBAL_DEPS += backend.mk
43 include backend.mk
45 # Add e.g. `export:: $(EXPORT_TARGETS)` rules. The *_TARGETS variables are defined
46 # in backend.mk.
47 $(foreach tier,$(RUNNABLE_TIERS),$(eval $(tier):: $($(call varize,$(tier))_TARGETS)))
48 endif
50 endif
52 space = $(NULL) $(NULL)
54 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
55 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
56 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
57 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
58 # These defs.mk files are used to define variables in a directory
59 # and all its subdirectories, recursively.
60 __depth := $(subst /, ,$(DEPTH))
61 ifeq (.,$(__depth))
62 __depth :=
63 endif
64 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
66 COMMA = ,
68 # Sanity check some variables
69 CHECK_VARS := \
70 XPI_NAME \
71 LIBRARY_NAME \
72 MODULE \
73 DEPTH \
74 XPI_PKGNAME \
75 INSTALL_EXTENSION_ID \
76 SHARED_LIBRARY_NAME \
77 SONAME \
78 STATIC_LIBRARY_NAME \
79 $(NULL)
81 # checks for internal spaces or trailing spaces in the variable
82 # named by $x
83 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
85 $(foreach x,$(CHECK_VARS),$(check-variable))
87 ifndef INCLUDED_FUNCTIONS_MK
88 include $(MOZILLA_DIR)/config/makefiles/functions.mk
89 endif
91 RM = rm -f
93 # FINAL_TARGET specifies the location into which we copy end-user-shipped
94 # build products (typelibs, components, chrome). It may already be specified by
95 # a moz.build file.
97 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
98 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
99 # shipped to a $(DIST_SUBDIR) subdirectory.
100 FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
101 # Override the stored value for the check to make sure that the variable is not
102 # redefined in the Makefile.in value.
103 FINAL_TARGET_FROZEN := '$(FINAL_TARGET)'
105 ifdef XPI_NAME
106 ACDEFINES += -DXPI_NAME=$(XPI_NAME)
107 endif
109 CC := $(CC_WRAPPER) $(CC)
110 CXX := $(CXX_WRAPPER) $(CXX)
111 MKDIR ?= mkdir
112 SLEEP ?= sleep
113 TOUCH ?= touch
116 # Build using PIC by default
118 _ENABLE_PIC=1
120 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
121 # and we don't have the same build logic to re-link them in the second pass.
122 ifdef SIMPLE_PROGRAMS
123 NO_PROFILE_GUIDED_OPTIMIZE = 1
124 endif
126 # No sense in profiling unit tests
127 ifdef CPP_UNIT_TESTS
128 NO_PROFILE_GUIDED_OPTIMIZE = 1
129 endif
131 # Enable profile-based feedback
132 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
133 ifdef MOZ_PROFILE_GENERATE
134 PGO_CFLAGS += -DNS_FREE_PERMANENT_DATA=1
135 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
136 PGO_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
137 endif # MOZ_PROFILE_GENERATE
139 ifdef MOZ_PROFILE_USE
140 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
141 PGO_LDFLAGS += $(PROFILE_USE_LDFLAGS)
142 endif # MOZ_PROFILE_USE
143 endif # NO_PROFILE_GUIDED_OPTIMIZE
145 # Overloaded by comm builds to refer to $(commtopsrcdir), so that
146 # `mail` resolves in en-US builds and in repacks.
147 LOCALE_TOPDIR ?= $(topsrcdir)
148 MAKE_JARS_FLAGS = \
149 -t $(LOCALE_TOPDIR) \
150 -f $(MOZ_JAR_MAKER_FILE_FORMAT) \
151 $(NULL)
153 ifdef USE_EXTENSION_MANIFEST
154 MAKE_JARS_FLAGS += -e
155 endif
157 TAR_CREATE_FLAGS = -chf
160 # Default command macros; can be overridden in <arch>.mk.
162 CCC = $(CXX)
164 INCLUDES = \
165 -I$(srcdir) \
166 -I$(CURDIR) \
167 $(LOCAL_INCLUDES) \
168 -I$(ABS_DIST)/include \
169 $(NULL)
171 include $(MOZILLA_DIR)/config/static-checking-config.mk
173 ifndef MOZ_LTO
174 MOZ_LTO_CFLAGS :=
175 MOZ_LTO_LDFLAGS :=
176 endif
178 LDFLAGS = $(MOZ_LTO_LDFLAGS) $(COMPUTED_LDFLAGS) $(PGO_LDFLAGS)
180 COMPILE_CFLAGS = $(MOZ_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
181 COMPILE_CXXFLAGS = $(MOZ_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
182 COMPILE_CMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
183 COMPILE_CMMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
184 ASFLAGS = $(COMPUTED_ASFLAGS)
185 SFLAGS = $(COMPUTED_SFLAGS)
187 HOST_CFLAGS = $(COMPUTED_HOST_CFLAGS) $(_HOST_DEPEND_CFLAGS)
188 HOST_CXXFLAGS = $(COMPUTED_HOST_CXXFLAGS) $(_HOST_DEPEND_CFLAGS)
189 HOST_C_LDFLAGS = $(COMPUTED_HOST_C_LDFLAGS)
190 HOST_CXX_LDFLAGS = $(COMPUTED_HOST_CXX_LDFLAGS)
192 WASM_CFLAGS = $(COMPUTED_WASM_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
193 WASM_CXXFLAGS = $(COMPUTED_WASM_CXXFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
194 WASM_LDFLAGS = $(COMPUTED_WASM_LDFLAGS)
196 ifdef MOZ_LTO
197 ifeq (Darwin,$(OS_TARGET))
198 # When linking on macOS, debug info is not linked along with the final binary,
199 # and the dwarf data stays in object files until they are "linked" with the
200 # dsymutil tool.
201 # With LTO, object files are temporary, and are not kept around, which
202 # means there's no object file for dsymutil to do its job. Consequently,
203 # there is no debug info for LTOed compilation units.
204 # The macOS linker has however an option to explicitly keep those object
205 # files, which dsymutil will then find.
206 # The catch is that the linker uses sequential numbers for those object
207 # files, and doesn't avoid conflicts from multiple linkers running at
208 # the same time. So in directories with multiple binaries, object files
209 # from the first linked binaries would be overwritten by those of the
210 # last linked binary. So we use a subdirectory containing the name of the
211 # linked binary.
212 LDFLAGS += -Wl,-object_path_lto,$(@F).lto.o/
213 endif
214 endif
216 # We only add color flags if neither the flag to disable color
217 # (e.g. "-fno-color-diagnostics" nor a flag to control color
218 # (e.g. "-fcolor-diagnostics=never") is present.
219 define colorize_flags
220 ifeq (,$(filter $(COLOR_CFLAGS:-f%=-fno-%),$$(1))$(findstring $(COLOR_CFLAGS),$$(1)))
221 $(1) += $(COLOR_CFLAGS)
222 endif
223 endef
225 color_flags_vars := \
226 COMPILE_CFLAGS \
227 COMPILE_CXXFLAGS \
228 COMPILE_CMFLAGS \
229 COMPILE_CMMFLAGS \
230 LDFLAGS \
231 WASM_LDFLAGS \
232 WASM_CFLAGS \
233 WASM_CXXFLAGS \
234 $(NULL)
236 ifdef MACH_STDOUT_ISATTY
237 ifdef COLOR_CFLAGS
238 # TODO Bug 1319166 - iTerm2 interprets some bytes sequences as a
239 # request to show a print dialog. Don't enable color on iTerm2 until
240 # a workaround is in place.
241 ifneq ($(TERM_PROGRAM),iTerm.app)
242 $(foreach var,$(color_flags_vars),$(eval $(call colorize_flags,$(var))))
243 endif
244 endif
245 endif
248 # Name of the binary code directories
250 # Override defaults
252 DEPENDENCIES = .md
254 ifdef MACOSX_DEPLOYMENT_TARGET
255 export MACOSX_DEPLOYMENT_TARGET
256 endif # MACOSX_DEPLOYMENT_TARGET
258 # Export to propagate to cl and submake for third-party code.
259 # Eventually, we'll want to just use -I.
260 ifdef INCLUDE
261 export INCLUDE
262 endif
264 # Export to propagate to link.exe and submake for third-party code.
265 # Eventually, we'll want to just use -LIBPATH.
266 ifdef LIB
267 export LIB
268 endif
270 ifdef MOZ_USING_CCACHE
271 ifdef CLANG_CXX
272 export CCACHE_CPP2=1
273 endif
274 endif
276 ifdef CCACHE_PREFIX
277 export CCACHE_PREFIX
278 endif
280 # Set link flags according to whether we want a console.
281 ifeq ($(OS_ARCH),WINNT)
282 ifdef MOZ_WINCONSOLE
283 ifeq ($(MOZ_WINCONSOLE),1)
284 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
285 else # MOZ_WINCONSOLE
286 WIN32_EXE_LDFLAGS += $(WIN32_GUI_EXE_LDFLAGS)
287 endif
288 else
289 # For setting subsystem version
290 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
291 endif
292 endif # WINNT
294 ifeq ($(OS_ARCH),WINNT)
295 ifneq (,$(filter msvc clang-cl,$(CC_TYPE)))
296 ifneq ($(CPU_ARCH),x86)
297 # Normal operation on 64-bit Windows needs 2 MB of stack. (Bug 582910)
298 # ASAN requires 6 MB of stack.
299 # Setting the stack to 8 MB to match the capability of other systems
300 # to deal with frame construction for unreasonably deep DOM trees
301 # with worst-case styling. This uses address space unnecessarily for
302 # non-main threads, but that should be tolerable on 64-bit systems.
303 # (Bug 256180)
304 WIN32_EXE_LDFLAGS += -STACK:8388608
305 else
306 # Since this setting affects the default stack size for non-main
307 # threads, too, to avoid burning the address space, increase only
308 # 512 KB over the default. Just enough to be able to deal with
309 # reasonable styling applied to DOM trees whose depth is near what
310 # Blink's HTML parser can output, esp.
311 # layout/base/crashtests/507119.html (Bug 256180)
312 WIN32_EXE_LDFLAGS += -STACK:1572864
313 endif
314 else
315 ifneq ($(CPU_ARCH),x86)
316 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:8388608
317 else
318 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:1572864
319 endif
320 endif
321 endif
323 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
325 ######################################################################
327 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
329 ifeq ($(OS_ARCH),Darwin)
330 ifndef NSDISTMODE
331 NSDISTMODE=absolute_symlink
332 endif
333 PWD := $(CURDIR)
334 endif
336 NSINSTALL_PY := $(PYTHON3) $(abspath $(MOZILLA_DIR)/config/nsinstall.py)
337 ifneq (,$(or $(filter WINNT,$(HOST_OS_ARCH)),$(if $(COMPILE_ENVIRONMENT),,1)))
338 NSINSTALL = $(NSINSTALL_PY)
339 else
340 NSINSTALL = $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)
341 endif # WINNT
344 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
345 INSTALL = $(NSINSTALL) -t
347 else
349 # This isn't laid out as conditional directives so that NSDISTMODE can be
350 # target-specific.
351 INSTALL = $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R)
353 endif # WINNT
355 # The default for install_cmd is simply INSTALL
356 install_cmd ?= $(INSTALL) $(1)
358 # Use nsinstall in copy mode to install files on the system
359 SYSINSTALL = $(NSINSTALL) -t
360 # This isn't necessarily true, just here
361 sysinstall_cmd = install_cmd
364 # Localization build automation
367 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
368 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
369 # overridden by the command line. (Besides, AB_CD is prettier).
370 AB_CD = $(MOZ_UI_LOCALE)
372 include $(MOZILLA_DIR)/config/AB_rCD.mk
374 # Many locales directories want this definition.
375 ACDEFINES += -DAB_CD=$(AB_CD)
377 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(LOCALE_TOPDIR)/$(1)/en-US,$(REAL_LOCALE_MERGEDIR)/$(subst /locales,,$(1)))
379 ifdef relativesrcdir
380 LOCALE_RELATIVEDIR ?= $(relativesrcdir)
381 endif
383 ifdef LOCALE_RELATIVEDIR
384 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(LOCALE_RELATIVEDIR))
385 endif
387 ifdef relativesrcdir
388 MAKE_JARS_FLAGS += --relativesrcdir=$(LOCALE_RELATIVEDIR)
389 ifneq (en-US,$(AB_CD))
390 ifdef IS_LANGUAGE_REPACK
391 MAKE_JARS_FLAGS += --l10n-base=$(REAL_LOCALE_MERGEDIR)
392 endif
393 else
394 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
395 endif # en-US
396 else
397 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
398 endif # ! relativesrcdir
400 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
401 MERGE_RELATIVE_FILE = $(call EXPAND_LOCALE_SRCDIR,$(2))/$(1)
403 ifneq (WINNT,$(OS_ARCH))
404 RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
405 endif # ! WINNT
407 # Enable verbose logs when not using `make -s`
408 ifeq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
409 export BUILD_VERBOSE_LOG = 1
410 endif