config/config.mk

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial