michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # config.mk michael@0: # michael@0: # Determines the platform and builds the macros needed to load the michael@0: # appropriate platform-specific .mk file, then defines all (most?) michael@0: # of the generic macros. michael@0: # michael@0: michael@0: # Define an include-at-most-once flag michael@0: ifdef INCLUDED_CONFIG_MK michael@0: $(error Do not include config.mk twice!) michael@0: endif michael@0: INCLUDED_CONFIG_MK = 1 michael@0: michael@0: EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this. michael@0: michael@0: ifndef topsrcdir michael@0: topsrcdir = $(DEPTH) michael@0: endif michael@0: michael@0: ifndef INCLUDED_AUTOCONF_MK michael@0: include $(DEPTH)/config/autoconf.mk michael@0: endif michael@0: michael@0: -include $(DEPTH)/.mozconfig.mk michael@0: michael@0: # Integrate with mozbuild-generated make files. We first verify that no michael@0: # variables provided by the automatically generated .mk files are michael@0: # present. If they are, this is a violation of the separation of michael@0: # responsibility between Makefile.in and mozbuild files. michael@0: _MOZBUILD_EXTERNAL_VARIABLES := \ michael@0: ANDROID_GENERATED_RESFILES \ michael@0: ANDROID_RES_DIRS \ michael@0: CMSRCS \ michael@0: CMMSRCS \ michael@0: CPP_UNIT_TESTS \ michael@0: DIRS \ michael@0: EXTRA_PP_COMPONENTS \ michael@0: EXTRA_PP_JS_MODULES \ michael@0: FORCE_SHARED_LIB \ michael@0: FORCE_STATIC_LIB \ michael@0: FINAL_LIBRARY \ michael@0: HOST_CSRCS \ michael@0: HOST_CMMSRCS \ michael@0: HOST_LIBRARY_NAME \ michael@0: HOST_PROGRAM \ michael@0: HOST_SIMPLE_PROGRAMS \ michael@0: IS_COMPONENT \ michael@0: JAR_MANIFEST \ michael@0: JAVA_JAR_TARGETS \ michael@0: JS_MODULES_PATH \ michael@0: LIBRARY_NAME \ michael@0: MODULE \ michael@0: MSVC_ENABLE_PGO \ michael@0: NO_DIST_INSTALL \ michael@0: PARALLEL_DIRS \ michael@0: PROGRAM \ michael@0: RESOURCE_FILES \ michael@0: SDK_HEADERS \ michael@0: SIMPLE_PROGRAMS \ michael@0: TEST_DIRS \ michael@0: TIERS \ michael@0: TOOL_DIRS \ michael@0: XPCSHELL_TESTS \ michael@0: XPIDL_MODULE \ michael@0: $(NULL) michael@0: michael@0: _DEPRECATED_VARIABLES := \ michael@0: ANDROID_RESFILES \ michael@0: LIBXUL_LIBRARY \ michael@0: MOCHITEST_A11Y_FILES \ michael@0: MOCHITEST_BROWSER_FILES \ michael@0: MOCHITEST_BROWSER_FILES_PARTS \ michael@0: MOCHITEST_CHROME_FILES \ michael@0: MOCHITEST_FILES \ michael@0: MOCHITEST_FILES_PARTS \ michael@0: MOCHITEST_METRO_FILES \ michael@0: MOCHITEST_ROBOCOP_FILES \ michael@0: SHORT_LIBNAME \ michael@0: $(NULL) michael@0: michael@0: ifndef EXTERNALLY_MANAGED_MAKE_FILE michael@0: # Using $(firstword) may not be perfect. But it should be good enough for most michael@0: # scenarios. michael@0: _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) michael@0: michael@0: $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ michael@0: $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ michael@0: )) michael@0: michael@0: $(foreach var,$(_DEPRECATED_VARIABLES),$(if $(filter file override,$(subst $(NULL) ,_,$(origin $(var)))),\ michael@0: $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build)\ michael@0: )) michael@0: michael@0: # Import the automatically generated backend file. If this file doesn't exist, michael@0: # the backend hasn't been properly configured. We want this to be a fatal michael@0: # error, hence not using "-include". michael@0: ifndef STANDALONE_MAKEFILE michael@0: GLOBAL_DEPS += backend.mk michael@0: include backend.mk michael@0: endif michael@0: michael@0: # Freeze the values specified by moz.build to catch them if they fail. michael@0: michael@0: $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) michael@0: $(foreach var,$(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) michael@0: michael@0: CHECK_MOZBUILD_VARIABLES = $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES), \ michael@0: $(if $(subst $($(var)_FROZEN),,'$($(var))'), \ michael@0: $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ michael@0: )) $(foreach var,$(_DEPRECATED_VARIABLES), \ michael@0: $(if $(subst $($(var)_FROZEN),,'$($(var))'), \ michael@0: $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build),\ michael@0: )) michael@0: michael@0: endif michael@0: michael@0: space = $(NULL) $(NULL) michael@0: michael@0: # Include defs.mk files that can be found in $(srcdir)/$(DEPTH), michael@0: # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir) michael@0: # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc. michael@0: # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is .. michael@0: # These defs.mk files are used to define variables in a directory michael@0: # and all its subdirectories, recursively. michael@0: __depth := $(subst /, ,$(DEPTH)) michael@0: ifeq (.,$(__depth)) michael@0: __depth := michael@0: endif michael@0: $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk))))) michael@0: michael@0: COMMA = , michael@0: michael@0: # Sanity check some variables michael@0: CHECK_VARS := \ michael@0: XPI_NAME \ michael@0: LIBRARY_NAME \ michael@0: MODULE \ michael@0: DEPTH \ michael@0: XPI_PKGNAME \ michael@0: INSTALL_EXTENSION_ID \ michael@0: SHARED_LIBRARY_NAME \ michael@0: STATIC_LIBRARY_NAME \ michael@0: $(NULL) michael@0: michael@0: # checks for internal spaces or trailing spaces in the variable michael@0: # named by $x michael@0: check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x))) michael@0: michael@0: $(foreach x,$(CHECK_VARS),$(check-variable)) michael@0: michael@0: ifndef INCLUDED_FUNCTIONS_MK michael@0: include $(topsrcdir)/config/makefiles/functions.mk michael@0: endif michael@0: michael@0: RM = rm -f michael@0: michael@0: # LIBXUL_DIST is not defined under js/src, thus we make it mean DIST there. michael@0: LIBXUL_DIST ?= $(DIST) michael@0: michael@0: # FINAL_TARGET specifies the location into which we copy end-user-shipped michael@0: # build products (typelibs, components, chrome). It may already be specified by michael@0: # a moz.build file. michael@0: # michael@0: # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME) michael@0: # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be michael@0: # shipped to a $(DIST_SUBDIR) subdirectory. michael@0: FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%) michael@0: # Override the stored value for the check to make sure that the variable is not michael@0: # redefined in the Makefile.in value. michael@0: FINAL_TARGET_FROZEN := '$(FINAL_TARGET)' michael@0: michael@0: ifdef XPI_NAME michael@0: DEFINES += -DXPI_NAME=$(XPI_NAME) michael@0: endif michael@0: michael@0: # The VERSION_NUMBER is suffixed onto the end of the DLLs we ship. michael@0: VERSION_NUMBER = 50 michael@0: michael@0: ifeq ($(HOST_OS_ARCH),WINNT) michael@0: win_srcdir := $(subst $(topsrcdir),$(WIN_TOP_SRC),$(srcdir)) michael@0: BUILD_TOOLS = $(WIN_TOP_SRC)/build/unix michael@0: else michael@0: win_srcdir := $(srcdir) michael@0: BUILD_TOOLS = $(topsrcdir)/build/unix michael@0: endif michael@0: michael@0: CONFIG_TOOLS = $(MOZ_BUILD_ROOT)/config michael@0: AUTOCONF_TOOLS = $(topsrcdir)/build/autoconf michael@0: michael@0: # Disable MOZ_PSEUDO_DERECURSE when it contains no-pymake and we're running michael@0: # pymake. This can be removed when no-pymake is removed from the default in michael@0: # build/autoconf/compiler-opts.m4. michael@0: ifdef .PYMAKE michael@0: comma = , michael@0: ifneq (,$(filter no-pymake,$(subst $(comma), ,$(MOZ_PSEUDO_DERECURSE)))) michael@0: MOZ_PSEUDO_DERECURSE := michael@0: endif michael@0: endif michael@0: michael@0: # Disable MOZ_PSEUDO_DERECURSE on PGO builds until it's fixed. michael@0: ifneq (,$(MOZ_PROFILE_USE)$(MOZ_PROFILE_GENERATE)) michael@0: MOZ_PSEUDO_DERECURSE := michael@0: endif michael@0: michael@0: # michael@0: # Strip off the excessively long version numbers on these platforms, michael@0: # but save the version to allow multiple versions of the same base michael@0: # platform to be built in the same tree. michael@0: # michael@0: ifneq (,$(filter FreeBSD HP-UX Linux NetBSD OpenBSD SunOS,$(OS_ARCH))) michael@0: OS_RELEASE := $(basename $(OS_RELEASE)) michael@0: michael@0: # Allow the user to ignore the OS_VERSION, which is usually irrelevant. michael@0: ifdef WANT_MOZILLA_CONFIG_OS_VERSION michael@0: OS_VERS := $(suffix $(OS_RELEASE)) michael@0: OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//') michael@0: endif michael@0: michael@0: endif michael@0: michael@0: OS_CONFIG := $(OS_ARCH)$(OS_RELEASE) michael@0: michael@0: ifdef _MSC_VER michael@0: CC_WRAPPER ?= $(call py_action,cl) michael@0: CXX_WRAPPER ?= $(call py_action,cl) michael@0: endif # _MSC_VER michael@0: michael@0: CC := $(CC_WRAPPER) $(CC) michael@0: CXX := $(CXX_WRAPPER) $(CXX) michael@0: MKDIR ?= mkdir michael@0: SLEEP ?= sleep michael@0: TOUCH ?= touch michael@0: michael@0: ifdef .PYMAKE michael@0: PYCOMMANDPATH += $(PYTHON_SITE_PACKAGES) michael@0: endif michael@0: michael@0: PYTHON_PATH = $(PYTHON) $(topsrcdir)/config/pythonpath.py michael@0: michael@0: # determine debug-related options michael@0: _DEBUG_ASFLAGS := michael@0: _DEBUG_CFLAGS := michael@0: _DEBUG_LDFLAGS := michael@0: michael@0: ifdef MOZ_DEBUG michael@0: _DEBUG_CFLAGS += $(MOZ_DEBUG_ENABLE_DEFS) michael@0: XULPPFLAGS += $(MOZ_DEBUG_ENABLE_DEFS) michael@0: else michael@0: _DEBUG_CFLAGS += $(MOZ_DEBUG_DISABLE_DEFS) michael@0: XULPPFLAGS += $(MOZ_DEBUG_DISABLE_DEFS) michael@0: endif michael@0: michael@0: ifneq (,$(MOZ_DEBUG)$(MOZ_DEBUG_SYMBOLS)) michael@0: ifeq ($(AS),yasm) michael@0: ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) michael@0: _DEBUG_ASFLAGS += -g cv8 michael@0: else michael@0: ifneq ($(OS_ARCH),Darwin) michael@0: _DEBUG_ASFLAGS += -g dwarf2 michael@0: endif michael@0: endif michael@0: else michael@0: _DEBUG_ASFLAGS += $(MOZ_DEBUG_FLAGS) michael@0: endif michael@0: _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS) michael@0: _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS) michael@0: endif michael@0: michael@0: MOZALLOC_LIB = $(call EXPAND_LIBNAME_PATH,mozalloc,$(DIST)/lib) michael@0: michael@0: ASFLAGS += $(_DEBUG_ASFLAGS) michael@0: OS_CFLAGS += $(_DEBUG_CFLAGS) michael@0: OS_CXXFLAGS += $(_DEBUG_CFLAGS) michael@0: OS_LDFLAGS += $(_DEBUG_LDFLAGS) michael@0: michael@0: # XXX: What does this? Bug 482434 filed for better explanation. michael@0: ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) michael@0: ifdef MOZ_DEBUG michael@0: ifneq (,$(MOZ_BROWSE_INFO)$(MOZ_BSCFILE)) michael@0: OS_CFLAGS += -FR michael@0: OS_CXXFLAGS += -FR michael@0: endif michael@0: else # ! MOZ_DEBUG michael@0: michael@0: # MOZ_DEBUG_SYMBOLS generates debug symbols in separate PDB files. michael@0: # Used for generating an optimized build with debugging symbols. michael@0: # Used in the Windows nightlies to generate symbols for crash reporting. michael@0: ifdef MOZ_DEBUG_SYMBOLS michael@0: OS_CXXFLAGS += -UDEBUG -DNDEBUG michael@0: OS_CFLAGS += -UDEBUG -DNDEBUG michael@0: ifdef HAVE_64BIT_OS michael@0: OS_LDFLAGS += -DEBUG -OPT:REF,ICF michael@0: else michael@0: OS_LDFLAGS += -DEBUG -OPT:REF michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # Handle trace-malloc and DMD in optimized builds. michael@0: # No opt to give sane callstacks. michael@0: # michael@0: ifneq (,$(NS_TRACE_MALLOC)$(MOZ_DMD)) michael@0: MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG michael@0: ifdef HAVE_64BIT_OS michael@0: OS_LDFLAGS = -DEBUG -OPT:REF,ICF michael@0: else michael@0: OS_LDFLAGS = -DEBUG -OPT:REF michael@0: endif michael@0: endif # NS_TRACE_MALLOC || MOZ_DMD michael@0: michael@0: endif # MOZ_DEBUG michael@0: michael@0: # We don't build a static CRT when building a custom CRT, michael@0: # it appears to be broken. So don't link to jemalloc if michael@0: # the Makefile wants static CRT linking. michael@0: ifeq ($(MOZ_MEMORY)_$(USE_STATIC_LIBS),1_1) michael@0: # Disable default CRT libs and add the right lib path for the linker michael@0: MOZ_GLUE_LDFLAGS= michael@0: endif michael@0: michael@0: endif # WINNT && !GNU_CC michael@0: michael@0: ifdef MOZ_GLUE_PROGRAM_LDFLAGS michael@0: DEFINES += -DMOZ_GLUE_IN_PROGRAM michael@0: else michael@0: MOZ_GLUE_PROGRAM_LDFLAGS=$(MOZ_GLUE_LDFLAGS) michael@0: endif michael@0: michael@0: # michael@0: # Build using PIC by default michael@0: # michael@0: _ENABLE_PIC=1 michael@0: michael@0: # Determine if module being compiled is destined michael@0: # to be merged into libxul michael@0: michael@0: ifneq (,$(filter xul xul-%,$(FINAL_LIBRARY) $(LIBRARY_NAME))) michael@0: LIBXUL_LIBRARY := 1 michael@0: endif michael@0: michael@0: ifdef LIBXUL_LIBRARY michael@0: ifdef IS_COMPONENT michael@0: $(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY) michael@0: endif michael@0: ifeq (,$(filter xul xul-%,$(LIBRARY_NAME))) michael@0: FORCE_STATIC_LIB=1 michael@0: endif michael@0: endif michael@0: michael@0: # If we are building this component into an extension/xulapp, it cannot be michael@0: # statically linked. In the future we may want to add a xulapp meta-component michael@0: # build option. michael@0: michael@0: ifdef XPI_NAME michael@0: ifdef IS_COMPONENT michael@0: EXPORT_LIBRARY= michael@0: FORCE_STATIC_LIB= michael@0: FORCE_SHARED_LIB=1 michael@0: endif michael@0: endif michael@0: michael@0: ifndef SHARED_LIBRARY_NAME michael@0: ifdef LIBRARY_NAME michael@0: SHARED_LIBRARY_NAME=$(LIBRARY_NAME) michael@0: endif michael@0: endif michael@0: michael@0: ifndef STATIC_LIBRARY_NAME michael@0: ifdef LIBRARY_NAME michael@0: STATIC_LIBRARY_NAME=$(LIBRARY_NAME) michael@0: endif michael@0: endif michael@0: michael@0: # PGO on MSVC is opt-in michael@0: ifdef _MSC_VER michael@0: ifndef MSVC_ENABLE_PGO michael@0: NO_PROFILE_GUIDED_OPTIMIZE = 1 michael@0: endif michael@0: endif michael@0: michael@0: # No sense in profiling tools michael@0: ifdef INTERNAL_TOOLS michael@0: NO_PROFILE_GUIDED_OPTIMIZE = 1 michael@0: endif michael@0: michael@0: # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway, michael@0: # and we don't have the same build logic to re-link them in the second pass. michael@0: ifdef SIMPLE_PROGRAMS michael@0: NO_PROFILE_GUIDED_OPTIMIZE = 1 michael@0: endif michael@0: michael@0: # No sense in profiling unit tests michael@0: ifdef CPP_UNIT_TESTS michael@0: NO_PROFILE_GUIDED_OPTIMIZE = 1 michael@0: endif michael@0: michael@0: # Enable profile-based feedback michael@0: ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE)) michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS)) michael@0: OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS)) michael@0: OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS) michael@0: ifeq (WINNT,$(OS_ARCH)) michael@0: AR_FLAGS += -LTCG michael@0: endif michael@0: endif # MOZ_PROFILE_GENERATE michael@0: michael@0: ifdef MOZ_PROFILE_USE michael@0: OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS)) michael@0: OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS)) michael@0: OS_LDFLAGS += $(PROFILE_USE_LDFLAGS) michael@0: ifeq (WINNT,$(OS_ARCH)) michael@0: AR_FLAGS += -LTCG michael@0: endif michael@0: endif # MOZ_PROFILE_USE michael@0: endif # NO_PROFILE_GUIDED_OPTIMIZE michael@0: michael@0: ifdef _MSC_VER michael@0: OS_LDFLAGS += $(DELAYLOAD_LDFLAGS) michael@0: endif # _MSC_VER michael@0: michael@0: ifneq (,$(LIBXUL_LIBRARY)) michael@0: DEFINES += -DMOZILLA_INTERNAL_API michael@0: endif michael@0: michael@0: # Force XPCOM/widget/gfx methods to be _declspec(dllexport) when we're michael@0: # building libxul libraries michael@0: ifdef LIBXUL_LIBRARY michael@0: DEFINES += \ michael@0: -DIMPL_LIBXUL \ michael@0: $(NULL) michael@0: michael@0: ifndef JS_SHARED_LIBRARY michael@0: DEFINES += -DSTATIC_EXPORTABLE_JS_API michael@0: endif michael@0: endif michael@0: michael@0: MAKE_JARS_FLAGS = \ michael@0: -t $(topsrcdir) \ michael@0: -f $(MOZ_CHROME_FILE_FORMAT) \ michael@0: $(NULL) michael@0: michael@0: ifdef USE_EXTENSION_MANIFEST michael@0: MAKE_JARS_FLAGS += -e michael@0: endif michael@0: michael@0: TAR_CREATE_FLAGS = -chf michael@0: michael@0: # michael@0: # Personal makefile customizations go in these optional make include files. michael@0: # michael@0: MY_CONFIG := $(DEPTH)/config/myconfig.mk michael@0: MY_RULES := $(DEPTH)/config/myrules.mk michael@0: michael@0: # michael@0: # Default command macros; can be overridden in .mk. michael@0: # michael@0: CCC = $(CXX) michael@0: michael@0: # Java macros michael@0: JAVA_GEN_DIR = _javagen michael@0: JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR) michael@0: JAVA_IFACES_PKG_NAME = org/mozilla/interfaces michael@0: michael@0: OS_INCLUDES += $(MOZ_JPEG_CFLAGS) $(MOZ_PNG_CFLAGS) $(MOZ_ZLIB_CFLAGS) $(MOZ_PIXMAN_CFLAGS) michael@0: michael@0: # NSPR_CFLAGS and NSS_CFLAGS must appear ahead of OS_INCLUDES to avoid Linux michael@0: # builds wrongly picking up system NSPR/NSS header files. michael@0: INCLUDES = \ michael@0: -I$(srcdir) \ michael@0: -I. \ michael@0: $(LOCAL_INCLUDES) \ michael@0: -I$(DIST)/include \ michael@0: $(if $(LIBXUL_SDK),-I$(LIBXUL_SDK)/include) \ michael@0: $(NSPR_CFLAGS) $(NSS_CFLAGS) \ michael@0: $(OS_INCLUDES) \ michael@0: $(NULL) michael@0: michael@0: include $(topsrcdir)/config/static-checking-config.mk michael@0: michael@0: CFLAGS = $(OS_CPPFLAGS) $(OS_CFLAGS) michael@0: CXXFLAGS = $(OS_CPPFLAGS) $(OS_CXXFLAGS) michael@0: LDFLAGS = $(OS_LDFLAGS) $(MOZBUILD_LDFLAGS) $(MOZ_FIX_LINK_PATHS) michael@0: michael@0: # Allow each module to override the *default* optimization settings michael@0: # by setting MODULE_OPTIMIZE_FLAGS if the developer has not given michael@0: # arguments to --enable-optimize michael@0: ifdef MOZ_OPTIMIZE michael@0: ifeq (1,$(MOZ_OPTIMIZE)) michael@0: ifdef MODULE_OPTIMIZE_FLAGS michael@0: CFLAGS += $(MODULE_OPTIMIZE_FLAGS) michael@0: CXXFLAGS += $(MODULE_OPTIMIZE_FLAGS) michael@0: else michael@0: ifneq (,$(if $(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE),$(MOZ_PGO_OPTIMIZE_FLAGS))) michael@0: CFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) michael@0: CXXFLAGS += $(MOZ_PGO_OPTIMIZE_FLAGS) michael@0: else michael@0: CFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: endif # neq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) michael@0: endif # MODULE_OPTIMIZE_FLAGS michael@0: else michael@0: CFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: CXXFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: endif # MOZ_OPTIMIZE == 1 michael@0: LDFLAGS += $(MOZ_OPTIMIZE_LDFLAGS) michael@0: endif # MOZ_OPTIMIZE michael@0: michael@0: ifdef CROSS_COMPILE michael@0: HOST_CFLAGS += $(HOST_OPTIMIZE_FLAGS) michael@0: else michael@0: ifdef MOZ_OPTIMIZE michael@0: ifeq (1,$(MOZ_OPTIMIZE)) michael@0: ifdef MODULE_OPTIMIZE_FLAGS michael@0: HOST_CFLAGS += $(MODULE_OPTIMIZE_FLAGS) michael@0: else michael@0: HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: endif # MODULE_OPTIMIZE_FLAGS michael@0: else michael@0: HOST_CFLAGS += $(MOZ_OPTIMIZE_FLAGS) michael@0: endif # MOZ_OPTIMIZE == 1 michael@0: endif # MOZ_OPTIMIZE michael@0: endif # CROSS_COMPILE michael@0: michael@0: CFLAGS += $(MOZ_FRAMEPTR_FLAGS) michael@0: CXXFLAGS += $(MOZ_FRAMEPTR_FLAGS) michael@0: michael@0: # Check for FAIL_ON_WARNINGS & FAIL_ON_WARNINGS_DEBUG (Shorthand for Makefiles michael@0: # to request that we use the 'warnings as errors' compile flags) michael@0: michael@0: # NOTE: First, we clear FAIL_ON_WARNINGS[_DEBUG] if we're doing a Windows PGO michael@0: # build, since WARNINGS_AS_ERRORS has been suspected of causing isuses in that michael@0: # situation. (See bug 437002.) michael@0: ifeq (WINNT_1,$(OS_ARCH)_$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) michael@0: FAIL_ON_WARNINGS_DEBUG= michael@0: FAIL_ON_WARNINGS= michael@0: endif # WINNT && (MOS_PROFILE_GENERATE ^ MOZ_PROFILE_USE) michael@0: michael@0: # Now, check for debug version of flag; it turns on normal flag in debug builds. michael@0: ifdef FAIL_ON_WARNINGS_DEBUG michael@0: ifdef MOZ_DEBUG michael@0: FAIL_ON_WARNINGS = 1 michael@0: endif # MOZ_DEBUG michael@0: endif # FAIL_ON_WARNINGS_DEBUG michael@0: michael@0: # Check for normal version of flag, and add WARNINGS_AS_ERRORS if it's set to 1. michael@0: ifdef FAIL_ON_WARNINGS michael@0: CXXFLAGS += $(WARNINGS_AS_ERRORS) michael@0: CFLAGS += $(WARNINGS_AS_ERRORS) michael@0: endif # FAIL_ON_WARNINGS michael@0: michael@0: ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_) michael@0: #// Currently, unless USE_STATIC_LIBS is defined, the multithreaded michael@0: #// DLL version of the RTL is used... michael@0: #// michael@0: #//------------------------------------------------------------------------ michael@0: ifdef USE_STATIC_LIBS michael@0: RTL_FLAGS=-MT # Statically linked multithreaded RTL michael@0: ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)) michael@0: ifndef MOZ_NO_DEBUG_RTL michael@0: RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL michael@0: endif michael@0: endif # MOZ_DEBUG || NS_TRACE_MALLOC michael@0: michael@0: else # !USE_STATIC_LIBS michael@0: michael@0: RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL michael@0: ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC)) michael@0: ifndef MOZ_NO_DEBUG_RTL michael@0: RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL michael@0: endif michael@0: endif # MOZ_DEBUG || NS_TRACE_MALLOC michael@0: endif # USE_STATIC_LIBS michael@0: endif # WINNT && !GNU_CC michael@0: michael@0: ifeq ($(OS_ARCH),Darwin) michael@0: # Compiling ObjC requires an Apple compiler anyway, so it's ok to set michael@0: # host CMFLAGS here. michael@0: HOST_CMFLAGS += -fobjc-exceptions michael@0: HOST_CMMFLAGS += -fobjc-exceptions michael@0: OS_COMPILE_CMFLAGS += -fobjc-exceptions michael@0: OS_COMPILE_CMMFLAGS += -fobjc-exceptions michael@0: ifeq ($(MOZ_WIDGET_TOOLKIT),uikit) michael@0: OS_COMPILE_CMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch michael@0: OS_COMPILE_CMMFLAGS += -fobjc-abi-version=2 -fobjc-legacy-dispatch michael@0: endif michael@0: endif michael@0: michael@0: COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(RTL_FLAGS) $(OS_CPPFLAGS) $(OS_COMPILE_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(EXTRA_COMPILE_FLAGS) michael@0: 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) michael@0: COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) $(EXTRA_COMPILE_FLAGS) michael@0: COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) $(EXTRA_COMPILE_FLAGS) michael@0: ASFLAGS += $(EXTRA_ASSEMBLER_FLAGS) michael@0: michael@0: ifndef CROSS_COMPILE michael@0: HOST_CFLAGS += $(RTL_FLAGS) michael@0: endif michael@0: michael@0: # michael@0: # Name of the binary code directories michael@0: # michael@0: # Override defaults michael@0: michael@0: # We need to know where to find the libraries we michael@0: # put on the link line for binaries, and should michael@0: # we link statically or dynamic? Assuming dynamic for now. michael@0: michael@0: ifneq (WINNT_,$(OS_ARCH)_$(GNU_CC)) michael@0: LIBS_DIR = -L$(DIST)/bin -L$(DIST)/lib michael@0: ifdef LIBXUL_SDK michael@0: LIBS_DIR += -L$(LIBXUL_SDK)/bin -L$(LIBXUL_SDK)/lib michael@0: endif michael@0: endif michael@0: michael@0: # Default location of include files michael@0: ifndef LIBXUL_SDK michael@0: IDL_PARSER_DIR = $(topsrcdir)/xpcom/idl-parser michael@0: IDL_PARSER_CACHE_DIR = $(DEPTH)/xpcom/idl-parser michael@0: else michael@0: IDL_PARSER_DIR = $(LIBXUL_SDK)/sdk/bin michael@0: IDL_PARSER_CACHE_DIR = $(LIBXUL_SDK)/sdk/bin michael@0: endif michael@0: michael@0: SDK_LIB_DIR = $(DIST)/sdk/lib michael@0: SDK_BIN_DIR = $(DIST)/sdk/bin michael@0: michael@0: DEPENDENCIES = .md michael@0: michael@0: MOZ_COMPONENT_LIBS=$(XPCOM_LIBS) $(MOZ_COMPONENT_NSPR_LIBS) michael@0: michael@0: ifdef MACOSX_DEPLOYMENT_TARGET michael@0: export MACOSX_DEPLOYMENT_TARGET michael@0: endif # MACOSX_DEPLOYMENT_TARGET michael@0: michael@0: ifdef MOZ_USING_CCACHE michael@0: ifdef CLANG_CXX michael@0: export CCACHE_CPP2=1 michael@0: endif michael@0: endif michael@0: michael@0: # Set link flags according to whether we want a console. michael@0: ifdef MOZ_WINCONSOLE michael@0: ifeq ($(MOZ_WINCONSOLE),1) michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: ifdef GNU_CC michael@0: WIN32_EXE_LDFLAGS += -mconsole michael@0: else michael@0: WIN32_EXE_LDFLAGS += -SUBSYSTEM:CONSOLE michael@0: endif michael@0: endif michael@0: else # MOZ_WINCONSOLE michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: ifdef GNU_CC michael@0: WIN32_EXE_LDFLAGS += -mwindows michael@0: else michael@0: WIN32_EXE_LDFLAGS += -SUBSYSTEM:WINDOWS michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifdef _MSC_VER michael@0: ifeq ($(CPU_ARCH),x86_64) michael@0: # set stack to 2MB on x64 build. See bug 582910 michael@0: WIN32_EXE_LDFLAGS += -STACK:2097152 michael@0: endif michael@0: endif michael@0: michael@0: # If we're building a component on MSVC, we don't want to generate an michael@0: # import lib, because that import lib will collide with the name of a michael@0: # static version of the same library. michael@0: ifeq ($(GNU_LD)$(OS_ARCH),WINNT) michael@0: ifdef IS_COMPONENT michael@0: LDFLAGS += -IMPLIB:fake.lib michael@0: DELETE_AFTER_LINK = fake.lib fake.exp michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # Include any personal overrides the user might think are needed. michael@0: # michael@0: -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk michael@0: -include $(MY_CONFIG) michael@0: michael@0: ###################################################################### michael@0: michael@0: GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) $(wildcard *.err) $(wildcard *.pure) $(wildcard *_pure_*.o) Templates.DB michael@0: michael@0: ifeq ($(OS_ARCH),Darwin) michael@0: ifndef NSDISTMODE michael@0: NSDISTMODE=absolute_symlink michael@0: endif michael@0: PWD := $(CURDIR) michael@0: endif michael@0: michael@0: NSINSTALL_PY := $(PYTHON) $(abspath $(topsrcdir)/config/nsinstall.py) michael@0: # For Pymake, wherever we use nsinstall.py we're also going to try to make it michael@0: # a native command where possible. Since native commands can't be used outside michael@0: # of single-line commands, we continue to provide INSTALL for general use. michael@0: # Single-line commands should be switched over to install_cmd. michael@0: NSINSTALL_NATIVECMD := %nsinstall nsinstall michael@0: michael@0: ifdef NSINSTALL_BIN michael@0: NSINSTALL = $(NSINSTALL_BIN) michael@0: else michael@0: ifeq ($(HOST_OS_ARCH),WINNT) michael@0: NSINSTALL = $(NSINSTALL_PY) michael@0: else michael@0: NSINSTALL = $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX) michael@0: endif # WINNT michael@0: endif # NSINSTALL_BIN michael@0: michael@0: michael@0: ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH))) michael@0: INSTALL = $(NSINSTALL) -t michael@0: ifdef .PYMAKE michael@0: install_cmd = $(NSINSTALL_NATIVECMD) -t $(1) michael@0: endif # .PYMAKE michael@0: michael@0: else michael@0: michael@0: # This isn't laid out as conditional directives so that NSDISTMODE can be michael@0: # target-specific. michael@0: INSTALL = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R)) michael@0: michael@0: endif # WINNT michael@0: michael@0: # The default for install_cmd is simply INSTALL michael@0: install_cmd ?= $(INSTALL) $(1) michael@0: michael@0: # Use nsinstall in copy mode to install files on the system michael@0: SYSINSTALL = $(NSINSTALL) -t michael@0: # This isn't necessarily true, just here michael@0: sysinstall_cmd = install_cmd michael@0: michael@0: # michael@0: # Localization build automation michael@0: # michael@0: michael@0: # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode michael@0: # MOZ_UI_LOCALE directly, but use an intermediate variable that can be michael@0: # overridden by the command line. (Besides, AB_CD is prettier). michael@0: AB_CD = $(MOZ_UI_LOCALE) michael@0: michael@0: ifndef L10NBASEDIR michael@0: L10NBASEDIR = $(error L10NBASEDIR not defined by configure) michael@0: else michael@0: IS_LANGUAGE_REPACK = 1 michael@0: endif michael@0: michael@0: EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/$(1)/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/$(subst /locales,,$(1))) michael@0: michael@0: ifdef relativesrcdir michael@0: LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(relativesrcdir)) michael@0: endif michael@0: michael@0: ifdef relativesrcdir michael@0: MAKE_JARS_FLAGS += --relativesrcdir=$(relativesrcdir) michael@0: ifneq (en-US,$(AB_CD)) michael@0: ifdef LOCALE_MERGEDIR michael@0: MAKE_JARS_FLAGS += --locale-mergedir=$(LOCALE_MERGEDIR) michael@0: endif michael@0: ifdef IS_LANGUAGE_REPACK michael@0: MAKE_JARS_FLAGS += --l10n-base=$(L10NBASEDIR)/$(AB_CD) michael@0: endif michael@0: else michael@0: MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR) michael@0: endif # en-US michael@0: else michael@0: MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR) michael@0: endif # ! relativesrcdir michael@0: michael@0: ifdef LOCALE_MERGEDIR michael@0: MERGE_FILE = $(firstword \ michael@0: $(wildcard $(LOCALE_MERGEDIR)/$(subst /locales,,$(relativesrcdir))/$(1)) \ michael@0: $(wildcard $(LOCALE_SRCDIR)/$(1)) \ michael@0: $(srcdir)/en-US/$(1) ) michael@0: else michael@0: MERGE_FILE = $(LOCALE_SRCDIR)/$(1) michael@0: endif michael@0: MERGE_FILES = $(foreach f,$(1),$(call MERGE_FILE,$(f))) michael@0: michael@0: ifneq (WINNT,$(OS_ARCH)) michael@0: RUN_TEST_PROGRAM = $(LIBXUL_DIST)/bin/run-mozilla.sh michael@0: endif # ! WINNT michael@0: michael@0: # michael@0: # Java macros michael@0: # michael@0: michael@0: # Make sure any compiled classes work with at least JVM 1.4 michael@0: JAVAC_FLAGS += -source 1.4 michael@0: michael@0: ifdef MOZ_DEBUG michael@0: JAVAC_FLAGS += -g michael@0: endif michael@0: michael@0: CREATE_PRECOMPLETE_CMD = $(PYTHON) $(abspath $(topsrcdir)/config/createprecomplete.py) michael@0: michael@0: # MDDEPDIR is the subdirectory where dependency files are stored michael@0: MDDEPDIR := .deps michael@0: michael@0: EXPAND_LIBS_EXEC = $(PYTHON) $(topsrcdir)/config/expandlibs_exec.py $(if $@,--depend $(MDDEPDIR)/$@.pp --target $@) michael@0: EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/expandlibs_gen.py $(if $@,--depend $(MDDEPDIR)/$@.pp) michael@0: EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR) michael@0: EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC) michael@0: EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC) michael@0: EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD) michael@0: EXPAND_MKSHLIB_ARGS = --uselist michael@0: ifdef SYMBOL_ORDER michael@0: EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER) michael@0: endif michael@0: EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB) michael@0: michael@0: ifneq (,$(MOZ_LIBSTDCXX_TARGET_VERSION)$(MOZ_LIBSTDCXX_HOST_VERSION)) michael@0: ifneq ($(OS_ARCH),Darwin) michael@0: 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 michael@0: endif michael@0: michael@0: ifdef MOZ_LIBSTDCXX_TARGET_VERSION michael@0: EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat) michael@0: endif michael@0: ifdef MOZ_LIBSTDCXX_HOST_VERSION michael@0: HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat) michael@0: endif michael@0: endif michael@0: michael@0: ifeq (,$(filter $(OS_TARGET),WINNT Darwin)) michael@0: 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 michael@0: endif michael@0: michael@0: define CHECK_BINARY michael@0: $(call CHECK_STDCXX,$(1)) michael@0: $(call CHECK_TEXTREL,$(1)) michael@0: endef michael@0: michael@0: # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including michael@0: # this file michael@0: OBJ_SUFFIX := $(_OBJ_SUFFIX) michael@0: michael@0: # PGO builds with GCC build objects with instrumentation in a first pass, michael@0: # then objects optimized, without instrumentation, in a second pass. If michael@0: # we overwrite the objects from the first pass with those from the second, michael@0: # we end up not getting instrumentation data for better optimization on michael@0: # incremental builds. As a consequence, we use a different object suffix michael@0: # for the first pass. michael@0: ifndef NO_PROFILE_GUIDED_OPTIMIZE michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: ifdef GNU_CC michael@0: OBJ_SUFFIX := i_o michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo) michael@0: # expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker michael@0: # arguments syntax. Should only be used for system libraries michael@0: michael@0: # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir) michael@0: # expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX) michael@0: michael@0: # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo) michael@0: # expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX) michael@0: michael@0: ifdef GNU_CC michael@0: EXPAND_LIBNAME = $(addprefix -l,$(1)) michael@0: else michael@0: EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) michael@0: endif michael@0: EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) michael@0: EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX)) michael@0: michael@0: PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply michael@0: michael@0: export CL_INCLUDES_PREFIX michael@0: # Make sure that the build system can handle non-ASCII characters michael@0: # in environment variables to prevent it from breking silently on michael@0: # non-English systems. michael@0: export NONASCII michael@0: michael@0: ifdef MOZ_GTK2_CFLAGS michael@0: MOZ_GTK2_CFLAGS := -I$(topsrcdir)/widget/gtk/compat $(MOZ_GTK2_CFLAGS) michael@0: endif michael@0: michael@0: DEFINES += -DNO_NSPR_10_SUPPORT michael@0: michael@0: ifdef IS_GYP_DIR michael@0: LOCAL_INCLUDES += \ michael@0: -I$(topsrcdir)/ipc/chromium/src \ michael@0: -I$(topsrcdir)/ipc/glue \ michael@0: -I$(DEPTH)/ipc/ipdl/_ipdlheaders \ michael@0: $(NULL) michael@0: michael@0: ifeq (WINNT,$(OS_TARGET)) michael@0: # These get set via VC project file settings for normal GYP builds. michael@0: DEFINES += -DUNICODE -D_UNICODE michael@0: endif michael@0: michael@0: DISABLE_STL_WRAPPING := 1 michael@0: # Skip most Mozilla-specific include locations. michael@0: INCLUDES = -I. $(LOCAL_INCLUDES) -I$(DEPTH)/dist/include michael@0: endif