michael@0: # -*- makefile -*- michael@0: # vim:set ts=8 sw=8 sts=8 noet: 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 file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: # michael@0: michael@0: ifndef topsrcdir michael@0: $(error topsrcdir was not set)) michael@0: endif michael@0: michael@0: # Define an include-at-most-once flag michael@0: ifdef INCLUDED_RULES_MK michael@0: $(error Do not include rules.mk twice!) michael@0: endif michael@0: INCLUDED_RULES_MK = 1 michael@0: michael@0: # Make sure that anything that needs to be defined in moz.build wasn't michael@0: # overwritten. michael@0: _eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES) michael@0: michael@0: ifndef MOZILLA_DIR michael@0: MOZILLA_DIR = $(topsrcdir) michael@0: endif michael@0: michael@0: ifndef INCLUDED_CONFIG_MK michael@0: include $(topsrcdir)/config/config.mk michael@0: endif michael@0: michael@0: ifndef INCLUDED_VERSION_MK michael@0: include $(topsrcdir)/config/version.mk michael@0: endif michael@0: michael@0: USE_AUTOTARGETS_MK = 1 michael@0: include $(topsrcdir)/config/makefiles/makeutils.mk michael@0: michael@0: # Only build with Pymake (not GNU make) on Windows. michael@0: ifeq ($(HOST_OS_ARCH),WINNT) michael@0: ifndef L10NBASEDIR michael@0: ifndef .PYMAKE michael@0: $(error Pymake is required to build on Windows. Run |./mach build| to \ michael@0: automatically use pymake or invoke pymake directly via \ michael@0: |python build/pymake/make.py|.) michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifdef REBUILD_CHECK michael@0: ifdef .PYMAKE michael@0: REPORT_BUILD = @%rebuild_check rebuild_check $@ $^ michael@0: else michael@0: REPORT_BUILD = $(info $(shell $(PYTHON) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^)) michael@0: endif michael@0: else michael@0: REPORT_BUILD = $(info $(notdir $@)) michael@0: endif michael@0: michael@0: EXEC = exec michael@0: michael@0: # Don't copy xulrunner files at install time, when using system xulrunner michael@0: ifdef SYSTEM_LIBXUL michael@0: SKIP_COPY_XULRUNNER=1 michael@0: endif michael@0: michael@0: # ELOG prints out failed command when building silently (gmake -s). Pymake michael@0: # prints out failed commands anyway, so ELOG just makes things worse by michael@0: # forcing shell invocations. michael@0: ifndef .PYMAKE michael@0: ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS)))) michael@0: ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh michael@0: else michael@0: ELOG := michael@0: endif # -s michael@0: else michael@0: ELOG := michael@0: endif # ifndef .PYMAKE michael@0: michael@0: _VPATH_SRCS = $(abspath $<) michael@0: michael@0: ################################################################################ michael@0: # Testing frameworks support michael@0: ################################################################################ michael@0: michael@0: testxpcobjdir = $(DEPTH)/_tests/xpcshell michael@0: michael@0: ifdef ENABLE_TESTS michael@0: michael@0: # Add test directories to the regular directories list. TEST_DIRS should michael@0: # arguably have the same status as TOOL_DIRS and other *_DIRS variables. It is michael@0: # coded this way until Makefiles stop using the "ifdef ENABLE_TESTS; DIRS +=" michael@0: # convention. michael@0: # michael@0: # The current developer workflow expects tests to be updated when processing michael@0: # the default target. If we ever change this implementation, the behavior michael@0: # should be preserved or the change should be widely communicated. A michael@0: # consequence of not processing test dir targets during the default target is michael@0: # that changes to tests may not be updated and code could assume to pass michael@0: # locally against non-current test code. michael@0: DIRS += $(TEST_DIRS) michael@0: michael@0: ifdef CPP_UNIT_TESTS michael@0: ifdef COMPILE_ENVIRONMENT michael@0: michael@0: # Compile the tests to $(DIST)/bin. Make lots of niceties available by default michael@0: # through TestHarness.h, by modifying the list of includes and the libs against michael@0: # which stuff links. michael@0: CPPSRCS += $(CPP_UNIT_TESTS) michael@0: CPP_UNIT_TEST_BINS := $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX)) michael@0: SIMPLE_PROGRAMS += $(CPP_UNIT_TEST_BINS) michael@0: INCLUDES += -I$(DIST)/include/testing michael@0: LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS) michael@0: michael@0: ifndef MOZ_PROFILE_GENERATE michael@0: libs:: $(CPP_UNIT_TEST_BINS) $(call mkdir_deps,$(DIST)/cppunittests) michael@0: $(NSINSTALL) $(CPP_UNIT_TEST_BINS) $(DIST)/cppunittests michael@0: endif michael@0: michael@0: run-cppunittests:: michael@0: @$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)) michael@0: michael@0: cppunittests-remote: DM_TRANS?=adb michael@0: cppunittests-remote: michael@0: @if [ '${TEST_DEVICE}' != '' -o '$(DM_TRANS)' = 'adb' ]; then \ michael@0: $(PYTHON) -u $(topsrcdir)/testing/remotecppunittests.py \ michael@0: --xre-path=$(DEPTH)/dist/bin \ michael@0: --localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \ michael@0: --dm_trans=$(DM_TRANS) \ michael@0: --deviceIP=${TEST_DEVICE} \ michael@0: $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)) $(EXTRA_TEST_ARGS); \ michael@0: else \ michael@0: echo 'please prepare your host with environment variables for TEST_DEVICE'; \ michael@0: fi michael@0: michael@0: endif # COMPILE_ENVIRONMENT michael@0: endif # CPP_UNIT_TESTS michael@0: michael@0: .PHONY: check michael@0: michael@0: ifdef PYTHON_UNIT_TESTS michael@0: michael@0: RUN_PYTHON_UNIT_TESTS := $(addsuffix -run,$(PYTHON_UNIT_TESTS)) michael@0: michael@0: .PHONY: $(RUN_PYTHON_UNIT_TESTS) michael@0: michael@0: check:: $(RUN_PYTHON_UNIT_TESTS) michael@0: michael@0: $(RUN_PYTHON_UNIT_TESTS): %-run: % michael@0: @PYTHONDONTWRITEBYTECODE=1 $(PYTHON) $< michael@0: michael@0: endif # PYTHON_UNIT_TESTS michael@0: michael@0: endif # ENABLE_TESTS michael@0: michael@0: michael@0: # michael@0: # Library rules michael@0: # michael@0: # If FORCE_STATIC_LIB is set, build a static library. michael@0: # Otherwise, build a shared library. michael@0: # michael@0: michael@0: ifndef LIBRARY michael@0: ifdef STATIC_LIBRARY_NAME michael@0: REAL_LIBRARY := $(LIB_PREFIX)$(STATIC_LIBRARY_NAME).$(LIB_SUFFIX) michael@0: # Only build actual library if it is installed in DIST/lib or SDK michael@0: ifeq (,$(SDK_LIBRARY)$(DIST_INSTALL)$(NO_EXPAND_LIBS)) michael@0: LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX) michael@0: else michael@0: LIBRARY := $(REAL_LIBRARY) $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX) michael@0: endif michael@0: endif # STATIC_LIBRARY_NAME michael@0: endif # LIBRARY michael@0: michael@0: ifndef HOST_LIBRARY michael@0: ifdef HOST_LIBRARY_NAME michael@0: HOST_LIBRARY := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX) michael@0: endif michael@0: endif michael@0: michael@0: ifdef LIBRARY michael@0: ifdef FORCE_SHARED_LIB michael@0: ifdef MKSHLIB michael@0: michael@0: ifdef LIB_IS_C_ONLY michael@0: MKSHLIB = $(MKCSHLIB) michael@0: endif michael@0: michael@0: ifneq (,$(filter WINNT,$(OS_ARCH))) michael@0: IMPORT_LIBRARY := $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX) michael@0: endif michael@0: michael@0: ifdef MAKE_FRAMEWORK michael@0: SHARED_LIBRARY := $(SHARED_LIBRARY_NAME) michael@0: else michael@0: SHARED_LIBRARY := $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX) michael@0: endif michael@0: michael@0: EMBED_MANIFEST_AT=2 michael@0: michael@0: endif # MKSHLIB michael@0: endif # FORCE_SHARED_LIB michael@0: endif # LIBRARY michael@0: michael@0: ifdef FORCE_STATIC_LIB michael@0: ifndef FORCE_SHARED_LIB michael@0: SHARED_LIBRARY := $(NULL) michael@0: DEF_FILE := $(NULL) michael@0: IMPORT_LIBRARY := $(NULL) michael@0: endif michael@0: endif michael@0: michael@0: ifdef FORCE_SHARED_LIB michael@0: ifndef FORCE_STATIC_LIB michael@0: LIBRARY := $(NULL) michael@0: endif michael@0: endif michael@0: michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: ifndef GNU_CC michael@0: michael@0: # michael@0: # Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per michael@0: # directory. For parallel builds, this PDB file is shared and locked by michael@0: # MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8 michael@0: # without SP1, don't do parallel builds. michael@0: # michael@0: # The final PDB for libraries and programs is created by the linker and uses michael@0: # a different name from the single PDB file created by the compiler. See michael@0: # bug 462740. michael@0: # michael@0: michael@0: ifdef SIMPLE_PROGRAMS michael@0: COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb michael@0: else michael@0: COMPILE_PDB_FLAG ?= -Fdgenerated.pdb michael@0: endif michael@0: COMPILE_CFLAGS += $(COMPILE_PDB_FLAG) michael@0: COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG) michael@0: michael@0: LINK_PDBFILE ?= $(basename $(@F)).pdb michael@0: ifdef MOZ_DEBUG michael@0: CODFILE=$(basename $(@F)).cod michael@0: endif michael@0: michael@0: ifdef DEFFILE michael@0: OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE)) michael@0: EXTRA_DEPS += $(DEFFILE) michael@0: endif michael@0: michael@0: else #!GNU_CC michael@0: michael@0: ifdef DEFFILE michael@0: OS_LDFLAGS += $(call normalizepath,$(DEFFILE)) michael@0: EXTRA_DEPS += $(DEFFILE) michael@0: endif michael@0: michael@0: endif # !GNU_CC michael@0: michael@0: endif # WINNT michael@0: michael@0: ifeq ($(SOLARIS_SUNPRO_CXX),1) michael@0: ifeq (86,$(findstring 86,$(OS_TEST))) michael@0: OS_LDFLAGS += -M $(topsrcdir)/config/solaris_ia32.map michael@0: endif # x86 michael@0: endif # Solaris Sun Studio C++ michael@0: michael@0: ifeq ($(HOST_OS_ARCH),WINNT) michael@0: HOST_PDBFILE=$(basename $(@F)).pdb michael@0: HOST_PDB_FLAG ?= -Fd$(HOST_PDBFILE) michael@0: HOST_CFLAGS += $(HOST_PDB_FLAG) michael@0: HOST_CXXFLAGS += $(HOST_PDB_FLAG) michael@0: endif michael@0: michael@0: # Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: EXCLUDED_OBJS := $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) michael@0: SIMPLE_PROGRAMS := michael@0: endif michael@0: michael@0: ifdef COMPILE_ENVIRONMENT michael@0: ifndef TARGETS michael@0: TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) michael@0: endif michael@0: michael@0: COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX))) michael@0: SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX))) michael@0: # CPPSRCS can have different extensions (eg: .cpp, .cc) michael@0: CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS)))) michael@0: CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX))) michael@0: CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX))) michael@0: ASOBJS = $(notdir $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))) michael@0: ifndef OBJS michael@0: _OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS) michael@0: OBJS = $(strip $(_OBJS)) michael@0: endif michael@0: michael@0: HOST_COBJS = $(addprefix host_,$(notdir $(HOST_CSRCS:.c=.$(OBJ_SUFFIX)))) michael@0: # HOST_CPPOBJS can have different extensions (eg: .cpp, .cc) michael@0: HOST_CPPOBJS = $(addprefix host_,$(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(HOST_CPPSRCS))))) michael@0: HOST_CMOBJS = $(addprefix host_,$(notdir $(HOST_CMSRCS:.m=.$(OBJ_SUFFIX)))) michael@0: HOST_CMMOBJS = $(addprefix host_,$(notdir $(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))) michael@0: ifndef HOST_OBJS michael@0: _HOST_OBJS = $(HOST_COBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS) michael@0: HOST_OBJS = $(strip $(_HOST_OBJS)) michael@0: endif michael@0: else michael@0: LIBRARY := michael@0: SHARED_LIBRARY := michael@0: IMPORT_LIBRARY := michael@0: REAL_LIBRARY := michael@0: PROGRAM := michael@0: SIMPLE_PROGRAMS := michael@0: HOST_LIBRARY := michael@0: HOST_PROGRAM := michael@0: HOST_SIMPLE_PROGRAMS := michael@0: SDK_BINARY := $(filter %.py,$(SDK_BINARY)) michael@0: SDK_LIBRARY := michael@0: endif michael@0: michael@0: ALL_TRASH = \ michael@0: $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \ michael@0: $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \ michael@0: $(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \ michael@0: $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\ michael@0: $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \ michael@0: $(wildcard *.pdb) $(CODFILE) $(IMPORT_LIBRARY) \ michael@0: $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \ michael@0: $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \ michael@0: $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \ michael@0: $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \ michael@0: $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp) michael@0: ALL_TRASH_DIRS = \ michael@0: $(GARBAGE_DIRS) /no-such-file michael@0: michael@0: ifdef QTDIR michael@0: GARBAGE += $(MOCSRCS) michael@0: endif michael@0: michael@0: ifdef SIMPLE_PROGRAMS michael@0: GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX)) michael@0: endif michael@0: michael@0: ifdef HOST_SIMPLE_PROGRAMS michael@0: GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX)) michael@0: endif michael@0: michael@0: # michael@0: # the Solaris WorkShop template repository cache. it occasionally can get michael@0: # out of sync, so targets like clobber should kill it. michael@0: # michael@0: ifeq ($(SOLARIS_SUNPRO_CXX),1) michael@0: GARBAGE_DIRS += SunWS_cache michael@0: endif michael@0: michael@0: ifdef MOZ_UPDATE_XTERM michael@0: # Its good not to have a newline at the end of the titlebar string because it michael@0: # makes the make -s output easier to read. Echo -n does not work on all michael@0: # platforms, but we can trick printf into doing it. michael@0: UPDATE_TITLE = printf '\033]0;%s in %s\007' $(1) $(relativesrcdir)/$(2) ; michael@0: endif michael@0: michael@0: ifdef MACH michael@0: ifndef NO_BUILDSTATUS_MESSAGES michael@0: define BUILDSTATUS michael@0: @echo 'BUILDSTATUS $1' michael@0: michael@0: endef michael@0: endif michael@0: endif michael@0: michael@0: define SUBMAKE # $(call SUBMAKE,target,directory,static) michael@0: +@$(UPDATE_TITLE) michael@0: +$(MAKE) $(if $(2),-C $(2)) $(1) michael@0: michael@0: endef # The extra line is important here! don't delete it michael@0: michael@0: define TIER_DIR_SUBMAKE michael@0: $(call SUBMAKE,$(4),$(3),$(5)) michael@0: michael@0: endef # Ths empty line is important. michael@0: michael@0: ifneq (,$(strip $(DIRS))) michael@0: LOOP_OVER_DIRS = \ michael@0: $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir))) michael@0: endif michael@0: michael@0: # we only use this for the makefiles target and other stuff that doesn't matter michael@0: ifneq (,$(strip $(PARALLEL_DIRS))) michael@0: LOOP_OVER_PARALLEL_DIRS = \ michael@0: $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir))) michael@0: endif michael@0: michael@0: ifneq (,$(strip $(TOOL_DIRS))) michael@0: LOOP_OVER_TOOL_DIRS = \ michael@0: $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir))) michael@0: endif michael@0: michael@0: # michael@0: # Now we can differentiate between objects used to build a library, and michael@0: # objects used to build an executable in the same directory. michael@0: # michael@0: ifndef PROGOBJS michael@0: PROGOBJS = $(OBJS) michael@0: endif michael@0: michael@0: ifndef HOST_PROGOBJS michael@0: HOST_PROGOBJS = $(HOST_OBJS) michael@0: endif michael@0: michael@0: GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR)) michael@0: michael@0: # michael@0: # Tags: emacs (etags), vi (ctags) michael@0: # TAG_PROGRAM := ctags -L - michael@0: # michael@0: TAG_PROGRAM = xargs etags -a michael@0: michael@0: # michael@0: # Turn on C++ linking if we have any .cpp or .mm files michael@0: # (moved this from config.mk so that config.mk can be included michael@0: # before the CPPSRCS are defined) michael@0: # michael@0: ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),) michael@0: HOST_CPP_PROG_LINK = 1 michael@0: endif michael@0: michael@0: # michael@0: # This will strip out symbols that the component should not be michael@0: # exporting from the .dynsym section. michael@0: # michael@0: ifdef IS_COMPONENT michael@0: EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS) michael@0: endif # IS_COMPONENT michael@0: michael@0: # michael@0: # MacOS X specific stuff michael@0: # michael@0: michael@0: ifeq ($(OS_ARCH),Darwin) michael@0: ifdef SHARED_LIBRARY michael@0: ifdef IS_COMPONENT michael@0: EXTRA_DSO_LDOPTS += -bundle michael@0: else michael@0: EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be michael@0: # fatal symbol name clashes between components. michael@0: # michael@0: ifeq ($(OS_ARCH),NetBSD) michael@0: ifeq ($(DLL_SUFFIX),.so.1.0) michael@0: ifdef IS_COMPONENT michael@0: EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifeq ($(OS_ARCH),FreeBSD) michael@0: ifdef IS_COMPONENT michael@0: EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic michael@0: endif michael@0: endif michael@0: michael@0: ifeq ($(OS_ARCH),NetBSD) michael@0: ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST))) michael@0: ifneq (,$(filter layout/%,$(relativesrcdir))) michael@0: OS_CFLAGS += -Wa,-xgot michael@0: OS_CXXFLAGS += -Wa,-xgot michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag michael@0: # which uses internal symbols first michael@0: # michael@0: ifeq ($(OS_ARCH),HP-UX) michael@0: ifdef IS_COMPONENT michael@0: ifeq ($(GNU_CC)$(GNU_CXX),) michael@0: EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic michael@0: ifneq ($(HAS_EXTRAEXPORTS),1) michael@0: MKSHLIB += -Wl,+eNSGetModule -Wl,+eerrno michael@0: MKCSHLIB += +eNSGetModule +eerrno michael@0: ifneq ($(OS_TEST),ia64) michael@0: MKSHLIB += -Wl,+e_shlInit michael@0: MKCSHLIB += +e_shlInit michael@0: endif # !ia64 michael@0: endif # !HAS_EXTRAEXPORTS michael@0: endif # non-gnu compilers michael@0: endif # IS_COMPONENT michael@0: endif # HP-UX michael@0: michael@0: ifeq ($(OS_ARCH),AIX) michael@0: ifdef IS_COMPONENT michael@0: ifneq ($(HAS_EXTRAEXPORTS),1) michael@0: MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall michael@0: MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall michael@0: endif # HAS_EXTRAEXPORTS michael@0: endif # IS_COMPONENT michael@0: endif # AIX michael@0: michael@0: # michael@0: # Linux: add -Bsymbolic flag for components michael@0: # michael@0: ifeq ($(OS_ARCH),Linux) michael@0: ifdef IS_COMPONENT michael@0: EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # GNU doesn't have path length limitation michael@0: # michael@0: michael@0: ifeq ($(OS_ARCH),GNU) michael@0: OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024 michael@0: endif michael@0: michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: ifdef USE_DELAYIMP michael@0: OS_LIBS += $(call EXPAND_LIBNAME,delayimp) michael@0: endif michael@0: endif michael@0: michael@0: # michael@0: # MINGW32 michael@0: # michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: ifdef GNU_CC michael@0: ifndef IS_COMPONENT michael@0: DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifeq ($(USE_TVFS),1) michael@0: IFLAGS1 = -rb michael@0: IFLAGS2 = -rb michael@0: else michael@0: IFLAGS1 = -m 644 michael@0: IFLAGS2 = -m 755 michael@0: endif michael@0: michael@0: ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) michael@0: OUTOPTION = -Fo# eol michael@0: PREPROCESS_OPTION = -P -Fi# eol michael@0: else michael@0: OUTOPTION = -o # eol michael@0: PREPROCESS_OPTION = -E -o #eol michael@0: endif # WINNT && !GNU_CC michael@0: michael@0: ifneq (,$(filter ml%,$(AS))) michael@0: ASOUTOPTION = -Fo# eol michael@0: else michael@0: ASOUTOPTION = -o # eol michael@0: endif michael@0: michael@0: ifeq (,$(CROSS_COMPILE)) michael@0: HOST_OUTOPTION = $(OUTOPTION) michael@0: else michael@0: HOST_OUTOPTION = -o # eol michael@0: endif michael@0: ################################################################################ michael@0: michael@0: # Ensure the build config is up to date. This is done automatically when builds michael@0: # are performed through |mach build|. The check here is to catch people not michael@0: # using mach. If we ever enforce builds through mach, this code can be removed. michael@0: ifndef MOZBUILD_BACKEND_CHECKED michael@0: ifndef MACH michael@0: ifndef TOPLEVEL_BUILD michael@0: $(DEPTH)/backend.RecursiveMakeBackend: michael@0: $(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config) michael@0: michael@0: include $(DEPTH)/backend.RecursiveMakeBackend.pp michael@0: michael@0: default:: $(DEPTH)/backend.RecursiveMakeBackend michael@0: michael@0: export MOZBUILD_BACKEND_CHECKED=1 michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: # The root makefile doesn't want to do a plain export/libs, because michael@0: # of the tiers and because of libxul. Suppress the default rules in favor michael@0: # of something else. Makefiles which use this var *must* provide a sensible michael@0: # default rule before including rules.mk michael@0: default all:: michael@0: $(MAKE) export michael@0: ifdef MOZ_PSEUDO_DERECURSE michael@0: ifdef COMPILE_ENVIRONMENT michael@0: $(MAKE) compile michael@0: endif michael@0: endif michael@0: $(MAKE) libs michael@0: $(MAKE) tools michael@0: michael@0: ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),) michael@0: ECHO := echo michael@0: QUIET := michael@0: else michael@0: ECHO := true michael@0: QUIET := -q michael@0: endif michael@0: michael@0: # Do everything from scratch michael@0: everything:: michael@0: $(MAKE) clean michael@0: $(MAKE) all michael@0: michael@0: ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS))) michael@0: $(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only) michael@0: endif michael@0: michael@0: HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS)) michael@0: michael@0: # Dependencies which, if modified, should cause everything to rebuild michael@0: GLOBAL_DEPS += Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk michael@0: michael@0: ############################################## michael@0: ifdef COMPILE_ENVIRONMENT michael@0: OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS) michael@0: michael@0: compile:: $(OBJ_TARGETS) michael@0: michael@0: include $(topsrcdir)/config/makefiles/target_binaries.mk michael@0: endif michael@0: michael@0: ifdef IS_TOOL_DIR michael@0: # One would think "tools:: libs" would work, but it turns out that combined with michael@0: # bug 907365, this makes make forget to run some rules sometimes. michael@0: tools:: michael@0: @$(MAKE) libs michael@0: endif michael@0: michael@0: ############################################## michael@0: ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE)) michael@0: ifdef MOZ_PROFILE_USE michael@0: ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) michael@0: # When building with PGO, we have to make sure to re-link michael@0: # in the MOZ_PROFILE_USE phase if we linked in the michael@0: # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink michael@0: # file in the link rule in the GENERATE phase to indicate michael@0: # that we need a relink. michael@0: ifdef SHARED_LIBRARY michael@0: $(SHARED_LIBRARY): pgo.relink michael@0: endif michael@0: ifdef PROGRAM michael@0: $(PROGRAM): pgo.relink michael@0: endif michael@0: michael@0: # In the second pass, we need to merge the pgc files into the pgd file. michael@0: # The compiler would do this for us automatically if they were in the right michael@0: # place, but they're in dist/bin. michael@0: ifneq (,$(SHARED_LIBRARY)$(PROGRAM)) michael@0: export:: michael@0: ifdef PROGRAM michael@0: $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \ michael@0: $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin michael@0: endif michael@0: ifdef SHARED_LIBRARY michael@0: $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \ michael@0: $(SHARED_LIBRARY_NAME) $(DIST)/bin michael@0: endif michael@0: endif # SHARED_LIBRARY || PROGRAM michael@0: endif # WINNT_ michael@0: endif # MOZ_PROFILE_USE michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: # Clean up profiling data during PROFILE_GENERATE phase michael@0: export:: michael@0: ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_) michael@0: $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);) michael@0: else michael@0: ifdef GNU_CC michael@0: -$(RM) *.gcda michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE)) michael@0: ifdef GNU_CC michael@0: # Force rebuilding libraries and programs in both passes because each michael@0: # pass uses different object files. michael@0: $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE michael@0: endif michael@0: endif michael@0: michael@0: endif # NO_PROFILE_GUIDED_OPTIMIZE michael@0: michael@0: ############################################## michael@0: michael@0: checkout: michael@0: $(MAKE) -C $(topsrcdir) -f client.mk checkout michael@0: michael@0: clean clobber realclean clobber_all:: michael@0: -$(RM) $(ALL_TRASH) michael@0: -$(RM) -r $(ALL_TRASH_DIRS) michael@0: michael@0: ifdef TIERS michael@0: clean clobber realclean clobber_all distclean:: michael@0: $(foreach dir, \ michael@0: $(foreach tier, $(TIERS), $(tier_$(tier)_staticdirs) $(tier_$(tier)_dirs)), \ michael@0: -$(call SUBMAKE,$@,$(dir))) michael@0: else michael@0: clean clobber realclean clobber_all distclean:: michael@0: $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir))) michael@0: endif michael@0: michael@0: distclean:: michael@0: -$(RM) -r $(ALL_TRASH_DIRS) michael@0: -$(RM) $(ALL_TRASH) \ michael@0: Makefile .HSancillary \ michael@0: $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \ michael@0: $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \ michael@0: $(wildcard *.$(IMPORT_LIB_SUFFIX)) michael@0: michael@0: alltags: michael@0: $(RM) TAGS michael@0: find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM) michael@0: michael@0: # michael@0: # PROGRAM = Foo michael@0: # creates OBJS, links with LIBS to create Foo michael@0: # michael@0: $(PROGRAM): $(PROGOBJS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: @$(RM) $@.manifest michael@0: ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) michael@0: $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS) michael@0: ifdef MSMANIFEST_TOOL michael@0: @if test -f $@.manifest; then \ michael@0: if test -f '$(srcdir)/$@.manifest'; then \ michael@0: echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \ michael@0: else \ michael@0: echo 'Embedding manifest from $@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ michael@0: fi; \ michael@0: elif test -f '$(srcdir)/$@.manifest'; then \ michael@0: echo 'Embedding manifest from $(srcdir)/$@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \ michael@0: fi michael@0: endif # MSVC with manifest tool michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: # touch it a few seconds into the future to work around FAT's michael@0: # 2-second granularity michael@0: touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink michael@0: endif michael@0: else # !WINNT || GNU_CC michael@0: $(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS) michael@0: $(call CHECK_BINARY,$@) michael@0: endif # WINNT && !GNU_CC michael@0: michael@0: ifdef ENABLE_STRIP michael@0: $(STRIP) $(STRIP_FLAGS) $@ michael@0: endif michael@0: ifdef MOZ_POST_PROGRAM_COMMAND michael@0: $(MOZ_POST_PROGRAM_COMMAND) $@ michael@0: endif michael@0: michael@0: $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH)) michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: ifdef MSMANIFEST_TOOL michael@0: @if test -f $@.manifest; then \ michael@0: if test -f '$(srcdir)/$@.manifest'; then \ michael@0: echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \ michael@0: else \ michael@0: echo 'Embedding manifest from $@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ michael@0: fi; \ michael@0: elif test -f '$(srcdir)/$@.manifest'; then \ michael@0: echo 'Embedding manifest from $(srcdir)/$@.manifest'; \ michael@0: mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \ michael@0: fi michael@0: endif # MSVC with manifest tool michael@0: else michael@0: ifeq ($(HOST_CPP_PROG_LINK),1) michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: else michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: endif # HOST_CPP_PROG_LINK michael@0: endif michael@0: michael@0: # michael@0: # This is an attempt to support generation of multiple binaries michael@0: # in one directory, it assumes everything to compile Foo is in michael@0: # Foo.o (from either Foo.c or Foo.cpp). michael@0: # michael@0: # SIMPLE_PROGRAMS = Foo Bar michael@0: # creates Foo.o Bar.o, links with LIBS to create Foo, Bar. michael@0: # michael@0: $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) michael@0: $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS) michael@0: ifdef MSMANIFEST_TOOL michael@0: @if test -f $@.manifest; then \ michael@0: mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \ michael@0: rm -f $@.manifest; \ michael@0: fi michael@0: endif # MSVC with manifest tool michael@0: else michael@0: $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS) michael@0: $(call CHECK_BINARY,$@) michael@0: endif # WINNT && !GNU_CC michael@0: michael@0: ifdef ENABLE_STRIP michael@0: $(STRIP) $(STRIP_FLAGS) $@ michael@0: endif michael@0: ifdef MOZ_POST_PROGRAM_COMMAND michael@0: $(MOZ_POST_PROGRAM_COMMAND) $@ michael@0: endif michael@0: michael@0: $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC)) michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: else michael@0: ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX)) michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: else michael@0: $(EXPAND_LIBS_EXEC) -- $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS) michael@0: endif michael@0: endif michael@0: michael@0: ifdef DTRACE_PROBE_OBJ michael@0: EXTRA_DEPS += $(DTRACE_PROBE_OBJ) michael@0: OBJS += $(DTRACE_PROBE_OBJ) michael@0: endif michael@0: michael@0: $(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: $(RM) $(LIBRARY) michael@0: $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(SHARED_LIBRARY_LIBS) michael@0: michael@0: $(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: # When we only build a library descriptor, blow out any existing library michael@0: $(REPORT_BUILD) michael@0: $(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY) $(EXPORT_LIBRARY:%=%/$(REAL_LIBRARY))) michael@0: $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(SHARED_LIBRARY_LIBS) michael@0: michael@0: ifeq ($(OS_ARCH),WINNT) michael@0: # Import libraries are created by the rules creating shared libraries. michael@0: # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY), michael@0: # but make will happily consider the import library before it is refreshed michael@0: # when rebuilding the corresponding shared library. Defining an empty recipe michael@0: # for import libraries forces make to wait for the shared library recipe to michael@0: # have run before considering other targets that depend on the import library. michael@0: # See bug 795204. michael@0: $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ; michael@0: endif michael@0: michael@0: $(HOST_LIBRARY): $(HOST_OBJS) Makefile michael@0: $(REPORT_BUILD) michael@0: $(RM) $@ michael@0: $(EXPAND_LIBS_EXEC) --extract -- $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS) michael@0: michael@0: ifdef HAVE_DTRACE michael@0: ifndef XP_MACOSX michael@0: ifdef DTRACE_PROBE_OBJ michael@0: ifndef DTRACE_LIB_DEPENDENT michael@0: NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS)) michael@0: $(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS) michael@0: dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS) michael@0: endif michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files, michael@0: # so instead of deleting .o files after repacking them into a dylib, we make michael@0: # symlinks back to the originals. The symlinks are a no-op for stabs debugging, michael@0: # so no need to conditionalize on OS version or debugging format. michael@0: michael@0: $(SHARED_LIBRARY): $(OBJS) $(DEF_FILE) $(RESFILE) $(LIBRARY) $(EXTRA_DEPS) $(GLOBAL_DEPS) michael@0: $(REPORT_BUILD) michael@0: ifndef INCREMENTAL_LINKER michael@0: $(RM) $@ michael@0: endif michael@0: ifdef DTRACE_LIB_DEPENDENT michael@0: ifndef XP_MACOSX michael@0: dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS)) michael@0: endif michael@0: $(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) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS)) michael@0: @$(RM) $(DTRACE_PROBE_OBJ) michael@0: else # ! DTRACE_LIB_DEPENDENT michael@0: $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS)) michael@0: endif # DTRACE_LIB_DEPENDENT michael@0: $(call CHECK_BINARY,$@) michael@0: michael@0: ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) michael@0: ifdef MSMANIFEST_TOOL michael@0: ifdef EMBED_MANIFEST_AT michael@0: @if test -f $@.manifest; then \ michael@0: mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \ michael@0: rm -f $@.manifest; \ michael@0: fi michael@0: endif # EMBED_MANIFEST_AT michael@0: endif # MSVC with manifest tool michael@0: ifdef MOZ_PROFILE_GENERATE michael@0: touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink michael@0: endif michael@0: endif # WINNT && !GCC michael@0: @$(RM) foodummyfilefoo $(DELETE_AFTER_LINK) michael@0: chmod +x $@ michael@0: ifdef ENABLE_STRIP michael@0: $(STRIP) $(STRIP_FLAGS) $@ michael@0: endif michael@0: ifdef MOZ_POST_DSO_LIB_COMMAND michael@0: $(MOZ_POST_DSO_LIB_COMMAND) $@ michael@0: endif michael@0: michael@0: ifeq ($(SOLARIS_SUNPRO_CC),1) michael@0: _MDDEPFILE = $(MDDEPDIR)/$(@F).pp michael@0: michael@0: define MAKE_DEPS_AUTO_CC michael@0: if test -d $(@D); then \ michael@0: echo 'Building deps for $< using Sun Studio cc'; \ michael@0: $(CC) $(COMPILE_CFLAGS) -xM $< >$(_MDDEPFILE) ; \ michael@0: $(PYTHON) $(topsrcdir)/build/unix/add_phony_targets.py $(_MDDEPFILE) ; \ michael@0: fi michael@0: endef michael@0: define MAKE_DEPS_AUTO_CXX michael@0: if test -d $(@D); then \ michael@0: echo 'Building deps for $< using Sun Studio CC'; \ michael@0: $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \ michael@0: $(PYTHON) $(topsrcdir)/build/unix/add_phony_targets.py $(_MDDEPFILE) ; \ michael@0: fi michael@0: endef michael@0: endif # Sun Studio on Solaris michael@0: michael@0: # The object file is in the current directory, and the source file can be any michael@0: # relative path. This macro adds the dependency obj: src for each source file. michael@0: # This dependency must be first for the $< flag to work correctly, and the michael@0: # rules that have commands for these targets must not list any other michael@0: # prerequisites, or they will override the $< variable. michael@0: define src_objdep michael@0: $(basename $2$(notdir $1)).$(OBJ_SUFFIX): $1 $$(call mkdir_deps,$$(MDDEPDIR)) michael@0: endef michael@0: $(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f)))) michael@0: $(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),host_))) michael@0: michael@0: $(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS) michael@0: michael@0: # Rules for building native targets must come first because of the host_ prefix michael@0: $(HOST_COBJS): michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS) michael@0: michael@0: $(HOST_CPPOBJS): michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS) michael@0: michael@0: $(HOST_CMOBJS): michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS) michael@0: michael@0: $(HOST_CMMOBJS): michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS) michael@0: michael@0: $(COBJS): michael@0: $(REPORT_BUILD) michael@0: @$(MAKE_DEPS_AUTO_CC) michael@0: $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs: michael@0: # 'moc' only knows about #defines it gets on the command line (-D...), not in michael@0: # included headers like mozilla-config.h michael@0: $(filter moc_%.cpp,$(CPPSRCS)): moc_%.cpp: %.h michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@ michael@0: michael@0: $(filter moc_%.cc,$(CPPSRCS)): moc_%.cc: %.cc michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@ michael@0: michael@0: $(filter qrc_%.cpp,$(CPPSRCS)): qrc_%.cpp: %.qrc michael@0: $(REPORT_BUILD) michael@0: $(ELOG) $(RCC) -name $* $< $(OUTOPTION)$@ michael@0: michael@0: ifdef ASFILES michael@0: # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept michael@0: # a '-c' flag. michael@0: $(ASOBJS): michael@0: $(REPORT_BUILD) michael@0: $(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS) michael@0: endif michael@0: michael@0: $(SOBJS): michael@0: $(REPORT_BUILD) michael@0: $(AS) -o $@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) $(TARGET_LOCAL_INCLUDES) -c $< michael@0: michael@0: $(CPPOBJS): michael@0: $(REPORT_BUILD) michael@0: @$(MAKE_DEPS_AUTO_CXX) michael@0: $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(CMMOBJS): michael@0: $(REPORT_BUILD) michael@0: @$(MAKE_DEPS_AUTO_CXX) michael@0: $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(CMOBJS): michael@0: $(REPORT_BUILD) michael@0: @$(MAKE_DEPS_AUTO_CC) michael@0: $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.i,$(CPPSRCS:%.cpp=%.i)): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.i,$(CPPSRCS:%.cc=%.i)): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.i,$(CSRCS:%.c=%.i)): %.i: %.c $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(filter %.i,$(CMMSRCS:%.mm=%.i)): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR)) michael@0: $(REPORT_BUILD) michael@0: $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) michael@0: michael@0: $(RESFILE): %.res: %.rc michael@0: $(REPORT_BUILD) michael@0: @echo Creating Resource file: $@ michael@0: ifdef GNU_CC michael@0: $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS) michael@0: else michael@0: $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS) michael@0: endif michael@0: michael@0: # Cancel GNU make built-in implicit rules michael@0: ifndef .PYMAKE michael@0: MAKEFLAGS += -r michael@0: endif michael@0: michael@0: ifneq (,$(filter WINNT,$(OS_ARCH))) michael@0: SEP := ; michael@0: else michael@0: SEP := : michael@0: endif michael@0: michael@0: EMPTY := michael@0: SPACE := $(EMPTY) $(EMPTY) michael@0: michael@0: # MSYS has its own special path form, but javac expects the source and class michael@0: # paths to be in the DOS form (i.e. e:/builds/...). This function does the michael@0: # appropriate conversion on Windows, but is a noop on other systems. michael@0: ifeq ($(HOST_OS_ARCH),WINNT) michael@0: # We use 'pwd -W' to get DOS form of the path. However, since the given path michael@0: # could be a file or a non-existent path, we cannot call 'pwd -W' directly michael@0: # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W' michael@0: # on it, then merge with the rest of the path. michael@0: root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\1|') michael@0: non-root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\2|') michael@0: normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1))) michael@0: else michael@0: normalizepath = $(1) michael@0: endif michael@0: michael@0: ############################################################################### michael@0: # Java rules michael@0: ############################################################################### michael@0: ifneq (,$(JAVAFILES)$(ANDROID_RESFILES)$(ANDROID_APKNAME)$(JAVA_JAR_TARGETS)) michael@0: include $(topsrcdir)/config/makefiles/java-build.mk michael@0: endif michael@0: michael@0: ############################################################################### michael@0: # Bunch of things that extend the 'export' rule (in order): michael@0: ############################################################################### michael@0: michael@0: ifneq ($(XPI_NAME),) michael@0: $(FINAL_TARGET): michael@0: $(NSINSTALL) -D $@ michael@0: michael@0: export:: $(FINAL_TARGET) michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Copy each element of PREF_JS_EXPORTS michael@0: michael@0: # The default location for PREF_JS_EXPORTS is the gre prefs directory. michael@0: PREF_DIR = defaults/pref michael@0: michael@0: # If DIST_SUBDIR is defined it indicates that app and gre dirs are michael@0: # different and that we are building app related resources. Hence, michael@0: # PREF_DIR should point to the app prefs location. michael@0: ifneq (,$(DIST_SUBDIR)$(XPI_NAME)$(LIBXUL_SDK)) michael@0: PREF_DIR = defaults/preferences michael@0: endif michael@0: michael@0: # on win32, pref files need CRLF line endings... see bug 206029 michael@0: ifeq (WINNT,$(OS_ARCH)) michael@0: PREF_PPFLAGS += --line-endings=crlf michael@0: endif michael@0: michael@0: ifneq ($(PREF_JS_EXPORTS),) michael@0: ifndef NO_DIST_INSTALL michael@0: PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR) michael@0: PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS) michael@0: PP_TARGETS += PREF_JS_EXPORTS michael@0: endif michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig michael@0: michael@0: ifneq ($(AUTOCFG_JS_EXPORTS),) michael@0: ifndef NO_DIST_INSTALL michael@0: AUTOCFG_JS_EXPORTS_FILES := $(AUTOCFG_JS_EXPORTS) michael@0: AUTOCFG_JS_EXPORTS_DEST := $(FINAL_TARGET)/defaults/autoconfig michael@0: AUTOCFG_JS_EXPORTS_TARGET := export michael@0: INSTALL_TARGETS += AUTOCFG_JS_EXPORTS michael@0: endif michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Install a linked .xpt into the appropriate place. michael@0: # This should ideally be performed by the non-recursive idl make file. Some day. michael@0: ifdef XPT_NAME #{ michael@0: michael@0: ifndef NO_DIST_INSTALL michael@0: _XPT_NAME_FILES := $(DEPTH)/config/makefiles/xpidl/xpt/$(XPT_NAME) michael@0: _XPT_NAME_DEST := $(FINAL_TARGET)/components michael@0: INSTALL_TARGETS += _XPT_NAME michael@0: michael@0: ifndef NO_INTERFACES_MANIFEST michael@0: libs:: $(call mkdir_deps,$(FINAL_TARGET)/components) michael@0: $(call py_action,buildlist,$(FINAL_TARGET)/components/interfaces.manifest 'interfaces $(XPT_NAME)') michael@0: $(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest 'manifest components/interfaces.manifest') michael@0: endif michael@0: endif michael@0: michael@0: endif #} XPT_NAME michael@0: michael@0: ################################################################################ michael@0: # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components michael@0: ifneq (,$(filter %.js,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))) michael@0: ifeq (,$(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))) michael@0: ifndef NO_JS_MANIFEST michael@0: $(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0) michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: ifdef EXTRA_COMPONENTS michael@0: libs:: $(EXTRA_COMPONENTS) michael@0: ifndef NO_DIST_INSTALL michael@0: EXTRA_COMPONENTS_FILES := $(EXTRA_COMPONENTS) michael@0: EXTRA_COMPONENTS_DEST := $(FINAL_TARGET)/components michael@0: INSTALL_TARGETS += EXTRA_COMPONENTS michael@0: endif michael@0: michael@0: endif michael@0: michael@0: ifdef EXTRA_PP_COMPONENTS michael@0: ifndef NO_DIST_INSTALL michael@0: EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components michael@0: PP_TARGETS += EXTRA_PP_COMPONENTS michael@0: endif michael@0: endif michael@0: michael@0: EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)) michael@0: ifneq (,$(EXTRA_MANIFESTS)) michael@0: libs:: $(call mkdir_deps,$(FINAL_TARGET)) michael@0: $(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest $(patsubst %,'manifest components/%',$(notdir $(EXTRA_MANIFESTS)))) michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Copy each element of EXTRA_JS_MODULES to michael@0: # $(FINAL_TARGET)/$(JS_MODULES_PATH). JS_MODULES_PATH defaults to "modules" michael@0: # if it is undefined. michael@0: JS_MODULES_PATH ?= modules michael@0: FINAL_JS_MODULES_PATH := $(FINAL_TARGET)/$(JS_MODULES_PATH) michael@0: michael@0: ifdef EXTRA_JS_MODULES michael@0: ifndef NO_DIST_INSTALL michael@0: EXTRA_JS_MODULES_FILES := $(EXTRA_JS_MODULES) michael@0: EXTRA_JS_MODULES_DEST := $(FINAL_JS_MODULES_PATH) michael@0: INSTALL_TARGETS += EXTRA_JS_MODULES michael@0: endif michael@0: endif michael@0: michael@0: ifdef EXTRA_PP_JS_MODULES michael@0: ifndef NO_DIST_INSTALL michael@0: EXTRA_PP_JS_MODULES_PATH := $(FINAL_JS_MODULES_PATH) michael@0: PP_TARGETS += EXTRA_PP_JS_MODULES michael@0: endif michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Copy testing-only JS modules to appropriate destination. michael@0: # michael@0: # For each file defined in TESTING_JS_MODULES, copy it to michael@0: # objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path michael@0: # wlll be appended to the output directory. michael@0: michael@0: ifdef ENABLE_TESTS michael@0: ifdef TESTING_JS_MODULES michael@0: testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR) michael@0: michael@0: GENERATED_DIRS += $(testmodulesdir) michael@0: michael@0: ifndef NO_DIST_INSTALL michael@0: TESTING_JS_MODULES_FILES := $(TESTING_JS_MODULES) michael@0: TESTING_JS_MODULES_DEST := $(testmodulesdir) michael@0: INSTALL_TARGETS += TESTING_JS_MODULES michael@0: endif michael@0: michael@0: endif michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # SDK michael@0: michael@0: ifneq (,$(SDK_LIBRARY)) michael@0: ifndef NO_DIST_INSTALL michael@0: SDK_LIBRARY_FILES := $(SDK_LIBRARY) michael@0: SDK_LIBRARY_DEST := $(SDK_LIB_DIR) michael@0: INSTALL_TARGETS += SDK_LIBRARY michael@0: endif michael@0: endif # SDK_LIBRARY michael@0: michael@0: ifneq (,$(strip $(SDK_BINARY))) michael@0: ifndef NO_DIST_INSTALL michael@0: SDK_BINARY_FILES := $(SDK_BINARY) michael@0: SDK_BINARY_DEST := $(SDK_BIN_DIR) michael@0: INSTALL_TARGETS += SDK_BINARY michael@0: endif michael@0: endif # SDK_BINARY michael@0: michael@0: ################################################################################ michael@0: # CHROME PACKAGING michael@0: michael@0: chrome:: michael@0: $(MAKE) realchrome michael@0: $(LOOP_OVER_PARALLEL_DIRS) michael@0: $(LOOP_OVER_DIRS) michael@0: $(LOOP_OVER_TOOL_DIRS) michael@0: michael@0: $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome) michael@0: michael@0: ifneq (,$(JAR_MANIFEST)) michael@0: ifndef NO_DIST_INSTALL michael@0: michael@0: ifdef XPI_NAME michael@0: ifdef XPI_ROOT_APPID michael@0: # For add-on packaging we may specify that an application michael@0: # sub-dir should be added to the root chrome manifest with michael@0: # a specific application id. michael@0: MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)' michael@0: endif michael@0: michael@0: # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's michael@0: # no way langpacks will get packaged right, so error out. michael@0: ifneq (,$(DIST_SUBDIR)) michael@0: ifndef XPI_ROOT_APPID michael@0: $(error XPI_ROOT_APPID is not defined - langpacks will break.) michael@0: endif michael@0: endif michael@0: endif michael@0: michael@0: libs realchrome:: $(FINAL_TARGET)/chrome michael@0: $(call py_action,jar_maker,\ michael@0: $(QUIET) -j $(FINAL_TARGET)/chrome \ michael@0: $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \ michael@0: $(JAR_MANIFEST)) michael@0: michael@0: endif michael@0: michael@0: # This is a temporary check to ensure patches relying on the old behavior michael@0: # of silently picking up jar.mn files continue to work. michael@0: else # No JAR_MANIFEST michael@0: ifneq (,$(wildcard $(srcdir)/jar.mn)) michael@0: $(error $(srcdir) contains a jar.mn file but this file is not declared in a JAR_MANIFESTS variable in a moz.build file) michael@0: endif michael@0: endif michael@0: michael@0: ifneq ($(DIST_FILES),) michael@0: DIST_FILES_PATH := $(FINAL_TARGET) michael@0: DIST_FILES_FLAGS := $(XULAPP_DEFINES) michael@0: PP_TARGETS += DIST_FILES michael@0: endif michael@0: michael@0: ifneq ($(DIST_CHROME_FILES),) michael@0: DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome michael@0: DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES) michael@0: PP_TARGETS += DIST_CHROME_FILES michael@0: endif michael@0: michael@0: ifneq ($(XPI_PKGNAME),) michael@0: tools realchrome:: michael@0: ifdef STRIP_XPI michael@0: ifndef MOZ_DEBUG michael@0: @echo 'Stripping $(XPI_PKGNAME) package directory...' michael@0: @echo $(FINAL_TARGET) michael@0: @cd $(FINAL_TARGET) && find . ! -type d \ michael@0: ! -name '*.js' \ michael@0: ! -name '*.xpt' \ michael@0: ! -name '*.gif' \ michael@0: ! -name '*.jpg' \ michael@0: ! -name '*.png' \ michael@0: ! -name '*.xpm' \ michael@0: ! -name '*.txt' \ michael@0: ! -name '*.rdf' \ michael@0: ! -name '*.sh' \ michael@0: ! -name '*.properties' \ michael@0: ! -name '*.dtd' \ michael@0: ! -name '*.html' \ michael@0: ! -name '*.xul' \ michael@0: ! -name '*.css' \ michael@0: ! -name '*.xml' \ michael@0: ! -name '*.jar' \ michael@0: ! -name '*.dat' \ michael@0: ! -name '*.tbl' \ michael@0: ! -name '*.src' \ michael@0: ! -name '*.reg' \ michael@0: $(PLATFORM_EXCLUDE_LIST) \ michael@0: -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \; michael@0: endif michael@0: endif michael@0: @echo 'Packaging $(XPI_PKGNAME).xpi...' michael@0: cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi * michael@0: endif michael@0: michael@0: ifdef INSTALL_EXTENSION_ID michael@0: ifndef XPI_NAME michael@0: $(error XPI_NAME must be set for INSTALL_EXTENSION_ID) michael@0: endif michael@0: michael@0: tools:: michael@0: $(RM) -r '$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)' michael@0: $(NSINSTALL) -D '$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)' michael@0: $(call copy_dir,$(FINAL_TARGET),$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)) michael@0: michael@0: endif michael@0: michael@0: ############################################################################# michael@0: # MDDEPDIR is the subdirectory where all the dependency files are placed. michael@0: # This uses a make rule (instead of a macro) to support parallel michael@0: # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two michael@0: # processes could simultaneously try to create the same directory. michael@0: # michael@0: # We use $(CURDIR) in the rule's target to ensure that we don't find michael@0: # a dependency directory in the source tree via VPATH (perhaps from michael@0: # a previous build in the source tree) and thus neglect to create a michael@0: # dependency directory in the object directory, where we really need michael@0: # it. michael@0: michael@0: ifneq (,$(filter-out all chrome default export realchrome clean clobber clobber_all distclean realclean,$(MAKECMDGOALS))) michael@0: MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_MDDEPEND_FILES) $(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS))) $(TARGETS))))) michael@0: michael@0: ifneq (,$(MDDEPEND_FILES)) michael@0: $(call include_deps,$(MDDEPEND_FILES)) michael@0: endif michael@0: michael@0: endif michael@0: michael@0: michael@0: ifneq (,$(filter export,$(MAKECMDGOALS))) michael@0: MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_EXPORT_MDDEPEND_FILES)))) michael@0: michael@0: ifneq (,$(MDDEPEND_FILES)) michael@0: $(call include_deps,$(MDDEPEND_FILES)) michael@0: endif michael@0: michael@0: endif michael@0: michael@0: ############################################################################# michael@0: michael@0: -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk michael@0: -include $(MY_RULES) michael@0: michael@0: # michael@0: # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG) michael@0: # or in $(MY_RULES) michael@0: # michael@0: ifdef ETAGS michael@0: ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),) michael@0: all:: TAGS michael@0: TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS) michael@0: $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS) michael@0: endif michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Install/copy rules michael@0: # michael@0: # The INSTALL_TARGETS variable contains a list of all install target michael@0: # categories. Each category defines a list of files and executables, and an michael@0: # install destination, michael@0: # michael@0: # FOO_FILES := foo bar michael@0: # FOO_EXECUTABLES := baz michael@0: # FOO_DEST := target_path michael@0: # INSTALL_TARGETS += FOO michael@0: # michael@0: # Additionally, a FOO_TARGET variable may be added to indicate the target for michael@0: # which the files and executables are installed. Default is "libs". michael@0: # michael@0: # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given michael@0: # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is, michael@0: # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed michael@0: # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h michael@0: michael@0: # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall. michael@0: ifneq (,$(filter $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd))) michael@0: ifeq (,$(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX))) michael@0: nsinstall_is_usable = $(if $(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)),yes) michael@0: michael@0: define install_cmd_override michael@0: $(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1) michael@0: endef michael@0: endif michael@0: endif michael@0: michael@0: install_target_tier = $(or $($(1)_TARGET),libs) michael@0: INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category)))) michael@0: michael@0: install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2))) michael@0: install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file))) michael@0: install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file))) michael@0: michael@0: # Work around a GNU make 3.81 bug where it gives $< the wrong value. michael@0: # See details in bug 934864. michael@0: define create_dependency michael@0: $(1): $(2) michael@0: $(1): $(2) michael@0: endef michael@0: michael@0: define install_target_template michael@0: $(call install_cmd_override,$(2)) michael@0: $(call create_dependency,$(2),$(1)) michael@0: endef michael@0: michael@0: $(foreach category,$(INSTALL_TARGETS),\ michael@0: $(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \ michael@0: $(foreach tier,$(call install_target_tier,$(category)),\ michael@0: $(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \ michael@0: $(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \ michael@0: ) \ michael@0: $(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \ michael@0: $(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \ michael@0: ) \ michael@0: ) michael@0: michael@0: $(foreach tier,$(INSTALL_TARGETS_TIERS), \ michael@0: $(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \ michael@0: ) michael@0: michael@0: install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS)) michael@0: michael@0: $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))): michael@0: $(install_targets_sanity) michael@0: $(call install_cmd,$(IFLAGS1) '$<' '$(@D)') michael@0: michael@0: $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))): michael@0: $(install_targets_sanity) michael@0: $(call install_cmd,$(IFLAGS2) '$<' '$(@D)') michael@0: michael@0: ################################################################################ michael@0: # Preprocessing rules michael@0: # michael@0: # The PP_TARGETS variable contains a list of all preprocessing target michael@0: # categories. Each category has associated variables listing input files, the michael@0: # output directory, extra preprocessor flags, and so on. For example: michael@0: # michael@0: # FOO := input-file michael@0: # FOO_PATH := target-directory michael@0: # FOO_FLAGS := -Dsome_flag michael@0: # PP_TARGETS += FOO michael@0: # michael@0: # If PP_TARGETS lists a category name (like FOO, above), then we consult the michael@0: # following make variables to see what to do: michael@0: # michael@0: # - lists input files to be preprocessed with mozbuild.action.preprocessor. michael@0: # We search VPATH for the names given here. If an input file name ends in michael@0: # '.in', that suffix is omitted from the output file name. michael@0: # michael@0: # - _PATH names the directory in which to place the preprocessed output michael@0: # files. We create this directory if it does not already exist. Setting michael@0: # this variable is optional; if unset, we install the files in $(CURDIR). michael@0: # michael@0: # - _FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition michael@0: # to the usual bunch. Setting this variable is optional. michael@0: # michael@0: # - _TARGET names the 'make' target that should depend on creating the output michael@0: # files. Setting this variable is optional; if unset, we preprocess the michael@0: # files for the 'libs' target. michael@0: # michael@0: # - _KEEP_PATH may be set to 1 to indicate the paths given in are to be michael@0: # kept under _PATH. That is, if is bar/baz/qux.h.in and _PATH is michael@0: # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h michael@0: # instead of $(DIST)/include/qux.h. michael@0: michael@0: pp_target_tier = $(or $($(1)_TARGET),libs) michael@0: PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category)))) michael@0: michael@0: pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=))) michael@0: pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file))) michael@0: michael@0: $(foreach category,$(PP_TARGETS), \ michael@0: $(foreach tier,$(call pp_target_tier,$(category)), \ michael@0: $(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \ michael@0: ) \ michael@0: $(foreach file,$($(category)), \ michael@0: $(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \ michael@0: $(file) $(GLOBAL_DEPS))) \ michael@0: ) \ michael@0: $(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \ michael@0: ) michael@0: michael@0: $(foreach tier,$(PP_TARGETS_TIERS), \ michael@0: $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \ michael@0: ) michael@0: michael@0: PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier)))) michael@0: $(PP_TARGETS_ALL_RESULTS): michael@0: $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS)) michael@0: $(RM) '$@' michael@0: $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) '$<' -o '$@') michael@0: michael@0: # The depfile is based on the filename, and we don't want conflicts. So check michael@0: # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS. michael@0: PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS)) michael@0: $(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \ michael@0: $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \ michael@0: $(error Multiple preprocessing rules are creating a $(file) file) \ michael@0: ) \ michael@0: ) michael@0: michael@0: ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS))) michael@0: # If the depfile for a preprocessed file doesn't exist, add a dep to force michael@0: # re-preprocessing. michael@0: $(foreach file,$(PP_TARGETS_ALL_RESULTS), \ michael@0: $(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \ michael@0: , \ michael@0: $(eval $(file): FORCE) \ michael@0: ) \ michael@0: ) michael@0: michael@0: MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS)))))) michael@0: michael@0: ifneq (,$(MDDEPEND_FILES)) michael@0: $(call include_deps,$(MDDEPEND_FILES)) michael@0: endif michael@0: michael@0: endif michael@0: michael@0: # Pull in non-recursive targets if this is a partial tree build. michael@0: ifndef TOPLEVEL_BUILD michael@0: include $(topsrcdir)/config/makefiles/nonrecursive.mk michael@0: endif michael@0: michael@0: ################################################################################ michael@0: # Special gmake rules. michael@0: ################################################################################ michael@0: michael@0: michael@0: # michael@0: # Re-define the list of default suffixes, so gmake won't have to churn through michael@0: # hundreds of built-in suffix rules for stuff we don't need. michael@0: # michael@0: .SUFFIXES: michael@0: michael@0: # michael@0: # Fake targets. Always run these rules, even if a file/directory with that michael@0: # name already exists. michael@0: # michael@0: .PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE michael@0: michael@0: # Used as a dependency to force targets to rebuild michael@0: FORCE: michael@0: michael@0: # Delete target if error occurs when building target michael@0: .DELETE_ON_ERROR: michael@0: michael@0: tags: TAGS michael@0: michael@0: TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h) michael@0: -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h) michael@0: $(LOOP_OVER_PARALLEL_DIRS) michael@0: $(LOOP_OVER_DIRS) michael@0: michael@0: ifndef INCLUDED_DEBUGMAKE_MK #{ michael@0: ## Only parse when an echo* or show* target is requested michael@0: ifneq (,$(call isTargetStem,echo,show)) michael@0: include $(topsrcdir)/config/makefiles/debugmake.mk michael@0: endif #} michael@0: endif #} michael@0: michael@0: documentation: michael@0: @cd $(DEPTH) michael@0: $(DOXYGEN) $(DEPTH)/config/doxygen.cfg michael@0: michael@0: ifdef ENABLE_TESTS michael@0: check:: michael@0: $(LOOP_OVER_PARALLEL_DIRS) michael@0: $(LOOP_OVER_DIRS) michael@0: $(LOOP_OVER_TOOL_DIRS) michael@0: endif michael@0: michael@0: michael@0: FREEZE_VARIABLES = \ michael@0: CSRCS \ michael@0: CPPSRCS \ michael@0: EXPORTS \ michael@0: DIRS \ michael@0: LIBRARY \ michael@0: MODULE \ michael@0: TIERS \ michael@0: EXTRA_COMPONENTS \ michael@0: EXTRA_PP_COMPONENTS \ michael@0: $(NULL) michael@0: michael@0: $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) michael@0: michael@0: CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \ michael@0: $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).))) michael@0: michael@0: libs export:: michael@0: $(CHECK_FROZEN_VARIABLES) michael@0: michael@0: PURGECACHES_DIRS ?= $(DIST)/bin michael@0: ifdef MOZ_WEBAPP_RUNTIME michael@0: PURGECACHES_DIRS += $(DIST)/bin/webapprt michael@0: endif michael@0: michael@0: PURGECACHES_FILES = $(addsuffix /.purgecaches,$(PURGECACHES_DIRS)) michael@0: michael@0: default all:: $(PURGECACHES_FILES) michael@0: michael@0: $(PURGECACHES_FILES): michael@0: if test -d $(@D) ; then touch $@ ; fi michael@0: michael@0: .DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default) michael@0: michael@0: ############################################################################# michael@0: # Derived targets and dependencies michael@0: michael@0: include $(topsrcdir)/config/makefiles/autotargets.mk michael@0: ifneq ($(NULL),$(AUTO_DEPS)) michael@0: default all libs tools export:: $(AUTO_DEPS) michael@0: endif michael@0: michael@0: export:: $(GENERATED_FILES) michael@0: michael@0: GARBAGE += $(GENERATED_FILES)