# -*- makefile -*- # vim:set ts=8 sw=8 sts=8 noet: # # 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 topsrcdir
$(error topsrcdir was not set)) endif
# Define an include-at-most-once flag
ifdef INCLUDED_RULES_MK
$(error Do not include rules.mk twice!) endif
INCLUDED_RULES_MK = 1
ifndef INCLUDED_CONFIG_MK include $(topsrcdir)/config/config.mk endif
USE_AUTOTARGETS_MK = 1 include $(MOZILLA_DIR)/config/makefiles/makeutils.mk
# 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)
# # Library rules # # If FORCE_STATIC_LIB is set, build a static library. # Otherwise, build a shared library. #
ifndef LIBRARY
ifdef REAL_LIBRARY
ifdef NO_EXPAND_LIBS # Only build actual library if it is requested.
LIBRARY := $(REAL_LIBRARY) endif endif endif
ifdef FORCE_SHARED_LIB
ifdef MKSHLIB
ifdef LIB_IS_C_ONLY
MKSHLIB = $(MKCSHLIB) endif
endif# MKSHLIB endif# FORCE_SHARED_LIB
ifeq ($(OS_ARCH),WINNT)
# # This next line captures both the default (non-MOZ_COPY_PDBS) # case as well as the MOZ_COPY_PDBS-for-mingwclang case. # # For the default case, placing the pdb in the build # directory is needed. # # For the MOZ_COPY_PDBS, non-mingwclang case - we need to # build the pdb next to the executable (handled in the if # statement immediately below.) # # For the MOZ_COPY_PDBS, mingwclang case - we also need to # build the pdb next to the executable, but this macro doesn't # work for jsapi-tests which is a little special, so we specify # the output directory below with MOZ_PROGRAM_LDFLAGS. #
LINK_PDBFILE ?= $(basename $(@F)).pdb
ifeq (arm-Darwin,$(TARGET_CPU)-$(OS_TARGET))
ifdef PROGRAM
MOZ_PROGRAM_LDFLAGS += -Wl,-rpath -Wl,@executable_path/Frameworks endif endif
# For Mac executables, set the @rpath to be @executable_path by default so that # shared libraries built with an @rpath install name in the same directory # as the executable can be resolved. Executables not in the same directory # should override the @rpath with a relative path such as @executable_path/../ # depending on their install location. ifeq ($(OS_ARCH),Darwin)
MOZ_PROGRAM_LDFLAGS += -Wl,-rpath,@executable_path endif
# Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass, and do not # attempt to install them
ifdef MOZ_PROFILE_GENERATE
$(foreach category,$(INSTALL_TARGETS),\
$(eval $(category)_FILES := $(foreach file,$($(category)_FILES),$(if $(filter $(SIMPLE_PROGRAMS),$(notdir $(file))),,$(file)))))
SIMPLE_PROGRAMS := 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
# # Tags: emacs (etags), vi (ctags) # TAG_PROGRAM := ctags -L - #
TAG_PROGRAM = xargs etags -a
# # Turn on C++ linking if we have any .cpp or .mm files # (moved this from config.mk so that config.mk can be included # before the CPPSRCS are defined) # ifneq ($(HOST_CPPSRCS),)
HOST_CPP_PROG_LINK = 1 endif
ifeq (,$(CROSS_COMPILE))
HOST_OUTOPTION = $(OUTOPTION) else # Windows-to-Windows cross compiles should always use MSVC-style options for # host compiles. ifeq (WINNT_WINNT,$(HOST_OS_ARCH)_$(OS_ARCH)) ifneq (,$(filter-out clang-cl,$(HOST_CC_TYPE)))
$(error MSVC-style compilers should be used for host compilations!) endif
HOST_OUTOPTION = -Fo# eol else
HOST_OUTOPTION = -o # eol endif endif ################################################################################
# Ensure the build config is up to date. This is done automatically when builds # are performed through |mach build|. The check here is to catch people not # using mach. If we ever enforce builds through mach, this code can be removed.
ifndef MOZBUILD_BACKEND_CHECKED
ifndef MACH
ifndef TOPLEVEL_BUILD
BUILD_BACKEND_FILES := $(addprefix $(DEPTH)/backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
$(DEPTH)/backend.%Backend:
$(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
# 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
default all::
$(foreach tier,$(TIERS),$(call SUBMAKE,$(tier)))
# Dependencies which, if modified, should cause everything to rebuild
GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk
ifeq ($(MOZ_WIDGET_TOOLKIT),windows) # We always build .res files for programs and shared libraries
resfile = $(notdir $1).res # We also build .res files for simple programs if a corresponding manifest # exists. We'll generate a .rc file that includes the manifest.
resfile_for_manifest = $(if $(wildcard $(srcdir)/$(notdir $1).manifest),$(call resfile,$1)) else
resfile =
resfile_for_manifest = 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. # define simple_program_deps
$1: $(1:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) $(STATIC_LIBS) $(EXTRA_DEPS) $(call resfile_for_manifest,$1) $(GLOBAL_DEPS) endef
$(foreach p,$(SIMPLE_PROGRAMS),$(eval $(call simple_program_deps,$(p))))
ifeq ($(OS_ARCH),WINNT) # 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
# 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.
# 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 $3$(notdir $1)).$2: $1 $$(call mkdir_deps,$$(MDDEPDIR)) endef
$(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX))))
$(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX),host_)))
$(foreach f,$(WASM_CSRCS) $(WASM_CPPSRCS),$(eval $(call src_objdep,$(f),wasm)))
# The Rust compiler only outputs library objects, and so we need different # mangling to generate dependency rules for it.
mk_global_crate_libname = $(basename lib$(notdir $1)).$(LIB_SUFFIX)
crate_src_libdep = $(call mk_global_crate_libname,$1): $1 $$(call mkdir_deps,$$(MDDEPDIR))
$(foreach f,$(RS_STATICLIB_CRATE_SRC),$(eval $(call crate_src_libdep,$(f))))
# Rules for building native targets must come first because of the host_ prefix
$(HOST_COBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(NSPR_CFLAGS) $<
$(call BUILDSTATUS,END_Object $@)
# Windows program run via Wine don't like Unix absolute paths (they look # like command line arguments). So when needed, create relative paths # from absolute paths. We start with $(DEPTH), which gets us to topobjdir, # then add "/.." for each component of topobjdir, which gets us to /. # then we can add the absolute path after that and we have a relative path, # albeit longer than it could be.
ifdef WINE
relativize = $(if $(filter /%,$1),$(DEPTH)$(subst $(space),,$(foreach d,$(subst /, ,$(topobjdir)),/..))$1,$1) else
relativize = $1 endif
ifdef WINE # asmarm64 needs a library that can be found in $PATH but for some reason, # wine wants its path in $WINEPATH, so fill that to make it happy.
$(ASOBJS) $(SOBJS): export WINEPATH=$(subst :,;,$(PATH)) endif
ifdef ASFILES # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept # a '-c' flag.
$(ASOBJS):
$(REPORT_BUILD_VERBOSE)
$(call BUILDSTATUS,OBJECT_FILE $@)
$(call WINEWRAP,$(AS)) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(call relativize,$<)
$(call BUILDSTATUS,END_Object $@) endif
ifneq (,$(RUST_TESTS)$(RUST_LIBRARY_FILE)$(HOST_RUST_LIBRARY_FILE)$(RUST_PROGRAMS)$(HOST_RUST_PROGRAMS)) include $(MOZILLA_DIR)/config/makefiles/rust.mk endif
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))))
define PREPROCESS_RULES
_PREPROCESSED_$1_FILES := $$(call _group_srcs,$1,$$($2)) # Make preprocessed files PHONY so they are always executed, since they are # manual targets and we don't necessarily write to $@.
.PHONY: $$(_PREPROCESSED_$1_FILES)
# Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to # reach $(srcdir)/frontend/Parser.i
vpath %.$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
vpath %.$1 $$(addprefix $$(CURDIR)/,$$(sort $$(dir $$($2))))
# 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
# 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
# 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)
# 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
############################################################################### # Bunch of things that extend the 'export' rule (in order): ###############################################################################
################################################################################ # The default location for prefs is the gre prefs directory. # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
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))
PREF_DIR = defaults/preferences endif
ifdef XPI_NAME
ifdef XPI_ROOT_APPID # For add-on packaging we may specify that an application # sub-dir should be added to the root chrome manifest with # a specific application id.
MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)' endif
# if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's # no way langpacks will get packaged right, so error out. ifneq (,$(DIST_SUBDIR))
ifndef XPI_ROOT_APPID
$(error XPI_ROOT_APPID is not defined - langpacks will break.) endif endif 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::
@echo'Packaging $(XPI_PKGNAME).xpi...'
$(call py_action,zip $(XPI_PKGNAME).xpi,-C $(FINAL_TARGET) ../$(XPI_PKGNAME).xpi '*') endif
############################################################################# # MDDEPDIR is the subdirectory where all the dependency files are placed. # This uses a make rule (instead of a macro) to support parallel # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two # 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.
################################################################################ # Install/copy rules # # The INSTALL_TARGETS variable contains a list of all install target # categories. Each category defines a list of files and executables, and an # install destination, # # 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 $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd))) ifeq (,$(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)))
nsinstall_is_usable = $(if $(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)),yes)
install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
################################################################################ # 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 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 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.
# 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) \
) \
)
# Pull in non-recursive targets if this is a partial tree build.
ifndef TOPLEVEL_BUILD include $(MOZILLA_DIR)/config/makefiles/nonrecursive.mk endif
################################################################################ # Special gmake rules. ################################################################################
# # 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 chrome realchrome export install libs makefiles 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:
ifndef INCLUDED_DEBUGMAKE_MK #{ ## Only parse when an echo* or show* target is requested ifneq (,$(call isTargetStem,echo,show)) include $(MOZILLA_DIR)/config/makefiles/debugmake.mk endif#} endif#}
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)).)))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.