Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / config / config.mk
1 #
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 #
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/
9 #
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.
14 #
15 # The Original Code is mozilla.org code.
16 #
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.
21 #
22 # Contributor(s):
23 #   Benjamin Smedberg <benjamin@smedbergs.us>
24 #
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.
36 #
37 # ***** END LICENSE BLOCK *****
38
39 #
40 # config.mk
41 #
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.
45 #
46
47 # Define an include-at-most-once flag
48 #ifdef INCLUDED_CONFIG_MK
49 #$(error Don't include config.mk twice!)
50 #endif
51 INCLUDED_CONFIG_MK = 1
52
53 EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
54
55 ifndef topsrcdir
56 topsrcdir       = $(DEPTH)
57 endif
58
59 ifndef INCLUDED_AUTOCONF_MK
60 include $(DEPTH)/config/autoconf.mk
61 endif
62
63 COMMA = ,
64
65 # Sanity check some variables
66 CHECK_VARS := \
67  XPI_NAME \
68  LIBRARY_NAME \
69  MODULE \
70  DEPTH \
71  SHORT_LIBNAME \
72  XPI_PKGNAME \
73  INSTALL_EXTENSION_ID \
74  SHARED_LIBRARY_NAME \
75  STATIC_LIBRARY_NAME \
76  $(NULL)
77
78 # checks for internal spaces or trailing spaces in the variable
79 # named by $x
80 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
81
82 $(foreach x,$(CHECK_VARS),$(check-variable))
83
84 core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))
85
86 nullstr :=
87 space :=$(nullstr) # EOL
88
89 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)))))))
90
91 # FINAL_TARGET specifies the location into which we copy end-user-shipped
92 # build products (typelibs, components, chrome).
93 #
94 # It will usually be the well-loved $(DIST)/bin, today, but can also be an
95 # XPI-contents staging directory for ambitious and right-thinking extensions.
96 FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)
97
98 ifdef XPI_NAME
99 DEFINES += -DXPI_NAME=$(XPI_NAME)
100 endif
101
102 # MAKE_JARS_TARGET is a staging area for make-jars.pl.  When packaging in
103 # the jar format, make-jars leaves behind a directory structure that's not
104 # needed in $(FINAL_TARGET).  For both, flat, and symlink, the directory
105 # structure contains the chrome, so leave it in $(FINAL_TARGET).
106 ifeq (jar,$(MOZ_CHROME_FILE_FORMAT))
107 MAKE_JARS_TARGET = $(if $(XPI_NAME),$(FINAL_TARGET).stage,$(DIST)/chrome-stage)
108 else
109 MAKE_JARS_TARGET = $(FINAL_TARGET)
110 endif
111
112 # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
113 VERSION_NUMBER          = 50
114
115 ifeq ($(HOST_OS_ARCH),WINNT)
116 win_srcdir      := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir))
117 BUILD_TOOLS     = $(WIN_TOP_SRC)/build/unix
118 else
119 win_srcdir      := $(srcdir)
120 BUILD_TOOLS     = $(topsrcdir)/build/unix
121 endif
122
123 CONFIG_TOOLS    = $(MOZ_BUILD_ROOT)/config
124 AUTOCONF_TOOLS  = $(topsrcdir)/build/autoconf
125
126 ifeq ($(OS_ARCH),QNX)
127 ifeq ($(OS_TARGET),NTO)
128 LD              := qcc -Vgcc_ntox86 -nostdlib
129 else
130 LD              := $(CC)
131 endif
132 endif
133 ifeq ($(OS_ARCH),BeOS)
134 BEOS_ADDON_WORKAROUND   = 1
135 endif
136
137 #
138 # Strip off the excessively long version numbers on these platforms,
139 # but save the version to allow multiple versions of the same base
140 # platform to be built in the same tree.
141 #
142 ifneq (,$(filter FreeBSD HP-UX IRIX Linux NetBSD OpenBSD OSF1 SunOS,$(OS_ARCH)))
143 OS_RELEASE      := $(basename $(OS_RELEASE))
144
145 # Allow the user to ignore the OS_VERSION, which is usually irrelevant.
146 ifdef WANT_MOZILLA_CONFIG_OS_VERSION
147 OS_VERS         := $(suffix $(OS_RELEASE))
148 OS_VERSION      := $(shell echo $(OS_VERS) | sed 's/-.*//')
149 endif
150
151 endif
152
153 OS_CONFIG       := $(OS_ARCH)$(OS_RELEASE)
154
155 FINAL_LINK_LIBS = $(DEPTH)/config/final-link-libs
156 FINAL_LINK_COMPS = $(DEPTH)/config/final-link-comps
157 FINAL_LINK_COMP_NAMES = $(DEPTH)/config/final-link-comp-names
158
159 MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
160 MOZ_WIDGET_SUPPORT_LIBS    = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
161
162 ifdef MOZ_MEMORY
163 ifneq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
164 JEMALLOC_LIBS = $(MKSHLIB_FORCE_ALL) $(call EXPAND_MOZLIBNAME,jemalloc) $(MKSHLIB_UNFORCE_ALL)
165 # If we are linking jemalloc into a program, we want the jemalloc symbols
166 # to be exported
167 ifneq (,$(SIMPLE_PROGRAMS)$(PROGRAM))
168 JEMALLOC_LIBS += $(MOZ_JEMALLOC_STANDALONE_GLUE_LDOPTS)
169 endif
170 endif
171 endif
172
173 CC := $(CC_WRAPPER) $(CC)
174 CXX := $(CXX_WRAPPER) $(CXX)
175
176 # determine debug-related options
177 _DEBUG_CFLAGS :=
178 _DEBUG_LDFLAGS :=
179
180 ifdef MOZ_DEBUG
181   _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS) $(MOZ_DEBUG_FLAGS)
182   _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
183   XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS)
184 else
185   _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
186   XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS)
187   ifdef MOZ_DEBUG_SYMBOLS
188     _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
189     _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)
190   endif
191 endif
192
193 MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib)
194
195 OS_CFLAGS += $(_DEBUG_CFLAGS)
196 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
197 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
198
199 # XXX: What does this? Bug 482434 filed for better explanation.
200 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
201 ifdef MOZ_DEBUG
202 ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE))
203 OS_CFLAGS += -FR
204 OS_CXXFLAGS += -FR
205 endif
206 else # ! MOZ_DEBUG
207
208 # We don't build a static CRT when building a custom CRT,
209 # it appears to be broken. So don't link to jemalloc if
210 # the Makefile wants static CRT linking.
211 ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_)
212 # Disable default CRT libs and add the right lib path for the linker
213 OS_LDFLAGS += $(MOZ_MEMORY_LDFLAGS)
214 endif
215
216 # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files.
217 # Used for generating an optimized build with debugging symbols.
218 # Used in the Windows nightlies to generate symbols for crash reporting.
219 ifdef MOZ_DEBUG_SYMBOLS
220 OS_CXXFLAGS += -Zi -UDEBUG -DNDEBUG
221 OS_CFLAGS += -Zi -UDEBUG -DNDEBUG
222 ifdef HAVE_64BIT_OS
223 OS_LDFLAGS += -DEBUG -OPT:REF,ICF
224 else
225 OS_LDFLAGS += -DEBUG -OPT:REF
226 endif
227 endif
228
229 ifdef MOZ_QUANTIFY
230 # -FIXED:NO is needed for Quantify to work, but it increases the size
231 # of executables, so only use it if building for Quantify.
232 WIN32_EXE_LDFLAGS += -FIXED:NO
233
234 # We need -OPT:NOICF to prevent identical methods from being merged together.
235 # Otherwise, Quantify doesn't know which method was actually called when it's
236 # showing you the profile.
237 OS_LDFLAGS += -OPT:NOICF
238 endif
239
240 #
241 # Handle trace-malloc in optimized builds.
242 # No opt to give sane callstacks.
243 #
244 ifdef NS_TRACE_MALLOC
245 MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
246 ifdef HAVE_64BIT_OS
247 OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF,ICF
248 else
249 OS_LDFLAGS = -DEBUG -PDB:NONE -OPT:REF
250 endif
251 endif # NS_TRACE_MALLOC
252
253 endif # MOZ_DEBUG
254 endif # WINNT && !GNU_CC
255
256 #
257 # Build using PIC by default
258 # Do not use PIC if not building a shared lib (see exceptions below)
259 #
260
261 ifndef BUILD_STATIC_LIBS
262 _ENABLE_PIC=1
263 endif
264 ifneq (,$(FORCE_SHARED_LIB)$(FORCE_USE_PIC))
265 _ENABLE_PIC=1
266 endif
267
268 # In Firefox, all components are linked into either libxul or the static
269 # meta-component, and should be compiled with PIC.
270 ifdef MOZ_META_COMPONENT
271 _ENABLE_PIC=1
272 endif
273
274 # If module is going to be merged into the nsStaticModule, 
275 # make sure that the entry points are translated and 
276 # the module is built static.
277
278 ifdef IS_COMPONENT
279 ifdef EXPORT_LIBRARY
280 ifneq (,$(BUILD_STATIC_LIBS))
281 ifdef MODULE_NAME
282 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
283 FORCE_STATIC_LIB=1
284 endif
285 endif
286 endif
287 endif
288
289 # Determine if module being compiled is destined 
290 # to be merged into libxul
291
292 ifdef MOZ_ENABLE_LIBXUL
293 ifdef LIBXUL_LIBRARY
294 ifdef IS_COMPONENT
295 ifdef MODULE_NAME
296 DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1
297 else
298 $(error Component makefile does not specify MODULE_NAME.)
299 endif
300 endif
301 FORCE_STATIC_LIB=1
302 _ENABLE_PIC=1
303 SHORT_LIBNAME=
304 endif
305 endif
306
307 # If we are building this component into an extension/xulapp, it cannot be
308 # statically linked. In the future we may want to add a xulapp meta-component
309 # build option.
310
311 ifdef XPI_NAME
312 _ENABLE_PIC=1
313 ifdef IS_COMPONENT
314 EXPORT_LIBRARY=
315 FORCE_STATIC_LIB=
316 FORCE_SHARED_LIB=1
317 endif
318 endif
319
320 #
321 # Disable PIC if necessary
322 #
323
324 ifndef _ENABLE_PIC
325 DSO_CFLAGS=
326 ifeq ($(OS_ARCH)_$(HAVE_GCC3_ABI),Darwin_1)
327 DSO_PIC_CFLAGS=-mdynamic-no-pic
328 else
329 DSO_PIC_CFLAGS=
330 endif
331 endif
332
333 ifndef SHARED_LIBRARY_NAME
334 ifdef LIBRARY_NAME
335 SHARED_LIBRARY_NAME=$(LIBRARY_NAME)
336 endif
337 endif
338
339 ifndef STATIC_LIBRARY_NAME
340 ifdef LIBRARY_NAME
341 STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
342 endif
343 endif
344
345 ifeq (WINNT,$(OS_ARCH))
346 MOZ_FAKELIBS = 1
347 endif
348
349 # This comes from configure
350 ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE
351 NO_PROFILE_GUIDED_OPTIMIZE = 1
352 endif
353
354 # No sense in profiling tools
355 ifdef INTERNAL_TOOLS
356 NO_PROFILE_GUIDED_OPTIMIZE = 1
357 endif
358
359 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
360 # and we don't have the same build logic to re-link them in the second pass.
361 ifdef SIMPLE_PROGRAMS
362 NO_PROFILE_GUIDED_OPTIMIZE = 1
363 endif
364
365 # Enable profile-based feedback
366 ifndef NO_PROFILE_GUIDED_OPTIMIZE
367 ifdef MOZ_PROFILE_GENERATE
368 OS_CFLAGS += $(PROFILE_GEN_CFLAGS)
369 OS_CXXFLAGS += $(PROFILE_GEN_CFLAGS)
370 OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
371 ifeq (WINNT,$(OS_ARCH))
372 AR_FLAGS += -LTCG
373 endif
374 endif # MOZ_PROFILE_GENERATE
375
376 ifdef MOZ_PROFILE_USE
377 OS_CFLAGS += $(PROFILE_USE_CFLAGS)
378 OS_CXXFLAGS += $(PROFILE_USE_CFLAGS)
379 OS_LDFLAGS += $(PROFILE_USE_LDFLAGS)
380 ifeq (WINNT,$(OS_ARCH))
381 AR_FLAGS += -LTCG
382 endif
383 endif # MOZ_PROFILE_USE
384 endif # NO_PROFILE_GUIDED_OPTIMIZE
385
386
387 # Does the makefile specifies the internal XPCOM API linkage?
388 ifneq (,$(MOZILLA_INTERNAL_API)$(LIBXUL_LIBRARY))
389 DEFINES += -DMOZILLA_INTERNAL_API
390 endif
391
392 # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're
393 # building libxul libraries
394 ifdef MOZ_ENABLE_LIBXUL
395 ifdef LIBXUL_LIBRARY
396 DEFINES += \
397                 -D_IMPL_NS_COM \
398                 -DEXPORT_XPT_API \
399                 -DEXPORT_XPTC_API \
400                 -D_IMPL_NS_GFX \
401                 -D_IMPL_NS_WIDGET \
402                 -DIMPL_XREAPI \
403                 -DIMPL_NS_NET \
404                 -DIMPL_THEBES \
405                 $(NULL)
406
407 ifndef JS_SHARED_LIBRARY
408 DEFINES += -DSTATIC_EXPORTABLE_JS_API
409 endif
410 endif
411 endif
412
413 # Force _all_ exported methods to be |_declspec(dllexport)| when we're
414 # building them into the executable.
415
416 ifeq (,$(filter-out WINNT WINCE OS2, $(OS_ARCH)))
417 ifdef BUILD_STATIC_LIBS
418 DEFINES += \
419         -D_IMPL_NS_GFX \
420         -D_IMPL_NS_MSG_BASE \
421         -D_IMPL_NS_WIDGET \
422         $(NULL)
423 endif
424 endif
425
426 # Flags passed to make-jars.pl
427
428 MAKE_JARS_FLAGS = \
429         -t $(topsrcdir) \
430         -f $(MOZ_CHROME_FILE_FORMAT) \
431         $(NULL)
432
433 ifdef USE_EXTENSION_MANIFEST
434 MAKE_JARS_FLAGS += -e
435 endif
436
437 ifdef BOTH_MANIFESTS
438 MAKE_JARS_FLAGS += --both-manifests
439 endif
440
441 TAR_CREATE_FLAGS = -cvhf
442
443 ifeq ($(OS_ARCH),BSD_OS)
444 TAR_CREATE_FLAGS = -cvLf
445 endif
446
447 ifeq ($(OS_ARCH),OS2)
448 TAR_CREATE_FLAGS = -cvf
449 endif
450
451 #
452 # Personal makefile customizations go in these optional make include files.
453 #
454 MY_CONFIG       := $(DEPTH)/config/myconfig.mk
455 MY_RULES        := $(DEPTH)/config/myrules.mk
456
457 #
458 # Default command macros; can be overridden in <arch>.mk.
459 #
460 CCC             = $(CXX)
461 NFSPWD          = $(CONFIG_TOOLS)/nfspwd
462 PURIFY          = purify $(PURIFYOPTIONS)
463 QUANTIFY        = quantify $(QUANTIFYOPTIONS)
464 ifdef CROSS_COMPILE
465 XPIDL_COMPILE   = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpidl$(HOST_BIN_SUFFIX)
466 XPIDL_LINK      = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/host/bin/host_xpt_link$(HOST_BIN_SUFFIX)
467 else
468 XPIDL_COMPILE   = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpidl$(BIN_SUFFIX)
469 XPIDL_LINK      = $(CYGWIN_WRAPPER) $(LIBXUL_DIST)/bin/xpt_link$(BIN_SUFFIX)
470 endif
471
472 # Java macros
473 JAVA_GEN_DIR  = _javagen
474 JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR)
475 JAVA_IFACES_PKG_NAME = org/mozilla/interfaces
476
477 INCLUDES = \
478   $(LOCAL_INCLUDES) \
479   -I$(srcdir) \
480   -I. \
481   -I$(DIST)/include -I$(DIST)/include/nsprpub \
482   $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include -I$(LIBXUL_SDK)/include/nsprpub) \
483   $(OS_INCLUDES) \
484   $(NULL) 
485
486 include $(topsrcdir)/config/static-checking-config.mk
487
488 CFLAGS          = $(OS_CFLAGS)
489 CXXFLAGS        = $(OS_CXXFLAGS)
490 LDFLAGS         = $(OS_LDFLAGS) $(MOZ_FIX_LINK_PATHS)
491
492 # Allow each module to override the *default* optimization settings
493 # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given
494 # arguments to --enable-optimize
495 ifdef MOZ_OPTIMIZE
496 ifeq (1,$(MOZ_OPTIMIZE))
497 ifdef MODULE_OPTIMIZE_FLAGS
498 CFLAGS          += $(MODULE_OPTIMIZE_FLAGS)
499 CXXFLAGS        += $(MODULE_OPTIMIZE_FLAGS)
500 else
501 CFLAGS          += $(MOZ_OPTIMIZE_FLAGS)
502 CXXFLAGS        += $(MOZ_OPTIMIZE_FLAGS)
503 endif # MODULE_OPTIMIZE_FLAGS
504 else
505 CFLAGS          += $(MOZ_OPTIMIZE_FLAGS)
506 CXXFLAGS        += $(MOZ_OPTIMIZE_FLAGS)
507 endif # MOZ_OPTIMIZE == 1
508 LDFLAGS         += $(MOZ_OPTIMIZE_LDFLAGS)
509 endif # MOZ_OPTIMIZE
510
511 ifdef CROSS_COMPILE
512 HOST_CFLAGS     += $(HOST_OPTIMIZE_FLAGS)
513 else
514 ifdef MOZ_OPTIMIZE
515 ifeq (1,$(MOZ_OPTIMIZE))
516 ifdef MODULE_OPTIMIZE_FLAGS
517 HOST_CFLAGS     += $(MODULE_OPTIMIZE_FLAGS)
518 else
519 HOST_CFLAGS     += $(MOZ_OPTIMIZE_FLAGS)
520 endif # MODULE_OPTIMIZE_FLAGS
521 else
522 HOST_CFLAGS     += $(MOZ_OPTIMIZE_FLAGS)
523 endif # MOZ_OPTIMIZE == 1
524 endif # MOZ_OPTIMIZE
525 endif # CROSS_COMPILE
526
527 # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles
528 # to request that we use the 'warnings as errors' compile flags)
529
530 # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO
531 # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that
532 # situation. (See bug 437002.)
533 ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
534 FAIL_ON_WARNINGS_DEBUG=
535 FAIL_ON_WARNINGS=
536 endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE)
537
538 # Also clear FAIL_ON_WARNINGS[_DEBUG] for Android builds, since
539 # they have some platform-specific warnings we haven't fixed yet.
540 ifeq ($(OS_TARGET),Android)
541 FAIL_ON_WARNINGS_DEBUG=
542 FAIL_ON_WARNINGS=
543 endif # Android
544
545 # Now, check for debug version of flag; it turns on normal flag in debug builds.
546 ifdef FAIL_ON_WARNINGS_DEBUG
547 ifdef MOZ_DEBUG
548 FAIL_ON_WARNINGS = 1
549 endif # MOZ_DEBUG
550 endif # FAIL_ON_WARNINGS_DEBUG
551
552 # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1.
553 ifdef FAIL_ON_WARNINGS
554 CXXFLAGS += $(WARNINGS_AS_ERRORS)
555 CFLAGS   += $(WARNINGS_AS_ERRORS)
556 endif # FAIL_ON_WARNINGS
557
558 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
559 #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded
560 #// DLL version of the RTL is used...
561 #//
562 #//------------------------------------------------------------------------
563 ifdef USE_STATIC_LIBS
564 RTL_FLAGS=-MT          # Statically linked multithreaded RTL
565 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
566 ifndef MOZ_NO_DEBUG_RTL
567 RTL_FLAGS=-MTd         # Statically linked multithreaded MSVC4.0 debug RTL
568 endif
569 endif # MOZ_DEBUG || NS_TRACE_MALLOC
570
571 else # !USE_STATIC_LIBS
572
573 RTL_FLAGS=-MD          # Dynamically linked, multithreaded RTL
574 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
575 ifndef MOZ_NO_DEBUG_RTL
576 RTL_FLAGS=-MDd         # Dynamically linked, multithreaded MSVC4.0 debug RTL
577 endif 
578 endif # MOZ_DEBUG || NS_TRACE_MALLOC
579 endif # USE_STATIC_LIBS
580 endif # WINNT && !GNU_CC
581
582 ifeq ($(OS_ARCH),Darwin)
583 # Darwin doesn't cross-compile, so just set both types of flags here.
584 HOST_CMFLAGS += -fobjc-exceptions
585 HOST_CMMFLAGS += -fobjc-exceptions
586 OS_COMPILE_CMFLAGS += -fobjc-exceptions
587 OS_COMPILE_CMMFLAGS += -fobjc-exceptions
588 endif
589
590 COMPILE_CFLAGS  = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
591 COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
592 COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
593 COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)
594
595 ifndef CROSS_COMPILE
596 HOST_CFLAGS += $(RTL_FLAGS)
597 endif
598
599 #
600 # Name of the binary code directories
601 #
602 # Override defaults
603
604 # We need to know where to find the libraries we
605 # put on the link line for binaries, and should
606 # we link statically or dynamic?  Assuming dynamic for now.
607
608 ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC))
609 ifneq (,$(filter-out WINCE,$(OS_ARCH)))
610 LIBS_DIR        = -L$(DIST)/bin -L$(DIST)/lib
611 ifdef LIBXUL_SDK
612 LIBS_DIR        += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib
613 endif
614 endif
615 endif
616
617 # Default location of include files
618 IDL_DIR         = $(DIST)/idl
619
620 XPIDL_FLAGS = -I$(srcdir) -I$(IDL_DIR)
621 ifdef LIBXUL_SDK
622 XPIDL_FLAGS += -I$(LIBXUL_SDK)/idl
623 endif
624
625 SDK_LIB_DIR = $(DIST)/sdk/lib
626 SDK_BIN_DIR = $(DIST)/sdk/bin
627
628 DEPENDENCIES    = .md
629
630 MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS)
631
632 ifeq (xpconnect, $(findstring xpconnect, $(BUILD_MODULES)))
633 DEFINES +=  -DXPCONNECT_STANDALONE
634 endif
635
636 ifeq ($(OS_ARCH),OS2)
637 ELF_DYNSTR_GC   = echo
638 else
639 ELF_DYNSTR_GC   = :
640 endif
641
642 ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
643 OS_LIBS += $(MOZ_QT_LIBS)
644 endif
645
646 ifndef CROSS_COMPILE
647 ifdef USE_ELF_DYNSTR_GC
648 ifdef MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS
649 ELF_DYNSTR_GC   = $(DEPTH)/config/elf-dynstr-gc
650 endif
651 endif
652 endif
653
654 ifeq ($(OS_ARCH),Darwin)
655 ifdef NEXT_ROOT
656 export NEXT_ROOT
657 PBBUILD = NEXT_ROOT= $(PBBUILD_BIN)
658 else # NEXT_ROOT
659 PBBUILD = $(PBBUILD_BIN)
660 endif # NEXT_ROOT
661 PBBUILD_SETTINGS = GCC_VERSION="$(GCC_VERSION)" SYMROOT=build ARCHS="$(OS_TEST)"
662 ifdef MACOS_SDK_DIR
663 PBBUILD_SETTINGS += SDKROOT="$(MACOS_SDK_DIR)"
664 endif # MACOS_SDK_DIR
665 ifdef MACOSX_DEPLOYMENT_TARGET
666 export MACOSX_DEPLOYMENT_TARGET
667 PBBUILD_SETTINGS += MACOSX_DEPLOYMENT_TARGET="$(MACOSX_DEPLOYMENT_TARGET)"
668 endif # MACOSX_DEPLOYMENT_TARGET
669 ifdef MOZ_OPTIMIZE
670 ifeq (2,$(MOZ_OPTIMIZE))
671 # Only override project defaults if the config specified explicit settings
672 PBBUILD_SETTINGS += GCC_MODEL_TUNING= OPTIMIZATION_CFLAGS="$(MOZ_OPTIMIZE_FLAGS)"
673 endif # MOZ_OPTIMIZE=2
674 endif # MOZ_OPTIMIZE
675 ifeq (1,$(HAS_XCODE_2_1))
676 # Xcode 2.1 puts its build products in a directory corresponding to the
677 # selected build style/configuration.
678 XCODE_PRODUCT_DIR = build/$(BUILDSTYLE)
679 else
680 XCODE_PRODUCT_DIR = build
681 endif # HAS_XCODE_2_1=1
682 endif # OS_ARCH=Darwin
683
684
685 ifdef MOZ_NATIVE_MAKEDEPEND
686 MKDEPEND_DIR    =
687 MKDEPEND        = $(CYGWIN_WRAPPER) $(MOZ_NATIVE_MAKEDEPEND)
688 else
689 MKDEPEND_DIR    = $(CONFIG_TOOLS)/mkdepend
690 MKDEPEND        = $(CYGWIN_WRAPPER) $(MKDEPEND_DIR)/mkdepend$(BIN_SUFFIX)
691 endif
692
693 # Set link flags according to whether we want a console.
694 ifdef MOZ_WINCONSOLE
695 ifeq ($(MOZ_WINCONSOLE),1)
696 ifeq ($(OS_ARCH),OS2)
697 BIN_FLAGS       += -Zlinker -PM:VIO
698 endif
699 ifeq ($(OS_ARCH),WINNT)
700 ifdef GNU_CC
701 WIN32_EXE_LDFLAGS       += -mconsole
702 else
703 WIN32_EXE_LDFLAGS       += -SUBSYSTEM:CONSOLE
704 endif
705 endif
706 else # MOZ_WINCONSOLE
707 ifeq ($(OS_ARCH),OS2)
708 BIN_FLAGS       += -Zlinker -PM:PM
709 endif
710 ifeq ($(OS_ARCH),WINNT)
711 ifdef GNU_CC
712 WIN32_EXE_LDFLAGS       += -mwindows
713 else
714 WIN32_EXE_LDFLAGS       += -SUBSYSTEM:WINDOWS
715 endif
716 endif
717 endif
718 endif
719
720 # If we're building a component on MSVC, we don't want to generate an
721 # import lib, because that import lib will collide with the name of a
722 # static version of the same library.
723 ifeq ($(GNU_LD)$(OS_ARCH),WINNT)
724 ifdef IS_COMPONENT
725 LDFLAGS += -IMPLIB:fake.lib
726 DELETE_AFTER_LINK = fake.lib fake.exp
727 endif
728 endif
729
730 #
731 # Include any personal overrides the user might think are needed.
732 #
733 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
734 -include $(MY_CONFIG)
735
736 ######################################################################
737 # Now test variables that might have been set or overridden by $(MY_CONFIG).
738
739 DEFINES         += -DOSTYPE=\"$(OS_CONFIG)\"
740 DEFINES         += -DOSARCH=$(OS_ARCH)
741
742 ######################################################################
743
744 GARBAGE         += $(DEPENDENCIES) $(MKDEPENDENCIES) $(MKDEPENDENCIES).bak core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB $(FAKE_LIBRARY)
745
746 ifeq ($(OS_ARCH),Darwin)
747 ifndef NSDISTMODE
748 NSDISTMODE=absolute_symlink
749 endif
750 PWD := $(CURDIR)
751 endif
752
753 ifdef NSINSTALL_BIN
754 NSINSTALL       = $(CYGWIN_WRAPPER) $(NSINSTALL_BIN)
755 else
756 ifeq (OS2,$(CROSS_COMPILE)$(OS_ARCH))
757 NSINSTALL       = $(MOZ_TOOLS_DIR)/nsinstall
758 else
759 NSINSTALL       = $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)
760 endif # OS2
761 endif # NSINSTALL_BIN
762
763
764 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
765 INSTALL         = $(NSINSTALL)
766 else
767 ifeq ($(NSDISTMODE),copy)
768 # copy files, but preserve source mtime
769 INSTALL         = $(NSINSTALL) -t
770 else
771 ifeq ($(NSDISTMODE),absolute_symlink)
772 # install using absolute symbolic links
773 ifeq ($(OS_ARCH),Darwin)
774 INSTALL         = $(NSINSTALL) -L $(PWD)
775 else
776 INSTALL         = $(NSINSTALL) -L `$(NFSPWD)`
777 endif # Darwin
778 else
779 # install using relative symbolic links
780 INSTALL         = $(NSINSTALL) -R
781 endif # absolute_symlink
782 endif # copy
783 endif # WINNT/OS2
784
785 # Use nsinstall in copy mode to install files on the system
786 SYSINSTALL      = $(NSINSTALL) -t
787
788 ifeq ($(OS_ARCH),WINNT)
789 ifneq (,$(CYGDRIVE_MOUNT))
790 export CYGDRIVE_MOUNT
791 endif
792 endif
793
794 #
795 # Localization build automation
796 #
797
798 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
799 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
800 # overridden by the command line. (Besides, AB_CD is prettier).
801 AB_CD = $(MOZ_UI_LOCALE)
802
803 ifndef L10NBASEDIR
804 L10NBASEDIR = $(error L10NBASEDIR not defined by configure)
805 endif
806
807 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(L10NBASEDIR)/$(AB_CD)/$(subst /locales,,$(1)))
808
809 ifdef relativesrcdir
810 LOCALE_SRCDIR = $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir))
811 endif
812
813 ifdef LOCALE_SRCDIR
814 # if LOCALE_MERGEDIR is set, use mergedir first, then the localization,
815 # and finally en-US
816 ifdef LOCALE_MERGEDIR
817 MAKE_JARS_FLAGS += -c $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))
818 endif
819 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
820 ifdef LOCALE_MERGEDIR
821 MAKE_JARS_FLAGS += -c $(topsrcdir)/$(relativesrcdir)/en-US
822 endif
823 endif
824
825 ifdef WINCE
826 RUN_TEST_PROGRAM = $(PYTHON) $(topsrcdir)/build/mobile/devicemanager-run-test.py
827 else
828 ifeq (OS2,$(OS_ARCH))
829 RUN_TEST_PROGRAM = $(topsrcdir)/build/os2/test_os2.cmd "$(DIST)"
830 else
831 ifneq (WINNT,$(OS_ARCH))
832 RUN_TEST_PROGRAM = $(DIST)/bin/run-mozilla.sh
833 endif # ! WINNT
834 endif # ! OS2
835 endif # ! WINCE
836
837 #
838 # Java macros
839 #
840
841 # Make sure any compiled classes work with at least JVM 1.4
842 JAVAC_FLAGS += -source 1.4
843
844 ifdef MOZ_DEBUG
845 JAVAC_FLAGS += -g
846 endif
847
848 ifdef TIERS
849 DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
850 STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
851 endif
852
853 OPTIMIZE_JARS_CMD = $(PYTHON) $(call core_abspath,$(topsrcdir)/config/optimizejars.py)