tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

config.mk (11999B)


      1 #
      2 # This Source Code Form is subject to the terms of the Mozilla Public
      3 # License, v. 2.0. If a copy of the MPL was not distributed with this
      4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      5 
      6 #
      7 # config.mk
      8 #
      9 # Determines the platform and builds the macros needed to load the
     10 # appropriate platform-specific .mk file, then defines all (most?)
     11 # of the generic macros.
     12 #
     13 
     14 varize = $(subst -,_,$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))))
     15 
     16 # Define an include-at-most-once flag
     17 ifdef INCLUDED_CONFIG_MK
     18 $(error Do not include config.mk twice!)
     19 endif
     20 INCLUDED_CONFIG_MK = 1
     21 
     22 EXIT_ON_ERROR = set -e; # Shell loops continue past errors without this.
     23 
     24 ifndef topsrcdir
     25 topsrcdir	= $(DEPTH)
     26 endif
     27 
     28 ifndef INCLUDED_AUTOCONF_MK
     29 include $(DEPTH)/config/autoconf.mk
     30 endif
     31 
     32 -include $(DEPTH)/.mozconfig.mk
     33 
     34 # MDDEPDIR is the subdirectory where dependency files are stored
     35 MDDEPDIR := .deps
     36 
     37 ifndef EXTERNALLY_MANAGED_MAKE_FILE
     38 # Import the automatically generated backend file. If this file doesn't exist,
     39 # the backend hasn't been properly configured. We want this to be a fatal
     40 # error, hence not using "-include".
     41 ifndef STANDALONE_MAKEFILE
     42 GLOBAL_DEPS += backend.mk
     43 include backend.mk
     44 
     45 # Add e.g. `export:: $(EXPORT_TARGETS)` rules. The *_TARGETS variables are defined
     46 # in backend.mk.
     47 $(foreach tier,$(RUNNABLE_TIERS),$(eval $(if $(filter .,$(DEPTH)),recurse_$(tier):,$(tier)::) $($(call varize,$(tier))_TARGETS)))
     48 endif
     49 
     50 endif
     51 
     52 space = $(NULL) $(NULL)
     53 
     54 # Include defs.mk files that can be found in $(srcdir)/$(DEPTH),
     55 # $(srcdir)/$(DEPTH-1), $(srcdir)/$(DEPTH-2), etc., and $(srcdir)
     56 # where $(DEPTH-1) is one level less of depth, $(DEPTH-2), two, etc.
     57 # i.e. for DEPTH=../../.., DEPTH-1 is ../.. and DEPTH-2 is ..
     58 # These defs.mk files are used to define variables in a directory
     59 # and all its subdirectories, recursively.
     60 __depth := $(subst /, ,$(DEPTH))
     61 ifeq (.,$(__depth))
     62 __depth :=
     63 endif
     64 $(foreach __d,$(__depth) .,$(eval __depth = $(wordlist 2,$(words $(__depth)),$(__depth))$(eval -include $(subst $(space),/,$(strip $(srcdir) $(__depth) defs.mk)))))
     65 
     66 COMMA = ,
     67 
     68 # Sanity check some variables
     69 CHECK_VARS := \
     70 XPI_NAME \
     71 LIBRARY_NAME \
     72 MODULE \
     73 DEPTH \
     74 XPI_PKGNAME \
     75 SHARED_LIBRARY_NAME \
     76 SONAME \
     77 STATIC_LIBRARY_NAME \
     78 $(NULL)
     79 
     80 # checks for internal spaces or trailing spaces in the variable
     81 # named by $x
     82 check-variable = $(if $(filter-out 0 1,$(words $($(x))z)),$(error Spaces are not allowed in $(x)))
     83 
     84 $(foreach x,$(CHECK_VARS),$(check-variable))
     85 
     86 ifndef INCLUDED_FUNCTIONS_MK
     87 include $(MOZILLA_DIR)/config/makefiles/functions.mk
     88 endif
     89 
     90 RM = rm -f
     91 
     92 # FINAL_TARGET specifies the location into which we copy end-user-shipped
     93 # build products (typelibs, components, chrome). It may already be specified by
     94 # a moz.build file.
     95 #
     96 # If XPI_NAME is set, the files will be shipped to $(DIST)/xpi-stage/$(XPI_NAME)
     97 # instead of $(DIST)/bin. In both cases, if DIST_SUBDIR is set, the files will be
     98 # shipped to a $(DIST_SUBDIR) subdirectory.
     99 FINAL_TARGET ?= $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)
    100 # Override the stored value for the check to make sure that the variable is not
    101 # redefined in the Makefile.in value.
    102 FINAL_TARGET_FROZEN := '$(FINAL_TARGET)'
    103 
    104 ifdef XPI_NAME
    105 ACDEFINES += -DXPI_NAME=$(XPI_NAME)
    106 endif
    107 
    108 CC := $(CC_WRAPPER) $(CC)
    109 CXX := $(CXX_WRAPPER) $(CXX)
    110 MKDIR ?= mkdir
    111 SLEEP ?= sleep
    112 TOUCH ?= touch
    113 
    114 # Don't build SIMPLE_PROGRAMS with PGO, since they don't need it anyway,
    115 # and we don't have the same build logic to re-link them in the second pass.
    116 ifdef SIMPLE_PROGRAMS
    117 NO_PROFILE_GUIDED_OPTIMIZE = 1
    118 endif
    119 
    120 # No sense in profiling unit tests
    121 ifdef CPP_UNIT_TESTS
    122 NO_PROFILE_GUIDED_OPTIMIZE = 1
    123 endif
    124 
    125 # Enable profile-based feedback
    126 ifdef MOZ_PROFILE_GENERATE
    127 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
    128 PGO_CFLAGS += -DNS_FREE_PERMANENT_DATA=1
    129 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS))
    130 endif # NO_PROFILE_GUIDED_OPTIMIZE
    131 PGO_LDFLAGS += $(PROFILE_GEN_LDFLAGS)
    132 endif # MOZ_PROFILE_GENERATE
    133 
    134 ifdef MOZ_PROFILE_USE
    135 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
    136 PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS))
    137 endif # NO_PROFILE_GUIDED_OPTIMIZE
    138 PGO_LDFLAGS += $(PROFILE_USE_LDFLAGS)
    139 endif # MOZ_PROFILE_USE
    140 
    141 # Overloaded by comm builds to refer to $(commtopsrcdir), so that
    142 # `mail` resolves in en-US builds and in repacks.
    143 LOCALE_TOPDIR ?= $(topsrcdir)
    144 MAKE_JARS_FLAGS = \
    145 -t $(LOCALE_TOPDIR) \
    146 -f $(MOZ_JAR_MAKER_FILE_FORMAT) \
    147 $(NULL)
    148 
    149 ifdef USE_EXTENSION_MANIFEST
    150 MAKE_JARS_FLAGS += -e
    151 endif
    152 
    153 TAR_CREATE_FLAGS = -chf
    154 
    155 #
    156 # Default command macros; can be overridden in <arch>.mk.
    157 #
    158 CCC = $(CXX)
    159 
    160 INCLUDES = \
    161  -I$(srcdir) \
    162  -I$(CURDIR) \
    163  $(LOCAL_INCLUDES) \
    164  -I$(ABS_DIST)/include \
    165  $(NULL)
    166 
    167 include $(MOZILLA_DIR)/config/static-checking-config.mk
    168 
    169 ifndef MOZ_LTO
    170 MOZ_LTO_CFLAGS :=
    171 MOZ_LTO_LDFLAGS :=
    172 endif
    173 
    174 LDFLAGS		= $(MOZ_LTO_LDFLAGS) $(COMPUTED_LDFLAGS) $(PGO_LDFLAGS)
    175 
    176 COMPILE_CFLAGS	= $(MOZ_LTO_CFLAGS) $(COMPUTED_CFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
    177 COMPILE_CXXFLAGS = $(MOZ_LTO_CFLAGS) $(COMPUTED_CXXFLAGS) $(PGO_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
    178 COMPILE_CMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS)
    179 COMPILE_CMMFLAGS = $(MOZ_LTO_CFLAGS) $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS)
    180 ASFLAGS = $(COMPUTED_ASFLAGS)
    181 SFLAGS = $(COMPUTED_SFLAGS)
    182 
    183 HOST_CFLAGS = $(COMPUTED_HOST_CFLAGS) $(_HOST_DEPEND_CFLAGS)
    184 HOST_CXXFLAGS = $(COMPUTED_HOST_CXXFLAGS) $(_HOST_DEPEND_CFLAGS)
    185 HOST_C_LDFLAGS = $(COMPUTED_HOST_LDFLAGS) $(COMPUTED_HOST_C_LDFLAGS)
    186 HOST_CXX_LDFLAGS = $(COMPUTED_HOST_LDFLAGS) $(COMPUTED_HOST_CXX_LDFLAGS)
    187 
    188 WASM_CFLAGS = $(COMPUTED_WASM_CFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
    189 WASM_CXXFLAGS = $(COMPUTED_WASM_CXXFLAGS) $(_DEPEND_CFLAGS) $(MK_COMPILE_DEFINES)
    190 
    191 ifdef MOZ_LTO
    192 ifeq (Darwin,$(OS_TARGET))
    193 # When linking on macOS, debug info is not linked along with the final binary,
    194 # and the dwarf data stays in object files until they are "linked" with the
    195 # dsymutil tool.
    196 # With LTO, object files are temporary, and are not kept around, which
    197 # means there's no object file for dsymutil to do its job. Consequently,
    198 # there is no debug info for LTOed compilation units.
    199 # The macOS linker has however an option to explicitly keep those object
    200 # files, which dsymutil will then find.
    201 # The catch is that the linker uses sequential numbers for those object
    202 # files, and doesn't avoid conflicts from multiple linkers running at
    203 # the same time. So in directories with multiple binaries, object files
    204 # from the first linked binaries would be overwritten by those of the
    205 # last linked binary. So we use a subdirectory containing the name of the
    206 # linked binary.
    207 LDFLAGS += -Wl,-object_path_lto,$(@F).lto.o/
    208 endif
    209 endif
    210 
    211 # We only add color flags if neither the flag to disable color
    212 # (e.g. "-fno-color-diagnostics" nor a flag to control color
    213 # (e.g. "-fcolor-diagnostics=never") is present.
    214 define colorize_flags
    215 ifeq (,$(filter $(COLOR_CFLAGS:-f%=-fno-%),$$(1))$(findstring $(COLOR_CFLAGS),$$(1)))
    216 $(1) += $(COLOR_CFLAGS)
    217 endif
    218 endef
    219 
    220 color_flags_vars := \
    221  COMPILE_CFLAGS \
    222  COMPILE_CXXFLAGS \
    223  COMPILE_CMFLAGS \
    224  COMPILE_CMMFLAGS \
    225  WASM_CFLAGS \
    226  WASM_CXXFLAGS \
    227  $(NULL)
    228 
    229 ifdef MACH_STDOUT_ISATTY
    230 ifdef COLOR_CFLAGS
    231 # TODO Bug 1319166 - iTerm2 interprets some bytes  sequences as a
    232 # request to show a print dialog. Don't enable color on iTerm2 until
    233 # a workaround is in place.
    234 ifneq ($(TERM_PROGRAM),iTerm.app)
    235 $(foreach var,$(color_flags_vars),$(eval $(call colorize_flags,$(var))))
    236 endif
    237 endif
    238 endif
    239 
    240 #
    241 # Name of the binary code directories
    242 #
    243 # Override defaults
    244 
    245 DEPENDENCIES	= .md
    246 
    247 # Export to propagate to cl and submake for third-party code.
    248 # Eventually, we'll want to just use -I.
    249 ifdef INCLUDE
    250 export INCLUDE
    251 endif
    252 
    253 # Export to propagate to link.exe and submake for third-party code.
    254 # Eventually, we'll want to just use -LIBPATH.
    255 ifdef LIB
    256 export LIB
    257 endif
    258 
    259 ifdef MOZ_USING_CCACHE
    260 ifeq ($(CC_TYPE),clang)
    261 export CCACHE_CPP2=1
    262 endif
    263 endif
    264 
    265 ifdef CCACHE_PREFIX
    266 export CCACHE_PREFIX
    267 endif
    268 
    269 ifeq ($(OS_ARCH),WINNT)
    270 ifneq (,$(filter msvc clang-cl,$(CC_TYPE)))
    271 ifneq ($(TARGET_CPU),x86)
    272 # Normal operation on 64-bit Windows needs 2 MB of stack. (Bug 582910)
    273 # ASAN requires 6 MB of stack.
    274 # Setting the stack to 8 MB to match the capability of other systems
    275 # to deal with frame construction for unreasonably deep DOM trees
    276 # with worst-case styling. This uses address space unnecessarily for
    277 # non-main threads, but that should be tolerable on 64-bit systems.
    278 # (Bug 256180)
    279 WIN32_EXE_LDFLAGS      += -STACK:8388608
    280 else
    281 # Since this setting affects the default stack size for non-main
    282 # threads, too, to avoid burning the address space, increase only
    283 # 512 KB over the default. Just enough to be able to deal with
    284 # reasonable styling applied to DOM trees whose depth is near what
    285 # Blink's HTML parser can output, esp.
    286 # layout/base/crashtests/507119.html (Bug 256180)
    287 ifndef MOZ_DEBUG
    288 WIN32_EXE_LDFLAGS      += -STACK:1572864
    289 else
    290 # In debug builds, layout code has extra logging helpers on the stack,
    291 # which can go over the 1.5MB limit on some deeply-nested crashtests.
    292 WIN32_EXE_LDFLAGS      += -STACK:2097152
    293 endif
    294 endif
    295 else
    296 ifneq ($(TARGET_CPU),x86)
    297 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:8388608
    298 else
    299 MOZ_PROGRAM_LDFLAGS += -Wl,-Xlink=-STACK:1572864
    300 endif
    301 endif
    302 endif
    303 
    304 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
    305 
    306 ######################################################################
    307 
    308 ifeq ($(OS_ARCH),Darwin)
    309 ifndef NSDISTMODE
    310 NSDISTMODE=absolute_symlink
    311 endif
    312 PWD := $(CURDIR)
    313 endif
    314 
    315 NSINSTALL_PY := $(PYTHON3) $(abspath $(MOZILLA_DIR)/config/nsinstall.py)
    316 ifneq (,$(or $(filter WINNT,$(HOST_OS_ARCH)),$(if $(COMPILE_ENVIRONMENT),,1)))
    317 NSINSTALL = $(NSINSTALL_PY)
    318 else
    319 NSINSTALL = $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)
    320 endif # WINNT
    321 
    322 
    323 ifeq (,$(CROSS_COMPILE)$(filter-out WINNT, $(OS_ARCH)))
    324 INSTALL = $(NSINSTALL) -t
    325 
    326 else
    327 
    328 # This isn't laid out as conditional directives so that NSDISTMODE can be
    329 # target-specific.
    330 INSTALL         = $(if $(filter copy, $(NSDISTMODE)), $(NSINSTALL) -t, $(if $(filter absolute_symlink, $(NSDISTMODE)), $(NSINSTALL) -L $(PWD), $(NSINSTALL) -R))
    331 
    332 endif # WINNT
    333 
    334 # The default for install_cmd is simply INSTALL
    335 install_cmd ?= $(INSTALL) $(1)
    336 
    337 # Use nsinstall in copy mode to install files on the system
    338 SYSINSTALL	= $(NSINSTALL) -t
    339 # This isn't necessarily true, just here
    340 sysinstall_cmd = install_cmd
    341 
    342 #
    343 # Localization build automation
    344 #
    345 
    346 # Because you might wish to "make locales AB_CD=ab-CD", we don't hardcode
    347 # MOZ_UI_LOCALE directly, but use an intermediate variable that can be
    348 # overridden by the command line. (Besides, AB_CD is prettier).
    349 AB_CD = $(MOZ_UI_LOCALE)
    350 
    351 include $(MOZILLA_DIR)/config/AB_rCD.mk
    352 
    353 # Many locales directories want this definition.
    354 ACDEFINES += -DAB_CD=$(AB_CD)
    355 
    356 EXPAND_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(LOCALE_TOPDIR)/$(1)/en-US,$(REAL_LOCALE_MERGEDIR)/$(subst /locales,,$(1)))
    357 
    358 ifdef relativesrcdir
    359 LOCALE_RELATIVEDIR ?= $(relativesrcdir)
    360 endif
    361 
    362 ifdef LOCALE_RELATIVEDIR
    363 LOCALE_SRCDIR ?= $(call EXPAND_LOCALE_SRCDIR,$(LOCALE_RELATIVEDIR))
    364 endif
    365 
    366 ifdef relativesrcdir
    367 MAKE_JARS_FLAGS += --relativesrcdir=$(LOCALE_RELATIVEDIR)
    368 ifneq (en-US,$(AB_CD))
    369 ifdef IS_LANGUAGE_REPACK
    370 MAKE_JARS_FLAGS += --l10n-base=$(REAL_LOCALE_MERGEDIR)
    371 endif
    372 else
    373 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
    374 endif # en-US
    375 else
    376 MAKE_JARS_FLAGS += -c $(LOCALE_SRCDIR)
    377 endif # ! relativesrcdir
    378 
    379 MERGE_FILE = $(LOCALE_SRCDIR)/$(1)
    380 MERGE_RELATIVE_FILE = $(call EXPAND_LOCALE_SRCDIR,$(2))/$(1)
    381 
    382 # Enable verbose logs when not using `make -s`
    383 ifeq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
    384 export BUILD_VERBOSE_LOG = 1
    385 endif