Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / config / config.mk
blobe03b31a22ab94f91868c9a6b64153a1021985af1
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 ifndef EXTERNALLY_MANAGED_MAKE_FILE
33 # Using $(firstword) may not be perfect. But it should be good enough for most
34 # scenarios.
35 _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST))
37 CHECK_MOZBUILD_VARIABLES = $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES), \
38 $(if $(subst $($(var)_FROZEN),,'$($(var))'), \
39 $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\
40 )) $(foreach var,$(_DEPRECATED_VARIABLES), \
41 $(if $(subst $($(var)_FROZEN),,'$($(var))'), \
42 $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build),\
45 # Check variables set after autoconf.mk (included at the top of Makefiles) is
46 # included and before config.mk is included.
47 _eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES)
49 # Import the automatically generated backend file. If this file doesn't exist,
50 # the backend hasn't been properly configured. We want this to be a fatal
51 # error, hence not using "-include".
52 ifndef STANDALONE_MAKEFILE
53 GLOBAL_DEPS += backend.mk
54 include backend.mk
55 endif
57 # Freeze the values specified by moz.build to catch them if they fail.
58 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
59 endif
61 space = $(NULL) $(NULL)
63 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
64 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
65 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
66 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
67 # These defs.mk files are used to define variables in a directory
68 # and all its subdirectories, recursively.
69 __depth := $(subst /, ,$(DEPTH))
70 ifeq (.,$(__depth))
71 __depth :=
72 endif
73 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
75 COMMA = ,
77 # Sanity check some variables
78 CHECK_VARS := \
79 XPI_NAME \
80 LIBRARY_NAME \
81 MODULE \
82 DEPTH \
83 XPI_PKGNAME \
84 INSTALL_EXTENSION_ID \
85 SHARED_LIBRARY_NAME \
86 SONAME \
87 STATIC_LIBRARY_NAME \
88 $(NULL)
90 # checks for internal spaces or trailing spaces in the variable
91 # named by $x
92 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
94 $(foreach x,$(CHECK_VARS),$(check-variable))
96 ifndef INCLUDED_FUNCTIONS_MK
97 include $(MOZILLA_DIR)/config/makefiles/functions.mk
98 endif
100 RM = rm -f
102 # LIBXUL_DIST is not defined under js/src, thus we make it mean DIST there.
103 LIBXUL_DIST ?= $(DIST)
105 # FINAL_TARGET specifies the location into which we copy end-user-shipped
106 # build products (typelibs, components, chrome). It may already be specified by
107 # a moz.build file.
109 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
110 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
111 # shipped to a $(DIST_SUBDIR) subdirectory.
112 FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
113 # Override the stored value for the check to make sure that the variable is not
114 # redefined in the Makefile.in value.
115 FINAL_TARGET_FROZEN := '$(FINAL_TARGET)'
117 ifdef XPI_NAME
118 DEFINES += -DXPI_NAME=$(XPI_NAME)
119 endif
121 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
122 VERSION_NUMBER = 50
124 ifeq ($(HOST_OS_ARCH),WINNT)
125 ifeq ($(MOZILLA_DIR),$(topsrcdir))
126 win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
127 else
128 # This means we're in comm-central's topsrcdir, so we need to adjust
129 # WIN_TOP_SRC (which points to mozilla's topsrcdir) for the substitution
130 # to win_srcdir.
131 cc_WIN_TOP_SRC := $(WIN_TOP_SRC:%/mozilla=%)
132 win_srcdir := $(subst $(topsrcdir),$(cc_WIN_TOP_SRC),$(srcdir))
133 endif
134 BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
135 else
136 win_srcdir := $(srcdir)
137 BUILD_TOOLS = $(MOZILLA_DIR)/build/unix
138 endif
140 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
141 AUTOCONF_TOOLS = $(MOZILLA_DIR)/build/autoconf
144 # Strip off the excessively long version numbers on these platforms,
145 # but save the version to allow multiple versions of the same base
146 # platform to be built in the same tree.
148 ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
149 OS_RELEASE := $(basename $(OS_RELEASE))
151 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
152 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
153 OS_VERS := $(suffix $(OS_RELEASE))
154 OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
155 endif
157 endif
159 OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
161 ifdef _MSC_VER
162 CC_WRAPPER ?= $(call py_action,cl)
163 CXX_WRAPPER ?= $(call py_action,cl)
164 endif # _MSC_VER
166 CC := $(CC_WRAPPER) $(CC)
167 CXX := $(CXX_WRAPPER) $(CXX)
168 MKDIR ?= mkdir
169 SLEEP ?= sleep
170 TOUCH ?= touch
172 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
174 # determine debug-related options
175 _DEBUG_ASFLAGS :=
176 _DEBUG_CFLAGS :=
177 _DEBUG_LDFLAGS :=
179 ifdef MOZ_DEBUG
180 _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
181 XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
182 else
183 _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
184 XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
185 endif
187 ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
188 ifeq ($(AS),yasm)
189 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
190 _DEBUG_ASFLAGS += -g cv8
191 else
192 ifneq ($(OS_ARCH),Darwin)
193 _DEBUG_ASFLAGS += -g dwarf2
194 endif
195 endif
196 else
197 _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
198 endif
199 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
200 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
201 endif
203 ASFLAGS += $(_DEBUG_ASFLAGS)
204 OS_CFLAGS += $(_DEBUG_CFLAGS)
205 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
206 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
208 # XXX: What does this? Bug 482434 filed for better explanation.
209 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
210 ifdef MOZ_DEBUG
211 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
212 OS_CFLAGS += -FR
213 OS_CXXFLAGS += -FR
214 endif
215 else # ! MOZ_DEBUG
217 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
218 # Used for generating an optimized build with debugging symbols.
219 # Used in the Windows nightlies to generate symbols for crash reporting.
220 ifdef MOZ_DEBUG_SYMBOLS
221 OS_CXXFLAGS += -UDEBUG -DNDEBUG
222 OS_CFLAGS += -UDEBUG -DNDEBUG
223 ifdef HAVE_64BIT_BUILD
224 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
225 else
226 OS_LDFLAGS += -DEBUG -OPT:REF
227 endif
228 endif
231 # Handle DMD in optimized builds.
232 # No opt to give sane callstacks.
234 ifdef MOZ_DMD
235 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
236 ifdef HAVE_64BIT_BUILD
237 OS_LDFLAGS = -DEBUG -OPT:REF,ICF
238 else
239 OS_LDFLAGS = -DEBUG -OPT:REF
240 endif
241 endif # MOZ_DMD
243 endif # MOZ_DEBUG
245 endif # WINNT && !GNU_CC
247 ifdef MOZ_GLUE_IN_PROGRAM
248 DEFINES += -DMOZ_GLUE_IN_PROGRAM
249 endif
252 # Build using PIC by default
254 _ENABLE_PIC=1
256 # No sense in profiling tools
257 ifdef INTERNAL_TOOLS
258 NO_PROFILE_GUIDED_OPTIMIZE = 1
259 endif
261 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
262 # and we don't have the same build logic to re-link them in the second pass.
263 ifdef SIMPLE_PROGRAMS
264 NO_PROFILE_GUIDED_OPTIMIZE = 1
265 endif
267 # No sense in profiling unit tests
268 ifdef CPP_UNIT_TESTS
269 NO_PROFILE_GUIDED_OPTIMIZE = 1
270 endif
272 # Enable profile-based feedback
273 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
274 ifdef MOZ_PROFILE_GENERATE
275 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
276 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
277 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
278 ifeq (WINNT,$(OS_ARCH))
279 AR_FLAGS += -LTCG
280 endif
281 endif # MOZ_PROFILE_GENERATE
283 ifdef MOZ_PROFILE_USE
284 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
285 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
286 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
287 ifeq (WINNT,$(OS_ARCH))
288 AR_FLAGS += -LTCG
289 endif
290 endif # MOZ_PROFILE_USE
291 endif # NO_PROFILE_GUIDED_OPTIMIZE
293 MAKE_JARS_FLAGS = \
294 -t $(topsrcdir) \
295 -f $(MOZ_CHROME_FILE_FORMAT) \
296 $(NULL)
298 ifdef USE_EXTENSION_MANIFEST
299 MAKE_JARS_FLAGS += -e
300 endif
302 TAR_CREATE_FLAGS = -chf
305 # Personal makefile customizations go in these optional make include files.
307 MY_CONFIG := $(DEPTH)/config/myconfig.mk
308 MY_RULES := $(DEPTH)/config/myrules.mk
311 # Default command macros; can be overridden in <arch>.mk.
313 CCC = $(CXX)
315 # Java macros
316 JAVA_GEN_DIR = _javagen
317 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
318 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
320 INCLUDES = \
321 -I$(srcdir) \
322 -I. \
323 $(LOCAL_INCLUDES) \
324 -I$(DIST)/include \
325 $(NULL)
327 ifndef IS_GYP_DIR
328 # NSPR_CFLAGS and NSS_CFLAGS must appear ahead of the other flags to avoid Linux
329 # builds wrongly picking up system NSPR/NSS header files.
330 OS_INCLUDES := \
331 $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
332 $(NSPR_CFLAGS) $(NSS_CFLAGS) \
333 $(MOZ_JPEG_CFLAGS) \
334 $(MOZ_PNG_CFLAGS) \
335 $(MOZ_ZLIB_CFLAGS) \
336 $(MOZ_PIXMAN_CFLAGS) \
337 $(NULL)
338 endif
340 include $(MOZILLA_DIR)/config/static-checking-config.mk
342 CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS)
343 CXXFLAGS = $(OS_CPPFLAGS) $(OS_CXXFLAGS)
344 LDFLAGS = $(OS_LDFLAGS) $(MOZBUILD_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
346 # Allow each module to override the *default* optimization settings
347 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
348 # arguments to --enable-optimize
349 ifdef MOZ_OPTIMIZE
350 ifeq (1,$(MOZ_OPTIMIZE))
351 ifdef MODULE_OPTIMIZE_FLAGS
352 CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
353 CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
354 else
355 ifneq (,$(if $(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE),$(MOZ_PGO_OPTIMIZE_FLAGS)))
356 CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
357 CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
358 else
359 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
360 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
361 endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
362 endif # MODULE_OPTIMIZE_FLAGS
363 else
364 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
365 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
366 endif # MOZ_OPTIMIZE == 1
367 LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
368 endif # MOZ_OPTIMIZE
370 ifdef CROSS_COMPILE
371 HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
372 else
373 ifdef MOZ_OPTIMIZE
374 ifeq (1,$(MOZ_OPTIMIZE))
375 ifdef MODULE_OPTIMIZE_FLAGS
376 HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
377 else
378 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
379 endif # MODULE_OPTIMIZE_FLAGS
380 else
381 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
382 endif # MOZ_OPTIMIZE == 1
383 endif # MOZ_OPTIMIZE
384 endif # CROSS_COMPILE
386 CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
387 CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
389 # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
390 # to request that we use the 'warnings as errors' compile flags)
392 # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO
393 # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that
394 # situation. (See bug 437002.)
395 ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
396 FAIL_ON_WARNINGS_DEBUG=
397 FAIL_ON_WARNINGS=
398 endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE)
400 # Now, check for debug version of flag; it turns on normal flag in debug builds.
401 ifdef FAIL_ON_WARNINGS_DEBUG
402 ifdef MOZ_DEBUG
403 FAIL_ON_WARNINGS = 1
404 endif # MOZ_DEBUG
405 endif # FAIL_ON_WARNINGS_DEBUG
407 # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1.
408 ifdef FAIL_ON_WARNINGS
409 # Never treat warnings as errors in clang-cl, because it warns about many more
410 # things than MSVC does.
411 ifndef CLANG_CL
412 CXXFLAGS += $(WARNINGS_AS_ERRORS)
413 CFLAGS += $(WARNINGS_AS_ERRORS)
414 endif # CLANG_CL
415 endif # FAIL_ON_WARNINGS
417 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
418 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
419 #// DLL version of the RTL is used...
421 #//------------------------------------------------------------------------
422 ifdef USE_STATIC_LIBS
423 RTL_FLAGS=-MT # Statically linked multithreaded RTL
424 ifdef MOZ_DEBUG
425 ifndef MOZ_NO_DEBUG_RTL
426 RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
427 endif
428 endif # MOZ_DEBUG
430 else # !USE_STATIC_LIBS
432 RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
433 ifdef MOZ_DEBUG
434 ifndef MOZ_NO_DEBUG_RTL
435 RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
436 endif
437 endif # MOZ_DEBUG
438 endif # USE_STATIC_LIBS
439 endif # WINNT && !GNU_CC
441 ifeq ($(OS_ARCH),Darwin)
442 # Compiling ObjC requires an Apple compiler anyway, so it's ok to set
443 # host CMFLAGS here.
444 HOST_CMFLAGS += -fobjc-exceptions
445 HOST_CMMFLAGS += -fobjc-exceptions
446 OS_COMPILE_CMFLAGS += -fobjc-exceptions
447 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
448 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
449 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
450 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
451 endif
452 endif
454 COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS)
455 COMPILE_CXXFLAGS = $(if $(DISABLE_STL_WRAPPING),,$(STL_FLAGS)) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(OS_INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(EXTRA_COMPILE_FLAGS)
456 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) $(EXTRA_COMPILE_FLAGS)
457 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) $(EXTRA_COMPILE_FLAGS)
458 ASFLAGS += $(EXTRA_ASSEMBLER_FLAGS)
460 ifndef CROSS_COMPILE
461 HOST_CFLAGS += $(RTL_FLAGS)
462 endif
465 # Name of the binary code directories
467 # Override defaults
469 # Default location of include files
470 ifndef LIBXUL_SDK
471 IDL_PARSER_DIR = $(topsrcdir)/xpcom/idl-parser
472 IDL_PARSER_CACHE_DIR = $(DEPTH)/xpcom/idl-parser
473 else
474 IDL_PARSER_DIR = $(LIBXUL_SDK)/sdk/bin
475 IDL_PARSER_CACHE_DIR = $(LIBXUL_SDK)/sdk/bin
476 endif
478 SDK_LIB_DIR = $(DIST)/sdk/lib
479 SDK_BIN_DIR = $(DIST)/sdk/bin
481 DEPENDENCIES = .md
483 ifdef MACOSX_DEPLOYMENT_TARGET
484 export MACOSX_DEPLOYMENT_TARGET
485 endif # MACOSX_DEPLOYMENT_TARGET
487 ifdef MOZ_USING_CCACHE
488 ifdef CLANG_CXX
489 export CCACHE_CPP2=1
490 endif
491 endif
493 # Set link flags according to whether we want a console.
494 ifeq ($(OS_ARCH),WINNT)
495 ifdef MOZ_WINCONSOLE
496 ifeq ($(MOZ_WINCONSOLE),1)
497 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
498 else # MOZ_WINCONSOLE
499 WIN32_EXE_LDFLAGS += $(WIN32_GUI_EXE_LDFLAGS)
500 endif
501 else
502 # For setting subsystem version
503 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
504 endif
505 endif # WINNT
507 ifdef _MSC_VER
508 ifeq ($(CPU_ARCH),x86_64)
509 # set stack to 2MB on x64 build. See bug 582910
510 WIN32_EXE_LDFLAGS += -STACK:2097152
511 endif
512 endif
515 # Include any personal overrides the user might think are needed.
517 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
518 -include $(MY_CONFIG)
520 ######################################################################
522 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
524 ifeq ($(OS_ARCH),Darwin)
525 ifndef NSDISTMODE
526 NSDISTMODE=absolute_symlink
527 endif
528 PWD := $(CURDIR)
529 endif
531 NSINSTALL_PY := $(PYTHON) $(abspath $(MOZILLA_DIR)/config/nsinstall.py)
532 # For Pymake, wherever we use nsinstall.py we're also going to try to make it
533 # a native command where possible. Since native commands can't be used outside
534 # of single-line commands, we continue to provide INSTALL for general use.
535 # Single-line commands should be switched over to install_cmd.
536 NSINSTALL_NATIVECMD := %nsinstall nsinstall
538 ifdef NSINSTALL_BIN
539 NSINSTALL = $(NSINSTALL_BIN)
540 else
541 ifeq ($(HOST_OS_ARCH),WINNT)
542 NSINSTALL = $(NSINSTALL_PY)
543 else
544 NSINSTALL = $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)
545 endif # WINNT
546 endif # NSINSTALL_BIN
549 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
550 INSTALL = $(NSINSTALL) -t
552 else
554 # This isn't laid out as conditional directives so that NSDISTMODE can be
555 # target-specific.
556 INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
558 endif # WINNT
560 # The default for install_cmd is simply INSTALL
561 install_cmd ?= $(INSTALL) $(1)
563 # Use nsinstall in copy mode to install files on the system
564 SYSINSTALL = $(NSINSTALL) -t
565 # This isn't necessarily true, just here
566 sysinstall_cmd = install_cmd
569 # Localization build automation
572 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
573 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
574 # overridden by the command line. (Besides, AB_CD is prettier).
575 AB_CD = $(MOZ_UI_LOCALE)
576 # Many locales directories want this definition.
577 DEFINES += -DAB_CD=$(AB_CD)
579 ifndef L10NBASEDIR
580 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
581 else
582 IS_LANGUAGE_REPACK = 1
583 endif
585 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/$(subst /locales,,$(1)))
587 ifdef relativesrcdir
588 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
589 endif
591 ifdef relativesrcdir
592 MAKE_JARS_FLAGS += --relativesrcdir=$(relativesrcdir)
593 ifneq (en-US,$(AB_CD))
594 ifdef LOCALE_MERGEDIR
595 MAKE_JARS_FLAGS += --locale-mergedir=$(LOCALE_MERGEDIR)
596 endif
597 ifdef IS_LANGUAGE_REPACK
598 MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD)
599 endif
600 else
601 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
602 endif # en-US
603 else
604 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
605 endif # ! relativesrcdir
607 ifdef LOCALE_MERGEDIR
608 MERGE_FILE = $(firstword \
609 $(wildcard $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))/$(1)) \
610 $(wildcard $(LOCALE_SRCDIR)/$(1)) \
611 $(srcdir)/en-US/$(1) )
612 else
613 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
614 endif
615 MERGE_FILES = $(foreach f,$(1),$(call MERGE_FILE,$(f)))
617 # These marcros are similar to MERGE_FILE, but no merging, and en-US first.
618 # They're used for searchplugins, for example.
619 EN_US_OR_L10N_FILE = $(firstword \
620 $(wildcard $(srcdir)/en-US/$(1)) \
621 $(LOCALE_SRCDIR)/$(1) )
622 EN_US_OR_L10N_FILES = $(foreach f,$(1),$(call EN_US_OR_L10N_FILE,$(f)))
624 ifneq (WINNT,$(OS_ARCH))
625 RUN_TEST_PROGRAM = $(LIBXUL_DIST)/bin/run-mozilla.sh
626 endif # ! WINNT
629 # Java macros
632 # Make sure any compiled classes work with at least JVM 1.4
633 JAVAC_FLAGS += -source 1.4
635 ifdef MOZ_DEBUG
636 JAVAC_FLAGS += -g
637 endif
639 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(abspath $(MOZILLA_DIR)/config/createprecomplete.py)
641 # MDDEPDIR is the subdirectory where dependency files are stored
642 MDDEPDIR := .deps
644 EXPAND_LIBS_EXEC = $(PYTHON) $(MOZILLA_DIR)/config/expandlibs_exec.py
645 EXPAND_LIBS_GEN = $(PYTHON) $(MOZILLA_DIR)/config/expandlibs_gen.py
646 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
647 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
648 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
649 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
650 EXPAND_MKSHLIB_ARGS = --uselist
651 ifdef SYMBOL_ORDER
652 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
653 endif
654 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
656 ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION))
657 ifneq ($(OS_ARCH),Darwin)
658 CHECK_STDCXX = @$(TOOLCHAIN_PREFIX)objdump -p $(1) | grep -v -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null || ( echo 'TEST-UNEXPECTED-FAIL | check_stdcxx | We do not want these libstdc++ symbols to be used:' && $(TOOLCHAIN_PREFIX)objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && false)
659 endif
660 endif
662 ifeq (,$(filter $(OS_TARGET),WINNT Darwin))
663 CHECK_TEXTREL = @$(TOOLCHAIN_PREFIX)readelf -d $(1) | grep TEXTREL > /dev/null && echo 'TEST-UNEXPECTED-FAIL | check_textrel | We do not want text relocations in libraries and programs' || true
664 endif
666 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
667 # While this is very unlikely (libc being added by the compiler at the end
668 # of the linker command line), if libmozglue.so ends up after libc.so, all
669 # hell breaks loose, so better safe than sorry, and check it's actually the
670 # case.
671 CHECK_MOZGLUE_ORDER = @$(TOOLCHAIN_PREFIX)readelf -d $(1) | grep NEEDED | awk '{ libs[$$NF] = ++n } END { if (libs["[libmozglue.so]"] && libs["[libc.so]"] < libs["[libmozglue.so]"]) { print "libmozglue.so must be linked before libc.so"; exit 1 } }'
672 endif
674 define CHECK_BINARY
675 $(call CHECK_STDCXX,$(1))
676 $(call CHECK_TEXTREL,$(1))
677 $(call LOCAL_CHECKS,$(1))
678 $(call CHECK_MOZGLUE_ORDER,$(1))
679 endef
681 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
682 # this file
683 OBJ_SUFFIX := $(_OBJ_SUFFIX)
685 # PGO builds with GCC build objects with instrumentation in a first pass,
686 # then objects optimized, without instrumentation, in a second pass. If
687 # we overwrite the objects from the first pass with those from the second,
688 # we end up not getting instrumentation data for better optimization on
689 # incremental builds. As a consequence, we use a different object suffix
690 # for the first pass.
691 ifndef NO_PROFILE_GUIDED_OPTIMIZE
692 ifdef MOZ_PROFILE_GENERATE
693 ifdef GNU_CC
694 OBJ_SUFFIX := i_o
695 endif
696 endif
697 endif
699 PLY_INCLUDE = -I$(MOZILLA_DIR)/other-licenses/ply
701 export CL_INCLUDES_PREFIX
702 # Make sure that the build system can handle non-ASCII characters
703 # in environment variables to prevent it from breking silently on
704 # non-English systems.
705 export NONASCII
707 DEFINES += -DNO_NSPR_10_SUPPORT
709 # Freeze the values specified by moz.build to catch them if they fail.
710 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))