Bumping manifests a=b2g-bump
[gecko.git] / config / config.mk
blob3062ba25d713e2202a4a844e834adaaaa4d3e999
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 $(topsrcdir)/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 win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
126 BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
127 else
128 win_srcdir := $(srcdir)
129 BUILD_TOOLS = $(topsrcdir)/build/unix
130 endif
132 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
133 AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
136 # Strip off the excessively long version numbers on these platforms,
137 # but save the version to allow multiple versions of the same base
138 # platform to be built in the same tree.
140 ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
141 OS_RELEASE := $(basename $(OS_RELEASE))
143 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
144 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
145 OS_VERS := $(suffix $(OS_RELEASE))
146 OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
147 endif
149 endif
151 OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
153 ifdef _MSC_VER
154 CC_WRAPPER ?= $(call py_action,cl)
155 CXX_WRAPPER ?= $(call py_action,cl)
156 endif # _MSC_VER
158 CC := $(CC_WRAPPER) $(CC)
159 CXX := $(CXX_WRAPPER) $(CXX)
160 MKDIR ?= mkdir
161 SLEEP ?= sleep
162 TOUCH ?= touch
164 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
166 # determine debug-related options
167 _DEBUG_ASFLAGS :=
168 _DEBUG_CFLAGS :=
169 _DEBUG_LDFLAGS :=
171 ifdef MOZ_DEBUG
172 _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
173 XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
174 else
175 _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
176 XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
177 endif
179 ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
180 ifeq ($(AS),yasm)
181 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
182 _DEBUG_ASFLAGS += -g cv8
183 else
184 ifneq ($(OS_ARCH),Darwin)
185 _DEBUG_ASFLAGS += -g dwarf2
186 endif
187 endif
188 else
189 _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
190 endif
191 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
192 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
193 endif
195 ASFLAGS += $(_DEBUG_ASFLAGS)
196 OS_CFLAGS += $(_DEBUG_CFLAGS)
197 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
198 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
200 # XXX: What does this? Bug 482434 filed for better explanation.
201 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
202 ifdef MOZ_DEBUG
203 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
204 OS_CFLAGS += -FR
205 OS_CXXFLAGS += -FR
206 endif
207 else # ! MOZ_DEBUG
209 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
210 # Used for generating an optimized build with debugging symbols.
211 # Used in the Windows nightlies to generate symbols for crash reporting.
212 ifdef MOZ_DEBUG_SYMBOLS
213 OS_CXXFLAGS += -UDEBUG -DNDEBUG
214 OS_CFLAGS += -UDEBUG -DNDEBUG
215 ifdef HAVE_64BIT_BUILD
216 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
217 else
218 OS_LDFLAGS += -DEBUG -OPT:REF
219 endif
220 endif
223 # Handle trace-malloc and DMD in optimized builds.
224 # No opt to give sane callstacks.
226 ifneq (,$(NS_TRACE_MALLOC)$(MOZ_DMD))
227 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
228 ifdef HAVE_64BIT_BUILD
229 OS_LDFLAGS = -DEBUG -OPT:REF,ICF
230 else
231 OS_LDFLAGS = -DEBUG -OPT:REF
232 endif
233 endif # NS_TRACE_MALLOC || MOZ_DMD
235 endif # MOZ_DEBUG
237 # We don't build a static CRT when building a custom CRT,
238 # it appears to be broken. So don't link to jemalloc if
239 # the Makefile wants static CRT linking.
240 ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_1)
241 # Disable default CRT libs and add the right lib path for the linker
242 MOZ_GLUE_LDFLAGS=
243 endif
245 endif # WINNT && !GNU_CC
247 ifdef MOZ_GLUE_PROGRAM_LDFLAGS
248 DEFINES += -DMOZ_GLUE_IN_PROGRAM
249 else
250 MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS)
251 endif
254 # Build using PIC by default
256 _ENABLE_PIC=1
258 # Determine if module being compiled is destined
259 # to be merged into libxul
261 ifneq (,$(filter xul xul-%,$(FINAL_LIBRARY) $(LIBRARY_NAME)))
262 LIBXUL_LIBRARY := 1
263 endif
265 ifdef LIBXUL_LIBRARY
266 ifdef IS_COMPONENT
267 $(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)
268 endif
269 endif
271 # PGO on MSVC is opt-in
272 ifdef _MSC_VER
273 ifndef MSVC_ENABLE_PGO
274 NO_PROFILE_GUIDED_OPTIMIZE = 1
275 endif
276 endif
278 # No sense in profiling tools
279 ifdef INTERNAL_TOOLS
280 NO_PROFILE_GUIDED_OPTIMIZE = 1
281 endif
283 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
284 # and we don't have the same build logic to re-link them in the second pass.
285 ifdef SIMPLE_PROGRAMS
286 NO_PROFILE_GUIDED_OPTIMIZE = 1
287 endif
289 # No sense in profiling unit tests
290 ifdef CPP_UNIT_TESTS
291 NO_PROFILE_GUIDED_OPTIMIZE = 1
292 endif
294 # Enable profile-based feedback
295 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
296 ifdef MOZ_PROFILE_GENERATE
297 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
298 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
299 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
300 ifeq (WINNT,$(OS_ARCH))
301 AR_FLAGS += -LTCG
302 endif
303 endif # MOZ_PROFILE_GENERATE
305 ifdef MOZ_PROFILE_USE
306 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
307 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
308 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
309 ifeq (WINNT,$(OS_ARCH))
310 AR_FLAGS += -LTCG
311 endif
312 endif # MOZ_PROFILE_USE
313 endif # NO_PROFILE_GUIDED_OPTIMIZE
315 ifdef _MSC_VER
316 OS_LDFLAGS += $(DELAYLOAD_LDFLAGS)
317 endif # _MSC_VER
319 ifneq (,$(LIBXUL_LIBRARY))
320 DEFINES += -DMOZILLA_INTERNAL_API
321 endif
323 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
324 # building libxul libraries
325 ifdef LIBXUL_LIBRARY
326 DEFINES += \
327 -DIMPL_LIBXUL \
328 $(NULL)
330 ifndef JS_SHARED_LIBRARY
331 DEFINES += -DSTATIC_EXPORTABLE_JS_API
332 endif
333 endif
335 MAKE_JARS_FLAGS = \
336 -t $(topsrcdir) \
337 -f $(MOZ_CHROME_FILE_FORMAT) \
338 $(NULL)
340 ifdef USE_EXTENSION_MANIFEST
341 MAKE_JARS_FLAGS += -e
342 endif
344 TAR_CREATE_FLAGS = -chf
347 # Personal makefile customizations go in these optional make include files.
349 MY_CONFIG := $(DEPTH)/config/myconfig.mk
350 MY_RULES := $(DEPTH)/config/myrules.mk
353 # Default command macros; can be overridden in <arch>.mk.
355 CCC = $(CXX)
357 # Java macros
358 JAVA_GEN_DIR = _javagen
359 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
360 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
362 OS_INCLUDES += $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS) $(MOZ_PIXMAN_CFLAGS)
364 # NSPR_CFLAGS and NSS_CFLAGS must appear ahead of OS_INCLUDES to avoid Linux
365 # builds wrongly picking up system NSPR/NSS header files.
366 INCLUDES = \
367 -I$(srcdir) \
368 -I. \
369 $(LOCAL_INCLUDES) \
370 -I$(DIST)/include \
371 $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
372 $(NSPR_CFLAGS) $(NSS_CFLAGS) \
373 $(OS_INCLUDES) \
374 $(NULL)
376 include $(topsrcdir)/config/static-checking-config.mk
378 CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS)
379 CXXFLAGS = $(OS_CPPFLAGS) $(OS_CXXFLAGS)
380 LDFLAGS = $(OS_LDFLAGS) $(MOZBUILD_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
382 # Allow each module to override the *default* optimization settings
383 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
384 # arguments to --enable-optimize
385 ifdef MOZ_OPTIMIZE
386 ifeq (1,$(MOZ_OPTIMIZE))
387 ifdef MODULE_OPTIMIZE_FLAGS
388 CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
389 CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
390 else
391 ifneq (,$(if $(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE),$(MOZ_PGO_OPTIMIZE_FLAGS)))
392 CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
393 CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
394 else
395 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
396 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
397 endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
398 endif # MODULE_OPTIMIZE_FLAGS
399 else
400 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
401 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
402 endif # MOZ_OPTIMIZE == 1
403 LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
404 endif # MOZ_OPTIMIZE
406 ifdef CROSS_COMPILE
407 HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
408 else
409 ifdef MOZ_OPTIMIZE
410 ifeq (1,$(MOZ_OPTIMIZE))
411 ifdef MODULE_OPTIMIZE_FLAGS
412 HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
413 else
414 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
415 endif # MODULE_OPTIMIZE_FLAGS
416 else
417 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
418 endif # MOZ_OPTIMIZE == 1
419 endif # MOZ_OPTIMIZE
420 endif # CROSS_COMPILE
422 CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
423 CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
425 # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
426 # to request that we use the 'warnings as errors' compile flags)
428 # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO
429 # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that
430 # situation. (See bug 437002.)
431 ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
432 FAIL_ON_WARNINGS_DEBUG=
433 FAIL_ON_WARNINGS=
434 endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE)
436 # Now, check for debug version of flag; it turns on normal flag in debug builds.
437 ifdef FAIL_ON_WARNINGS_DEBUG
438 ifdef MOZ_DEBUG
439 FAIL_ON_WARNINGS = 1
440 endif # MOZ_DEBUG
441 endif # FAIL_ON_WARNINGS_DEBUG
443 # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1.
444 ifdef FAIL_ON_WARNINGS
445 CXXFLAGS += $(WARNINGS_AS_ERRORS)
446 CFLAGS += $(WARNINGS_AS_ERRORS)
447 endif # FAIL_ON_WARNINGS
449 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
450 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
451 #// DLL version of the RTL is used...
453 #//------------------------------------------------------------------------
454 ifdef USE_STATIC_LIBS
455 RTL_FLAGS=-MT # Statically linked multithreaded RTL
456 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
457 ifndef MOZ_NO_DEBUG_RTL
458 RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
459 endif
460 endif # MOZ_DEBUG || NS_TRACE_MALLOC
462 else # !USE_STATIC_LIBS
464 RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
465 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
466 ifndef MOZ_NO_DEBUG_RTL
467 RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
468 endif
469 endif # MOZ_DEBUG || NS_TRACE_MALLOC
470 endif # USE_STATIC_LIBS
471 endif # WINNT && !GNU_CC
473 ifeq ($(OS_ARCH),Darwin)
474 # Compiling ObjC requires an Apple compiler anyway, so it's ok to set
475 # host CMFLAGS here.
476 HOST_CMFLAGS += -fobjc-exceptions
477 HOST_CMMFLAGS += -fobjc-exceptions
478 OS_COMPILE_CMFLAGS += -fobjc-exceptions
479 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
480 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
481 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
482 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
483 endif
484 endif
486 COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS)
487 COMPILE_CXXFLAGS = $(if $(DISABLE_STL_WRAPPING),,$(STL_FLAGS)) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(EXTRA_COMPILE_FLAGS)
488 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) $(EXTRA_COMPILE_FLAGS)
489 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) $(EXTRA_COMPILE_FLAGS)
490 ASFLAGS += $(EXTRA_ASSEMBLER_FLAGS)
492 ifndef CROSS_COMPILE
493 HOST_CFLAGS += $(RTL_FLAGS)
494 endif
497 # Name of the binary code directories
499 # Override defaults
501 # Default location of include files
502 ifndef LIBXUL_SDK
503 IDL_PARSER_DIR = $(topsrcdir)/xpcom/idl-parser
504 IDL_PARSER_CACHE_DIR = $(DEPTH)/xpcom/idl-parser
505 else
506 IDL_PARSER_DIR = $(LIBXUL_SDK)/sdk/bin
507 IDL_PARSER_CACHE_DIR = $(LIBXUL_SDK)/sdk/bin
508 endif
510 SDK_LIB_DIR = $(DIST)/sdk/lib
511 SDK_BIN_DIR = $(DIST)/sdk/bin
513 DEPENDENCIES = .md
515 ifdef MACOSX_DEPLOYMENT_TARGET
516 export MACOSX_DEPLOYMENT_TARGET
517 endif # MACOSX_DEPLOYMENT_TARGET
519 ifdef MOZ_USING_CCACHE
520 ifdef CLANG_CXX
521 export CCACHE_CPP2=1
522 endif
523 endif
525 # Set link flags according to whether we want a console.
526 ifeq ($(OS_ARCH),WINNT)
527 ifdef MOZ_WINCONSOLE
528 ifeq ($(MOZ_WINCONSOLE),1)
529 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
530 else # MOZ_WINCONSOLE
531 WIN32_EXE_LDFLAGS += $(WIN32_GUI_EXE_LDFLAGS)
532 endif
533 else
534 # For setting subsystem version
535 WIN32_EXE_LDFLAGS += $(WIN32_CONSOLE_EXE_LDFLAGS)
536 endif
537 endif # WINNT
539 ifdef _MSC_VER
540 ifeq ($(CPU_ARCH),x86_64)
541 # set stack to 2MB on x64 build. See bug 582910
542 WIN32_EXE_LDFLAGS += -STACK:2097152
543 endif
544 endif
546 # If we're building a component on MSVC, we don't want to generate an
547 # import lib, because that import lib will collide with the name of a
548 # static version of the same library.
549 ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
550 ifdef IS_COMPONENT
551 LDFLAGS += -IMPLIB:fake.lib
552 DELETE_AFTER_LINK = fake.lib fake.exp
553 endif
554 endif
557 # Include any personal overrides the user might think are needed.
559 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
560 -include $(MY_CONFIG)
562 ######################################################################
564 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
566 ifeq ($(OS_ARCH),Darwin)
567 ifndef NSDISTMODE
568 NSDISTMODE=absolute_symlink
569 endif
570 PWD := $(CURDIR)
571 endif
573 NSINSTALL_PY := $(PYTHON) $(abspath $(topsrcdir)/config/nsinstall.py)
574 # For Pymake, wherever we use nsinstall.py we're also going to try to make it
575 # a native command where possible. Since native commands can't be used outside
576 # of single-line commands, we continue to provide INSTALL for general use.
577 # Single-line commands should be switched over to install_cmd.
578 NSINSTALL_NATIVECMD := %nsinstall nsinstall
580 ifdef NSINSTALL_BIN
581 NSINSTALL = $(NSINSTALL_BIN)
582 else
583 ifeq ($(HOST_OS_ARCH),WINNT)
584 NSINSTALL = $(NSINSTALL_PY)
585 else
586 NSINSTALL = $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)
587 endif # WINNT
588 endif # NSINSTALL_BIN
591 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
592 INSTALL = $(NSINSTALL) -t
594 else
596 # This isn't laid out as conditional directives so that NSDISTMODE can be
597 # target-specific.
598 INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
600 endif # WINNT
602 # The default for install_cmd is simply INSTALL
603 install_cmd ?= $(INSTALL) $(1)
605 # Use nsinstall in copy mode to install files on the system
606 SYSINSTALL = $(NSINSTALL) -t
607 # This isn't necessarily true, just here
608 sysinstall_cmd = install_cmd
611 # Localization build automation
614 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
615 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
616 # overridden by the command line. (Besides, AB_CD is prettier).
617 AB_CD = $(MOZ_UI_LOCALE)
618 # Many locales directories want this definition.
619 DEFINES += -DAB_CD=$(AB_CD)
621 ifndef L10NBASEDIR
622 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
623 else
624 IS_LANGUAGE_REPACK = 1
625 endif
627 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/$(subst /locales,,$(1)))
629 ifdef relativesrcdir
630 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
631 endif
633 ifdef relativesrcdir
634 MAKE_JARS_FLAGS += --relativesrcdir=$(relativesrcdir)
635 ifneq (en-US,$(AB_CD))
636 ifdef LOCALE_MERGEDIR
637 MAKE_JARS_FLAGS += --locale-mergedir=$(LOCALE_MERGEDIR)
638 endif
639 ifdef IS_LANGUAGE_REPACK
640 MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD)
641 endif
642 else
643 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
644 endif # en-US
645 else
646 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
647 endif # ! relativesrcdir
649 ifdef LOCALE_MERGEDIR
650 MERGE_FILE = $(firstword \
651 $(wildcard $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))/$(1)) \
652 $(wildcard $(LOCALE_SRCDIR)/$(1)) \
653 $(srcdir)/en-US/$(1) )
654 else
655 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
656 endif
657 MERGE_FILES = $(foreach f,$(1),$(call MERGE_FILE,$(f)))
659 ifneq (WINNT,$(OS_ARCH))
660 RUN_TEST_PROGRAM = $(LIBXUL_DIST)/bin/run-mozilla.sh
661 endif # ! WINNT
664 # Java macros
667 # Make sure any compiled classes work with at least JVM 1.4
668 JAVAC_FLAGS += -source 1.4
670 ifdef MOZ_DEBUG
671 JAVAC_FLAGS += -g
672 endif
674 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(abspath $(topsrcdir)/config/createprecomplete.py)
676 # MDDEPDIR is the subdirectory where dependency files are stored
677 MDDEPDIR := .deps
679 EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py
680 EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py
681 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
682 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
683 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
684 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
685 EXPAND_MKSHLIB_ARGS = --uselist
686 ifdef SYMBOL_ORDER
687 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
688 endif
689 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
691 ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION))
692 ifneq ($(OS_ARCH),Darwin)
693 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)
694 endif
695 endif
697 ifeq (,$(filter $(OS_TARGET),WINNT Darwin))
698 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
699 endif
701 define CHECK_BINARY
702 $(call CHECK_STDCXX,$(1))
703 $(call CHECK_TEXTREL,$(1))
704 $(call LOCAL_CHECKS,$(1))
705 endef
707 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
708 # this file
709 OBJ_SUFFIX := $(_OBJ_SUFFIX)
711 # PGO builds with GCC build objects with instrumentation in a first pass,
712 # then objects optimized, without instrumentation, in a second pass. If
713 # we overwrite the objects from the first pass with those from the second,
714 # we end up not getting instrumentation data for better optimization on
715 # incremental builds. As a consequence, we use a different object suffix
716 # for the first pass.
717 ifndef NO_PROFILE_GUIDED_OPTIMIZE
718 ifdef MOZ_PROFILE_GENERATE
719 ifdef GNU_CC
720 OBJ_SUFFIX := i_o
721 endif
722 endif
723 endif
725 # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
726 # expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker
727 # arguments syntax. Should only be used for system libraries
729 # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
730 # expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
732 # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
733 # expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
735 ifdef GNU_CC
736 EXPAND_LIBNAME = $(addprefix -l,$(1))
737 else
738 EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
739 endif
740 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
741 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
743 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
745 export CL_INCLUDES_PREFIX
746 # Make sure that the build system can handle non-ASCII characters
747 # in environment variables to prevent it from breking silently on
748 # non-English systems.
749 export NONASCII
751 DEFINES += -DNO_NSPR_10_SUPPORT
753 ifdef IS_GYP_DIR
754 LOCAL_INCLUDES += \
755 -I$(topsrcdir)/ipc/chromium/src \
756 -I$(topsrcdir)/ipc/glue \
757 -I$(DEPTH)/ipc/ipdl/_ipdlheaders \
758 $(NULL)
760 ifeq (WINNT,$(OS_TARGET))
761 # These get set via VC project file settings for normal GYP builds.
762 DEFINES += -DUNICODE -D_UNICODE
763 endif
765 DISABLE_STL_WRAPPING := 1
766 # Skip most Mozilla-specific include locations.
767 INCLUDES = -I. $(LOCAL_INCLUDES) -I$(DEPTH)/dist/include
768 endif
770 # Freeze the values specified by moz.build to catch them if they fail.
771 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))