Bug 476245. Keep better track of our anonymous content. r=smaug, sr=jst
[mozilla-central.git] / config / config.mk
blob910032530147aca2973a07cd65d6fed4e804d7c3
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is mozilla.org code.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 1998
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
23 # Benjamin Smedberg <benjamin@smedbergs.us>
25 # Alternatively, the contents of this file may be used under the terms of
26 # either of the GNU General Public License Version 2 or later (the "GPL"),
27 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
40 # config.mk
42 # Determines the platform and builds the macros needed to load the
43 # appropriate platform-specific .mk file, then defines all (most?)
44 # of the generic macros.
47 # Define an include-at-most-once flag
48 INCLUDED_CONFIG_MK = 1
50 EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
52 ifndef topsrcdir
53 topsrcdir = $(DEPTH)
54 endif
56 ifndef INCLUDED_AUTOCONF_MK
57 include $(DEPTH)/config/autoconf.mk
58 endif
59 ifndef INCLUDED_INSURE_MK
60 ifdef MOZ_INSURIFYING
61 include $(topsrcdir)/config/insure.mk
62 endif
63 endif
65 COMMA = ,
67 # Sanity check some variables
68 CHECK_VARS := \
69 XPI_NAME \
70 LIBRARY_NAME \
71 MODULE \
72 DEPTH \
73 SHORT_LIBNAME \
74 XPI_PKGNAME \
75 INSTALL_EXTENSION_ID \
76 SHARED_LIBRARY_NAME \
77 STATIC_LIBRARY_NAME \
78 $(NULL)
80 # checks for internal spaces or trailing spaces in the variable
81 # named by $x
82 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
84 $(foreach x,$(CHECK_VARS),$(check-variable))
86 # FINAL_TARGET specifies the location into which we copy end-user-shipped
87 # build products (typelibs, components, chrome).
89 # It will usually be the well-loved $(DIST)/bin, today, but can also be an
90 # XPI-contents staging directory for ambitious and right-thinking extensions.
91 FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)
93 # MAKE_JARS_TARGET is a staging area for make-jars.pl. When packaging in
94 # the jar format, make-jars leaves behind a directory structure that's not
95 # needed in $(FINAL_TARGET). For both, flat, and symlink, the directory
96 # structure contains the chrome, so leave it in $(FINAL_TARGET).
97 ifeq (jar,$(MOZ_CHROME_FILE_FORMAT))
98 MAKE_JARS_TARGET = $(if $(XPI_NAME),$(FINAL_TARGET).stage,$(DIST)/chrome-stage)
99 else
100 MAKE_JARS_TARGET = $(FINAL_TARGET)
101 endif
104 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
105 # Since the longest of these is 5 characters without the suffix,
106 # be sure to not set VERSION_NUMBER to anything longer than 3
107 # characters for Win16's sake.
109 VERSION_NUMBER = 50
111 ifeq ($(HOST_OS_ARCH),WINNT)
112 win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
113 BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix
114 else
115 win_srcdir := $(srcdir)
116 BUILD_TOOLS = $(topsrcdir)/build/unix
117 endif
119 CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config
120 AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf
122 ifeq ($(OS_ARCH),QNX)
123 ifeq ($(OS_TARGET),NTO)
124 LD := qcc -Vgcc_ntox86 -nostdlib
125 else
126 LD := $(CC)
127 endif
128 endif
129 ifeq ($(OS_ARCH),BeOS)
130 BEOS_ADDON_WORKAROUND = 1
131 endif
134 # Strip off the excessively long version numbers on these platforms,
135 # but save the version to allow multiple versions of the same base
136 # platform to be built in the same tree.
138 ifneq (,$(filter FreeBSD HP-UX IRIX Linux NetBSD OpenBSD OSF1 SunOS,$(OS_ARCH)))
139 OS_RELEASE := $(basename $(OS_RELEASE))
141 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
142 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
143 OS_VERS := $(suffix $(OS_RELEASE))
144 OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
145 endif
147 endif
149 OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
151 FINAL_LINK_LIBS = $(DEPTH)/config/final-link-libs
152 FINAL_LINK_COMPS = $(DEPTH)/config/final-link-comps
153 FINAL_LINK_COMP_NAMES = $(DEPTH)/config/final-link-comp-names
155 MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
156 MOZ_WIDGET_SUPPORT_LIBS = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
158 ifdef MOZ_MEMORY
159 ifneq ($(OS_ARCH),WINNT)
160 JEMALLOC_LIBS = $(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME,jemalloc) $(MKSHLIB_UNFORCE_ALL)
161 endif
162 endif
164 # determine debug-related options
165 _DEBUG_CFLAGS :=
166 _DEBUG_LDFLAGS :=
168 ifndef MOZ_DEBUG
169 # global debugging is disabled
170 # check if it was explicitly enabled for this module
171 ifneq (, $(findstring $(MODULE), $(MOZ_DEBUG_MODULES)))
172 MOZ_DEBUG:=1
173 endif
174 else
175 # global debugging is enabled
176 # check if it was explicitly disabled for this module
177 ifneq (, $(findstring ^$(MODULE), $(MOZ_DEBUG_MODULES)))
178 MOZ_DEBUG:=
179 endif
180 endif
182 ifdef MOZ_DEBUG
183 _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
184 XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
185 else
186 _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
187 XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
188 endif
190 # determine if -g should be passed to the compiler, based on
191 # the current module, and the value of MOZ_DBGRINFO_MODULES
193 ifdef MOZ_DEBUG
194 MOZ_DBGRINFO_MODULES += ALL_MODULES
195 pattern := ALL_MODULES ^ALL_MODULES
196 else
197 MOZ_DBGRINFO_MODULES += ^ALL_MODULES
198 pattern := ALL_MODULES ^ALL_MODULES
199 endif
201 ifdef MODULE
202 # our current Makefile specifies a module name - add it to our pattern
203 pattern += $(MODULE) ^$(MODULE)
204 endif
206 # start by finding the first relevant module name
207 # (remember that the order of the module names in MOZ_DBGRINFO_MODULES
208 # is reversed from the order the user specified to configure -
209 # this allows the user to put general names at the beginning
210 # of the list, and to override them with explicit module names later
211 # in the list)
213 first_match:=$(firstword $(filter $(pattern), $(MOZ_DBGRINFO_MODULES)))
215 ifeq ($(first_match), $(MODULE))
216 # the user specified explicitly that
217 # this module should be compiled with -g
218 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
219 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
220 else
221 ifeq ($(first_match), ^$(MODULE))
222 # the user specified explicitly that this module
223 # should not be compiled with -g (nothing to do)
224 else
225 ifeq ($(first_match), ALL_MODULES)
226 # the user didn't mention this module explicitly,
227 # but wanted all modules to be compiled with -g
228 _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
229 _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
230 else
231 ifeq ($(first_match), ^ALL_MODULES)
232 # the user didn't mention this module explicitly,
233 # but wanted all modules to be compiled without -g (nothing to do)
234 endif
235 endif
236 endif
237 endif
240 # append debug flags
241 # (these might have been above when processing MOZ_DBGRINFO_MODULES)
242 OS_CFLAGS += $(_DEBUG_CFLAGS)
243 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
244 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
246 # MOZ_PROFILE equivs for win32
247 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
248 ifdef MOZ_DEBUG
249 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
250 OS_CFLAGS += -FR
251 OS_CXXFLAGS += -FR
252 endif
253 else # ! MOZ_DEBUG
255 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
256 # Used for generating an optimized build with debugging symbols.
257 # Used in the Windows nightlies to generate symbols for crash reporting.
258 ifdef MOZ_DEBUG_SYMBOLS
259 OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
260 OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
261 OS_LDFLAGS += -DEBUG -OPT:REF -OPT:nowin98
262 endif
264 ifdef MOZ_QUANTIFY
265 # -FIXED:NO is needed for Quantify to work, but it increases the size
266 # of executables, so only use it if building for Quantify.
267 WIN32_EXE_LDFLAGS += -FIXED:NO
269 # We need -OPT:NOICF to prevent identical methods from being merged together.
270 # Otherwise, Quantify doesn't know which method was actually called when it's
271 # showing you the profile.
272 OS_LDFLAGS += -OPT:NOICF
273 endif
276 # Handle trace-malloc in optimized builds.
277 # No opt to give sane callstacks.
279 ifdef NS_TRACE_MALLOC
280 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
281 OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF -OPT:nowin98
282 endif # NS_TRACE_MALLOC
284 endif # MOZ_DEBUG
285 endif # WINNT && !GNU_CC
288 # Build using PIC by default
289 # Do not use PIC if not building a shared lib (see exceptions below)
292 ifndef BUILD_STATIC_LIBS
293 _ENABLE_PIC=1
294 endif
295 ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
296 _ENABLE_PIC=1
297 endif
299 # In Firefox, all components are linked into either libxul or the static
300 # meta-component, and should be compiled with PIC.
301 ifdef MOZ_META_COMPONENT
302 _ENABLE_PIC=1
303 endif
305 # If module is going to be merged into the nsStaticModule,
306 # make sure that the entry points are translated and
307 # the module is built static.
309 ifdef IS_COMPONENT
310 ifdef EXPORT_LIBRARY
311 ifneq (,$(BUILD_STATIC_LIBS))
312 ifdef MODULE_NAME
313 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
314 FORCE_STATIC_LIB=1
315 endif
316 endif
317 endif
318 endif
320 # Determine if module being compiled is destined
321 # to be merged into libxul
323 ifdef MOZ_ENABLE_LIBXUL
324 ifdef LIBXUL_LIBRARY
325 ifdef IS_COMPONENT
326 ifdef MODULE_NAME
327 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
328 else
329 $(error Component makefile does not specify MODULE_NAME.)
330 endif
331 endif
332 FORCE_STATIC_LIB=1
333 _ENABLE_PIC=1
334 SHORT_LIBNAME=
335 endif
336 endif
338 # If we are building this component into an extension/xulapp, it cannot be
339 # statically linked. In the future we may want to add a xulapp meta-component
340 # build option.
342 ifdef XPI_NAME
343 _ENABLE_PIC=1
344 ifdef IS_COMPONENT
345 EXPORT_LIBRARY=
346 FORCE_STATIC_LIB=
347 FORCE_SHARED_LIB=1
348 endif
349 endif
352 # Disable PIC if necessary
355 ifndef _ENABLE_PIC
356 DSO_CFLAGS=
357 ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
358 DSO_PIC_CFLAGS=-mdynamic-no-pic
359 else
360 DSO_PIC_CFLAGS=
361 endif
362 endif
364 ifndef SHARED_LIBRARY_NAME
365 ifdef LIBRARY_NAME
366 SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
367 endif
368 endif
370 ifndef STATIC_LIBRARY_NAME
371 ifdef LIBRARY_NAME
372 STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
373 endif
374 endif
376 # This comes from configure
377 ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE
378 NO_PROFILE_GUIDED_OPTIMIZE = 1
379 endif
381 # Enable profile-based feedback
382 ifndef NO_PROFILE_GUIDED_OPTIMIZE
383 ifdef MOZ_PROFILE_GENERATE
384 # No sense in profiling tools
385 ifndef INTERNAL_TOOLS
386 OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
387 OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
388 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
389 ifeq (WINNT,$(OS_ARCH))
390 AR_FLAGS += -LTCG
391 endif
392 endif # INTERNAL_TOOLS
393 endif # MOZ_PROFILE_GENERATE
395 ifdef MOZ_PROFILE_USE
396 ifndef INTERNAL_TOOLS
397 OS_CFLAGS += $(PROFILE_USE_CFLAGS)
398 OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
399 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
400 ifeq (WINNT,$(OS_ARCH))
401 AR_FLAGS += -LTCG
402 endif
403 endif # INTERNAL_TOOLS
404 endif # MOZ_PROFILE_USE
405 endif # NO_PROFILE_GUIDED_OPTIMIZE
408 # Does the makefile specifies the internal XPCOM API linkage?
409 ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY))
410 DEFINES += -DMOZILLA_INTERNAL_API
411 endif
413 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
414 # building libxul libraries
415 ifdef MOZ_ENABLE_LIBXUL
416 ifdef LIBXUL_LIBRARY
417 DEFINES += \
418 -D_IMPL_NS_COM \
419 -DEXPORT_XPT_API \
420 -DEXPORT_XPTC_API \
421 -D_IMPL_NS_COM_OBSOLETE \
422 -D_IMPL_NS_GFX \
423 -D_IMPL_NS_WIDGET \
424 -DIMPL_XREAPI \
425 -DIMPL_NS_NET \
426 -DIMPL_THEBES \
427 $(NULL)
429 ifndef MOZ_NATIVE_ZLIB
430 DEFINES += -DZLIB_INTERNAL
431 endif
432 endif
433 endif
435 # Force _all_ exported methods to be |_declspec(dllexport)| when we're
436 # building them into the executable.
438 ifeq (,$(filter-out WINNT WINCE OS2, $(OS_ARCH)))
439 ifdef BUILD_STATIC_LIBS
440 DEFINES += \
441 -D_IMPL_NS_GFX \
442 -D_IMPL_NS_MSG_BASE \
443 -D_IMPL_NS_WIDGET \
444 $(NULL)
445 endif
446 endif
448 # Flags passed to make-jars.pl
450 MAKE_JARS_FLAGS = \
451 -t $(topsrcdir) \
452 -f $(MOZ_CHROME_FILE_FORMAT) \
453 $(NULL)
455 ifdef USE_EXTENSION_MANIFEST
456 MAKE_JARS_FLAGS += -e
457 endif
459 ifdef BOTH_MANIFESTS
460 MAKE_JARS_FLAGS += --both-manifests
461 endif
463 TAR_CREATE_FLAGS = -cvhf
465 ifeq ($(OS_ARCH),BSD_OS)
466 TAR_CREATE_FLAGS = -cvLf
467 endif
469 ifeq ($(OS_ARCH),OS2)
470 TAR_CREATE_FLAGS = -cvf
471 endif
474 # Personal makefile customizations go in these optional make include files.
476 MY_CONFIG := $(DEPTH)/config/myconfig.mk
477 MY_RULES := $(DEPTH)/config/myrules.mk
480 # Default command macros; can be overridden in <arch>.mk.
482 CCC = $(CXX)
483 NFSPWD = $(CONFIG_TOOLS)/nfspwd
484 PURIFY = purify $(PURIFYOPTIONS)
485 QUANTIFY = quantify $(QUANTIFYOPTIONS)
486 ifdef CROSS_COMPILE
487 XPIDL_COMPILE = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpidl$(HOST_BIN_SUFFIX)
488 XPIDL_LINK = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpt_link$(HOST_BIN_SUFFIX)
489 else
490 XPIDL_COMPILE = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpidl$(BIN_SUFFIX)
491 XPIDL_LINK = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpt_link$(BIN_SUFFIX)
492 endif
494 # Java macros
495 JAVA_GEN_DIR = _javagen
496 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
497 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
499 REQ_INCLUDES = -I$(srcdir) -I. $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include
500 ifdef LIBXUL_SDK
501 REQ_INCLUDES_SDK = $(foreach d,$(REQUIRES),-I$(LIBXUL_SDK)/include/$d) -I$(LIBXUL_SDK)/include
502 endif
504 INCLUDES = $(LOCAL_INCLUDES) $(REQ_INCLUDES) $(REQ_INCLUDES_SDK) -I$(PUBLIC) $(OS_INCLUDES)
506 ifndef MOZILLA_INTERNAL_API
507 INCLUDES += -I$(LIBXUL_DIST)/sdk/include
508 endif
510 include $(topsrcdir)/config/static-checking-config.mk
512 CFLAGS = $(OS_CFLAGS)
513 CXXFLAGS = $(OS_CXXFLAGS)
514 LDFLAGS = $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
516 # Allow each module to override the *default* optimization settings
517 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
518 # arguments to --enable-optimize
519 ifdef MOZ_OPTIMIZE
520 ifeq (1,$(MOZ_OPTIMIZE))
521 ifdef MODULE_OPTIMIZE_FLAGS
522 CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
523 CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS)
524 else
525 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
526 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
527 endif # MODULE_OPTIMIZE_FLAGS
528 else
529 CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
530 CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS)
531 endif # MOZ_OPTIMIZE == 1
532 LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS)
533 endif # MOZ_OPTIMIZE
535 ifdef CROSS_COMPILE
536 HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS)
537 else
538 ifdef MOZ_OPTIMIZE
539 ifeq (1,$(MOZ_OPTIMIZE))
540 ifdef MODULE_OPTIMIZE_FLAGS
541 HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS)
542 else
543 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
544 endif # MODULE_OPTIMIZE_FLAGS
545 else
546 HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS)
547 endif # MOZ_OPTIMIZE == 1
548 endif # MOZ_OPTIMIZE
549 endif # CROSS_COMPILE
552 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
553 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
554 #// DLL version of the RTL is used...
556 #//------------------------------------------------------------------------
557 ifdef USE_STATIC_LIBS
558 RTL_FLAGS=-MT # Statically linked multithreaded RTL
559 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
560 ifndef MOZ_NO_DEBUG_RTL
561 RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
562 endif
563 endif # MOZ_DEBUG || NS_TRACE_MALLOC
565 else # !USE_STATIC_LIBS
567 RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
568 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
569 ifndef MOZ_NO_DEBUG_RTL
570 RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
571 endif
572 endif # MOZ_DEBUG || NS_TRACE_MALLOC
573 endif # USE_STATIC_LIBS
574 endif # WINNT && !GNU_CC
576 ifeq ($(OS_ARCH),Darwin)
577 # Darwin doesn't cross-compile, so just set both types of flags here.
578 HOST_CMFLAGS += -fobjc-exceptions
579 HOST_CMMFLAGS += -fobjc-exceptions
580 OS_COMPILE_CMFLAGS += -fobjc-exceptions
581 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
582 endif
584 COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
585 COMPILE_CXXFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROFILER_CFLAGS) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
586 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
587 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
589 ifndef CROSS_COMPILE
590 HOST_CFLAGS += $(RTL_FLAGS)
591 endif
594 # Name of the binary code directories
596 # Override defaults
598 # We need to know where to find the libraries we
599 # put on the link line for binaries, and should
600 # we link statically or dynamic? Assuming dynamic for now.
602 ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
603 ifneq (,$(filter-out WINCE,$(OS_ARCH)))
604 LIBS_DIR = -L$(DIST)/bin -L$(DIST)/lib
605 ifdef LIBXUL_SDK
606 LIBS_DIR += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
607 endif
608 endif
609 endif
611 # Default location of include files
612 IDL_DIR = $(DIST)/idl
613 ifdef MODULE
614 PUBLIC = $(DIST)/include/$(MODULE)
615 else
616 PUBLIC = $(DIST)/include
617 endif
619 XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
620 ifdef LIBXUL_SDK
621 XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
622 endif
624 SDK_PUBLIC = $(DIST)/sdk/include
625 SDK_IDL_DIR = $(DIST)/sdk/idl
626 SDK_LIB_DIR = $(DIST)/sdk/lib
627 SDK_BIN_DIR = $(DIST)/sdk/bin
629 DEPENDENCIES = .md
631 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
633 ifdef GC_LEAK_DETECTOR
634 XPCOM_LIBS += -lboehm
635 endif
637 ifeq (xpconnect, $(findstring xpconnect, $(BUILD_MODULES)))
638 DEFINES += -DXPCONNECT_STANDALONE
639 endif
641 ifeq ($(OS_ARCH),OS2)
642 ELF_DYNSTR_GC = echo
643 else
644 ELF_DYNSTR_GC = :
645 endif
647 ifndef CROSS_COMPILE
648 ifdef USE_ELF_DYNSTR_GC
649 ifdef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
650 ELF_DYNSTR_GC = $(DEPTH)/config/elf-dynstr-gc
651 endif
652 endif
653 endif
655 ifeq ($(OS_ARCH),Darwin)
656 ifdef NEXT_ROOT
657 export NEXT_ROOT
658 PBBUILD = NEXT_ROOT= $(PBBUILD_BIN)
659 else # NEXT_ROOT
660 PBBUILD = $(PBBUILD_BIN)
661 endif # NEXT_ROOT
662 PBBUILD_SETTINGS = GCC_VERSION="$(GCC_VERSION)" SYMROOT=build ARCHS="$(OS_TEST)"
663 ifdef MACOS_SDK_DIR
664 PBBUILD_SETTINGS += SDKROOT="$(MACOS_SDK_DIR)"
665 endif # MACOS_SDK_DIR
666 ifdef MACOSX_DEPLOYMENT_TARGET
667 export MACOSX_DEPLOYMENT_TARGET
668 PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)"
669 endif # MACOSX_DEPLOYMENT_TARGET
670 ifdef MOZ_OPTIMIZE
671 ifeq (2,$(MOZ_OPTIMIZE))
672 # Only override project defaults if the config specified explicit settings
673 PBBUILD_SETTINGS += GCC_MODEL_TUNING= OPTIMIZATION_CFLAGS="$(MOZ_OPTIMIZE_FLAGS)"
674 endif # MOZ_OPTIMIZE=2
675 endif # MOZ_OPTIMIZE
676 ifeq (1,$(HAS_XCODE_2_1))
677 # Xcode 2.1 puts its build products in a directory corresponding to the
678 # selected build style/configuration.
679 XCODE_PRODUCT_DIR = build/$(BUILDSTYLE)
680 else
681 XCODE_PRODUCT_DIR = build
682 endif # HAS_XCODE_2_1=1
683 endif # OS_ARCH=Darwin
686 ifdef MOZ_NATIVE_MAKEDEPEND
687 MKDEPEND_DIR =
688 MKDEPEND = $(CYGWIN_WRAPPER) $(MOZ_NATIVE_MAKEDEPEND)
689 else
690 MKDEPEND_DIR = $(CONFIG_TOOLS)/mkdepend
691 MKDEPEND = $(CYGWIN_WRAPPER) $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
692 endif
694 # Set link flags according to whether we want a console.
695 ifdef MOZ_WINCONSOLE
696 ifeq ($(MOZ_WINCONSOLE),1)
697 ifeq ($(OS_ARCH),OS2)
698 BIN_FLAGS += -Zlinker -PM:VIO
699 endif
700 ifeq ($(OS_ARCH),WINNT)
701 ifdef GNU_CC
702 WIN32_EXE_LDFLAGS += -mconsole
703 else
704 WIN32_EXE_LDFLAGS += -SUBSYSTEM:CONSOLE
705 endif
706 endif
707 else # MOZ_WINCONSOLE
708 ifeq ($(OS_ARCH),OS2)
709 BIN_FLAGS += -Zlinker -PM:PM
710 endif
711 ifeq ($(OS_ARCH),WINNT)
712 ifdef GNU_CC
713 WIN32_EXE_LDFLAGS += -mwindows
714 else
715 WIN32_EXE_LDFLAGS += -SUBSYSTEM:WINDOWS
716 endif
717 endif
718 endif
719 endif
721 # Flags needed to link against the component library
722 ifdef MOZ_COMPONENTLIB
723 MOZ_COMPONENTLIB_EXTRA_DSO_LIBS = mozcomps xpcom_compat
725 # Tell the linker where NSS is, if we're building crypto
726 ifeq ($(OS_ARCH),Darwin)
727 ifeq (,$(findstring crypto,$(MOZ_META_COMPONENTS)))
728 MOZ_COMPONENTLIB_EXTRA_LIBS = $(foreach library, $(patsubst -l%, $(LIB_PREFIX)%$(DLL_SUFFIX), $(filter -l%, $(NSS_LIBS))), -dylib_file @executable_path/$(library):$(DIST)/bin/$(library))
729 endif
730 endif
731 endif
733 # If we're building a component on MSVC, we don't want to generate an
734 # import lib, because that import lib will collide with the name of a
735 # static version of the same library.
736 ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
737 ifdef IS_COMPONENT
738 LDFLAGS += -IMPLIB:fake.lib
739 DELETE_AFTER_LINK = fake.lib fake.exp
740 endif
741 endif
744 # Include any personal overrides the user might think are needed.
746 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
747 -include $(MY_CONFIG)
749 ######################################################################
750 # Now test variables that might have been set or overridden by $(MY_CONFIG).
752 DEFINES += -DOSTYPE=\"$(OS_CONFIG)\"
753 DEFINES += -DOSARCH=$(OS_ARCH)
755 # For profiling
756 ifdef ENABLE_EAZEL_PROFILER
757 ifndef INTERNAL_TOOLS
758 ifneq ($(LIBRARY_NAME), xpt)
759 ifneq (, $(findstring $(shell $(topsrcdir)/build/unix/print-depth-path.sh | awk -F/ '{ print $$2; }'), $(MOZ_PROFILE_MODULES)))
760 PROFILER_CFLAGS = $(EAZEL_PROFILER_CFLAGS) -DENABLE_EAZEL_PROFILER
761 PROFILER_LIBS = $(EAZEL_PROFILER_LIBS)
762 endif
763 endif
764 endif
765 endif
767 ######################################################################
769 GARBAGE += $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB
771 ifeq ($(OS_ARCH),Darwin)
772 ifndef NSDISTMODE
773 NSDISTMODE=absolute_symlink
774 endif
775 PWD := $(shell pwd)
776 endif
778 ifdef NSINSTALL_BIN
779 NSINSTALL = $(CYGWIN_WRAPPER) $(NSINSTALL_BIN)
780 else
781 ifeq (WINNT,$(CROSS_COMPILE)$(OS_ARCH))
782 NSINSTALL = $(CYGWIN_WRAPPER) $(MOZ_TOOLS_DIR)/bin/nsinstall
783 else
784 ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
785 NSINSTALL = $(MOZ_TOOLS_DIR)/nsinstall
786 else
787 NSINSTALL = $(CONFIG_TOOLS)/nsinstall
788 endif # OS2
789 endif # WINNT
790 endif # NSINSTALL_BIN
793 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
794 INSTALL = $(NSINSTALL)
795 else
796 ifeq ($(NSDISTMODE),copy)
797 # copy files, but preserve source mtime
798 INSTALL = $(NSINSTALL) -t
799 else
800 ifeq ($(NSDISTMODE),absolute_symlink)
801 # install using absolute symbolic links
802 ifeq ($(OS_ARCH),Darwin)
803 INSTALL = $(NSINSTALL) -L $(PWD)
804 else
805 INSTALL = $(NSINSTALL) -L `$(NFSPWD)`
806 endif # Darwin
807 else
808 # install using relative symbolic links
809 INSTALL = $(NSINSTALL) -R
810 endif # absolute_symlink
811 endif # copy
812 endif # WINNT/OS2
814 ifeq (,$(filter-out WINCE,$(OS_ARCH)))
815 NSINSTALL = $(CYGWIN_WRAPPER) nsinstall
816 INSTALL = $(CYGWIN_WRAPPER) nsinstall
817 endif
819 # Use nsinstall in copy mode to install files on the system
820 SYSINSTALL = $(NSINSTALL) -t
822 ifeq ($(OS_ARCH),WINNT)
823 ifneq (,$(CYGDRIVE_MOUNT))
824 export CYGDRIVE_MOUNT
825 endif
826 endif
829 # Localization build automation
832 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
833 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
834 # overridden by the command line. (Besides, AB_CD is prettier).
835 AB_CD = $(MOZ_UI_LOCALE)
837 ifndef L10NBASEDIR
838 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
839 endif
841 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(L10NBASEDIR)/$(AB_CD)/$(subst /locales,,$(1)))
843 ifdef relativesrcdir
844 LOCALE_SRCDIR = $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
845 endif
847 ifdef LOCALE_SRCDIR
848 # if LOCALE_MERGEDIR is set, use mergedir first, then the localization,
849 # and finally en-US
850 ifdef LOCALE_MERGEDIR
851 MAKE_JARS_FLAGS += -c $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))
852 endif
853 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
854 ifdef LOCALE_MERGEDIR
855 MAKE_JARS_FLAGS += -c $(topsrcdir)/$(relativesrcdir)/en-US
856 endif
857 endif
859 ifeq (,$(filter WINCE WINNT OS2,$(OS_ARCH)))
860 RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
861 endif
864 # Java macros
867 # Make sure any compiled classes work with at least JVM 1.4
868 JAVAC_FLAGS += -source 1.4
870 ifdef MOZ_DEBUG
871 JAVAC_FLAGS += -g
872 endif
874 ifdef TIERS
875 DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
876 STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
877 endif