Bug 849918 - Initial support for PannerNode's 3D positional audio (equalpower panning...
[gecko.git] / config / config.mk
blob29837b23086f14e2ade5039d6073176ec2f9fde0
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 space = $(NULL) $(NULL)
32 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
33 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
34 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
35 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
36 # These defs.mk files are used to define variables in a directory
37 # and all its subdirectories, recursively.
38 __depth := $(subst /, ,$(DEPTH))
39 ifeq (.,$(__depth))
40 __depth :=
41 endif
42 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
44 COMMA = ,
46 # Sanity check some variables
47 CHECK_VARS := \
48 XPI_NAME \
49 LIBRARY_NAME \
50 MODULE \
51 DEPTH \
52 SHORT_LIBNAME \
53 XPI_PKGNAME \
54 INSTALL_EXTENSION_ID \
55 SHARED_LIBRARY_NAME \
56 STATIC_LIBRARY_NAME \
57 $(NULL)
59 # checks for internal spaces or trailing spaces in the variable
60 # named by $x
61 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
63 $(foreach x,$(CHECK_VARS),$(check-variable))
65 core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))
66 core_realpath = $(if $(realpath $(1)),$(realpath $(1)),$(call core_abspath,$(1)))
68 core_winabspath = $(firstword $(subst /, ,$(call core_abspath,$(1)))):$(subst $(space),,$(patsubst %,\\%,$(wordlist 2,$(words $(subst /, ,$(call core_abspath,$(1)))), $(strip $(subst /, ,$(call core_abspath,$(1)))))))
70 RM = rm -f
72 # LIBXUL_DIST is not defined under js/src, thus we make it mean DIST there.
73 LIBXUL_DIST ?= $(DIST)
75 # FINAL_TARGET specifies the location into which we copy end-user-shipped
76 # build products (typelibs, components, chrome).
78 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
79 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
80 # shipped to a $(DIST_SUBDIR) subdirectory.
81 FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
83 ifdef XPI_NAME
84 DEFINES += -DXPI_NAME=$(XPI_NAME)
85 endif
87 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
88 VERSION_NUMBER = 50
90 ifeq ($(HOST_OS_ARCH),WINNT)
91 win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
92 BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
93 else
94 win_srcdir := $(srcdir)
95 BUILD_TOOLS = $(topsrcdir)/build/unix
96 endif
98 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
99 AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
102 # Strip off the excessively long version numbers on these platforms,
103 # but save the version to allow multiple versions of the same base
104 # platform to be built in the same tree.
106 ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
107 OS_RELEASE := $(basename $(OS_RELEASE))
109 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
110 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
111 OS_VERS := $(suffix $(OS_RELEASE))
112 OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
113 endif
115 endif
117 OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
119 FINAL_LINK_LIBS = $(DEPTH)/config/final-link-libs
120 FINAL_LINK_COMPS = $(DEPTH)/config/final-link-comps
121 FINAL_LINK_COMP_NAMES = $(DEPTH)/config/final-link-comp-names
123 MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
124 MOZ_WIDGET_SUPPORT_LIBS = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
126 ifdef _MSC_VER
127 CC_WRAPPER ?= $(PYTHON) -O $(topsrcdir)/build/cl.py
128 CXX_WRAPPER ?= $(PYTHON) -O $(topsrcdir)/build/cl.py
129 endif # _MSC_VER
131 CC := $(CC_WRAPPER) $(CC)
132 CXX := $(CXX_WRAPPER) $(CXX)
133 MKDIR ?= mkdir
134 SLEEP ?= sleep
135 TOUCH ?= touch
137 ifdef .PYMAKE
138 PYCOMMANDPATH += $(topsrcdir)/config
139 endif
141 PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py
143 # determine debug-related options
144 _DEBUG_ASFLAGS :=
145 _DEBUG_CFLAGS :=
146 _DEBUG_LDFLAGS :=
148 ifdef MOZ_DEBUG
149 _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
150 XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
151 else
152 _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
153 XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
154 endif
156 ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS))
157 ifeq ($(AS),yasm)
158 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
159 _DEBUG_ASFLAGS += -g cv8
160 else
161 ifneq ($(OS_ARCH),Darwin)
162 _DEBUG_ASFLAGS += -g dwarf2
163 endif
164 endif
165 else
166 _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS)
167 endif
168 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
169 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
170 endif
172 MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib)
174 ASFLAGS += $(_DEBUG_ASFLAGS)
175 OS_CFLAGS += $(_DEBUG_CFLAGS)
176 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
177 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
179 # XXX: What does this? Bug 482434 filed for better explanation.
180 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
181 ifdef MOZ_DEBUG
182 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
183 OS_CFLAGS += -FR
184 OS_CXXFLAGS += -FR
185 endif
186 else # ! MOZ_DEBUG
188 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
189 # Used for generating an optimized build with debugging symbols.
190 # Used in the Windows nightlies to generate symbols for crash reporting.
191 ifdef MOZ_DEBUG_SYMBOLS
192 OS_CXXFLAGS += -UDEBUG -DNDEBUG
193 OS_CFLAGS += -UDEBUG -DNDEBUG
194 ifdef HAVE_64BIT_OS
195 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
196 else
197 OS_LDFLAGS += -DEBUG -OPT:REF
198 endif
199 endif
202 # Handle trace-malloc and DMD in optimized builds.
203 # No opt to give sane callstacks.
205 ifneq (,$(NS_TRACE_MALLOC)$(MOZ_DMD))
206 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
207 ifdef HAVE_64BIT_OS
208 OS_LDFLAGS = -DEBUG -OPT:REF,ICF
209 else
210 OS_LDFLAGS = -DEBUG -OPT:REF
211 endif
212 endif # NS_TRACE_MALLOC || MOZ_DMD
214 endif # MOZ_DEBUG
216 # We don't build a static CRT when building a custom CRT,
217 # it appears to be broken. So don't link to jemalloc if
218 # the Makefile wants static CRT linking.
219 ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_1)
220 # Disable default CRT libs and add the right lib path for the linker
221 MOZ_GLUE_LDFLAGS=
222 endif
224 endif # WINNT && !GNU_CC
226 ifdef MOZ_GLUE_PROGRAM_LDFLAGS
227 DEFINES += -DMOZ_GLUE_IN_PROGRAM
228 else
229 MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS)
230 endif
233 # Build using PIC by default
235 _ENABLE_PIC=1
237 # Determine if module being compiled is destined
238 # to be merged into libxul
240 ifdef LIBXUL_LIBRARY
241 ifdef IS_COMPONENT
242 ifdef MODULE_NAME
243 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
244 else
245 $(error Component makefile does not specify MODULE_NAME.)
246 endif
247 endif
248 FORCE_STATIC_LIB=1
249 SHORT_LIBNAME=
250 endif
252 # If we are building this component into an extension/xulapp, it cannot be
253 # statically linked. In the future we may want to add a xulapp meta-component
254 # build option.
256 ifdef XPI_NAME
257 ifdef IS_COMPONENT
258 EXPORT_LIBRARY=
259 FORCE_STATIC_LIB=
260 FORCE_SHARED_LIB=1
261 endif
262 endif
264 ifndef SHARED_LIBRARY_NAME
265 ifdef LIBRARY_NAME
266 SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
267 endif
268 endif
270 ifndef STATIC_LIBRARY_NAME
271 ifdef LIBRARY_NAME
272 STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
273 endif
274 endif
276 # No sense in profiling tools
277 ifdef INTERNAL_TOOLS
278 NO_PROFILE_GUIDED_OPTIMIZE = 1
279 endif
281 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
282 # and we don't have the same build logic to re-link them in the second pass.
283 ifdef SIMPLE_PROGRAMS
284 NO_PROFILE_GUIDED_OPTIMIZE = 1
285 endif
287 # No sense in profiling unit tests
288 ifdef CPP_UNIT_TESTS
289 NO_PROFILE_GUIDED_OPTIMIZE = 1
290 endif
292 # Enable profile-based feedback
293 ifndef NO_PROFILE_GUIDED_OPTIMIZE
294 ifdef MOZ_PROFILE_GENERATE
295 OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
296 OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
297 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
298 ifeq (WINNT,$(OS_ARCH))
299 AR_FLAGS += -LTCG
300 endif
301 endif # MOZ_PROFILE_GENERATE
303 ifdef MOZ_PROFILE_USE
304 OS_CFLAGS += $(PROFILE_USE_CFLAGS)
305 OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
306 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
307 ifeq (WINNT,$(OS_ARCH))
308 AR_FLAGS += -LTCG
309 endif
310 endif # MOZ_PROFILE_USE
311 endif # NO_PROFILE_GUIDED_OPTIMIZE
314 # Does the makefile specifies the internal XPCOM API linkage?
315 ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY))
316 DEFINES += -DMOZILLA_INTERNAL_API
317 endif
319 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
320 # building libxul libraries
321 ifdef LIBXUL_LIBRARY
322 DEFINES += \
323 -D_IMPL_NS_COM \
324 -DEXPORT_XPT_API \
325 -DEXPORT_XPTC_API \
326 -D_IMPL_NS_GFX \
327 -D_IMPL_NS_WIDGET \
328 -DIMPL_XREAPI \
329 -DIMPL_NS_NET \
330 -DIMPL_THEBES \
331 $(NULL)
333 ifndef JS_SHARED_LIBRARY
334 DEFINES += -DSTATIC_EXPORTABLE_JS_API
335 endif
336 endif
338 # Flags passed to JarMaker.py
339 MAKE_JARS_FLAGS = \
340 -t $(topsrcdir) \
341 -f $(MOZ_CHROME_FILE_FORMAT) \
342 $(NULL)
344 ifdef USE_EXTENSION_MANIFEST
345 MAKE_JARS_FLAGS += -e
346 endif
348 ifdef BOTH_MANIFESTS
349 MAKE_JARS_FLAGS += --both-manifests
350 endif
352 TAR_CREATE_FLAGS = -cvhf
353 TAR_CREATE_FLAGS_QUIET = -chf
355 ifeq ($(OS_ARCH),OS2)
356 TAR_CREATE_FLAGS = -cvf
357 TAR_CREATE_FLAGS_QUIET = -cf
358 endif
361 # Personal makefile customizations go in these optional make include files.
363 MY_CONFIG := $(DEPTH)/config/myconfig.mk
364 MY_RULES := $(DEPTH)/config/myrules.mk
367 # Default command macros; can be overridden in <arch>.mk.
369 CCC = $(CXX)
370 XPIDL_LINK = $(PYTHON) $(LIBXUL_DIST)/sdk/bin/xpt.py link
372 # Java macros
373 JAVA_GEN_DIR = _javagen
374 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
375 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
377 OS_INCLUDES += $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS)
379 # NSPR_CFLAGS and NSS_CFLAGS must appear ahead of OS_INCLUDES to avoid Linux
380 # builds wrongly picking up system NSPR/NSS header files.
381 INCLUDES = \
382 $(LOCAL_INCLUDES) \
383 -I$(srcdir) \
384 -I. \
385 -I$(DIST)/include \
386 $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \
387 $(NSPR_CFLAGS) $(NSS_CFLAGS) \
388 $(OS_INCLUDES) \
389 $(NULL)
391 include $(topsrcdir)/config/static-checking-config.mk
393 CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS)
394 CXXFLAGS = $(OS_CPPFLAGS) $(OS_CXXFLAGS)
395 LDFLAGS = $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
397 # Allow each module to override the *default* optimization settings
398 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
399 # arguments to --enable-optimize
400 ifdef MOZ_OPTIMIZE
401 ifeq (1,$(MOZ_OPTIMIZE))
402 ifdef MODULE_OPTIMIZE_FLAGS
403 CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
404 CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
405 else
406 ifneq (,$(if $(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE),$(MOZ_PGO_OPTIMIZE_FLAGS)))
407 CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
408 CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS)
409 else
410 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
411 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
412 endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
413 endif # MODULE_OPTIMIZE_FLAGS
414 else
415 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
416 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
417 endif # MOZ_OPTIMIZE == 1
418 LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
419 endif # MOZ_OPTIMIZE
421 ifdef CROSS_COMPILE
422 HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
423 else
424 ifdef MOZ_OPTIMIZE
425 ifeq (1,$(MOZ_OPTIMIZE))
426 ifdef MODULE_OPTIMIZE_FLAGS
427 HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
428 else
429 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
430 endif # MODULE_OPTIMIZE_FLAGS
431 else
432 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
433 endif # MOZ_OPTIMIZE == 1
434 endif # MOZ_OPTIMIZE
435 endif # CROSS_COMPILE
437 CFLAGS += $(MOZ_FRAMEPTR_FLAGS)
438 CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS)
440 # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
441 # to request that we use the 'warnings as errors' compile flags)
443 # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO
444 # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that
445 # situation. (See bug 437002.)
446 ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
447 FAIL_ON_WARNINGS_DEBUG=
448 FAIL_ON_WARNINGS=
449 endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE)
451 # Now, check for debug version of flag; it turns on normal flag in debug builds.
452 ifdef FAIL_ON_WARNINGS_DEBUG
453 ifdef MOZ_DEBUG
454 FAIL_ON_WARNINGS = 1
455 endif # MOZ_DEBUG
456 endif # FAIL_ON_WARNINGS_DEBUG
458 # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1.
459 ifdef FAIL_ON_WARNINGS
460 CXXFLAGS += $(WARNINGS_AS_ERRORS)
461 CFLAGS += $(WARNINGS_AS_ERRORS)
462 endif # FAIL_ON_WARNINGS
464 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
465 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
466 #// DLL version of the RTL is used...
468 #//------------------------------------------------------------------------
469 ifdef USE_STATIC_LIBS
470 RTL_FLAGS=-MT # Statically linked multithreaded RTL
471 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)$(MOZ_DMD))
472 ifndef MOZ_NO_DEBUG_RTL
473 RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
474 endif
475 endif # MOZ_DEBUG || NS_TRACE_MALLOC || MOZ_DMD
477 else # !USE_STATIC_LIBS
479 RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
480 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)$(MOZ_DMD))
481 ifndef MOZ_NO_DEBUG_RTL
482 RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
483 endif
484 endif # MOZ_DEBUG || NS_TRACE_MALLOC || MOZ_DMD
485 endif # USE_STATIC_LIBS
486 endif # WINNT && !GNU_CC
488 ifeq ($(OS_ARCH),Darwin)
489 # Compiling ObjC requires an Apple compiler anyway, so it's ok to set
490 # host CMFLAGS here.
491 HOST_CMFLAGS += -fobjc-exceptions
492 HOST_CMMFLAGS += -fobjc-exceptions
493 OS_COMPILE_CMFLAGS += -fobjc-exceptions
494 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
495 ifeq ($(MOZ_WIDGET_TOOLKIT),uikit)
496 OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
497 OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch
498 endif
499 endif
501 COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS)
502 COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CXXFLAGS)
503 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
504 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
506 ifndef CROSS_COMPILE
507 HOST_CFLAGS += $(RTL_FLAGS)
508 endif
511 # Name of the binary code directories
513 # Override defaults
515 # We need to know where to find the libraries we
516 # put on the link line for binaries, and should
517 # we link statically or dynamic? Assuming dynamic for now.
519 ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
520 LIBS_DIR = -L$(DIST)/bin -L$(DIST)/lib
521 ifdef LIBXUL_SDK
522 LIBS_DIR += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
523 endif
524 endif
526 # Default location of include files
527 IDL_DIR = $(DIST)/idl
529 XPIDL_FLAGS += -I$(srcdir) -I$(IDL_DIR)
530 ifdef LIBXUL_SDK
531 XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
532 endif
534 SDK_LIB_DIR = $(DIST)/sdk/lib
535 SDK_BIN_DIR = $(DIST)/sdk/bin
537 DEPENDENCIES = .md
539 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
541 ifeq ($(OS_ARCH),OS2)
542 ELF_DYNSTR_GC = echo
543 else
544 ELF_DYNSTR_GC = :
545 endif
547 ifndef CROSS_COMPILE
548 ifdef USE_ELF_DYNSTR_GC
549 ifdef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
550 ELF_DYNSTR_GC = $(DEPTH)/config/elf-dynstr-gc
551 endif
552 endif
553 endif
555 ifdef MACOSX_DEPLOYMENT_TARGET
556 export MACOSX_DEPLOYMENT_TARGET
557 endif # MACOSX_DEPLOYMENT_TARGET
559 ifdef MOZ_USING_CCACHE
560 ifdef CLANG_CXX
561 export CCACHE_CPP2=1
562 endif
563 endif
565 # Set link flags according to whether we want a console.
566 ifdef MOZ_WINCONSOLE
567 ifeq ($(MOZ_WINCONSOLE),1)
568 ifeq ($(OS_ARCH),OS2)
569 BIN_FLAGS += -Zlinker -PM:VIO
570 endif
571 ifeq ($(OS_ARCH),WINNT)
572 ifdef GNU_CC
573 WIN32_EXE_LDFLAGS += -mconsole
574 else
575 WIN32_EXE_LDFLAGS += -SUBSYSTEM:CONSOLE
576 endif
577 endif
578 else # MOZ_WINCONSOLE
579 ifeq ($(OS_ARCH),OS2)
580 BIN_FLAGS += -Zlinker -PM:PM
581 endif
582 ifeq ($(OS_ARCH),WINNT)
583 ifdef GNU_CC
584 WIN32_EXE_LDFLAGS += -mwindows
585 else
586 WIN32_EXE_LDFLAGS += -SUBSYSTEM:WINDOWS
587 endif
588 endif
589 endif
590 endif
592 ifdef _MSC_VER
593 ifeq ($(CPU_ARCH),x86_64)
594 # set stack to 2MB on x64 build. See bug 582910
595 WIN32_EXE_LDFLAGS += -STACK:2097152
596 endif
597 endif
599 # If we're building a component on MSVC, we don't want to generate an
600 # import lib, because that import lib will collide with the name of a
601 # static version of the same library.
602 ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
603 ifdef IS_COMPONENT
604 LDFLAGS += -IMPLIB:fake.lib
605 DELETE_AFTER_LINK = fake.lib fake.exp
606 endif
607 endif
610 # Include any personal overrides the user might think are needed.
612 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
613 -include $(MY_CONFIG)
615 ######################################################################
617 GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
619 ifeq ($(OS_ARCH),Darwin)
620 ifndef NSDISTMODE
621 NSDISTMODE=absolute_symlink
622 endif
623 PWD := $(CURDIR)
624 endif
626 NSINSTALL_PY := $(PYTHON) $(call core_abspath,$(topsrcdir)/config/nsinstall.py)
627 # For Pymake, wherever we use nsinstall.py we're also going to try to make it
628 # a native command where possible. Since native commands can't be used outside
629 # of single-line commands, we continue to provide INSTALL for general use.
630 # Single-line commands should be switched over to install_cmd.
631 NSINSTALL_NATIVECMD := %nsinstall nsinstall
633 ifdef NSINSTALL_BIN
634 NSINSTALL = $(NSINSTALL_BIN)
635 else
636 ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
637 NSINSTALL = $(MOZ_TOOLS_DIR)/nsinstall
638 else
639 ifeq ($(HOST_OS_ARCH),WINNT)
640 NSINSTALL = $(NSINSTALL_PY)
641 else
642 NSINSTALL = $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)
643 endif # WINNT
644 endif # OS2
645 endif # NSINSTALL_BIN
648 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
649 INSTALL = $(NSINSTALL) -t
650 ifdef .PYMAKE
651 install_cmd = $(NSINSTALL_NATIVECMD) -t $(1)
652 endif # .PYMAKE
654 else
656 # This isn't laid out as conditional directives so that NSDISTMODE can be
657 # target-specific.
658 INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
660 endif # WINNT/OS2
662 # The default for install_cmd is simply INSTALL
663 install_cmd ?= $(INSTALL) $(1)
665 # Use nsinstall in copy mode to install files on the system
666 SYSINSTALL = $(NSINSTALL) -t
667 # This isn't necessarily true, just here
668 sysinstall_cmd = install_cmd
671 # Localization build automation
674 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
675 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
676 # overridden by the command line. (Besides, AB_CD is prettier).
677 AB_CD = $(MOZ_UI_LOCALE)
679 ifndef L10NBASEDIR
680 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
681 else
682 IS_LANGUAGE_REPACK = 1
683 endif
685 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(call core_realpath,$(L10NBASEDIR))/$(AB_CD)/$(subst /locales,,$(1)))
687 ifdef relativesrcdir
688 LOCALE_SRCDIR = $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
689 endif
691 ifdef relativesrcdir
692 MAKE_JARS_FLAGS += --relativesrcdir=$(relativesrcdir)
693 ifneq (en-US,$(AB_CD))
694 ifdef LOCALE_MERGEDIR
695 MAKE_JARS_FLAGS += --locale-mergedir=$(LOCALE_MERGEDIR)
696 endif
697 ifdef IS_LANGUAGE_REPACK
698 MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD)
699 endif
700 else
701 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
702 endif # en-US
703 else
704 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
705 endif # ! relativesrcdir
707 ifdef LOCALE_MERGEDIR
708 MERGE_FILE = $(firstword \
709 $(wildcard $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))/$(1)) \
710 $(wildcard $(LOCALE_SRCDIR)/$(1)) \
711 $(srcdir)/en-US/$(1) )
712 else
713 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
714 endif
715 MERGE_FILES = $(foreach f,$(1),$(call MERGE_FILE,$(f)))
717 ifeq (OS2,$(OS_ARCH))
718 RUN_TEST_PROGRAM = $(topsrcdir)/build/os2/test_os2.cmd "$(LIBXUL_DIST)"
719 else
720 ifneq (WINNT,$(OS_ARCH))
721 RUN_TEST_PROGRAM = $(LIBXUL_DIST)/bin/run-mozilla.sh
722 endif # ! WINNT
723 endif # ! OS2
726 # Java macros
729 # Make sure any compiled classes work with at least JVM 1.4
730 JAVAC_FLAGS += -source 1.4
732 ifdef MOZ_DEBUG
733 JAVAC_FLAGS += -g
734 endif
736 CREATE_PRECOMPLETE_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/createprecomplete.py)
738 # MDDEPDIR is the subdirectory where dependency files are stored
739 MDDEPDIR := .deps
741 EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp --target $@)
742 EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$(@F).pp)
743 EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
744 EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
745 EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
746 EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
747 EXPAND_MKSHLIB_ARGS = --uselist
748 ifdef SYMBOL_ORDER
749 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
750 endif
751 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
753 ifdef STDCXX_COMPAT
754 ifneq ($(OS_ARCH),Darwin)
755 CHECK_STDCXX = objdump -p $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null && echo "TEST-UNEXPECTED-FAIL | | We don't want these libstdc++ symbols to be used:" && objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && exit 1 || exit 0
756 endif
758 EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
759 HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat)
760 endif
762 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
763 # this file
764 OBJ_SUFFIX := $(_OBJ_SUFFIX)
766 # PGO builds with GCC build objects with instrumentation in a first pass,
767 # then objects optimized, without instrumentation, in a second pass. If
768 # we overwrite the ojects from the first pass with those from the second,
769 # we end up not getting instrumentation data for better optimization on
770 # incremental builds. As a consequence, we use a different object suffix
771 # for the first pass.
772 ifndef NO_PROFILE_GUIDED_OPTIMIZE
773 ifdef MOZ_PROFILE_GENERATE
774 ifdef GNU_CC
775 OBJ_SUFFIX := i_o
776 endif
777 endif
778 endif
780 # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
781 # expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker
782 # arguments syntax. Should only be used for system libraries
784 # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
785 # expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
787 # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
788 # expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
790 ifdef GNU_CC
791 EXPAND_LIBNAME = $(addprefix -l,$(1))
792 else
793 EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
794 endif
795 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
796 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
798 # Include internal ply only if needed
799 ifndef MOZ_SYSTEM_PLY
800 PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
801 endif
803 export CL_INCLUDES_PREFIX
805 ifeq ($(MOZ_WIDGET_GTK),2)
806 MOZ_GTK2_CFLAGS := -I$(topsrcdir)/widget/gtk2/compat $(MOZ_GTK2_CFLAGS)
807 endif
809 DEFINES += -DNO_NSPR_10_SUPPORT