--- a/config/recurse.mk
+++ b/config/recurse.mk
@@ -1,52 +1,158 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
ifndef INCLUDED_RULES_MK
include $(topsrcdir)/config/rules.mk
endif
+# The traditional model of directory traversal with make is as follows:
+# make -C foo
+# Entering foo
+# make -C bar
+# Entering foo/bar
+# make -C baz
+# Entering foo/baz
+# make -C qux
+# Entering qux
+#
+# Pseudo derecurse transforms the above into:
+# make -C foo
+# make -C foo/bar
+# make -C foo/baz
+# make -C qux
+
+ifeq (.,$(DEPTH))
+
+include root.mk
+
+# Disable build status for mach in top directories without TIERS.
+# In practice this disables it when recursing under js/src, which confuses mach.
+ifndef TIERS
+BUILDSTATUS =
+endif
+
+# Main rules (export, compile, libs and tools) call recurse_* rules.
+# This wrapping is only really useful for build status.
+compile libs export tools::
+ $(call BUILDSTATUS,TIER_START $@)
+ +$(MAKE) recurse_$@
+ $(call BUILDSTATUS,TIER_FINISH $@)
+
+# Special rule that does install-manifests (cf. Makefile.in) + compile
+binaries::
+ +$(MAKE) recurse_compile
+
+# Carefully avoid $(eval) type of rule generation, which makes pymake slower
+# than necessary.
+# Get current tier and corresponding subtiers from the data in root.mk.
+CURRENT_TIER := $(filter $(foreach tier,compile libs export tools,recurse_$(tier) $(tier)-deps),$(MAKECMDGOALS))
+ifneq (,$(filter-out 0 1,$(words $(CURRENT_TIER))))
+$(error $(CURRENT_TIER) not supported on the same make command line)
+endif
+CURRENT_TIER := $(subst recurse_,,$(CURRENT_TIER:-deps=))
+
+# The rules here are doing directory traversal, so we don't want further
+# recursion to happen when running make -C subdir $tier. But some make files
+# further call make -C something else, and sometimes expect recursion to
+# happen in that case (see browser/metro/locales/Makefile.in for example).
+# Conveniently, every invocation of make increases MAKELEVEL, so only stop
+# recursion from happening at current MAKELEVEL + 1.
+ifdef CURRENT_TIER
+ifeq (0,$(MAKELEVEL))
+export NO_RECURSE_MAKELEVEL=1
+else
+export NO_RECURSE_MAKELEVEL=$(word $(MAKELEVEL),2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
+endif
+endif
+
+# Get all directories traversed for all subtiers in the current tier, or use
+# directly the $(*_dirs) variables available in root.mk when there is no
+# TIERS (like for js/src).
+CURRENT_DIRS := $($(CURRENT_TIER)_dirs)
+
+# The compile tier has different rules from other tiers.
+ifeq ($(CURRENT_TIER),compile)
+
+# Need a list of compile targets because we can't use pattern rules:
+# https://savannah.gnu.org/bugs/index.php?42833
+.PHONY: $(compile_targets)
+$(compile_targets):
+ $(call SUBMAKE,$(if $(filter $(@D),$(staticdirs)),,$(@F)),$(@D))
+
+else
+
+# Recursion rule for all directories traversed for all subtiers in the
+# current tier.
+$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): %/$(CURRENT_TIER):
+ $(call SUBMAKE,$(CURRENT_TIER),$*)
+
+.PHONY: $(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS))
+
+# Dummy rules for possibly inexisting dependencies for the above tier targets
+$(addsuffix /Makefile,$(CURRENT_DIRS)) $(addsuffix /backend.mk,$(CURRENT_DIRS)):
+
+ifeq ($(CURRENT_TIER),export)
+# At least build/export requires config/export for buildid, but who knows what
+# else, so keep this global dependency to make config/export first for now.
+$(addsuffix /$(CURRENT_TIER),$(filter-out config,$(CURRENT_DIRS))): config/$(CURRENT_TIER)
+
+# The export tier requires nsinstall, which is built from config. So every
+# subdirectory traversal needs to happen after building nsinstall in config,
+# which is done with the config/host target. Note the config/host target only
+# exists if nsinstall is actually built, which it is not on Windows, because we
+# use nsinstall.py there.
+ifneq (,$(filter config/host, $(compile_targets)))
+$(addsuffix /$(CURRENT_TIER),$(CURRENT_DIRS)): config/host
+
+# Ensure rules for config/host and its possible dependencies.
+.PHONY: $(filter %/host, $(compile_targets))
+$(filter %/host, $(compile_targets)):
+ $(call SUBMAKE,host,$(@D))
+endif
+endif
+
+endif # ifeq ($(CURRENT_TIER),compile)
+
+else
+
+# Don't recurse if MAKELEVEL is NO_RECURSE_MAKELEVEL as defined above
+ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
+
+compile libs export tools::
+
+else
#########################
# Tier traversal handling
#########################
ifdef TIERS
-compile libs export tools::
- $(call BUILDSTATUS,TIER_START $@ $(filter-out $(if $(filter export,$@),,precompile),$(TIERS)))
- $(foreach tier,$(TIERS), $(if $(filter-out compile_precompile libs_precompile tools_precompile,$@_$(tier)), \
- $(call BUILDSTATUS,SUBTIER_START $@ $(tier) $(if $(filter libs,$@),$(tier_$(tier)_staticdirs)) $(tier_$(tier)_dirs)) \
+libs export tools::
+ $(call BUILDSTATUS,TIER_START $@)
+ $(foreach tier,$(TIERS), $(if $(filter-out libs_precompile tools_precompile,$@_$(tier)), \
$(if $(filter libs,$@),$(foreach dir, $(tier_$(tier)_staticdirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),,1))) \
- $(foreach dir, $(tier_$(tier)_dirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),$@)) \
- $(call BUILDSTATUS,SUBTIER_FINISH $@ $(tier))))
+ $(foreach dir, $(tier_$(tier)_dirs), $(call TIER_DIR_SUBMAKE,$@,$(tier),$(dir),$@))))
$(call BUILDSTATUS,TIER_FINISH $@)
else
define CREATE_SUBTIER_TRAVERSAL_RULE
-PARALLEL_DIRS_$(1) = $$(addsuffix _$(1),$$(PARALLEL_DIRS))
-
-.PHONY: $(1) $$(PARALLEL_DIRS_$(1))
-
-ifdef PARALLEL_DIRS
-$$(PARALLEL_DIRS_$(1)): %_$(1): %/Makefile
- +@$$(call SUBMAKE,$(1),$$*)
-endif
+.PHONY: $(1)
$(1):: $$(SUBMAKEFILES)
-ifdef PARALLEL_DIRS
- +@$(MAKE) $$(PARALLEL_DIRS_$(1))
-endif
$$(LOOP_OVER_DIRS)
endef
-$(foreach subtier,export compile libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
+$(foreach subtier,export libs tools,$(eval $(call CREATE_SUBTIER_TRAVERSAL_RULE,$(subtier))))
-compile export:: $(SUBMAKEFILES)
- $(LOOP_OVER_TOOL_DIRS)
+endif # ifdef TIERS
+
+endif # ifeq ($(NO_RECURSE_MAKELEVEL),$(MAKELEVEL))
-tools:: $(SUBMAKEFILES)
- $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
+endif # ifeq (.,$(DEPTH))
-endif
+recurse:
+ @$(RECURSED_COMMAND)
+ $(LOOP_OVER_DIRS)
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -14,94 +14,89 @@ ifdef INCLUDED_RULES_MK
$(error Do not include rules.mk twice!)
endif
INCLUDED_RULES_MK = 1
# Make sure that anything that needs to be defined in moz.build wasn't
# overwritten.
_eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES)
-ifdef TIERS
-DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
-STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
-endif
-
ifndef MOZILLA_DIR
MOZILLA_DIR = $(MOZILLA_SRCDIR)
endif
ifndef INCLUDED_CONFIG_MK
include $(topsrcdir)/config/config.mk
endif
ifndef INCLUDED_VERSION_MK
include $(topsrcdir)/config/version.mk
endif
USE_AUTOTARGETS_MK = 1
include $(topsrcdir)/config/makefiles/makeutils.mk
-ifdef SDK_HEADERS
-EXPORTS += $(SDK_HEADERS)
-endif
-
REPORT_BUILD = $(info $(notdir $<))
EXEC = exec
-# Don't copy xulrunner files at install time, when using system xulrunner
-ifdef SYSTEM_LIBXUL
- SKIP_COPY_XULRUNNER=1
-endif
-
# ELOG prints out failed command when building silently (gmake -s). Pymake
# prints out failed commands anyway, so ELOG just makes things worse by
# forcing shell invocations.
ifndef .PYMAKE
ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
else
ELOG :=
endif # -s
else
ELOG :=
endif # ifndef .PYMAKE
_VPATH_SRCS = $(abspath $<)
-# Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
-VPATH += $(DIST)/lib
-ifdef LIBXUL_SDK
-VPATH += $(LIBXUL_SDK)/lib
-endif
-
################################################################################
# Testing frameworks support
################################################################################
ifdef ENABLE_TESTS
+# Add test directories to the regular directories list. TEST_DIRS should
+# arguably have the same status as other *_DIRS variables. It is coded this way
+# until Makefiles stop using the "ifdef ENABLE_TESTS; DIRS +=" convention.
+#
+# The current developer workflow expects tests to be updated when processing
+# the default target. If we ever change this implementation, the behavior
+# should be preserved or the change should be widely communicated. A
+# consequence of not processing test dir targets during the default target is
+# that changes to tests may not be updated and code could assume to pass
+# locally against non-current test code.
DIRS += $(TEST_DIRS)
ifdef CPP_UNIT_TESTS
+ifdef COMPILE_ENVIRONMENT
# Compile the tests to $(DIST)/bin. Make lots of niceties available by default
# through TestHarness.h, by modifying the list of includes and the libs against
# which stuff links.
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS)
INCLUDES += -I$(DIST)/include/testing
-LIBS += $(NSPR_LIBS)
+EXTRA_LIBS += $(NSPR_LIBS)
-# ...and run them the usual way
-check::
- @$(EXIT_ON_ERROR) \
- for f in $(CPP_UNIT_TESTS); do \
- XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
- done
+ifndef MOZ_PROFILE_GENERATE
+CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)
+CPP_UNIT_TESTS_DEST = $(DIST)/cppunittests
+CPP_UNIT_TESTS_TARGET = target
+INSTALL_TARGETS += CPP_UNIT_TESTS
+endif
+run-cppunittests::
+ @$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
+
+endif # COMPILE_ENVIRONMENT
endif # CPP_UNIT_TESTS
.PHONY: check xpcshell-tests check-interactive check-one
endif # ENABLE_TESTS
#
@@ -162,93 +157,109 @@ ifndef GNU_CC
# without SP1, don't do parallel builds.
#
# The final PDB for libraries and programs is created by the linker and uses
# a different name from the single PDB file created by the compiler. See
# bug 462740.
#
ifdef SIMPLE_PROGRAMS
-COMPILE_PDBFILE = $(basename $(@F)).pdb
+COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb
else
-COMPILE_PDBFILE = generated.pdb
+COMPILE_PDB_FLAG ?= -Fdgenerated.pdb
endif
+COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
+COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
-LINK_PDBFILE = $(basename $(@F)).pdb
+LINK_PDBFILE ?= $(basename $(@F)).pdb
ifdef MOZ_DEBUG
CODFILE=$(basename $(@F)).cod
endif
-ifdef MOZ_MAPINFO
-ifdef SHARED_LIBRARY_NAME
-MAPFILE=$(SHARED_LIBRARY_NAME).map
-else
-MAPFILE=$(basename $(@F)).map
-endif # SHARED_LIBRARY_NAME
-endif # MOZ_MAPINFO
-
ifdef DEFFILE
OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
EXTRA_DEPS += $(DEFFILE)
endif
-ifdef MAPFILE
-OS_LDFLAGS += -MAP:$(MAPFILE)
+else #!GNU_CC
+
+ifdef DEFFILE
+OS_LDFLAGS += $(call normalizepath,$(DEFFILE))
+EXTRA_DEPS += $(DEFFILE)
endif
endif # !GNU_CC
endif # WINNT
ifeq ($(SOLARIS_SUNPRO_CXX),1)
ifeq (86,$(findstring 86,$(OS_TEST)))
OS_LDFLAGS += -M $(MOZILLA_DIR)/config/solaris_ia32.map
endif # x86
endif # Solaris Sun Studio C++
ifeq ($(HOST_OS_ARCH),WINNT)
HOST_PDBFILE=$(basename $(@F)).pdb
+HOST_PDB_FLAG ?= -Fd$(HOST_PDBFILE)
+HOST_CFLAGS += $(HOST_PDB_FLAG)
+HOST_CXXFLAGS += $(HOST_PDB_FLAG)
endif
+# Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass
+ifdef MOZ_PROFILE_GENERATE
+SIMPLE_PROGRAMS :=
+endif
+
+ifdef COMPILE_ENVIRONMENT
ifndef TARGETS
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS)
endif
+COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX)))
+SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX)))
+# CPPSRCS can have different extensions (eg: .cpp, .cc)
+CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS))))
+CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX)))
+CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX)))
+ASOBJS = $(notdir $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX)))
ifndef OBJS
-_OBJS = \
- $(JRI_STUB_CFILES) \
- $(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
- $(CSRCS:.c=.$(OBJ_SUFFIX)) \
- $(SSRCS:.S=.$(OBJ_SUFFIX)) \
- $(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
- $(CMSRCS:.m=.$(OBJ_SUFFIX)) \
- $(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
- $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
-OBJS = $(strip $(_OBJS))
+_OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS)
+OBJS = $(strip $(_OBJS))
endif
+HOST_COBJS = $(addprefix host_,$(notdir $(HOST_CSRCS:.c=.$(OBJ_SUFFIX))))
+# HOST_CPPOBJS can have different extensions (eg: .cpp, .cc)
+HOST_CPPOBJS = $(addprefix host_,$(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(HOST_CPPSRCS)))))
+HOST_CMOBJS = $(addprefix host_,$(notdir $(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))))
+HOST_CMMOBJS = $(addprefix host_,$(notdir $(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX))))
ifndef HOST_OBJS
-_HOST_OBJS = \
- $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX))) \
- $(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(HOST_CPPSRCS:.cpp=.$(OBJ_SUFFIX)))) \
- $(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))) \
- $(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
+_HOST_OBJS = $(HOST_COBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
HOST_OBJS = $(strip $(_HOST_OBJS))
endif
-
-LIBOBJS := $(addprefix \", $(OBJS))
-LIBOBJS := $(addsuffix \", $(LIBOBJS))
+else
+LIBRARY :=
+SHARED_LIBRARY :=
+IMPORT_LIBRARY :=
+REAL_LIBRARY :=
+PROGRAM :=
+SIMPLE_PROGRAMS :=
+HOST_LIBRARY :=
+HOST_PROGRAM :=
+HOST_SIMPLE_PROGRAMS :=
+SDK_BINARY := $(filter %.py,$(SDK_BINARY))
+SDK_LIBRARY :=
+endif
ALL_TRASH = \
$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
- $(OBJS:.$(OBJ_SUFFIX)=.i) \
+ $(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
$(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) \
$(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
- $(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
+ $(wildcard *.pdb) $(CODFILE) $(IMPORT_LIBRARY) \
$(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
$(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
$(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
$(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
$(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
ALL_TRASH_DIRS = \
$(GARBAGE_DIRS) /no-such-file
@@ -267,74 +278,61 @@ endif
ifeq ($(SOLARIS_SUNPRO_CXX),1)
GARBAGE_DIRS += SunWS_cache
endif
ifdef MOZ_UPDATE_XTERM
# Its good not to have a newline at the end of the titlebar string because it
# makes the make -s output easier to read. Echo -n does not work on all
# platforms, but we can trick printf into doing it.
+ifeq (.,$(relativesrcdir))
+UPDATE_TITLE = printf '\033]0;%s in %s\007' $(1) $(2) ;
+else
UPDATE_TITLE = printf '\033]0;%s in %s\007' $(1) $(relativesrcdir)/$(2) ;
endif
+endif
-define SUBMAKE # $(call SUBMAKE,target,directory)
+ifdef MACH
+ifndef NO_BUILDSTATUS_MESSAGES
+define BUILDSTATUS
+@echo 'BUILDSTATUS $1'
+
+endef
+endif
+endif
+
+define SUBMAKE # $(call SUBMAKE,target,directory,static)
+@$(UPDATE_TITLE)
+@$(MAKE) $(if $(2),-C $(2)) $(1)
endef # The extra line is important here! don't delete it
+define TIER_DIR_SUBMAKE
+$(call SUBMAKE,$(4),$(3),$(5))
+
+endef # Ths empty line is important.
+
ifneq (,$(strip $(DIRS)))
LOOP_OVER_DIRS = \
$(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
endif
-# we only use this for the makefiles target and other stuff that doesn't matter
-ifneq (,$(strip $(PARALLEL_DIRS)))
-LOOP_OVER_PARALLEL_DIRS = \
- $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir)))
-endif
-
-ifneq (,$(strip $(STATIC_DIRS)))
-LOOP_OVER_STATIC_DIRS = \
- $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir)))
-endif
-
-ifneq (,$(strip $(TOOL_DIRS)))
-LOOP_OVER_TOOL_DIRS = \
- $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir)))
-endif
-
-ifdef PARALLEL_DIRS
-# create a bunch of fake targets for order-only processing
-PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
-PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
-PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
-
-.PHONY: $(PARALLEL_DIRS_export) $(PARALLEL_DIRS_libs) $(PARALLEL_DIRS_tools)
-endif
-
#
# Now we can differentiate between objects used to build a library, and
# objects used to build an executable in the same directory.
#
ifndef PROGOBJS
PROGOBJS = $(OBJS)
endif
ifndef HOST_PROGOBJS
HOST_PROGOBJS = $(HOST_OBJS)
endif
-# MAKE_DIRS: List of directories to build while looping over directories.
-# A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
-# variables we know to check can just set NEED_MDDEPDIR explicitly.
-ifneq (,$(OBJS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
-MAKE_DIRS += $(CURDIR)/$(MDDEPDIR)
-GARBAGE_DIRS += $(CURDIR)/$(MDDEPDIR)
-endif
+GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
#
# Tags: emacs (etags), vi (ctags)
# TAG_PROGRAM := ctags -L -
#
TAG_PROGRAM = xargs etags -a
#
@@ -383,17 +381,17 @@ endif
ifeq ($(OS_ARCH),FreeBSD)
ifdef IS_COMPONENT
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
endif
endif
ifeq ($(OS_ARCH),NetBSD)
ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
-ifeq ($(MODULE),layout)
+ifneq (,$(filter layout/%,$(relativesrcdir)))
OS_CFLAGS += -Wa,-xgot
OS_CXXFLAGS += -Wa,-xgot
endif
endif
endif
#
# HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
@@ -426,26 +424,36 @@ endif # AIX
#
# Linux: add -Bsymbolic flag for components
#
ifeq ($(OS_ARCH),Linux)
ifdef IS_COMPONENT
EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
endif
+ifdef LD_VERSION_SCRIPT
+EXTRA_DSO_LDOPTS += -Wl,--version-script,$(LD_VERSION_SCRIPT)
+EXTRA_DEPS += $(LD_VERSION_SCRIPT)
+endif
endif
#
# GNU doesn't have path length limitation
#
ifeq ($(OS_ARCH),GNU)
OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
endif
+ifeq ($(OS_ARCH),WINNT)
+ifdef USE_DELAYIMP
+OS_LIBS += $(call EXPAND_LIBNAME,delayimp)
+endif
+endif
+
#
# MINGW32
#
ifeq ($(OS_ARCH),WINNT)
ifdef GNU_CC
ifndef IS_COMPONENT
DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
endif
@@ -457,149 +465,158 @@ IFLAGS1 = -rb
IFLAGS2 = -rb
else
IFLAGS1 = -m 644
IFLAGS2 = -m 755
endif
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
OUTOPTION = -Fo# eol
+PREPROCESS_OPTION = -P -Fi# eol
else
OUTOPTION = -o # eol
+PREPROCESS_OPTION = -E -o #eol
endif # WINNT && !GNU_CC
+ifneq (,$(filter ml%,$(AS)))
+ASOUTOPTION = -Fo# eol
+else
+ASOUTOPTION = -o # eol
+endif
+
ifeq (,$(CROSS_COMPILE))
HOST_OUTOPTION = $(OUTOPTION)
else
HOST_OUTOPTION = -o # eol
endif
################################################################################
# The root makefile doesn't want to do a plain export/libs, because
# of the tiers and because of libxul. Suppress the default rules in favor
# of something else. Makefiles which use this var *must* provide a sensible
# default rule before including rules.mk
ifndef SUPPRESS_DEFAULT_RULES
default all::
$(MAKE) export
+ifdef COMPILE_ENVIRONMENT
$(MAKE) compile
- $(MAKE) libs
- $(MAKE) tools
-
-# Do depend as well
-alldep::
- $(MAKE) export
- $(MAKE) depend
+endif
$(MAKE) libs
$(MAKE) tools
endif # SUPPRESS_DEFAULT_RULES
-ifeq ($(filter s,$(MAKEFLAGS)),)
+ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
ECHO := echo
QUIET :=
else
ECHO := true
QUIET := -q
endif
-MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
-
-export_tier_%:
- @$(ECHO) "$@"
- @$(MAKE_TIER_SUBMAKEFILES)
- $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir)))
-
-libs_tier_%:
- @$(ECHO) "$@"
- @$(MAKE_TIER_SUBMAKEFILES)
- $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir)))
-
-tools_tier_%:
- @$(ECHO) "$@"
- @$(MAKE_TIER_SUBMAKEFILES)
- $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir)))
-
-$(foreach tier,$(TIERS),tier_$(tier))::
- @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
- $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir)))
- $(MAKE) export_$@
- $(MAKE) libs_$@
- $(MAKE) tools_$@
-
# Do everything from scratch
everything::
$(MAKE) clean
- $(MAKE) alldep
-
-# Add dummy depend target for tinderboxes
-depend::
+ $(MAKE) all
-ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS)))
-$(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only)
-endif
-
-HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS))
+STATIC_LIBS_DEPS := $(addsuffix .$(LIBS_DESC_SUFFIX),$(STATIC_LIBS))
# Dependencies which, if modified, should cause everything to rebuild
GLOBAL_DEPS += Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
##############################################
-compile:: $(MAKE_DIRS) $(OBJS) $(HOST_OBJS)
+ifdef COMPILE_ENVIRONMENT
+OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)
+
+compile:: host target
-libs:: $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS)
+host:: $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS)
+
+target:: $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS)
+
ifndef NO_DIST_INSTALL
-ifdef LIBRARY
-ifdef DIST_INSTALL
-ifdef IS_COMPONENT
- $(error Shipping static component libs makes no sense.)
-else
- $(call install_cmd,$(IFLAGS1) $(LIBRARY) $(DIST)/lib)
-endif
-endif # DIST_INSTALL
-endif # LIBRARY
ifdef SHARED_LIBRARY
ifdef IS_COMPONENT
- $(call install_cmd,$(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components)
- $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
+target:: $(SUBMAKEFILES) $(SHARED_LIBRARY)
+ $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
ifndef NO_COMPONENTS_MANIFEST
$(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest 'manifest components/components.manifest')
$(call py_action,buildlist,$(FINAL_TARGET)/components/components.manifest 'binary-component $(SHARED_LIBRARY)')
endif
-else # ! IS_COMPONENT
-ifneq (,$(filter WINNT,$(OS_ARCH)))
-ifndef NO_INSTALL_IMPORT_LIBRARY
- $(call install_cmd,$(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib)
-endif
-else
- $(call install_cmd,$(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib)
-endif
- $(call install_cmd,$(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET))
endif # IS_COMPONENT
endif # SHARED_LIBRARY
-ifdef PROGRAM
- $(call install_cmd,$(IFLAGS2) $(PROGRAM) $(FINAL_TARGET))
-endif
-ifdef SIMPLE_PROGRAMS
- $(call install_cmd,$(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET))
-endif
-ifdef HOST_PROGRAM
- $(call install_cmd,$(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin)
-endif
-ifdef HOST_SIMPLE_PROGRAMS
- $(call install_cmd,$(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin)
-endif
-ifdef HOST_LIBRARY
- $(call install_cmd,$(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib)
-endif
endif # !NO_DIST_INSTALL
-##############################################
+ifndef NO_DIST_INSTALL
+
+ifneq (,$(strip $(PROGRAM)$(SIMPLE_PROGRAMS)))
+PROGRAMS_EXECUTABLES = $(SIMPLE_PROGRAMS) $(PROGRAM)
+PROGRAMS_DEST ?= $(FINAL_TARGET)
+PROGRAMS_TARGET := target
+INSTALL_TARGETS += PROGRAMS
+endif
+
+ifdef LIBRARY
+ifdef DIST_INSTALL
+ifdef IS_COMPONENT
+ $(error Shipping static component libs makes no sense.)
+else
+DIST_LIBRARY_FILES = $(LIBRARY)
+DIST_LIBRARY_DEST ?= $(DIST)/lib
+DIST_LIBRARY_TARGET = target
+INSTALL_TARGETS += DIST_LIBRARY
+endif
+endif # DIST_INSTALL
+endif # LIBRARY
+
+
+ifdef SHARED_LIBRARY
+ifndef IS_COMPONENT
+SHARED_LIBRARY_FILES = $(SHARED_LIBRARY)
+SHARED_LIBRARY_DEST ?= $(FINAL_TARGET)
+SHARED_LIBRARY_TARGET = target
+INSTALL_TARGETS += SHARED_LIBRARY
-ifndef NO_PROFILE_GUIDED_OPTIMIZE
+ifneq (,$(filter WINNT,$(OS_ARCH)))
+ifndef NO_INSTALL_IMPORT_LIBRARY
+IMPORT_LIB_FILES = $(IMPORT_LIBRARY)
+endif # NO_INSTALL_IMPORT_LIBRARY
+else
+IMPORT_LIB_FILES = $(SHARED_LIBRARY)
+endif
+
+IMPORT_LIB_DEST ?= $(DIST)/lib
+IMPORT_LIB_TARGET = target
+ifdef IMPORT_LIB_FILES
+INSTALL_TARGETS += IMPORT_LIB
+endif
+
+endif # ! IS_COMPONENT
+endif # SHARED_LIBRARY
+
+ifneq (,$(strip $(HOST_SIMPLE_PROGRAMS)$(HOST_PROGRAM)))
+HOST_PROGRAMS_EXECUTABLES = $(HOST_SIMPLE_PROGRAMS) $(HOST_PROGRAM)
+HOST_PROGRAMS_DEST ?= $(DIST)/host/bin
+HOST_PROGRAMS_TARGET = host
+INSTALL_TARGETS += HOST_PROGRAMS
+endif
+
+ifdef HOST_LIBRARY
+HOST_LIBRARY_FILES = $(HOST_LIBRARY)
+HOST_LIBRARY_DEST ?= $(DIST)/host/lib
+HOST_LIBRARY_TARGET = host
+INSTALL_TARGETS += HOST_LIBRARY
+endif
+
+endif # !NO_DIST_INSTALL
+
+endif
+
+##############################################
+ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
ifdef MOZ_PROFILE_USE
ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
# When building with PGO, we have to make sure to re-link
# in the MOZ_PROFILE_USE phase if we linked in the
# MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
# file in the link rule in the GENERATE phase to indicate
# that we need a relink.
ifdef SHARED_LIBRARY
@@ -619,50 +636,78 @@ ifdef PROGRAM
$(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
endif
ifdef SHARED_LIBRARY
$(PYTHON) $(MOZILLA_SRCDIR)/build/win32/pgomerge.py \
$(patsubst $(DLL_PREFIX)%$(DLL_SUFFIX),%,$(SHARED_LIBRARY)) $(DIST)/bin
endif
endif # SHARED_LIBRARY || PROGRAM
endif # WINNT_
-endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
+endif # MOZ_PROFILE_USE
+ifdef MOZ_PROFILE_GENERATE
+# Clean up profiling data during PROFILE_GENERATE phase
+export::
+ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
+ $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
+else
+ifdef GNU_CC
+ -$(RM) *.gcda
+endif
+endif
+endif
+
+ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
+ifdef GNU_CC
+# Force rebuilding libraries and programs in both passes because each
+# pass uses different object files.
+$(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
+endif
+endif
+
endif # NO_PROFILE_GUIDED_OPTIMIZE
##############################################
checkout:
$(PYTHON) $(topsrcdir)/client.py checkout
clean clobber realclean clobber_all::
-$(RM) $(ALL_TRASH)
-$(RM) -r $(ALL_TRASH_DIRS)
- $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
+
+ifdef TIERS
+clean clobber realclean clobber_all distclean::
+ $(foreach dir, \
+ $(foreach tier, $(TIERS), $(tier_$(tier)_staticdirs) $(tier_$(tier)_dirs)), \
+ -$(call SUBMAKE,$@,$(dir)))
+else
+clean clobber realclean clobber_all distclean::
+ $(foreach dir,$(DIRS),-$(call SUBMAKE,$@,$(dir)))
+endif
distclean::
- $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
-$(RM) -r $(ALL_TRASH_DIRS)
-$(RM) $(ALL_TRASH) \
Makefile .HSancillary \
$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
$(wildcard *.$(IMPORT_LIB_SUFFIX))
alltags:
$(RM) TAGS
find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
#
# PROGRAM = Foo
# creates OBJS, links with LIBS to create Foo
#
-$(PROGRAM): $(PROGOBJS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
+$(PROGRAM): $(PROGOBJS) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
@$(RM) $@.manifest
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
- $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+ $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS)
ifdef MSMANIFEST_TOOL
@if test -f $@.manifest; then \
if test -f '$(srcdir)/$@.manifest'; then \
echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
else \
echo 'Embedding manifest from $@.manifest'; \
mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
@@ -673,141 +718,150 @@ ifdef MSMANIFEST_TOOL
fi
endif # MSVC with manifest tool
ifdef MOZ_PROFILE_GENERATE
# touch it a few seconds into the future to work around FAT's
# 2-second granularity
touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
endif
else # !WINNT || GNU_CC
- $(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
+ $(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
endif # WINNT && !GNU_CC
ifdef ENABLE_STRIP
- $(STRIP) $@
+ $(STRIP) $(STRIP_FLAGS) $@
endif
ifdef MOZ_POST_PROGRAM_COMMAND
$(MOZ_POST_PROGRAM_COMMAND) $@
endif
-$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
+$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
ifdef MSMANIFEST_TOOL
@if test -f $@.manifest; then \
if test -f '$(srcdir)/$@.manifest'; then \
echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
else \
echo 'Embedding manifest from $@.manifest'; \
mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
fi; \
elif test -f '$(srcdir)/$@.manifest'; then \
echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \
fi
endif # MSVC with manifest tool
else
ifeq ($(HOST_CPP_PROG_LINK),1)
- $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
else
- $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
endif # HOST_CPP_PROG_LINK
endif
#
# This is an attempt to support generation of multiple binaries
# in one directory, it assumes everything to compile Foo is in
# Foo.o (from either Foo.c or Foo.cpp).
#
# SIMPLE_PROGRAMS = Foo Bar
# creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
#
-$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(EXTRA_DEPS) $(GLOBAL_DEPS)
+$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
- $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
+ $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS)
ifdef MSMANIFEST_TOOL
@if test -f $@.manifest; then \
mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
rm -f $@.manifest; \
fi
endif # MSVC with manifest tool
else
- $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
+ $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
endif # WINNT && !GNU_CC
ifdef ENABLE_STRIP
- $(STRIP) $@
+ $(STRIP) $(STRIP_FLAGS) $@
endif
ifdef MOZ_POST_PROGRAM_COMMAND
$(MOZ_POST_PROGRAM_COMMAND) $@
endif
-$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
+$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
else
ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
- $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
else
- $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
+ $(EXPAND_LIBS_EXEC) -- $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
endif
endif
ifdef DTRACE_PROBE_OBJ
EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
+OBJS += $(DTRACE_PROBE_OBJ)
endif
-$(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
+$(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(STATIC_LIBS_DEPS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS)) $(EXTRA_DEPS) $(GLOBAL_DEPS)
$(RM) $(LIBRARY)
- $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(SHARED_LIBRARY_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
+ $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(STATIC_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
$(RANLIB) $@
-$(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
+$(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(STATIC_LIBS_DEPS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS)) $(EXTRA_DEPS) $(GLOBAL_DEPS)
# When we only build a library descriptor, blow out any existing library
$(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY))
- $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(SHARED_LIBRARY_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
+ $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(STATIC_LIBS) $(filter %.$(LIB_SUFFIX),$(EXTRA_LIBS))
ifeq ($(OS_ARCH),WINNT)
-$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
+# Import libraries are created by the rules creating shared libraries.
+# The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
+# but make will happily consider the import library before it is refreshed
+# when rebuilding the corresponding shared library. Defining an empty recipe
+# for import libraries forces make to wait for the shared library recipe to
+# have run before considering other targets that depend on the import library.
+# See bug 795204.
+$(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
endif
$(HOST_LIBRARY): $(HOST_OBJS) Makefile
$(RM) $@
- $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
+ $(EXPAND_LIBS_EXEC) --extract -- $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
$(HOST_RANLIB) $@
ifdef HAVE_DTRACE
ifndef XP_MACOSX
ifdef DTRACE_PROBE_OBJ
ifndef DTRACE_LIB_DEPENDENT
-$(DTRACE_PROBE_OBJ): $(OBJS)
- dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
+NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS))
+$(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS)
+ dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS)
endif
endif
endif
endif
# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
# so instead of deleting .o files after repacking them into a dylib, we make
# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
# so no need to conditionalize on OS version or debugging format.
-$(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(LIBRARY) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
+$(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(STATIC_LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
ifndef INCREMENTAL_LINKER
$(RM) $@
endif
ifdef DTRACE_LIB_DEPENDENT
ifndef XP_MACOSX
dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
endif
- $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
+ $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
@$(RM) $(DTRACE_PROBE_OBJ)
else # ! DTRACE_LIB_DEPENDENT
- $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
+ $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(EXTRA_LIBS) $(OS_LIBS) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
endif # DTRACE_LIB_DEPENDENT
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
ifdef MSMANIFEST_TOOL
ifdef EMBED_MANIFEST_AT
@if test -f $@.manifest; then \
mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
rm -f $@.manifest; \
@@ -816,17 +870,17 @@ endif # EMBED_MANIFEST_AT
endif # MSVC with manifest tool
ifdef MOZ_PROFILE_GENERATE
touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
endif
endif # WINNT && !GCC
@$(RM) foodummyfilefoo $(DELETE_AFTER_LINK)
chmod +x $@
ifdef ENABLE_STRIP
- $(STRIP) $@
+ $(STRIP) $(STRIP_FLAGS) $@
endif
ifdef MOZ_POST_DSO_LIB_COMMAND
$(MOZ_POST_DSO_LIB_COMMAND) $@
endif
ifeq ($(SOLARIS_SUNPRO_CC),1)
_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
@@ -841,145 +895,234 @@ define MAKE_DEPS_AUTO_CXX
if test -d $(@D); then \
echo 'Building deps for $< using Sun Studio CC'; \
$(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
$(PYTHON) $(MOZILLA_DIR)/build/unix/add_phony_targets.py $(_MDDEPFILE) ; \
fi
endef
endif # Sun Studio on Solaris
+# The object file is in the current directory, and the source file can be any
+# relative path. This macro adds the dependency obj: src for each source file.
+# This dependency must be first for the $< flag to work correctly, and the
+# rules that have commands for these targets must not list any other
+# prerequisites, or they will override the $< variable.
+define src_objdep
+$(basename $2$(notdir $1)).$(OBJ_SUFFIX): $1 $$(call mkdir_deps,$$(MDDEPDIR))
+endef
+$(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f))))
+$(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),host_)))
+
+$(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
+
# Rules for building native targets must come first because of the host_ prefix
-host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
+$(HOST_COBJS):
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
-host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
- $(REPORT_BUILD)
- $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
-
-host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
+$(HOST_CPPOBJS):
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
-host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
+$(HOST_CMOBJS):
$(REPORT_BUILD)
$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
-host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
+$(HOST_CMMOBJS):
$(REPORT_BUILD)
$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
-%:: %.c $(GLOBAL_DEPS)
+$(COBJS):
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
- $(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
+ $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
+# DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
+# 'moc' only knows about #defines it gets on the command line (-D...), not in
+# included headers like mozilla-config.h
+$(filter moc_%.cpp,$(CPPSRCS)): moc_%.cpp: %.h
$(REPORT_BUILD)
- @$(MAKE_DEPS_AUTO_CC)
- $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
+ $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
+
+$(filter moc_%.cc,$(CPPSRCS)): moc_%.cc: %.cc
+ $(REPORT_BUILD)
+ $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
+
+$(filter qrc_%.cpp,$(CPPSRCS)): qrc_%.cpp: %.qrc
+ $(REPORT_BUILD)
+ $(ELOG) $(RCC) -name $* $< $(OUTOPTION)$@
ifdef ASFILES
# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
# a '-c' flag.
-%.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) $(GLOBAL_DEPS)
- $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
+$(ASOBJS):
+ $(REPORT_BUILD)
+ $(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
endif
-%.$(OBJ_SUFFIX): %.S $(GLOBAL_DEPS)
- $(AS) -o $@ $(ASFLAGS) -c $<
+$(SOBJS):
+ $(REPORT_BUILD)
+ $(AS) -o $@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) $(TARGET_LOCAL_INCLUDES) -c $<
-%:: %.cpp $(GLOBAL_DEPS)
- @$(MAKE_DEPS_AUTO_CXX)
- $(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
-
-#
-# Please keep the next two rules in sync.
-#
-%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
+$(CPPOBJS):
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
- $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+ $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
+$(CMMOBJS):
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CXX)
-ifdef STRICT_CPLUSPLUS_SUFFIX
- echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
- $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
- $(RM) t_$*.cc
-else
- $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
-endif #STRICT_CPLUSPLUS_SUFFIX
+ $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
- $(REPORT_BUILD)
- @$(MAKE_DEPS_AUTO_CXX)
- $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
-
-$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
+$(CMOBJS):
$(REPORT_BUILD)
@$(MAKE_DEPS_AUTO_CC)
- $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
+ $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-%.s: %.cpp
- $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+$(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(filter %.s,$(CPPSRCS:%.cxx=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-%.s: %.cc
- $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
+ifneq (,$(filter %.i,$(MAKECMDGOALS)))
+# Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
+# of the full sources, as well as the $(notdir) version. So:
+# foo.cpp sub/bar.cpp
+# becomes:
+# foo.cpp sub/bar.cpp bar.cpp
+#
+# This way we can match both 'make sub/bar.i' and 'make bar.i'
+_group_srcs = $(sort $(patsubst %.$1,%.i,$(filter %.$1,$2 $(notdir $2))))
+_PREPROCESSED_CPP_FILES := $(call _group_srcs,cpp,$(CPPSRCS))
+_PREPROCESSED_CC_FILES := $(call _group_srcs,cc,$(CPPSRCS))
+_PREPROCESSED_CXX_FILES := $(call _group_srcs,cxx,$(CPPSRCS))
+_PREPROCESSED_C_FILES := $(call _group_srcs,c,$(CSRCS))
+_PREPROCESSED_CMM_FILES := $(call _group_srcs,mm,$(CMMSRCS))
+
+# Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
+# reach $(srcdir)/frontend/Parser.i
+VPATH += $(addprefix $(srcdir)/,$(sort $(dir $(CPPSRCS) $(CSRCS) $(CMMSRCS))))
-%.s: %.c
- $(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
+# Make preprocessed files PHONY so they are always executed, since they are
+# manual targets and we don't necessarily write to $@.
+.PHONY: $(_PREPROCESSED_CPP_FILES) $(_PREPROCESSED_CC_FILES) $(_PREPROCESSED_CXX_FILES) $(_PREPROCESSED_C_FILES) $(_PREPROCESSED_CMM_FILES)
+
+$(_PREPROCESSED_CPP_FILES): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
+ $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(_PREPROCESSED_CC_FILES): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
+ $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(_PREPROCESSED_CXX_FILES): %.i: %.cxx $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
+ $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
-%.i: %.cpp
- $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
+$(_PREPROCESSED_C_FILES): %.i: %.c $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
+ $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+$(_PREPROCESSED_CMM_FILES): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR))
+ $(REPORT_BUILD)
+ $(addprefix $(MKDIR) -p ,$(filter-out .,$(@D)))
+ $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
+
+# Default to pre-processing the actual unified file. This can be overridden
+# at the command-line to pre-process only the individual source file.
+PP_UNIFIED ?= 1
-%.i: %.cc
- $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
+# PP_REINVOKE gets set on the sub-make to prevent us from going in an
+# infinite loop if the filename doesn't exist in the unified source files.
+ifndef PP_REINVOKE
+
+MATCH_cpp = \(cpp\|cc|cxx\)
+UPPER_c = C
+UPPER_cpp = CPP
+UPPER_mm = CMM
+
+# When building with PP_UNIFIED=0, we also have to look in the Unified files to
+# find a matching pathname.
+_get_all_sources = $1 $(if $(filter Unified%,$1),$(shell sed -n 's/\#include "\(.*\)"$$/\1/p' $(filter Unified%,$1)))
+all_cpp_sources := $(call _get_all_sources,$(CPPSRCS))
+all_mm_sources := $(call _get_all_sources,$(CMMSRCS))
+all_c_sources := $(call _get_all_sources,$(CSRCS))
+all_sources := $(all_cpp_sources) $(all_cmm_sources) $(all_c_sources)
-%.i: %.c
- $(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
+# The catch-all %.i rule runs when we pass in a .i filename that doesn't match
+# one of the *SRCS variables. The two code paths depend on whether or not
+# we are requesting a unified file (PP_UNIFIED=1, the default) or not:
+#
+# PP_UNIFIED=1:
+# - Look for it in any of the Unified files, and re-exec make with
+# Unified_foo0.i as the target. This gets us the full unified preprocessed
+# file.
+#
+# PP_UNIFIED=0:
+# - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
+# make with that filename as the target. The *SRCS variables are modified
+# to have the Unified sources appended to them so that the static pattern
+# rules will match.
+%.i: FORCE
+ifeq ($(PP_UNIFIED),1)
+ @$(MAKE) PP_REINVOKE=1 \
+ $(or $(addsuffix .i, \
+ $(foreach type,c cpp mm, \
+ $(if $(filter Unified%,$($(UPPER_$(type))SRCS)), \
+ $(shell grep -l '#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified*.$(type) | sed 's/\.$(type)$$//') \
+ ))),$(error "File not found for preprocessing: $@"))
+else
+ @$(MAKE) PP_REINVOKE=1 $@ \
+ $(foreach type,c cpp mm,$(UPPER_$(type))SRCS="$(all_$(type)_sources)")
+endif
-%.i: %.mm
- $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
+endif
-%.res: %.rc
+endif
+
+$(RESFILE): %.res: %.rc
+ $(REPORT_BUILD)
@echo Creating Resource file: $@
ifdef GNU_CC
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
else
$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
endif
-# need 3 separate lines for OS/2
-%:: %.pl
- $(RM) $@
- cp $< $@
- chmod +x $@
+# Cancel GNU make built-in implicit rules
+MAKEFLAGS += -r
-%:: %.sh
- $(RM) $@
- cp $< $@
- chmod +x $@
+ifneq (,$(filter WINNT,$(OS_ARCH)))
+SEP := ;
+else
+SEP := :
+endif
-# Cancel these implicit rules
-#
-%: %,v
-
-%: RCS/%,v
-
-%: s.%
-
-%: SCCS/s.%
+EMPTY :=
+SPACE := $(EMPTY) $(EMPTY)
# MSYS has its own special path form, but javac expects the source and class
# paths to be in the DOS form (i.e. e:/builds/...). This function does the
# appropriate conversion on Windows, but is a noop on other systems.
ifeq ($(HOST_OS_ARCH),WINNT)
-# assume MSYS
# We use 'pwd -W' to get DOS form of the path. However, since the given path
# could be a file or a non-existent path, we cannot call 'pwd -W' directly
# on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
# on it, then merge with the rest of the path.
root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\1|')
non-root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\2|')
normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
else
@@ -1009,102 +1152,59 @@ backend.mk: $(BACKEND_INPUT_FILES)
endif
endif # MOZBUILD_DERIVED
###############################################################################
# Bunch of things that extend the 'export' rule (in order):
###############################################################################
-################################################################################
-# Copy each element of EXPORTS to $(DIST)/include
-
ifneq ($(XPI_NAME),)
$(FINAL_TARGET):
$(NSINSTALL) -D $@
export:: $(FINAL_TARGET)
endif
-ifndef NO_DIST_INSTALL
-ifneq (,$(EXPORTS))
-export:: $(EXPORTS)
- $(call install_cmd,$(IFLAGS1) $^ $(DIST)/include)
-endif
-endif # NO_DIST_INSTALL
-
-define EXPORT_NAMESPACE_RULE
-ifndef NO_DIST_INSTALL
-export:: $(EXPORTS_$(namespace))
- $(call install_cmd,$(IFLAGS1) $$^ $(DIST)/include/$(namespace))
-endif # NO_DIST_INSTALL
-endef
-
-$(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
-
################################################################################
# Copy each element of PREF_JS_EXPORTS
# The default location for PREF_JS_EXPORTS is the gre prefs directory.
PREF_DIR = defaults/pref
# If DIST_SUBDIR is defined it indicates that app and gre dirs are
# different and that we are building app related resources. Hence,
# PREF_DIR should point to the app prefs location.
ifneq (,$(DIST_SUBDIR)$(XPI_NAME)$(LIBXUL_SDK))
PREF_DIR = defaults/preferences
endif
-ifneq ($(PREF_JS_EXPORTS),)
# on win32, pref files need CRLF line endings... see bug 206029
ifeq (WINNT,$(OS_ARCH))
-PREF_PPFLAGS = --line-endings=crlf
+PREF_PPFLAGS += --line-endings=crlf
endif
+ifneq ($(PREF_JS_EXPORTS),)
ifndef NO_DIST_INSTALL
PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS)
PP_TARGETS += PREF_JS_EXPORTS
endif
endif
################################################################################
-# Copy testing-only JS modules to appropriate destination.
-#
-# For each file defined in TESTING_JS_MODULES, copy it to
-# objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path
-# wlll be appended to the output directory.
-
-ifdef ENABLE_TESTS
-ifdef TESTING_JS_MODULES
-testmodulesdir = $(MOZDEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
-
-libs::
- $(NSINSTALL) -D $(testmodulesdir)
-
-libs:: $(TESTING_JS_MODULES)
-ifndef NO_DIST_INSTALL
- $(INSTALL) $(IFLAGS) $^ $(testmodulesdir)
-endif
-
-endif
-endif
-
-################################################################################
# Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
ifneq ($(AUTOCFG_JS_EXPORTS),)
-$(FINAL_TARGET)/defaults/autoconfig::
- $(NSINSTALL) -D $@
-
ifndef NO_DIST_INSTALL
-export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
- $(call install_cmd,$(IFLAGS1) $^)
+AUTOCFG_JS_EXPORTS_FILES := $(AUTOCFG_JS_EXPORTS)
+AUTOCFG_JS_EXPORTS_DEST := $(FINAL_TARGET)/defaults/autoconfig
+AUTOCFG_JS_EXPORTS_TARGET := export
+INSTALL_TARGETS += AUTOCFG_JS_EXPORTS
endif
-
endif
################################################################################
# Install a linked .xpt into the appropriate place.
# This should ideally be performed by the non-recursive idl make file. Some day.
ifdef XPT_NAME #{
ifndef NO_DIST_INSTALL
@@ -1129,19 +1229,20 @@ ifndef NO_JS_MANIFEST
$(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0)
endif
endif
endif
ifdef EXTRA_COMPONENTS
libs:: $(EXTRA_COMPONENTS)
ifndef NO_DIST_INSTALL
- $(call install_cmd,$(IFLAGS1) $^ $(FINAL_TARGET)/components)
+EXTRA_COMPONENTS_FILES := $(EXTRA_COMPONENTS)
+EXTRA_COMPONENTS_DEST := $(FINAL_TARGET)/components
+INSTALL_TARGETS += EXTRA_COMPONENTS
endif
-
endif
ifdef EXTRA_PP_COMPONENTS
ifndef NO_DIST_INSTALL
EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
PP_TARGETS += EXTRA_PP_COMPONENTS
endif
endif
@@ -1155,70 +1256,66 @@ endif
################################################################################
# Copy each element of EXTRA_JS_MODULES to
# $(FINAL_TARGET)/$(JS_MODULES_PATH). JS_MODULES_PATH defaults to "modules"
# if it is undefined.
JS_MODULES_PATH ?= modules
FINAL_JS_MODULES_PATH := $(FINAL_TARGET)/$(JS_MODULES_PATH)
ifdef EXTRA_JS_MODULES
-libs:: $(EXTRA_JS_MODULES)
ifndef NO_DIST_INSTALL
- $(call install_cmd,$(IFLAGS1) $^ $(FINAL_JS_MODULES_PATH))
+EXTRA_JS_MODULES_FILES := $(EXTRA_JS_MODULES)
+EXTRA_JS_MODULES_DEST := $(FINAL_JS_MODULES_PATH)
+INSTALL_TARGETS += EXTRA_JS_MODULES
endif
-
endif
ifdef EXTRA_PP_JS_MODULES
ifndef NO_DIST_INSTALL
EXTRA_PP_JS_MODULES_PATH := $(FINAL_JS_MODULES_PATH)
PP_TARGETS += EXTRA_PP_JS_MODULES
endif
endif
################################################################################
# SDK
ifneq (,$(SDK_LIBRARY))
-$(SDK_LIB_DIR)::
- $(NSINSTALL) -D $@
-
ifndef NO_DIST_INSTALL
-libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
- $(call install_cmd,$(IFLAGS2) $^)
+SDK_LIBRARY_FILES := $(SDK_LIBRARY)
+SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
+SDK_LIBRARY_TARGET := target
+INSTALL_TARGETS += SDK_LIBRARY
endif
-
endif # SDK_LIBRARY
-ifneq (,$(SDK_BINARY))
-$(SDK_BIN_DIR)::
- $(NSINSTALL) -D $@
-
+# SDK_BINARY is still used in various makefiles for non-products of the
+# compilation, so we need to keep that running on the libs tier.
+ifneq (,$(strip $(SDK_BINARY)))
ifndef NO_DIST_INSTALL
-libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
- $(call install_cmd,$(IFLAGS2) $^)
+SDK_BINARY_FILES := $(SDK_BINARY)
+SDK_BINARY_DEST := $(SDK_BIN_DIR)
+# SDK_BINARY_TARGET is set in xpcom/idl-parser/Makefile.in
+SDK_BINARY_TARGET ?= libs target
+INSTALL_TARGETS += SDK_BINARY
endif
-
endif # SDK_BINARY
################################################################################
# CHROME PACKAGING
chrome::
$(MAKE) realchrome
- $(LOOP_OVER_PARALLEL_DIRS)
$(LOOP_OVER_DIRS)
- $(LOOP_OVER_TOOL_DIRS)
-$(FINAL_TARGET)/chrome:
- $(NSINSTALL) -D $@
+$(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
-libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
ifneq (,$(JAR_MANIFEST))
ifndef NO_DIST_INSTALL
+libs realchrome:: $(FINAL_TARGET)/chrome
$(call py_action,jar_maker,\
$(QUIET) -j $(FINAL_TARGET)/chrome \
$(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
$(JAR_MANIFEST))
endif
# This is a temporary check to ensure patches relying on the old behavior
# of silently picking up jar.mn files continue to work.
@@ -1229,22 +1326,18 @@ endif
endif
ifneq ($(DIST_FILES),)
DIST_FILES_PATH := $(FINAL_TARGET)
DIST_FILES_FLAGS := $(XULAPP_DEFINES)
PP_TARGETS += DIST_FILES
endif
-ifneq ($(DIST_CHROME_FILES),)
-DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome
-DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES)
-PP_TARGETS += DIST_CHROME_FILES
-endif
-
+# When you move this out of the tools tier, please remove the corresponding
+# hacks in recursivemake.py that check if Makefile.in sets the variable.
ifneq ($(XPI_PKGNAME),)
tools realchrome::
ifdef STRIP_XPI
ifndef MOZ_DEBUG
@echo 'Stripping $(XPI_PKGNAME) package directory...'
@echo $(FINAL_TARGET)
@cd $(FINAL_TARGET) && find . ! -type d \
! -name '*.js' \
@@ -1270,16 +1363,17 @@ ifndef MOZ_DEBUG
$(PLATFORM_EXCLUDE_LIST) \
-exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
endif
endif
@echo 'Packaging $(XPI_PKGNAME).xpi...'
cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
endif
+# See comment above about moving this out of the tools tier.
ifdef INSTALL_EXTENSION_ID
ifndef XPI_NAME
$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
endif
tools::
$(RM) -r '$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)'
$(NSINSTALL) -D '$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)'
@@ -1311,33 +1405,35 @@ REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_
# processes could simultaneously try to create the same directory.
#
# We use $(CURDIR) in the rule's target to ensure that we don't find
# a dependency directory in the source tree via VPATH (perhaps from
# a previous build in the source tree) and thus neglect to create a
# dependency directory in the object directory, where we really need
# it.
-$(CURDIR)/$(MDDEPDIR):
- $(MKDIR) -p $@
-
-ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
-ifneq (,$(OBJS)$(SIMPLE_PROGRAMS))
-MDDEPEND_FILES := $(strip $(wildcard $(MDDEPDIR)/*.pp))
+ifneq (,$(filter-out all chrome default export realchrome clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
+MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_MDDEPEND_FILES) $(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)))))))
ifneq (,$(MDDEPEND_FILES))
-ifdef .PYMAKE
-includedeps $(MDDEPEND_FILES)
-else
-include $(MDDEPEND_FILES)
-endif
+$(call include_deps,$(MDDEPEND_FILES))
endif
endif
+
+
+ifneq (,$(filter export,$(MAKECMDGOALS)))
+MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_EXPORT_MDDEPEND_FILES))))
+
+ifneq (,$(MDDEPEND_FILES))
+$(call include_deps,$(MDDEPEND_FILES))
endif
+
+endif
+
#############################################################################
-include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
-include $(MY_RULES)
#
# Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
# or in $(MY_RULES)
@@ -1359,132 +1455,198 @@ endif
#
# FOO_FILES := foo bar
# FOO_EXECUTABLES := baz
# FOO_DEST := target_path
# INSTALL_TARGETS += FOO
#
# Additionally, a FOO_TARGET variable may be added to indicate the target for
# which the files and executables are installed. Default is "libs".
+#
+# Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
+# in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
+# if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
+# file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
# If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
-ifneq (,$(filter $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
-ifeq (,$(wildcard $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)))
-nsinstall_is_usable = $(if $(wildcard $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)),yes)
+ifneq (,$(filter $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
+ifeq (,$(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)))
+nsinstall_is_usable = $(if $(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)),yes)
define install_cmd_override
-$(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY)) $$(1)
+$(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1)
endef
endif
endif
-define install_file_template
-$(or $(3),libs):: $(2)/$(notdir $(1))
-$(call install_cmd_override,$(2)/$(notdir $(1)))
-$(2)/$(notdir $(1)): $(1)
- $$(call install_cmd,$(4) '$$<' '$${@D}')
+install_target_tier = $(or $($(1)_TARGET),libs)
+INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category))))
+
+install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2)))
+install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file)))
+install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file)))
+
+# Work around a GNU make 3.81 bug where it gives $< the wrong value.
+# See details in bug 934864.
+define create_dependency
+$(1): $(2)
+$(1): $(2)
endef
+
+define install_target_template
+$(call install_cmd_override,$(2))
+$(call create_dependency,$(2),$(1))
+endef
+
$(foreach category,$(INSTALL_TARGETS),\
- $(if $($(category)_DEST),,$(error Missing $(category)_DEST))\
- $(foreach file,$($(category)_FILES),\
- $(eval $(call install_file_template,$(file),$($(category)_DEST),$($(category)_TARGET),$(IFLAGS1)))\
- )\
- $(foreach file,$($(category)_EXECUTABLES),\
- $(eval $(call install_file_template,$(file),$($(category)_DEST),$($(category)_TARGET),$(IFLAGS2)))\
- )\
+ $(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \
+ $(foreach tier,$(call install_target_tier,$(category)),\
+ $(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \
+ $(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \
+ ) \
+ $(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \
+ $(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \
+ ) \
)
+$(foreach tier,$(INSTALL_TARGETS_TIERS), \
+ $(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \
+)
+
+install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
+
+$(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))):
+ $(install_targets_sanity)
+ $(call install_cmd,$(IFLAGS1) '$<' '$(@D)')
+
+$(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))):
+ $(install_targets_sanity)
+ $(call install_cmd,$(IFLAGS2) '$<' '$(@D)')
+
################################################################################
# Preprocessing rules
#
# The PP_TARGETS variable contains a list of all preprocessing target
# categories. Each category has associated variables listing input files, the
# output directory, extra preprocessor flags, and so on. For example:
#
# FOO := input-file
# FOO_PATH := target-directory
# FOO_FLAGS := -Dsome_flag
# PP_TARGETS += FOO
#
# If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
# following make variables to see what to do:
#
-# - <C> lists input files to be preprocessed with config/Preprocessor.py. We
-# search VPATH for the names given here. If an input file name ends in '.in',
-# that suffix is omitted from the output file name.
+# - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
+# We search VPATH for the names given here. If an input file name ends in
+# '.in', that suffix is omitted from the output file name.
#
# - <C>_PATH names the directory in which to place the preprocessed output
# files. We create this directory if it does not already exist. Setting
# this variable is optional; if unset, we install the files in $(CURDIR).
#
-# - <C>_FLAGS lists flags to pass to Preprocessor.py, in addition to the usual
-# bunch. Setting this variable is optional.
+# - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
+# to the usual bunch. Setting this variable is optional.
#
# - <C>_TARGET names the 'make' target that should depend on creating the output
# files. Setting this variable is optional; if unset, we preprocess the
# files for the 'libs' target.
+#
+# - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
+# kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
+# $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
+# instead of $(DIST)/include/qux.h.
-# preprocess_file_template defines preprocessing rules.
-# $(call preprocess_file_template, source_file, output_file,
-# makefile_target, extra_flags)
-define preprocess_file_template
-$(2): $(1) $$(GLOBAL_DEPS)
- $$(RM) '$$@'
- $$(call py_action,preprocessor,$(4) $$(DEFINES) $$(ACDEFINES) $$(XULPPFLAGS) '$$<' -o '$$@')
-$(3):: $(2)
-endef
+pp_target_tier = $(or $($(1)_TARGET),libs)
+PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category))))
+
+pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=)))
+pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file)))
+
+$(foreach category,$(PP_TARGETS), \
+ $(foreach tier,$(call pp_target_tier,$(category)), \
+ $(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \
+ ) \
+ $(foreach file,$($(category)), \
+ $(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \
+ $(file) $(GLOBAL_DEPS))) \
+ ) \
+ $(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \
+)
+
+$(foreach tier,$(PP_TARGETS_TIERS), \
+ $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
+)
+
+PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
+$(PP_TARGETS_ALL_RESULTS):
+ $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS))
+ $(RM) '$@'
+ $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) '$<' -o '$@')
-$(foreach category,$(PP_TARGETS), \
- $(foreach file,$($(category)), \
- $(eval $(call preprocess_file_template, \
- $(file), \
- $(or $($(category)_PATH),$(CURDIR))/$(notdir $(file:.in=)), \
- $(or $($(category)_TARGET),libs), \
- $($(category)_FLAGS))) \
- ) \
- )
+# The depfile is based on the filename, and we don't want conflicts. So check
+# there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
+PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
+$(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
+ $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
+ $(error Multiple preprocessing rules are creating a $(file) file) \
+ ) \
+)
+
+ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS)))
+# If the depfile for a preprocessed file doesn't exist, add a dep to force
+# re-preprocessing.
+$(foreach file,$(PP_TARGETS_ALL_RESULTS), \
+ $(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \
+ , \
+ $(eval $(file): FORCE) \
+ ) \
+)
+
+MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS))))))
+
+ifneq (,$(MDDEPEND_FILES))
+$(call include_deps,$(MDDEPEND_FILES))
+endif
+
+endif
+
+# Pull in non-recursive targets if this is a partial tree build.
+ifndef TOPLEVEL_BUILD
+include $(MOZILLA_SRCDIR)/config/makefiles/nonrecursive.mk
+endif
################################################################################
# Special gmake rules.
################################################################################
#
-# Disallow parallel builds with MSVC < 8
-#
-ifneq (,$(filter 1200 1300 1310,$(_MSC_VER)))
-.NOTPARALLEL:
-endif
-
-#
# Re-define the list of default suffixes, so gmake won't have to churn through
# hundreds of built-in suffix rules for stuff we don't need.
#
.SUFFIXES:
#
# Fake targets. Always run these rules, even if a file/directory with that
# name already exists.
#
-.PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
+.PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) FORCE
# Used as a dependency to force targets to rebuild
FORCE:
# Delete target if error occurs when building target
.DELETE_ON_ERROR:
-# Properly set LIBPATTERNS for the platform
-.LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX)
-
tags: TAGS
TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h)
-etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
- $(LOOP_OVER_PARALLEL_DIRS)
$(LOOP_OVER_DIRS)
echo-variable-%:
@echo "$($*)"
echo-tiers:
@echo $(TIERS)
@@ -1508,27 +1670,25 @@ echo-module-filelist:
showtargs:
ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
@echo --------------------------------------------------------------------------------
@echo "PROGRAM = $(PROGRAM)"
@echo "SIMPLE_PROGRAMS = $(SIMPLE_PROGRAMS)"
@echo "LIBRARY = $(LIBRARY)"
@echo "SHARED_LIBRARY = $(SHARED_LIBRARY)"
- @echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
@echo "LIBS = $(LIBS)"
@echo "DEF_FILE = $(DEF_FILE)"
@echo "IMPORT_LIBRARY = $(IMPORT_LIBRARY)"
@echo "STATIC_LIBS = $(STATIC_LIBS)"
@echo "SHARED_LIBS = $(SHARED_LIBS)"
@echo "EXTRA_DSO_LDOPTS = $(EXTRA_DSO_LDOPTS)"
@echo "DEPENDENT_LIBS = $(DEPENDENT_LIBS)"
@echo --------------------------------------------------------------------------------
endif
- $(LOOP_OVER_PARALLEL_DIRS)
$(LOOP_OVER_DIRS)
showbuild:
@echo "MOZ_BUILD_ROOT = $(MOZ_BUILD_ROOT)"
@echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "CCC = $(CCC)"
@@ -1581,20 +1741,18 @@ showbuildmods::
@echo "Build Modules = $(BUILD_MODULES)"
@echo "Module dirs = $(BUILD_MODULE_DIRS)"
documentation:
@cd $(DEPTH)
$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
ifdef ENABLE_TESTS
-check:: $(MAKE_DIRS)
- $(LOOP_OVER_PARALLEL_DIRS)
+check::
$(LOOP_OVER_DIRS)
- $(LOOP_OVER_TOOL_DIRS)
endif
FREEZE_VARIABLES = \
CSRCS \
CPPSRCS \
EXPORTS \
DIRS \
@@ -1609,10 +1767,34 @@ FREEZE_VARIABLES = \
$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
$(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
libs export::
$(CHECK_FROZEN_VARIABLES)
-default all::
- if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi
+PURGECACHES_DIRS ?= $(DIST)/bin
+ifdef MOZ_WEBAPP_RUNTIME
+PURGECACHES_DIRS += $(DIST)/bin/webapprt
+endif
+
+PURGECACHES_FILES = $(addsuffix /.purgecaches,$(PURGECACHES_DIRS))
+
+default all:: $(PURGECACHES_FILES)
+
+$(PURGECACHES_FILES):
+ if test -d $(@D) ; then touch $@ ; fi
+
+.DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default)
+
+#############################################################################
+# Derived targets and dependencies
+
+include $(topsrcdir)/config/makefiles/autotargets.mk
+ifneq ($(NULL),$(AUTO_DEPS))
+ default all libs tools export:: $(AUTO_DEPS)
+endif
+
+export:: $(GENERATED_FILES)
+
+GARBAGE += $(GENERATED_FILES)
+