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/.
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
!)
18 INCLUDED_CONFIG_MK
= 1
20 EXIT_ON_ERROR
= set
-e
; # Shell loops continue past errors without this.
26 ifndef INCLUDED_AUTOCONF_MK
27 include $(DEPTH
)/config
/autoconf.mk
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 \
52 HOST_SIMPLE_PROGRAMS \
74 _DEPRECATED_VARIABLES
:= \
76 MOCHITEST_A11Y_FILES \
77 MOCHITEST_BROWSER_FILES \
78 MOCHITEST_BROWSER_FILES_PARTS \
79 MOCHITEST_CHROME_FILES \
81 MOCHITEST_FILES_PARTS \
82 MOCHITEST_METRO_FILES \
83 MOCHITEST_ROBOCOP_FILES \
87 ifndef EXTERNALLY_MANAGED_MAKE_FILE
88 # Using $(firstword) may not be perfect. But it should be good enough for most
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
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
),\
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
))
135 $(foreach __d
,$(__depth
) .
,$(eval __depth
= $(wordlist
2,$(words $(__depth
)),$(__depth
))$(eval
-include $(subst $(space
),/,$(strip $(srcdir) $(__depth
) defs.mk
)))))
139 # Sanity check some variables
146 INSTALL_EXTENSION_ID \
147 SHARED_LIBRARY_NAME \
148 STATIC_LIBRARY_NAME \
151 # checks for internal spaces or trailing spaces in the variable
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
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
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)'
179 DEFINES
+= -DXPI_NAME
=$(XPI_NAME
)
182 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
185 ifeq ($(HOST_OS_ARCH
),WINNT
)
186 win_srcdir
:= $(subst $(topsrcdir
),$(WIN_TOP_SRC
),$(srcdir))
187 BUILD_TOOLS
= $(WIN_TOP_SRC
)/build
/unix
189 win_srcdir
:= $(srcdir)
190 BUILD_TOOLS
= $(topsrcdir
)/build
/unix
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.
201 ifneq (,$(filter no-pymake
,$(subst $(comma
), ,$(MOZ_PSEUDO_DERECURSE
))))
202 MOZ_PSEUDO_DERECURSE
:=
206 # Disable MOZ_PSEUDO_DERECURSE on PGO builds until it's fixed.
207 ifneq (,$(MOZ_PROFILE_USE
)$(MOZ_PROFILE_GENERATE
))
208 MOZ_PSEUDO_DERECURSE
:=
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/-.*//')
227 OS_CONFIG
:= $(OS_ARCH
)$(OS_RELEASE
)
230 CC_WRAPPER ?
= $(call py_action
,cl
)
231 CXX_WRAPPER ?
= $(call py_action
,cl
)
234 CC
:= $(CC_WRAPPER
) $(CC
)
235 CXX
:= $(CXX_WRAPPER
) $(CXX
)
241 PYCOMMANDPATH
+= $(PYTHON_SITE_PACKAGES
)
244 PYTHON_PATH
= $(PYTHON
) $(topsrcdir
)/config
/pythonpath.py
246 # determine debug-related options
252 _DEBUG_CFLAGS
+= $(MOZ_DEBUG_ENABLE_DEFS
)
253 XULPPFLAGS
+= $(MOZ_DEBUG_ENABLE_DEFS
)
255 _DEBUG_CFLAGS
+= $(MOZ_DEBUG_DISABLE_DEFS
)
256 XULPPFLAGS
+= $(MOZ_DEBUG_DISABLE_DEFS
)
259 ifneq (,$(MOZ_DEBUG
)$(MOZ_DEBUG_SYMBOLS
))
261 ifeq ($(OS_ARCH
)_
$(GNU_CC
),WINNT_
)
262 _DEBUG_ASFLAGS
+= -g cv8
264 ifneq ($(OS_ARCH
),Darwin
)
265 _DEBUG_ASFLAGS
+= -g dwarf2
269 _DEBUG_ASFLAGS
+= $(MOZ_DEBUG_FLAGS
)
271 _DEBUG_CFLAGS
+= $(MOZ_DEBUG_FLAGS
)
272 _DEBUG_LDFLAGS
+= $(MOZ_DEBUG_LDFLAGS
)
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_
)
285 ifneq (,$(MOZ_BROWSE_INFO
)$(MOZ_BSCFILE
))
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
298 OS_LDFLAGS
+= -DEBUG
-OPT
:REF
,ICF
300 OS_LDFLAGS
+= -DEBUG
-OPT
:REF
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
311 OS_LDFLAGS
= -DEBUG
-OPT
:REF
,ICF
313 OS_LDFLAGS
= -DEBUG
-OPT
:REF
315 endif # NS_TRACE_MALLOC || MOZ_DMD
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
327 endif # WINNT && !GNU_CC
329 ifdef MOZ_GLUE_PROGRAM_LDFLAGS
330 DEFINES
+= -DMOZ_GLUE_IN_PROGRAM
332 MOZ_GLUE_PROGRAM_LDFLAGS
=$(MOZ_GLUE_LDFLAGS
)
336 # Build using PIC by default
340 # Determine if module being compiled is destined
341 # to be merged into libxul
343 ifneq (,$(filter xul
,$(FINAL_LIBRARY
) $(LIBRARY_NAME
)))
345 $(error LIBRARY_NAME or FINAL_LIBRARY is
"xul", LIBXUL_LIBRARY is implied
)
352 $(error IS_COMPONENT is set
, but is not compatible with LIBXUL_LIBRARY
)
354 ifneq (xul
,$(LIBRARY_NAME
))
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
371 ifndef SHARED_LIBRARY_NAME
373 SHARED_LIBRARY_NAME
=$(LIBRARY_NAME
)
377 ifndef STATIC_LIBRARY_NAME
379 STATIC_LIBRARY_NAME
=$(LIBRARY_NAME
)
383 # PGO on MSVC is opt-in
385 ifndef MSVC_ENABLE_PGO
386 NO_PROFILE_GUIDED_OPTIMIZE
= 1
390 # No sense in profiling tools
392 NO_PROFILE_GUIDED_OPTIMIZE
= 1
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
401 # No sense in profiling unit tests
403 NO_PROFILE_GUIDED_OPTIMIZE
= 1
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
))
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
))
424 endif # MOZ_PROFILE_USE
425 endif # NO_PROFILE_GUIDED_OPTIMIZE
428 OS_LDFLAGS
+= $(DELAYLOAD_LDFLAGS
)
431 ifneq (,$(LIBXUL_LIBRARY
))
432 DEFINES
+= -DMOZILLA_INTERNAL_API
435 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
436 # building libxul libraries
442 ifndef JS_SHARED_LIBRARY
443 DEFINES
+= -DSTATIC_EXPORTABLE_JS_API
449 -f
$(MOZ_CHROME_FILE_FORMAT
) \
452 ifdef USE_EXTENSION_MANIFEST
453 MAKE_JARS_FLAGS
+= -e
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.
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.
483 $(if
$(LIBXUL_SDK
),-I
$(LIBXUL_SDK
)/include) \
484 $(NSPR_CFLAGS
) $(NSS_CFLAGS
) \
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
498 ifeq (1,$(MOZ_OPTIMIZE
))
499 ifdef MODULE_OPTIMIZE_FLAGS
500 CFLAGS
+= $(MODULE_OPTIMIZE_FLAGS
)
501 CXXFLAGS
+= $(MODULE_OPTIMIZE_FLAGS
)
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
)
507 CFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
508 CXXFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
509 endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
510 endif # MODULE_OPTIMIZE_FLAGS
512 CFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
513 CXXFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
514 endif # MOZ_OPTIMIZE == 1
515 LDFLAGS
+= $(MOZ_OPTIMIZE_LDFLAGS
)
519 HOST_CFLAGS
+= $(HOST_OPTIMIZE_FLAGS
)
522 ifeq (1,$(MOZ_OPTIMIZE
))
523 ifdef MODULE_OPTIMIZE_FLAGS
524 HOST_CFLAGS
+= $(MODULE_OPTIMIZE_FLAGS
)
526 HOST_CFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
527 endif # MODULE_OPTIMIZE_FLAGS
529 HOST_CFLAGS
+= $(MOZ_OPTIMIZE_FLAGS
)
530 endif # MOZ_OPTIMIZE == 1
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
=
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
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
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
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
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
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
)
605 HOST_CFLAGS
+= $(RTL_FLAGS
)
609 # Name of the binary code directories
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
620 LIBS_DIR
+= -L
$(LIBXUL_SDK
)/bin
-L
$(LIBXUL_SDK
)/lib
624 # Default location of include files
626 IDL_PARSER_DIR
= $(topsrcdir
)/xpcom
/idl-parser
627 IDL_PARSER_CACHE_DIR
= $(DEPTH
)/xpcom
/idl-parser
629 IDL_PARSER_DIR
= $(LIBXUL_SDK
)/sdk
/bin
630 IDL_PARSER_CACHE_DIR
= $(LIBXUL_SDK
)/sdk
/bin
633 SDK_LIB_DIR
= $(DIST
)/sdk
/lib
634 SDK_BIN_DIR
= $(DIST
)/sdk
/bin
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
650 # Set link flags according to whether we want a console.
652 ifeq ($(MOZ_WINCONSOLE
),1)
653 ifeq ($(OS_ARCH
),WINNT
)
655 WIN32_EXE_LDFLAGS
+= -mconsole
657 WIN32_EXE_LDFLAGS
+= -SUBSYSTEM
:CONSOLE
660 else # MOZ_WINCONSOLE
661 ifeq ($(OS_ARCH
),WINNT
)
663 WIN32_EXE_LDFLAGS
+= -mwindows
665 WIN32_EXE_LDFLAGS
+= -SUBSYSTEM
:WINDOWS
672 ifeq ($(CPU_ARCH
),x86_64
)
673 # set stack to 2MB on x64 build. See bug 582910
674 WIN32_EXE_LDFLAGS
+= -STACK
:2097152
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
)
683 LDFLAGS
+= -IMPLIB
:fake.lib
684 DELETE_AFTER_LINK
= fake.lib fake.exp
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
)
700 NSDISTMODE
=absolute_symlink
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
713 NSINSTALL
= $(NSINSTALL_BIN
)
715 ifeq ($(HOST_OS_ARCH
),WINNT
)
716 NSINSTALL
= $(NSINSTALL_PY
)
718 NSINSTALL
= $(DIST
)/bin
/nsinstall
$(HOST_BIN_SUFFIX
)
720 endif # NSINSTALL_BIN
723 ifeq (,$(CROSS_COMPILE
)$(filter-out WINNT
, $(OS_ARCH
)))
724 INSTALL
= $(NSINSTALL
) -t
726 install_cmd
= $(NSINSTALL_NATIVECMD
) -t
$(1)
731 # This isn't laid out as conditional directives so that NSDISTMODE can be
733 INSTALL
= $(if
$(filter copy
, $(NSDISTMODE
)), $(NSINSTALL
) -t
, $(if
$(filter absolute_symlink
, $(NSDISTMODE
)), $(NSINSTALL
) -L
$(PWD
), $(NSINSTALL
) -R
))
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
)
755 L10NBASEDIR
= $(error L10NBASEDIR not defined by configure
)
757 IS_LANGUAGE_REPACK
= 1
760 EXPAND_LOCALE_SRCDIR
= $(if
$(filter en-US
,$(AB_CD
)),$(topsrcdir
)/$(1)/en-US
,$(or
$(realpath
$(L10NBASEDIR
)),$(abspath
$(L10NBASEDIR
)))/$(AB_CD
)/$(subst /locales
,,$(1)))
763 LOCALE_SRCDIR ?
= $(call EXPAND_LOCALE_SRCDIR
,$(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
)
772 ifdef IS_LANGUAGE_REPACK
773 MAKE_JARS_FLAGS
+= --l10n-base
=$(L10NBASEDIR
)/$(AB_CD
)
776 MAKE_JARS_FLAGS
+= -c
$(LOCALE_SRCDIR
)
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) )
788 MERGE_FILE
= $(LOCALE_SRCDIR
)/$(1)
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
800 # Make sure any compiled classes work with at least JVM 1.4
801 JAVAC_FLAGS
+= -source
1.4
807 CREATE_PRECOMPLETE_CMD
= $(PYTHON
) $(abspath
$(topsrcdir
)/config
/createprecomplete.py
)
809 # MDDEPDIR is the subdirectory where dependency files are stored
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
820 EXPAND_MKSHLIB_ARGS
+= --symbol-order
$(SYMBOL_ORDER
)
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
829 ifdef MOZ_LIBSTDCXX_TARGET_VERSION
830 EXTRA_LIBS
+= $(call EXPAND_LIBNAME_PATH
,stdc
++compat
,$(DEPTH
)/build
/unix
/stdc
++compat
)
832 ifdef MOZ_LIBSTDCXX_HOST_VERSION
833 HOST_EXTRA_LIBS
+= $(call EXPAND_LIBNAME_PATH
,host_stdc
++compat
,$(DEPTH
)/build
/unix
/stdc
++compat
)
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
842 $(call CHECK_STDCXX
,$(1))
843 $(call CHECK_TEXTREL
,$(1))
846 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
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
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)
875 EXPAND_LIBNAME
= $(addprefix -l
,$(1))
877 EXPAND_LIBNAME
= $(foreach lib
,$(1),$(LIB_PREFIX
)$(lib
).
$(LIB_SUFFIX
))
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.
890 ifdef MOZ_GTK2_CFLAGS
891 MOZ_GTK2_CFLAGS
:= -I
$(topsrcdir
)/widget
/gtk
/compat
$(MOZ_GTK2_CFLAGS
)
894 DEFINES
+= -DNO_NSPR_10_SUPPORT
898 -I
$(topsrcdir
)/ipc
/chromium
/src \
899 -I
$(topsrcdir
)/ipc
/glue \
900 -I
$(DEPTH
)/ipc
/ipdl
/_ipdlheaders \
903 ifeq (WINNT
,$(OS_TARGET
))
904 # These get set via VC project file settings for normal GYP builds.
905 DEFINES
+= -DUNICODE
-D_UNICODE
908 DISABLE_STL_WRAPPING
:= 1
909 # Skip most Mozilla-specific include locations.
910 INCLUDES
= -I.
$(LOCAL_INCLUDES
) -I
$(DEPTH
)/dist/include