tor-browser

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

rules.mk (13027B)


      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 ###                                                                 ###
      8 ###              R U L E S   O F   E N G A G E M E N T              ###
      9 ###                                                                 ###
     10 #######################################################################
     11 
     12 #######################################################################
     13 # Dont't use double-colon rules!                                      #
     14 #######################################################################
     15 
     16 ifndef HAVE_ALL_TARGET
     17 all: libs
     18 endif
     19 
     20 autobuild:
     21 ifeq ($(AUTOCLEAN),1)
     22 $(MAKE) clean
     23 endif
     24 $(MAKE) all
     25 $(MAKE) install
     26 
     27 platform:
     28 @echo $(OBJDIR_NAME)
     29 
     30 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
     31 USE_NT_C_SYNTAX=1
     32 endif
     33 
     34 # For whatever reason, "." can't be handled using make conditionals.
     35 # Based on automake's SUBDIRS "." handling.
     36 ifdef DIRS
     37 ifndef IGNORE_DIRS
     38 ifneq (,$(filter .,$(DIRS)))
     39 TARGETS = $(NULL)
     40 ALL_TRASH = $(NULL)
     41 endif
     42 
     43 $(DIRS):
     44 $(IGNORE_ERROR)@if [ "$@" != "." ]; then \
     45 	$(MAKE) -C $@ $(MAKECMDGOALS) ; \
     46 else \
     47 	IGNORE_DIRS=1 $(MAKE) -C $@ $(MAKECMDGOALS) ; \
     48 fi
     49 @$(CLICK_STOPWATCH)
     50 endif
     51 endif
     52 
     53 export: $(DIRS) private_export
     54 
     55 release_export: $(DIRS)
     56 
     57 libs program install: $(DIRS) $(TARGETS)
     58 ifneq ($(LIBRARY),)
     59 $(INSTALL) -m 664 $(LIBRARY) $(SOURCE_LIB_DIR)
     60 endif
     61 ifneq ($(SHARED_LIBRARY),)
     62 $(INSTALL) -m 775 $(SHARED_LIBRARY) $(SOURCE_LIB_DIR)
     63 ifdef MOZ_DEBUG_SYMBOLS
     64 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
     65 $(INSTALL) -m 644 $(SHARED_LIBRARY:$(DLL_SUFFIX)=pdb) $(SOURCE_LIB_DIR)
     66 endif
     67 endif
     68 endif
     69 ifneq ($(IMPORT_LIBRARY),)
     70 $(INSTALL) -m 775 $(IMPORT_LIBRARY) $(SOURCE_LIB_DIR)
     71 endif
     72 ifneq ($(PROGRAM),)
     73 $(INSTALL) -m 775 $(PROGRAM) $(SOURCE_BIN_DIR)
     74 ifdef MOZ_DEBUG_SYMBOLS
     75 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
     76 $(INSTALL) -m 644 $(PROGRAM:$(PROG_SUFFIX)=.pdb) $(SOURCE_BIN_DIR)
     77 endif
     78 endif
     79 endif
     80 ifneq ($(PROGRAMS),)
     81 $(INSTALL) -m 775 $(PROGRAMS) $(SOURCE_BIN_DIR)
     82 endif
     83 
     84 check: $(DIRS)
     85 
     86 clean clobber: $(DIRS)
     87 ifneq (,$(ALL_TRASH))
     88 rm -rf $(ALL_TRASH)
     89 endif
     90 
     91 realclean clobber_all: $(DIRS)
     92 rm -rf $(wildcard *.OBJ) dist $(ALL_TRASH)
     93 
     94 release_clean:
     95 rm -rf $(SOURCE_XP_DIR)/release/$(RELEASE_MD_DIR)
     96 
     97 release: release_clean release_export release_md
     98 
     99 ifndef NO_MD_RELEASE
    100    ifdef LIBRARY
    101        MD_LIB_RELEASE_FILES +=  $(LIBRARY)
    102    endif
    103    ifdef SHARED_LIBRARY
    104        MD_LIB_RELEASE_FILES +=  $(SHARED_LIBRARY)
    105    endif
    106    ifdef IMPORT_LIBRARY
    107        MD_LIB_RELEASE_FILES +=  $(IMPORT_LIBRARY)
    108    endif
    109    ifdef PROGRAM
    110        MD_BIN_RELEASE_FILES +=  $(PROGRAM)
    111    endif
    112    ifdef PROGRAMS
    113        MD_BIN_RELEASE_FILES +=  $(PROGRAMS)
    114    endif
    115 endif
    116 
    117 release_md:: $(DIRS)
    118 ifneq ($(MD_LIB_RELEASE_FILES),)
    119 $(INSTALL) -m 444 $(MD_LIB_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_LIB_DIR)
    120 endif
    121 ifneq ($(MD_BIN_RELEASE_FILES),)
    122 $(INSTALL) -m 555 $(MD_BIN_RELEASE_FILES) $(SOURCE_RELEASE_PREFIX)/$(SOURCE_RELEASE_BIN_DIR)
    123 endif
    124 
    125 alltags:
    126 rm -f TAGS
    127 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
    128 find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a
    129 
    130 .SECONDEXPANSION:
    131 %/d:
    132 @$(MAKE_OBJDIR)
    133 
    134 define PROGRAM_template
    135 
    136 ifndef $(1)_OBJS
    137 ifdef LIBRARY_NAME
    138 $(1)_OBJS := $$(patsubst $$(PROG_PREFIX)%,%,$$(patsubst %$$(PROG_SUFFIX),%,$(1)))$$(OBJ_SUFFIX)
    139 endif
    140 ifdef PROGRAMS
    141 $(1)_OBJS := $$(patsubst $$(PROG_PREFIX)%,%,$$(patsubst %$$(PROG_SUFFIX),%,$(1)))$$(OBJ_SUFFIX)
    142 endif
    143 ifndef $(1)_OBJS
    144 $(1)_OBJS := $$(OBJS)
    145 endif
    146 endif
    147 
    148 $(1): $$($(1)_OBJS) $$(EXTRA_LIBS) | $$$$(@D)/d
    149 rm -f $$@
    150 ifeq (,$$(filter-out _WIN%,$$(NS_USE_GCC)_$$(OS_TARGET)))
    151 $$(MKPROG) $$($(1)_OBJS) -Fe$$@ -link $$(LDFLAGS) $$(XLDFLAGS) $$(EXTRA_LIBS) $$(EXTRA_SHARED_LIBS) $$(OS_LIBS)
    152 ifdef MT
    153 if test -f $$@.manifest; then \
    154 	$$(MT) -NOLOGO -MANIFEST $$@.manifest -OUTPUTRESOURCE:$$@\;1; \
    155 	rm -f $$@.manifest; \
    156 fi
    157 endif	# MSVC with manifest tool
    158 else
    159 $$(MKPROG) -o $$@ $$(CFLAGS) $$($(1)_OBJS) $$(LDFLAGS) $$(EXTRA_LIBS) $$(EXTRA_SHARED_LIBS) $$(OS_LIBS)
    160 endif
    161 endef # PROGRAM_template
    162 
    163 ifdef PROGRAM
    164 $(eval $(call PROGRAM_template,$(PROGRAM)))
    165 else
    166 ifdef PROGRAMS
    167 $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
    168 endif
    169 endif
    170 
    171 get_objs:
    172 @echo $(OBJS)
    173 
    174 $(LIBRARY): $(OBJS) | $$(@D)/d
    175 rm -f $@
    176 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
    177 $(AR) $(subst /,\\,$(OBJS))
    178 else
    179 $(AR) $(OBJS)
    180 endif
    181 $(RANLIB) $@
    182 
    183 
    184 ifeq ($(OS_ARCH),WINNT)
    185 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
    186 endif
    187 
    188 ifdef SHARED_LIBRARY_LIBS
    189 ifdef BUILD_TREE
    190 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(shell $(MAKE) -C $(dir) --no-print-directory get_objs))
    191 else
    192 SUB_SHLOBJS = $(foreach dir,$(SHARED_LIBRARY_DIRS),$(addprefix $(dir)/,$(shell $(MAKE) -C $(dir) --no-print-directory get_objs)))
    193 endif
    194 endif
    195 
    196 $(SHARED_LIBRARY): $(OBJS) $(RES) $(MAPFILE) $(SUB_SHLOBJS) | $$(@D)/d
    197 rm -f $@
    198 ifeq ($(OS_TARGET)$(OS_RELEASE), AIX4.1)
    199 echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
    200 nm -B -C -g $(OBJS) \
    201 | awk '/ [T,D] / {print $$3}' \
    202 | sed -e 's/^\.//' \
    203 | sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
    204 $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
    205 -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS)
    206 else
    207 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
    208 ifdef NS_USE_GCC
    209 $(LINK_DLL) $(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES)
    210 else
    211 $(LINK_DLL) -MAP $(DLLBASE) $(subst /,\\,$(OBJS) $(SUB_SHLOBJS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS) $(LD_LIBS) $(RES))
    212 ifdef MT
    213 if test -f $@.manifest; then \
    214 	$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;2; \
    215 	rm -f $@.manifest; \
    216 fi
    217 endif	# MSVC with manifest tool
    218 endif
    219 else
    220 $(MKSHLIB) -o $@ $(OBJS) $(SUB_SHLOBJS) $(LD_LIBS) $(EXTRA_LIBS) $(EXTRA_SHARED_LIBS) $(OS_LIBS)
    221 chmod +x $@
    222 endif
    223 endif
    224 
    225 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
    226 $(RES): $(RESNAME) | $$(@D)/d
    227 # The resource compiler does not understand the -U option.
    228 ifdef NS_USE_GCC
    229 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
    230 else
    231 $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
    232 endif
    233 @echo $(RES) finished
    234 endif
    235 
    236 $(MAPFILE): $(MAPFILE_SOURCE) | $$(@D)/d
    237 $(PROCESS_MAP_FILE)
    238 
    239 WCCFLAGS1 := $(subst /,\\,$(CFLAGS))
    240 WCCFLAGS2 := $(subst -I,-i=,$(WCCFLAGS1))
    241 WCCFLAGS3 := $(subst -D,-d,$(WCCFLAGS2))
    242 
    243 # Translate source filenames to absolute paths. This is required for
    244 # debuggers under Windows & OS/2 to find source files automatically
    245 
    246 ifeq (,$(filter-out AIX,$(OS_TARGET)))
    247 # OS/2 and AIX
    248 NEED_ABSOLUTE_PATH := 1
    249 PWD := $(shell pwd)
    250 
    251 else
    252 # Windows
    253 ifeq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
    254 NEED_ABSOLUTE_PATH := 1
    255 # CURDIR is always an absolute path. If it doesn't start with a /, it's a
    256 # Windows path meaning we're running under MINGW make (as opposed to MSYS
    257 # make), or pymake. In both cases, it's preferable to use a Windows path,
    258 # so use $(CURDIR) as is.
    259 ifeq (,$(filter /%,$(CURDIR)))
    260 PWD := $(CURDIR)
    261 else
    262 PWD := $(shell pwd)
    263 ifeq (,$(findstring ;,$(PATH)))
    264 ifndef USE_MSYS
    265 PWD := $(subst \,/,$(shell cygpath -w $(PWD)))
    266 endif
    267 endif
    268 endif
    269 
    270 else
    271 # everything else
    272 PWD := $(shell pwd)
    273 endif
    274 endif
    275 
    276 # The quotes allow absolute paths to contain spaces.
    277 core_abspath = '$(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1)))'
    278 
    279 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.c | $$(@D)/d
    280 ifdef USE_NT_C_SYNTAX
    281 $(CC) -Fo$@ -c $(CSTD) $(CFLAGS) $(call core_abspath,$<)
    282 else
    283 ifdef NEED_ABSOLUTE_PATH
    284 $(CC) -o $@ -c $(CSTD) $(CFLAGS) $(call core_abspath,$<)
    285 else
    286 $(CC) -o $@ -c $(CSTD) $(CFLAGS) $<
    287 endif
    288 endif
    289 
    290 $(PROG_PREFIX)%$(OBJ_SUFFIX): %.c | $$(@D)/d
    291 ifdef USE_NT_C_SYNTAX
    292 $(CC) -Fo$@ -c $(CSTD) $(CFLAGS) $(call core_abspath,$<)
    293 else
    294 ifdef NEED_ABSOLUTE_PATH
    295 $(CC) -o $@ -c $(CSTD) $(CFLAGS) $(call core_abspath,$<)
    296 else
    297 $(CC) -o $@ -c $(CSTD) $(CFLAGS) $<
    298 endif
    299 endif
    300 
    301 ifneq (,$(filter-out _WIN%,$(NS_USE_GCC)_$(OS_TARGET)))
    302 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.s | $$(@D)/d
    303 $(AS) -o $@ $(ASFLAGS) -c $<
    304 endif
    305 
    306 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.asm | $$(@D)/d
    307 $(AS) -Fo$@ $(ASFLAGS) -c $<
    308 
    309 $(OBJDIR)/$(PROG_PREFIX)%$(OBJ_SUFFIX): %.S | $$(@D)/d
    310 $(AS) -o $@ $(ASFLAGS) -c $<
    311 
    312 $(OBJDIR)/$(PROG_PREFIX)%: %.cpp | $$(@D)/d
    313 ifdef USE_NT_C_SYNTAX
    314 $(CCC) -Fo$@ -c $(CXXSTD) $(CFLAGS) $(CXXFLAGS) $(call core_abspath,$<)
    315 else
    316 ifdef NEED_ABSOLUTE_PATH
    317 $(CCC) -o $@ -c $(CXXSTD) $(CFLAGS) $(CXXFLAGS) $(call core_abspath,$<)
    318 else
    319 $(CCC) -o $@ -c $(CXXSTD) $(CFLAGS) $(CXXFLAGS) $<
    320 endif
    321 endif
    322 
    323 define compile_ccc_pattern_RULE
    324 
    325 $$(OBJDIR)/$$(PROG_PREFIX)%$$(OBJ_SUFFIX): %.$(1) | $$$$(@D)/d
    326 ifdef STRICT_CPLUSPLUS_SUFFIX
    327 echo "#line 1 \"$$<\"" | cat - $$< > $$(OBJDIR)/t_$$*.cc
    328 $$(CCC) -o $$@ -c $$(CXXSTD) $$(CFLAGS) $$(CXXFLAGS) $$(OBJDIR)/t_$$*.cc
    329 rm -f $$(OBJDIR)/t_$$*.cc
    330 else
    331 ifdef USE_NT_C_SYNTAX
    332 $$(CCC) -Fo$$@ -c $$(CXXSTD) $$(CFLAGS) $$(CXXFLAGS) $$(call core_abspath,$$<)
    333 else
    334 ifdef NEED_ABSOLUTE_PATH
    335 $$(CCC) -o $$@ -c $$(CXXSTD) $$(CFLAGS) $$(CXXFLAGS) $$(call core_abspath,$$<)
    336 else
    337 $$(CCC) -o $$@ -c $$(CXXSTD) $$(CFLAGS) $$(CXXFLAGS) $$<
    338 endif
    339 endif
    340 endif #STRICT_CPLUSPLUS_SUFFIX
    341 endef # compile_ccc_pattern_RULE
    342 
    343 $(eval $(call compile_ccc_pattern_RULE,cc))
    344 $(eval $(call compile_ccc_pattern_RULE,cpp))
    345 
    346 %.i: %.cpp
    347 $(CCC) -C -E $(CFLAGS) $(CXXFLAGS) $< > $@
    348 
    349 %.i: %.c
    350 ifeq (,$(filter-out WIN%,$(OS_TARGET)))
    351 $(CC) -C /P $(CFLAGS) $< 
    352 else
    353 $(CC) -C -E $(CFLAGS) $< > $@
    354 endif
    355 
    356 ifneq (,$(filter-out WIN%,$(OS_TARGET)))
    357 %.i: %.s
    358 $(CC) -C -E $(CFLAGS) $< > $@
    359 endif
    360 
    361 %: %.pl
    362 rm -f $@; cp $< $@; chmod +x $@
    363 
    364 %: %.sh
    365 rm -f $@; cp $< $@; chmod +x $@
    366 
    367 define copy_varlist_into_dir_RULE
    368 ifdef $(2)
    369 ifneq (,$$(strip $$($(2))))
    370 $(3)/%: %
    371 $$(INSTALL) -m 444 $$^ $(3)
    372 
    373 $(1): $$(addprefix $(3)/,$$($(2))) | $(3)/d
    374 
    375 .NOTPARALLEL: $(1)
    376 endif
    377 else
    378 $(1):
    379 endif
    380 endef # copy_varlist_into_dir_RULE
    381 
    382 # export rule
    383 $(eval $(call copy_varlist_into_dir_RULE,export,EXPORTS,$(SOURCE_XPHEADERS_DIR)))
    384 
    385 # private_export rule
    386 $(eval $(call copy_varlist_into_dir_RULE,private_export,PRIVATE_EXPORTS,$(SOURCE_XPPRIVATE_DIR)))
    387 
    388 ##########################################################################
    389 ###   RULES FOR RUNNING REGRESSION SUITE TESTS
    390 ###   REQUIRES 'REGRESSION_SPEC' TO BE SET TO THE NAME OF A REGRESSION SPECFILE
    391 ###   AND RESULTS_SUBDIR TO BE SET TO SOMETHING LIKE SECURITY/PKCS5
    392 ##########################################################################
    393 
    394 TESTS_DIR = $(RESULTS_DIR)/$(RESULTS_SUBDIR)/$(OS_TARGET)$(OS_RELEASE)$(CPU_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)
    395 
    396 ifneq ($(REGRESSION_SPEC),)
    397 
    398 ifneq ($(BUILD_OPT),)
    399 REGDATE = $(subst \ ,, $(shell $(PERL)  $(CORE_DEPTH)/$(MODULE)/scripts/now))
    400 endif
    401 
    402 check: $(REGRESSION_SPEC) | $(TESTS_DIR)/d
    403 cd $(PLATFORM); \
    404 ../$(SOURCE_MD_DIR)/bin/regress$(PROG_SUFFIX) specfile=../$(REGRESSION_SPEC) progress $(EXTRA_REGRESS_OPTIONS)
    405 ifneq ($(BUILD_OPT),)
    406 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).sum $(TESTS_DIR); \
    407 $(NSINSTALL) -m 664 $(PLATFORM)/$(REGDATE).htm $(TESTS_DIR); \
    408 echo "Please now make sure your results files are copied to $(TESTS_DIR), "; \
    409 echo "then run 'reporter specfile=$(RESULTS_DIR)/rptspec'"
    410 endif
    411 else
    412 check:
    413 @echo "Error: you didn't specify REGRESSION_SPEC in your manifest.mn file!"
    414 endif
    415 
    416 # release_export rule
    417 $(eval $(call copy_varlist_into_dir_RULE,release_export,EXPORTS,$(SOURCE_RELEASE_XP_DIR)/include))
    418 
    419 #
    420 # HACK ALERT
    421 #
    422 # The only purpose of this rule is to pass Mozilla's Tinderbox depend
    423 # builds (http://tinderbox.mozilla.org/showbuilds.cgi).  Mozilla's
    424 # Tinderbox builds NSS continuously as part of the Mozilla client.
    425 # Because NSS's make depend is not implemented, whenever we change
    426 # an NSS header file, the depend build does not recompile the NSS
    427 # files that depend on the header.
    428 #
    429 # This rule makes all the objects depend on a dummy header file.
    430 # Check in a change to this dummy header file to force the depend
    431 # build to recompile everything.
    432 #
    433 # This rule should be removed when make depend is implemented.
    434 #
    435 
    436 DUMMY_DEPEND = $(CORE_DEPTH)/coreconf/coreconf.dep
    437 
    438 $(filter $(OBJDIR)/%$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%$(OBJ_SUFFIX): $(DUMMY_DEPEND)
    439 
    440 # END OF HACK
    441 
    442 ################################################################################
    443 # Special gmake rules.
    444 ################################################################################
    445 
    446 #
    447 # Re-define the list of default suffixes, so gmake won't have to churn through
    448 # hundreds of built-in suffix rules for stuff we don't need.
    449 #
    450 .SUFFIXES:
    451 .SUFFIXES: .out .a .ln .o .obj .c .cc .C .cpp .y .l .s .S .h .sh .i .pl .html .asm .dep
    452 
    453 #
    454 # Fake targets.  Always run these rules, even if a file/directory with that
    455 # name already exists.
    456 #
    457 .PHONY: all all_platforms alltags boot clean clobber clobber_all export install libs program realclean release $(DIRS)