Bug 983971 - Do not use gralloc for small size on ICS gonk r=nical
[gecko.git] / config / config.mk
blob79b8855d9f2689be8350e36a92817bf25c3af1d8
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 # Integrate with mozbuild-generated make files. We first verify that no
33 # variables provided by the automatically generated .mk files are
34 # present. If they are, this is a violation of the separation of
35 # responsibility between Makefile.in and mozbuild files.
36 _MOZBUILD_EXTERNAL_VARIABLES := \
37 ANDROID_GENERATED_RESFILES \
38 ANDROID_RES_DIRS \
39 CMSRCS \
40 CMMSRCS \
41 CPP_UNIT_TESTS \
42 DIRS \
43 EXTRA_PP_COMPONENTS \
44 EXTRA_PP_JS_MODULES \
45 FORCE_SHARED_LIB \
46 FORCE_STATIC_LIB \
47 FINAL_LIBRARY \
48 HOST_CSRCS \
49 HOST_CMMSRCS \
50 HOST_LIBRARY_NAME \
51 HOST_PROGRAM \
52 HOST_SIMPLE_PROGRAMS \
53 IS_COMPONENT \
54 JAR_MANIFEST \
55 JAVA_JAR_TARGETS \
56 JS_MODULES_PATH \
57 LIBRARY_NAME \
58 LIBXUL_LIBRARY \
59 MODULE \
60 MSVC_ENABLE_PGO \
61 NO_DIST_INSTALL \
62 PARALLEL_DIRS \
63 PROGRAM \
64 RESOURCE_FILES \
65 SDK_HEADERS \
66 SIMPLE_PROGRAMS \
67 TEST_DIRS \
68 TIERS \
69 TOOL_DIRS \
70 XPCSHELL_TESTS \
71 XPIDL_MODULE \
72 $(NULL)
74 _DEPRECATED_VARIABLES := \
75 ANDROID_RESFILES \
76 MOCHITEST_A11Y_FILES \
77 MOCHITEST_BROWSER_FILES \
78 MOCHITEST_BROWSER_FILES_PARTS \
79 MOCHITEST_CHROME_FILES \
80 MOCHITEST_FILES \
81 MOCHITEST_FILES_PARTS \
82 MOCHITEST_METRO_FILES \
83 MOCHITEST_ROBOCOP_FILES \
84 SHORT_LIBNAME \
85 $(NULL)
87 ifndef EXTERNALLY_MANAGED_MAKE_FILE
88 # Using $(firstword) may not be perfect. But it should be good enough for most
89 # scenarios.
90 _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST))
92 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\
93 $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\
96 $(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\
97 $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\
100 # Import the automatically generated backend file. If this file doesn't exist,
101 # the backend hasn't been properly configured. We want this to be a fatal
102 # error, hence not using "-include".
103 ifndef STANDALONE_MAKEFILE
104 GLOBAL_DEPS += backend.mk
105 include backend.mk
106 endif
108 # Freeze the values specified by moz.build to catch them if they fail.
110 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
111 $(foreach var,$(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
113 CHECK_MOZBUILD_VARIABLES = $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES), \
114 $(if $(subst $($(var)_FROZEN),,'$($(var))'), \
115 $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\
116 )) $(foreach var,$(_DEPRECATED_VARIABLES), \
117 $(if $(subst $($(var)_FROZEN),,'$($(var))'), \
118 $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build),\
121 endif
123 space = $(NULL) $(NULL)
125 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
126 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
127 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
128 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
129 # These defs.mk files are used to define variables in a directory
130 # and all its subdirectories, recursively.
131 __depth := $(subst /, ,$(DEPTH))
132 ifeq (.,$(__depth))
133 __depth :=
134 endif
135 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
137 COMMA = ,
139 # Sanity check some variables
140 CHECK_VARS := \
141 XPI_NAME \
142 LIBRARY_NAME \
143 MODULE \
144 DEPTH \
145 XPI_PKGNAME \
146 INSTALL_EXTENSION_ID \
147 SHARED_LIBRARY_NAME \
148 STATIC_LIBRARY_NAME \
149 $(NULL)
151 # checks for internal spaces or trailing spaces in the variable
152 # named by $x
153 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
155 $(foreach x,$(CHECK_VARS),$(check-variable))
157 ifndef INCLUDED_FUNCTIONS_MK
158 include $(topsrcdir)/config/makefiles/functions.mk
159 endif
161 RM = rm -f
163 # LIBXUL_DIST is not defined under js/src, thus we make it mean DIST there.
164 LIBXUL_DIST ?= $(DIST)
166 # FINAL_TARGET specifies the location into which we copy end-user-shipped
167 # build products (typelibs, components, chrome). It may already be specified by
168 # a moz.build file.
170 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
171 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
172 # shipped to a $(DIST_SUBDIR) subdirectory.
173 FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
174 # Override the stored value for the check to make sure that the variable is not
175 # redefined in the Makefile.in value.
176 FINAL_TARGET_FROZEN := '$(FINAL_TARGET)'
178 ifdef XPI_NAME
179 DEFINES += -DXPI_NAME=$(XPI_NAME)
180 endif
182 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
183 VERSION_NUMBER = 50
185 ifeq ($(HOST_OS_ARCH),WINNT)
186 win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
187 BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
188 else
189 win_srcdir := $(srcdir)
190 BUILD_TOOLS = $(topsrcdir)/build/unix
191 endif
193 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
194 AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
196 # Disable MOZ_PSEUDO_DERECURSE when it contains no-pymake and we're running
197 # pymake. This can be removed when no-pymake is removed from the default in
198 # build/autoconf/compiler-opts.m4.
199 ifdef .PYMAKE
200 comma = ,
201 ifneq (,$(filter no-pymake,$(subst $(comma), ,$(MOZ_PSEUDO_DERECURSE))))
202 MOZ_PSEUDO_DERECURSE :=
203 endif
204 endif
206 # Disable MOZ_PSEUDO_DERECURSE on PGO builds until it's fixed.
207 ifneq (,$(MOZ_PROFILE_USE)$(MOZ_PROFILE_GENERATE))
208 MOZ_PSEUDO_DERECURSE :=
209 endif
212 # Strip off the excessively long version numbers on these platforms,
213 # but save the version to allow multiple versions of the same base
214 # platform to be built in the same tree.
216 ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
217 OS_RELEASE := $(basename $(OS_RELEASE))
219 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
220 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
221 OS_VERS := $(suffix $(OS_RELEASE))
222 OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
223 endif
225 endif
227 OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
229 ifdef _MSC_VER
230 CC_WRAPPER ?= $(call py_action,cl)
231 CXX_WRAPPER ?= $(call py_action,cl)
232 endif # _MSC_VER
234 CC := $(CC_WRAPPER) $(CC)
235 CXX := $(CXX_WRAPPER) $(CXX)
236 MKDIR ?= mkdir
237 SLEEP ?= sleep
238 TOUCH ?= touch
240 ifdef .PYMAKE
241 PYCOMMANDPATH += $(PYTHON_SITE_PACKAGES)
242 endif
244 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
246 # determine debug-related options
247 _DEBUG_ASFLAGS :=
248 _DEBUG_CFLAGS :=
249 _DEBUG_LDFLAGS :=
251 ifdef MOZ_DEBUG
252 _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
253 XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
254 else
255 _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
256 XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
257 endif
259 ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
260 ifeq ($(AS),yasm)
261 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
262 _DEBUG_ASFLAGS += -g cv8
263 else
264 ifneq ($(OS_ARCH),Darwin)
265 _DEBUG_ASFLAGS += -g dwarf2
266 endif
267 endif
268 else
269 _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
270 endif
271 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
272 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
273 endif
275 MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib)
277 ASFLAGS += $(_DEBUG_ASFLAGS)
278 OS_CFLAGS += $(_DEBUG_CFLAGS)
279 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
280 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
282 # XXX: What does this? Bug 482434 filed for better explanation.
283 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
284 ifdef MOZ_DEBUG
285 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
286 OS_CFLAGS += -FR
287 OS_CXXFLAGS += -FR
288 endif
289 else # ! MOZ_DEBUG
291 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
292 # Used for generating an optimized build with debugging symbols.
293 # Used in the Windows nightlies to generate symbols for crash reporting.
294 ifdef MOZ_DEBUG_SYMBOLS
295 OS_CXXFLAGS += -UDEBUG -DNDEBUG
296 OS_CFLAGS += -UDEBUG -DNDEBUG
297 ifdef HAVE_64BIT_OS
298 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
299 else
300 OS_LDFLAGS += -DEBUG -OPT:REF
301 endif
302 endif
305 # Handle trace-malloc and DMD in optimized builds.
306 # No opt to give sane callstacks.
308 ifneq (,$(NS_TRACE_MALLOC)$(MOZ_DMD))
309 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
310 ifdef HAVE_64BIT_OS
311 OS_LDFLAGS = -DEBUG -OPT:REF,ICF
312 else
313 OS_LDFLAGS = -DEBUG -OPT:REF
314 endif
315 endif # NS_TRACE_MALLOC || MOZ_DMD
317 endif # MOZ_DEBUG
319 # We don't build a static CRT when building a custom CRT,
320 # it appears to be broken. So don't link to jemalloc if
321 # the Makefile wants static CRT linking.
322 ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_1)
323 # Disable default CRT libs and add the right lib path for the linker
324 MOZ_GLUE_LDFLAGS=
325 endif
327 endif # WINNT && !GNU_CC
329 ifdef MOZ_GLUE_PROGRAM_LDFLAGS
330 DEFINES += -DMOZ_GLUE_IN_PROGRAM
331 else
332 MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS)
333 endif
336 # Build using PIC by default
338 _ENABLE_PIC=1
340 # Determine if module being compiled is destined
341 # to be merged into libxul
343 ifneq (,$(filter xul,$(FINAL_LIBRARY) $(LIBRARY_NAME)))
344 ifdef LIBXUL_LIBRARY
345 $(error LIBRARY_NAME or FINAL_LIBRARY is "xul", LIBXUL_LIBRARY is implied)
346 endif
347 LIBXUL_LIBRARY := 1
348 endif
350 ifdef LIBXUL_LIBRARY
351 ifdef IS_COMPONENT
352 $(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)
353 endif
354 ifneq (xul,$(LIBRARY_NAME))
355 FORCE_STATIC_LIB=1
356 endif
357 endif
359 # If we are building this component into an extension/xulapp, it cannot be
360 # statically linked. In the future we may want to add a xulapp meta-component
361 # build option.
363 ifdef XPI_NAME
364 ifdef IS_COMPONENT
365 EXPORT_LIBRARY=
366 FORCE_STATIC_LIB=
367 FORCE_SHARED_LIB=1
368 endif
369 endif
371 ifndef SHARED_LIBRARY_NAME
372 ifdef LIBRARY_NAME
373 SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
374 endif
375 endif
377 ifndef STATIC_LIBRARY_NAME
378 ifdef LIBRARY_NAME
379 STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
380 endif
381 endif
383 # PGO on MSVC is opt-in
384 ifdef _MSC_VER
385 ifndef MSVC_ENABLE_PGO
386 NO_PROFILE_GUIDED_OPTIMIZE = 1
387 endif
388 endif
390 # No sense in profiling tools
391 ifdef INTERNAL_TOOLS
392 NO_PROFILE_GUIDED_OPTIMIZE = 1
393 endif
395 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
396 # and we don't have the same build logic to re-link them in the second pass.
397 ifdef SIMPLE_PROGRAMS
398 NO_PROFILE_GUIDED_OPTIMIZE = 1
399 endif
401 # No sense in profiling unit tests
402 ifdef CPP_UNIT_TESTS
403 NO_PROFILE_GUIDED_OPTIMIZE = 1
404 endif
406 # Enable profile-based feedback
407 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
408 ifdef MOZ_PROFILE_GENERATE
409 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
410 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
411 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
412 ifeq (WINNT,$(OS_ARCH))
413 AR_FLAGS += -LTCG
414 endif
415 endif # MOZ_PROFILE_GENERATE
417 ifdef MOZ_PROFILE_USE
418 OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
419 OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
420 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
421 ifeq (WINNT,$(OS_ARCH))
422 AR_FLAGS += -LTCG
423 endif
424 endif # MOZ_PROFILE_USE
425 endif # NO_PROFILE_GUIDED_OPTIMIZE
427 ifdef _MSC_VER
428 OS_LDFLAGS += $(DELAYLOAD_LDFLAGS)
429 endif # _MSC_VER
431 ifneq (,$(LIBXUL_LIBRARY))
432 DEFINES += -DMOZILLA_INTERNAL_API
433 endif
435 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
436 # building libxul libraries
437 ifdef LIBXUL_LIBRARY
438 DEFINES += \
439 -DIMPL_LIBXUL \
440 $(NULL)
442 ifndef JS_SHARED_LIBRARY
443 DEFINES += -DSTATIC_EXPORTABLE_JS_API
444 endif
445 endif
447 MAKE_JARS_FLAGS = \
448 -t $(topsrcdir) \
449 -f $(MOZ_CHROME_FILE_FORMAT) \
450 $(NULL)
452 ifdef USE_EXTENSION_MANIFEST
453 MAKE_JARS_FLAGS += -e
454 endif
456 TAR_CREATE_FLAGS = -chf
459 # Personal makefile customizations go in these optional make include files.
461 MY_CONFIG := $(DEPTH)/config/myconfig.mk
462 MY_RULES := $(DEPTH)/config/myrules.mk
465 # Default command macros; can be overridden in <arch>.mk.
467 CCC = $(CXX)
469 # Java macros
470 JAVA_GEN_DIR = _javagen
471 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
472 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
474 OS_INCLUDES += $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS) $(MOZ_PIXMAN_CFLAGS)
476 # NSPR_CFLAGS and NSS_CFLAGS must appear ahead of OS_INCLUDES to avoid Linux
477 # builds wrongly picking up system NSPR/NSS header files.
478 INCLUDES = \
479 -I$(srcdir) \
480 -I. \
481 $(LOCAL_INCLUDES) \
482 -I$(DIST)/include \
483 $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
484 $(NSPR_CFLAGS) $(NSS_CFLAGS) \
485 $(OS_INCLUDES) \
486 $(NULL)
488 include $(topsrcdir)/config/static-checking-config.mk
490 CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS)
491 CXXFLAGS = $(OS_CPPFLAGS) $(OS_CXXFLAGS)
492 LDFLAGS = $(OS_LDFLAGS) $(MOZBUILD_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
494 # Allow each module to override the *default* optimization settings
495 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
496 # arguments to --enable-optimize
497 ifdef MOZ_OPTIMIZE
498 ifeq (1,$(MOZ_OPTIMIZE))
499 ifdef MODULE_OPTIMIZE_FLAGS
500 CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
501 CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
502 else
503 ifneq (,$(if $(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE),$(MOZ_PGO_OPTIMIZE_FLAGS)))
504 CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
505 CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
506 else
507 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
508 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
509 endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
510 endif # MODULE_OPTIMIZE_FLAGS
511 else
512 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
513 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
514 endif # MOZ_OPTIMIZE == 1
515 LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
516 endif # MOZ_OPTIMIZE
518 ifdef CROSS_COMPILE
519 HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
520 else
521 ifdef MOZ_OPTIMIZE
522 ifeq (1,$(MOZ_OPTIMIZE))
523 ifdef MODULE_OPTIMIZE_FLAGS
524 HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
525 else
526 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
527 endif # MODULE_OPTIMIZE_FLAGS
528 else
529 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
530 endif # MOZ_OPTIMIZE == 1
531 endif # MOZ_OPTIMIZE
532 endif # CROSS_COMPILE
534 CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
535 CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
537 # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
538 # to request that we use the 'warnings as errors' compile flags)
540 # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO
541 # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that
542 # situation. (See bug 437002.)
543 ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
544 FAIL_ON_WARNINGS_DEBUG=
545 FAIL_ON_WARNINGS=
546 endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE)
548 # Now, check for debug version of flag; it turns on normal flag in debug builds.
549 ifdef FAIL_ON_WARNINGS_DEBUG
550 ifdef MOZ_DEBUG
551 FAIL_ON_WARNINGS = 1
552 endif # MOZ_DEBUG
553 endif # FAIL_ON_WARNINGS_DEBUG
555 # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1.
556 ifdef FAIL_ON_WARNINGS
557 CXXFLAGS += $(WARNINGS_AS_ERRORS)
558 CFLAGS += $(WARNINGS_AS_ERRORS)
559 endif # FAIL_ON_WARNINGS
561 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
562 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
563 #// DLL version of the RTL is used...
565 #//------------------------------------------------------------------------
566 ifdef USE_STATIC_LIBS
567 RTL_FLAGS=-MT # Statically linked multithreaded RTL
568 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
569 ifndef MOZ_NO_DEBUG_RTL
570 RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
571 endif
572 endif # MOZ_DEBUG || NS_TRACE_MALLOC
574 else # !USE_STATIC_LIBS
576 RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
577 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
578 ifndef MOZ_NO_DEBUG_RTL
579 RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
580 endif
581 endif # MOZ_DEBUG || NS_TRACE_MALLOC
582 endif # USE_STATIC_LIBS
583 endif # WINNT && !GNU_CC
585 ifeq ($(OS_ARCH),Darwin)
586 # Compiling ObjC requires an Apple compiler anyway, so it's ok to set
587 # host CMFLAGS here.
588 HOST_CMFLAGS += -fobjc-exceptions
589 HOST_CMMFLAGS += -fobjc-exceptions
590 OS_COMPILE_CMFLAGS += -fobjc-exceptions
591 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
592 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
593 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
594 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
595 endif
596 endif
598 COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS)
599 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)
600 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) $(EXTRA_COMPILE_FLAGS)
601 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) $(EXTRA_COMPILE_FLAGS)
602 ASFLAGS += $(EXTRA_ASSEMBLER_FLAGS)
604 ifndef CROSS_COMPILE
605 HOST_CFLAGS += $(RTL_FLAGS)
606 endif
609 # Name of the binary code directories
611 # Override defaults
613 # We need to know where to find the libraries we
614 # put on the link line for binaries, and should
615 # we link statically or dynamic? Assuming dynamic for now.
617 ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
618 LIBS_DIR = -L$(DIST)/bin -L$(DIST)/lib
619 ifdef LIBXUL_SDK
620 LIBS_DIR += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
621 endif
622 endif
624 # Default location of include files
625 ifndef LIBXUL_SDK
626 IDL_PARSER_DIR = $(topsrcdir)/xpcom/idl-parser
627 IDL_PARSER_CACHE_DIR = $(DEPTH)/xpcom/idl-parser
628 else
629 IDL_PARSER_DIR = $(LIBXUL_SDK)/sdk/bin
630 IDL_PARSER_CACHE_DIR = $(LIBXUL_SDK)/sdk/bin
631 endif
633 SDK_LIB_DIR = $(DIST)/sdk/lib
634 SDK_BIN_DIR = $(DIST)/sdk/bin
636 DEPENDENCIES = .md
638 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
640 ifdef MACOSX_DEPLOYMENT_TARGET
641 export MACOSX_DEPLOYMENT_TARGET
642 endif # MACOSX_DEPLOYMENT_TARGET
644 ifdef MOZ_USING_CCACHE
645 ifdef CLANG_CXX
646 export CCACHE_CPP2=1
647 endif
648 endif
650 # Set link flags according to whether we want a console.
651 ifdef MOZ_WINCONSOLE
652 ifeq ($(MOZ_WINCONSOLE),1)
653 ifeq ($(OS_ARCH),WINNT)
654 ifdef GNU_CC
655 WIN32_EXE_LDFLAGS += -mconsole
656 else
657 WIN32_EXE_LDFLAGS += -SUBSYSTEM:CONSOLE
658 endif
659 endif
660 else # MOZ_WINCONSOLE
661 ifeq ($(OS_ARCH),WINNT)
662 ifdef GNU_CC
663 WIN32_EXE_LDFLAGS += -mwindows
664 else
665 WIN32_EXE_LDFLAGS += -SUBSYSTEM:WINDOWS
666 endif
667 endif
668 endif
669 endif
671 ifdef _MSC_VER
672 ifeq ($(CPU_ARCH),x86_64)
673 # set stack to 2MB on x64 build. See bug 582910
674 WIN32_EXE_LDFLAGS += -STACK:2097152
675 endif
676 endif
678 # If we're building a component on MSVC, we don't want to generate an
679 # import lib, because that import lib will collide with the name of a
680 # static version of the same library.
681 ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
682 ifdef IS_COMPONENT
683 LDFLAGS += -IMPLIB:fake.lib
684 DELETE_AFTER_LINK = fake.lib fake.exp
685 endif
686 endif
689 # Include any personal overrides the user might think are needed.
691 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
692 -include $(MY_CONFIG)
694 ######################################################################
696 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
698 ifeq ($(OS_ARCH),Darwin)
699 ifndef NSDISTMODE
700 NSDISTMODE=absolute_symlink
701 endif
702 PWD := $(CURDIR)
703 endif
705 NSINSTALL_PY := $(PYTHON) $(abspath $(topsrcdir)/config/nsinstall.py)
706 # For Pymake, wherever we use nsinstall.py we're also going to try to make it
707 # a native command where possible. Since native commands can't be used outside
708 # of single-line commands, we continue to provide INSTALL for general use.
709 # Single-line commands should be switched over to install_cmd.
710 NSINSTALL_NATIVECMD := %nsinstall nsinstall
712 ifdef NSINSTALL_BIN
713 NSINSTALL = $(NSINSTALL_BIN)
714 else
715 ifeq ($(HOST_OS_ARCH),WINNT)
716 NSINSTALL = $(NSINSTALL_PY)
717 else
718 NSINSTALL = $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)
719 endif # WINNT
720 endif # NSINSTALL_BIN
723 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
724 INSTALL = $(NSINSTALL) -t
725 ifdef .PYMAKE
726 install_cmd = $(NSINSTALL_NATIVECMD) -t $(1)
727 endif # .PYMAKE
729 else
731 # This isn't laid out as conditional directives so that NSDISTMODE can be
732 # target-specific.
733 INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
735 endif # WINNT
737 # The default for install_cmd is simply INSTALL
738 install_cmd ?= $(INSTALL) $(1)
740 # Use nsinstall in copy mode to install files on the system
741 SYSINSTALL = $(NSINSTALL) -t
742 # This isn't necessarily true, just here
743 sysinstall_cmd = install_cmd
746 # Localization build automation
749 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
750 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
751 # overridden by the command line. (Besides, AB_CD is prettier).
752 AB_CD = $(MOZ_UI_LOCALE)
754 ifndef L10NBASEDIR
755 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
756 else
757 IS_LANGUAGE_REPACK = 1
758 endif
760 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/$(subst /locales,,$(1)))
762 ifdef relativesrcdir
763 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
764 endif
766 ifdef relativesrcdir
767 MAKE_JARS_FLAGS += --relativesrcdir=$(relativesrcdir)
768 ifneq (en-US,$(AB_CD))
769 ifdef LOCALE_MERGEDIR
770 MAKE_JARS_FLAGS += --locale-mergedir=$(LOCALE_MERGEDIR)
771 endif
772 ifdef IS_LANGUAGE_REPACK
773 MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD)
774 endif
775 else
776 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
777 endif # en-US
778 else
779 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
780 endif # ! relativesrcdir
782 ifdef LOCALE_MERGEDIR
783 MERGE_FILE = $(firstword \
784 $(wildcard $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))/$(1)) \
785 $(wildcard $(LOCALE_SRCDIR)/$(1)) \
786 $(srcdir)/en-US/$(1) )
787 else
788 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
789 endif
790 MERGE_FILES = $(foreach f,$(1),$(call MERGE_FILE,$(f)))
792 ifneq (WINNT,$(OS_ARCH))
793 RUN_TEST_PROGRAM = $(LIBXUL_DIST)/bin/run-mozilla.sh
794 endif # ! WINNT
797 # Java macros
800 # Make sure any compiled classes work with at least JVM 1.4
801 JAVAC_FLAGS += -source 1.4
803 ifdef MOZ_DEBUG
804 JAVAC_FLAGS += -g
805 endif
807 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(abspath $(topsrcdir)/config/createprecomplete.py)
809 # MDDEPDIR is the subdirectory where dependency files are stored
810 MDDEPDIR := .deps
812 EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$@.pp --target $@)
813 EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$@.pp)
814 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
815 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
816 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
817 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
818 EXPAND_MKSHLIB_ARGS = --uselist
819 ifdef SYMBOL_ORDER
820 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
821 endif
822 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
824 ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION))
825 ifneq ($(OS_ARCH),Darwin)
826 CHECK_STDCXX = @$(TOOLCHAIN_PREFIX)objdump -p $(1) | grep -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 || true
827 endif
829 ifdef MOZ_LIBSTDCXX_TARGET_VERSION
830 EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
831 endif
832 ifdef MOZ_LIBSTDCXX_HOST_VERSION
833 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat)
834 endif
835 endif
837 ifeq (,$(filter $(OS_TARGET),WINNT Darwin))
838 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
839 endif
841 define CHECK_BINARY
842 $(call CHECK_STDCXX,$(1))
843 $(call CHECK_TEXTREL,$(1))
844 endef
846 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
847 # this file
848 OBJ_SUFFIX := $(_OBJ_SUFFIX)
850 # PGO builds with GCC build objects with instrumentation in a first pass,
851 # then objects optimized, without instrumentation, in a second pass. If
852 # we overwrite the objects from the first pass with those from the second,
853 # we end up not getting instrumentation data for better optimization on
854 # incremental builds. As a consequence, we use a different object suffix
855 # for the first pass.
856 ifndef NO_PROFILE_GUIDED_OPTIMIZE
857 ifdef MOZ_PROFILE_GENERATE
858 ifdef GNU_CC
859 OBJ_SUFFIX := i_o
860 endif
861 endif
862 endif
864 # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
865 # expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker
866 # arguments syntax. Should only be used for system libraries
868 # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
869 # expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
871 # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
872 # expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
874 ifdef GNU_CC
875 EXPAND_LIBNAME = $(addprefix -l,$(1))
876 else
877 EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
878 endif
879 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
880 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
882 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
884 export CL_INCLUDES_PREFIX
885 # Make sure that the build system can handle non-ASCII characters
886 # in environment variables to prevent it from breking silently on
887 # non-English systems.
888 export NONASCII
890 ifdef MOZ_GTK2_CFLAGS
891 MOZ_GTK2_CFLAGS := -I$(topsrcdir)/widget/gtk/compat $(MOZ_GTK2_CFLAGS)
892 endif
894 DEFINES += -DNO_NSPR_10_SUPPORT
896 ifdef IS_GYP_DIR
897 LOCAL_INCLUDES += \
898 -I$(topsrcdir)/ipc/chromium/src \
899 -I$(topsrcdir)/ipc/glue \
900 -I$(DEPTH)/ipc/ipdl/_ipdlheaders \
901 $(NULL)
903 ifeq (WINNT,$(OS_TARGET))
904 # These get set via VC project file settings for normal GYP builds.
905 DEFINES += -DUNICODE -D_UNICODE
906 endif
908 DISABLE_STL_WRAPPING := 1
909 # Skip most Mozilla-specific include locations.
910 INCLUDES = -I. $(LOCAL_INCLUDES) -I$(DEPTH)/dist/include
911 endif