config/rules.mk

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 # -*- makefile -*-
michael@0 2 # vim:set ts=8 sw=8 sts=8 noet:
michael@0 3 #
michael@0 4 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 6 # You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 7 #
michael@0 8
michael@0 9 ifndef topsrcdir
michael@0 10 $(error topsrcdir was not set))
michael@0 11 endif
michael@0 12
michael@0 13 # Define an include-at-most-once flag
michael@0 14 ifdef INCLUDED_RULES_MK
michael@0 15 $(error Do not include rules.mk twice!)
michael@0 16 endif
michael@0 17 INCLUDED_RULES_MK = 1
michael@0 18
michael@0 19 # Make sure that anything that needs to be defined in moz.build wasn't
michael@0 20 # overwritten.
michael@0 21 _eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES)
michael@0 22
michael@0 23 ifndef MOZILLA_DIR
michael@0 24 MOZILLA_DIR = $(topsrcdir)
michael@0 25 endif
michael@0 26
michael@0 27 ifndef INCLUDED_CONFIG_MK
michael@0 28 include $(topsrcdir)/config/config.mk
michael@0 29 endif
michael@0 30
michael@0 31 ifndef INCLUDED_VERSION_MK
michael@0 32 include $(topsrcdir)/config/version.mk
michael@0 33 endif
michael@0 34
michael@0 35 USE_AUTOTARGETS_MK = 1
michael@0 36 include $(topsrcdir)/config/makefiles/makeutils.mk
michael@0 37
michael@0 38 # Only build with Pymake (not GNU make) on Windows.
michael@0 39 ifeq ($(HOST_OS_ARCH),WINNT)
michael@0 40 ifndef L10NBASEDIR
michael@0 41 ifndef .PYMAKE
michael@0 42 $(error Pymake is required to build on Windows. Run |./mach build| to \
michael@0 43 automatically use pymake or invoke pymake directly via \
michael@0 44 |python build/pymake/make.py|.)
michael@0 45 endif
michael@0 46 endif
michael@0 47 endif
michael@0 48
michael@0 49 ifdef REBUILD_CHECK
michael@0 50 ifdef .PYMAKE
michael@0 51 REPORT_BUILD = @%rebuild_check rebuild_check $@ $^
michael@0 52 else
michael@0 53 REPORT_BUILD = $(info $(shell $(PYTHON) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^))
michael@0 54 endif
michael@0 55 else
michael@0 56 REPORT_BUILD = $(info $(notdir $@))
michael@0 57 endif
michael@0 58
michael@0 59 EXEC = exec
michael@0 60
michael@0 61 # Don't copy xulrunner files at install time, when using system xulrunner
michael@0 62 ifdef SYSTEM_LIBXUL
michael@0 63 SKIP_COPY_XULRUNNER=1
michael@0 64 endif
michael@0 65
michael@0 66 # ELOG prints out failed command when building silently (gmake -s). Pymake
michael@0 67 # prints out failed commands anyway, so ELOG just makes things worse by
michael@0 68 # forcing shell invocations.
michael@0 69 ifndef .PYMAKE
michael@0 70 ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
michael@0 71 ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
michael@0 72 else
michael@0 73 ELOG :=
michael@0 74 endif # -s
michael@0 75 else
michael@0 76 ELOG :=
michael@0 77 endif # ifndef .PYMAKE
michael@0 78
michael@0 79 _VPATH_SRCS = $(abspath $<)
michael@0 80
michael@0 81 ################################################################################
michael@0 82 # Testing frameworks support
michael@0 83 ################################################################################
michael@0 84
michael@0 85 testxpcobjdir = $(DEPTH)/_tests/xpcshell
michael@0 86
michael@0 87 ifdef ENABLE_TESTS
michael@0 88
michael@0 89 # Add test directories to the regular directories list. TEST_DIRS should
michael@0 90 # arguably have the same status as TOOL_DIRS and other *_DIRS variables. It is
michael@0 91 # coded this way until Makefiles stop using the "ifdef ENABLE_TESTS; DIRS +="
michael@0 92 # convention.
michael@0 93 #
michael@0 94 # The current developer workflow expects tests to be updated when processing
michael@0 95 # the default target. If we ever change this implementation, the behavior
michael@0 96 # should be preserved or the change should be widely communicated. A
michael@0 97 # consequence of not processing test dir targets during the default target is
michael@0 98 # that changes to tests may not be updated and code could assume to pass
michael@0 99 # locally against non-current test code.
michael@0 100 DIRS += $(TEST_DIRS)
michael@0 101
michael@0 102 ifdef CPP_UNIT_TESTS
michael@0 103 ifdef COMPILE_ENVIRONMENT
michael@0 104
michael@0 105 # Compile the tests to $(DIST)/bin. Make lots of niceties available by default
michael@0 106 # through TestHarness.h, by modifying the list of includes and the libs against
michael@0 107 # which stuff links.
michael@0 108 CPPSRCS += $(CPP_UNIT_TESTS)
michael@0 109 CPP_UNIT_TEST_BINS := $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
michael@0 110 SIMPLE_PROGRAMS += $(CPP_UNIT_TEST_BINS)
michael@0 111 INCLUDES += -I$(DIST)/include/testing
michael@0 112 LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS)
michael@0 113
michael@0 114 ifndef MOZ_PROFILE_GENERATE
michael@0 115 libs:: $(CPP_UNIT_TEST_BINS) $(call mkdir_deps,$(DIST)/cppunittests)
michael@0 116 $(NSINSTALL) $(CPP_UNIT_TEST_BINS) $(DIST)/cppunittests
michael@0 117 endif
michael@0 118
michael@0 119 run-cppunittests::
michael@0 120 @$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS))
michael@0 121
michael@0 122 cppunittests-remote: DM_TRANS?=adb
michael@0 123 cppunittests-remote:
michael@0 124 @if [ '${TEST_DEVICE}' != '' -o '$(DM_TRANS)' = 'adb' ]; then \
michael@0 125 $(PYTHON) -u $(topsrcdir)/testing/remotecppunittests.py \
michael@0 126 --xre-path=$(DEPTH)/dist/bin \
michael@0 127 --localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
michael@0 128 --dm_trans=$(DM_TRANS) \
michael@0 129 --deviceIP=${TEST_DEVICE} \
michael@0 130 $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)) $(EXTRA_TEST_ARGS); \
michael@0 131 else \
michael@0 132 echo 'please prepare your host with environment variables for TEST_DEVICE'; \
michael@0 133 fi
michael@0 134
michael@0 135 endif # COMPILE_ENVIRONMENT
michael@0 136 endif # CPP_UNIT_TESTS
michael@0 137
michael@0 138 .PHONY: check
michael@0 139
michael@0 140 ifdef PYTHON_UNIT_TESTS
michael@0 141
michael@0 142 RUN_PYTHON_UNIT_TESTS := $(addsuffix -run,$(PYTHON_UNIT_TESTS))
michael@0 143
michael@0 144 .PHONY: $(RUN_PYTHON_UNIT_TESTS)
michael@0 145
michael@0 146 check:: $(RUN_PYTHON_UNIT_TESTS)
michael@0 147
michael@0 148 $(RUN_PYTHON_UNIT_TESTS): %-run: %
michael@0 149 @PYTHONDONTWRITEBYTECODE=1 $(PYTHON) $<
michael@0 150
michael@0 151 endif # PYTHON_UNIT_TESTS
michael@0 152
michael@0 153 endif # ENABLE_TESTS
michael@0 154
michael@0 155
michael@0 156 #
michael@0 157 # Library rules
michael@0 158 #
michael@0 159 # If FORCE_STATIC_LIB is set, build a static library.
michael@0 160 # Otherwise, build a shared library.
michael@0 161 #
michael@0 162
michael@0 163 ifndef LIBRARY
michael@0 164 ifdef STATIC_LIBRARY_NAME
michael@0 165 REAL_LIBRARY := $(LIB_PREFIX)$(STATIC_LIBRARY_NAME).$(LIB_SUFFIX)
michael@0 166 # Only build actual library if it is installed in DIST/lib or SDK
michael@0 167 ifeq (,$(SDK_LIBRARY)$(DIST_INSTALL)$(NO_EXPAND_LIBS))
michael@0 168 LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
michael@0 169 else
michael@0 170 LIBRARY := $(REAL_LIBRARY) $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
michael@0 171 endif
michael@0 172 endif # STATIC_LIBRARY_NAME
michael@0 173 endif # LIBRARY
michael@0 174
michael@0 175 ifndef HOST_LIBRARY
michael@0 176 ifdef HOST_LIBRARY_NAME
michael@0 177 HOST_LIBRARY := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
michael@0 178 endif
michael@0 179 endif
michael@0 180
michael@0 181 ifdef LIBRARY
michael@0 182 ifdef FORCE_SHARED_LIB
michael@0 183 ifdef MKSHLIB
michael@0 184
michael@0 185 ifdef LIB_IS_C_ONLY
michael@0 186 MKSHLIB = $(MKCSHLIB)
michael@0 187 endif
michael@0 188
michael@0 189 ifneq (,$(filter WINNT,$(OS_ARCH)))
michael@0 190 IMPORT_LIBRARY := $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
michael@0 191 endif
michael@0 192
michael@0 193 ifdef MAKE_FRAMEWORK
michael@0 194 SHARED_LIBRARY := $(SHARED_LIBRARY_NAME)
michael@0 195 else
michael@0 196 SHARED_LIBRARY := $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX)
michael@0 197 endif
michael@0 198
michael@0 199 EMBED_MANIFEST_AT=2
michael@0 200
michael@0 201 endif # MKSHLIB
michael@0 202 endif # FORCE_SHARED_LIB
michael@0 203 endif # LIBRARY
michael@0 204
michael@0 205 ifdef FORCE_STATIC_LIB
michael@0 206 ifndef FORCE_SHARED_LIB
michael@0 207 SHARED_LIBRARY := $(NULL)
michael@0 208 DEF_FILE := $(NULL)
michael@0 209 IMPORT_LIBRARY := $(NULL)
michael@0 210 endif
michael@0 211 endif
michael@0 212
michael@0 213 ifdef FORCE_SHARED_LIB
michael@0 214 ifndef FORCE_STATIC_LIB
michael@0 215 LIBRARY := $(NULL)
michael@0 216 endif
michael@0 217 endif
michael@0 218
michael@0 219 ifeq ($(OS_ARCH),WINNT)
michael@0 220 ifndef GNU_CC
michael@0 221
michael@0 222 #
michael@0 223 # Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per
michael@0 224 # directory. For parallel builds, this PDB file is shared and locked by
michael@0 225 # MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8
michael@0 226 # without SP1, don't do parallel builds.
michael@0 227 #
michael@0 228 # The final PDB for libraries and programs is created by the linker and uses
michael@0 229 # a different name from the single PDB file created by the compiler. See
michael@0 230 # bug 462740.
michael@0 231 #
michael@0 232
michael@0 233 ifdef SIMPLE_PROGRAMS
michael@0 234 COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb
michael@0 235 else
michael@0 236 COMPILE_PDB_FLAG ?= -Fdgenerated.pdb
michael@0 237 endif
michael@0 238 COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
michael@0 239 COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
michael@0 240
michael@0 241 LINK_PDBFILE ?= $(basename $(@F)).pdb
michael@0 242 ifdef MOZ_DEBUG
michael@0 243 CODFILE=$(basename $(@F)).cod
michael@0 244 endif
michael@0 245
michael@0 246 ifdef DEFFILE
michael@0 247 OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
michael@0 248 EXTRA_DEPS += $(DEFFILE)
michael@0 249 endif
michael@0 250
michael@0 251 else #!GNU_CC
michael@0 252
michael@0 253 ifdef DEFFILE
michael@0 254 OS_LDFLAGS += $(call normalizepath,$(DEFFILE))
michael@0 255 EXTRA_DEPS += $(DEFFILE)
michael@0 256 endif
michael@0 257
michael@0 258 endif # !GNU_CC
michael@0 259
michael@0 260 endif # WINNT
michael@0 261
michael@0 262 ifeq ($(SOLARIS_SUNPRO_CXX),1)
michael@0 263 ifeq (86,$(findstring 86,$(OS_TEST)))
michael@0 264 OS_LDFLAGS += -M $(topsrcdir)/config/solaris_ia32.map
michael@0 265 endif # x86
michael@0 266 endif # Solaris Sun Studio C++
michael@0 267
michael@0 268 ifeq ($(HOST_OS_ARCH),WINNT)
michael@0 269 HOST_PDBFILE=$(basename $(@F)).pdb
michael@0 270 HOST_PDB_FLAG ?= -Fd$(HOST_PDBFILE)
michael@0 271 HOST_CFLAGS += $(HOST_PDB_FLAG)
michael@0 272 HOST_CXXFLAGS += $(HOST_PDB_FLAG)
michael@0 273 endif
michael@0 274
michael@0 275 # Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass
michael@0 276 ifdef MOZ_PROFILE_GENERATE
michael@0 277 EXCLUDED_OBJS := $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX))
michael@0 278 SIMPLE_PROGRAMS :=
michael@0 279 endif
michael@0 280
michael@0 281 ifdef COMPILE_ENVIRONMENT
michael@0 282 ifndef TARGETS
michael@0 283 TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS)
michael@0 284 endif
michael@0 285
michael@0 286 COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX)))
michael@0 287 SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX)))
michael@0 288 # CPPSRCS can have different extensions (eg: .cpp, .cc)
michael@0 289 CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS))))
michael@0 290 CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX)))
michael@0 291 CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX)))
michael@0 292 ASOBJS = $(notdir $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX)))
michael@0 293 ifndef OBJS
michael@0 294 _OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS)
michael@0 295 OBJS = $(strip $(_OBJS))
michael@0 296 endif
michael@0 297
michael@0 298 HOST_COBJS = $(addprefix host_,$(notdir $(HOST_CSRCS:.c=.$(OBJ_SUFFIX))))
michael@0 299 # HOST_CPPOBJS can have different extensions (eg: .cpp, .cc)
michael@0 300 HOST_CPPOBJS = $(addprefix host_,$(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(HOST_CPPSRCS)))))
michael@0 301 HOST_CMOBJS = $(addprefix host_,$(notdir $(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))))
michael@0 302 HOST_CMMOBJS = $(addprefix host_,$(notdir $(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX))))
michael@0 303 ifndef HOST_OBJS
michael@0 304 _HOST_OBJS = $(HOST_COBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
michael@0 305 HOST_OBJS = $(strip $(_HOST_OBJS))
michael@0 306 endif
michael@0 307 else
michael@0 308 LIBRARY :=
michael@0 309 SHARED_LIBRARY :=
michael@0 310 IMPORT_LIBRARY :=
michael@0 311 REAL_LIBRARY :=
michael@0 312 PROGRAM :=
michael@0 313 SIMPLE_PROGRAMS :=
michael@0 314 HOST_LIBRARY :=
michael@0 315 HOST_PROGRAM :=
michael@0 316 HOST_SIMPLE_PROGRAMS :=
michael@0 317 SDK_BINARY := $(filter %.py,$(SDK_BINARY))
michael@0 318 SDK_LIBRARY :=
michael@0 319 endif
michael@0 320
michael@0 321 ALL_TRASH = \
michael@0 322 $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
michael@0 323 $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
michael@0 324 $(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
michael@0 325 $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
michael@0 326 $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
michael@0 327 $(wildcard *.pdb) $(CODFILE) $(IMPORT_LIBRARY) \
michael@0 328 $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
michael@0 329 $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
michael@0 330 $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
michael@0 331 $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
michael@0 332 $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
michael@0 333 ALL_TRASH_DIRS = \
michael@0 334 $(GARBAGE_DIRS) /no-such-file
michael@0 335
michael@0 336 ifdef QTDIR
michael@0 337 GARBAGE += $(MOCSRCS)
michael@0 338 endif
michael@0 339
michael@0 340 ifdef SIMPLE_PROGRAMS
michael@0 341 GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
michael@0 342 endif
michael@0 343
michael@0 344 ifdef HOST_SIMPLE_PROGRAMS
michael@0 345 GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
michael@0 346 endif
michael@0 347
michael@0 348 #
michael@0 349 # the Solaris WorkShop template repository cache. it occasionally can get
michael@0 350 # out of sync, so targets like clobber should kill it.
michael@0 351 #
michael@0 352 ifeq ($(SOLARIS_SUNPRO_CXX),1)
michael@0 353 GARBAGE_DIRS += SunWS_cache
michael@0 354 endif
michael@0 355
michael@0 356 ifdef MOZ_UPDATE_XTERM
michael@0 357 # Its good not to have a newline at the end of the titlebar string because it
michael@0 358 # makes the make -s output easier to read. Echo -n does not work on all
michael@0 359 # platforms, but we can trick printf into doing it.
michael@0 360 UPDATE_TITLE = printf '\033]0;%s in %s\007' $(1) $(relativesrcdir)/$(2) ;
michael@0 361 endif
michael@0 362
michael@0 363 ifdef MACH
michael@0 364 ifndef NO_BUILDSTATUS_MESSAGES
michael@0 365 define BUILDSTATUS
michael@0 366 @echo 'BUILDSTATUS $1'
michael@0 367
michael@0 368 endef
michael@0 369 endif
michael@0 370 endif
michael@0 371
michael@0 372 define SUBMAKE # $(call SUBMAKE,target,directory,static)
michael@0 373 +@$(UPDATE_TITLE)
michael@0 374 +$(MAKE) $(if $(2),-C $(2)) $(1)
michael@0 375
michael@0 376 endef # The extra line is important here! don't delete it
michael@0 377
michael@0 378 define TIER_DIR_SUBMAKE
michael@0 379 $(call SUBMAKE,$(4),$(3),$(5))
michael@0 380
michael@0 381 endef # Ths empty line is important.
michael@0 382
michael@0 383 ifneq (,$(strip $(DIRS)))
michael@0 384 LOOP_OVER_DIRS = \
michael@0 385 $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
michael@0 386 endif
michael@0 387
michael@0 388 # we only use this for the makefiles target and other stuff that doesn't matter
michael@0 389 ifneq (,$(strip $(PARALLEL_DIRS)))
michael@0 390 LOOP_OVER_PARALLEL_DIRS = \
michael@0 391 $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir)))
michael@0 392 endif
michael@0 393
michael@0 394 ifneq (,$(strip $(TOOL_DIRS)))
michael@0 395 LOOP_OVER_TOOL_DIRS = \
michael@0 396 $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir)))
michael@0 397 endif
michael@0 398
michael@0 399 #
michael@0 400 # Now we can differentiate between objects used to build a library, and
michael@0 401 # objects used to build an executable in the same directory.
michael@0 402 #
michael@0 403 ifndef PROGOBJS
michael@0 404 PROGOBJS = $(OBJS)
michael@0 405 endif
michael@0 406
michael@0 407 ifndef HOST_PROGOBJS
michael@0 408 HOST_PROGOBJS = $(HOST_OBJS)
michael@0 409 endif
michael@0 410
michael@0 411 GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
michael@0 412
michael@0 413 #
michael@0 414 # Tags: emacs (etags), vi (ctags)
michael@0 415 # TAG_PROGRAM := ctags -L -
michael@0 416 #
michael@0 417 TAG_PROGRAM = xargs etags -a
michael@0 418
michael@0 419 #
michael@0 420 # Turn on C++ linking if we have any .cpp or .mm files
michael@0 421 # (moved this from config.mk so that config.mk can be included
michael@0 422 # before the CPPSRCS are defined)
michael@0 423 #
michael@0 424 ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
michael@0 425 HOST_CPP_PROG_LINK = 1
michael@0 426 endif
michael@0 427
michael@0 428 #
michael@0 429 # This will strip out symbols that the component should not be
michael@0 430 # exporting from the .dynsym section.
michael@0 431 #
michael@0 432 ifdef IS_COMPONENT
michael@0 433 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
michael@0 434 endif # IS_COMPONENT
michael@0 435
michael@0 436 #
michael@0 437 # MacOS X specific stuff
michael@0 438 #
michael@0 439
michael@0 440 ifeq ($(OS_ARCH),Darwin)
michael@0 441 ifdef SHARED_LIBRARY
michael@0 442 ifdef IS_COMPONENT
michael@0 443 EXTRA_DSO_LDOPTS += -bundle
michael@0 444 else
michael@0 445 EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
michael@0 446 endif
michael@0 447 endif
michael@0 448 endif
michael@0 449
michael@0 450 #
michael@0 451 # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be
michael@0 452 # fatal symbol name clashes between components.
michael@0 453 #
michael@0 454 ifeq ($(OS_ARCH),NetBSD)
michael@0 455 ifeq ($(DLL_SUFFIX),.so.1.0)
michael@0 456 ifdef IS_COMPONENT
michael@0 457 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
michael@0 458 endif
michael@0 459 endif
michael@0 460 endif
michael@0 461
michael@0 462 ifeq ($(OS_ARCH),FreeBSD)
michael@0 463 ifdef IS_COMPONENT
michael@0 464 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
michael@0 465 endif
michael@0 466 endif
michael@0 467
michael@0 468 ifeq ($(OS_ARCH),NetBSD)
michael@0 469 ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
michael@0 470 ifneq (,$(filter layout/%,$(relativesrcdir)))
michael@0 471 OS_CFLAGS += -Wa,-xgot
michael@0 472 OS_CXXFLAGS += -Wa,-xgot
michael@0 473 endif
michael@0 474 endif
michael@0 475 endif
michael@0 476
michael@0 477 #
michael@0 478 # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
michael@0 479 # which uses internal symbols first
michael@0 480 #
michael@0 481 ifeq ($(OS_ARCH),HP-UX)
michael@0 482 ifdef IS_COMPONENT
michael@0 483 ifeq ($(GNU_CC)$(GNU_CXX),)
michael@0 484 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
michael@0 485 ifneq ($(HAS_EXTRAEXPORTS),1)
michael@0 486 MKSHLIB += -Wl,+eNSGetModule -Wl,+eerrno
michael@0 487 MKCSHLIB += +eNSGetModule +eerrno
michael@0 488 ifneq ($(OS_TEST),ia64)
michael@0 489 MKSHLIB += -Wl,+e_shlInit
michael@0 490 MKCSHLIB += +e_shlInit
michael@0 491 endif # !ia64
michael@0 492 endif # !HAS_EXTRAEXPORTS
michael@0 493 endif # non-gnu compilers
michael@0 494 endif # IS_COMPONENT
michael@0 495 endif # HP-UX
michael@0 496
michael@0 497 ifeq ($(OS_ARCH),AIX)
michael@0 498 ifdef IS_COMPONENT
michael@0 499 ifneq ($(HAS_EXTRAEXPORTS),1)
michael@0 500 MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
michael@0 501 MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
michael@0 502 endif # HAS_EXTRAEXPORTS
michael@0 503 endif # IS_COMPONENT
michael@0 504 endif # AIX
michael@0 505
michael@0 506 #
michael@0 507 # Linux: add -Bsymbolic flag for components
michael@0 508 #
michael@0 509 ifeq ($(OS_ARCH),Linux)
michael@0 510 ifdef IS_COMPONENT
michael@0 511 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
michael@0 512 endif
michael@0 513 endif
michael@0 514
michael@0 515 #
michael@0 516 # GNU doesn't have path length limitation
michael@0 517 #
michael@0 518
michael@0 519 ifeq ($(OS_ARCH),GNU)
michael@0 520 OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
michael@0 521 endif
michael@0 522
michael@0 523 ifeq ($(OS_ARCH),WINNT)
michael@0 524 ifdef USE_DELAYIMP
michael@0 525 OS_LIBS += $(call EXPAND_LIBNAME,delayimp)
michael@0 526 endif
michael@0 527 endif
michael@0 528
michael@0 529 #
michael@0 530 # MINGW32
michael@0 531 #
michael@0 532 ifeq ($(OS_ARCH),WINNT)
michael@0 533 ifdef GNU_CC
michael@0 534 ifndef IS_COMPONENT
michael@0 535 DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
michael@0 536 endif
michael@0 537 endif
michael@0 538 endif
michael@0 539
michael@0 540 ifeq ($(USE_TVFS),1)
michael@0 541 IFLAGS1 = -rb
michael@0 542 IFLAGS2 = -rb
michael@0 543 else
michael@0 544 IFLAGS1 = -m 644
michael@0 545 IFLAGS2 = -m 755
michael@0 546 endif
michael@0 547
michael@0 548 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
michael@0 549 OUTOPTION = -Fo# eol
michael@0 550 PREPROCESS_OPTION = -P -Fi# eol
michael@0 551 else
michael@0 552 OUTOPTION = -o # eol
michael@0 553 PREPROCESS_OPTION = -E -o #eol
michael@0 554 endif # WINNT && !GNU_CC
michael@0 555
michael@0 556 ifneq (,$(filter ml%,$(AS)))
michael@0 557 ASOUTOPTION = -Fo# eol
michael@0 558 else
michael@0 559 ASOUTOPTION = -o # eol
michael@0 560 endif
michael@0 561
michael@0 562 ifeq (,$(CROSS_COMPILE))
michael@0 563 HOST_OUTOPTION = $(OUTOPTION)
michael@0 564 else
michael@0 565 HOST_OUTOPTION = -o # eol
michael@0 566 endif
michael@0 567 ################################################################################
michael@0 568
michael@0 569 # Ensure the build config is up to date. This is done automatically when builds
michael@0 570 # are performed through |mach build|. The check here is to catch people not
michael@0 571 # using mach. If we ever enforce builds through mach, this code can be removed.
michael@0 572 ifndef MOZBUILD_BACKEND_CHECKED
michael@0 573 ifndef MACH
michael@0 574 ifndef TOPLEVEL_BUILD
michael@0 575 $(DEPTH)/backend.RecursiveMakeBackend:
michael@0 576 $(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
michael@0 577
michael@0 578 include $(DEPTH)/backend.RecursiveMakeBackend.pp
michael@0 579
michael@0 580 default:: $(DEPTH)/backend.RecursiveMakeBackend
michael@0 581
michael@0 582 export MOZBUILD_BACKEND_CHECKED=1
michael@0 583 endif
michael@0 584 endif
michael@0 585 endif
michael@0 586
michael@0 587 # The root makefile doesn't want to do a plain export/libs, because
michael@0 588 # of the tiers and because of libxul. Suppress the default rules in favor
michael@0 589 # of something else. Makefiles which use this var *must* provide a sensible
michael@0 590 # default rule before including rules.mk
michael@0 591 default all::
michael@0 592 $(MAKE) export
michael@0 593 ifdef MOZ_PSEUDO_DERECURSE
michael@0 594 ifdef COMPILE_ENVIRONMENT
michael@0 595 $(MAKE) compile
michael@0 596 endif
michael@0 597 endif
michael@0 598 $(MAKE) libs
michael@0 599 $(MAKE) tools
michael@0 600
michael@0 601 ifeq ($(findstring s,$(filter-out --%, $(MAKEFLAGS))),)
michael@0 602 ECHO := echo
michael@0 603 QUIET :=
michael@0 604 else
michael@0 605 ECHO := true
michael@0 606 QUIET := -q
michael@0 607 endif
michael@0 608
michael@0 609 # Do everything from scratch
michael@0 610 everything::
michael@0 611 $(MAKE) clean
michael@0 612 $(MAKE) all
michael@0 613
michael@0 614 ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS)))
michael@0 615 $(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only)
michael@0 616 endif
michael@0 617
michael@0 618 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS))
michael@0 619
michael@0 620 # Dependencies which, if modified, should cause everything to rebuild
michael@0 621 GLOBAL_DEPS += Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
michael@0 622
michael@0 623 ##############################################
michael@0 624 ifdef COMPILE_ENVIRONMENT
michael@0 625 OBJ_TARGETS = $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS)
michael@0 626
michael@0 627 compile:: $(OBJ_TARGETS)
michael@0 628
michael@0 629 include $(topsrcdir)/config/makefiles/target_binaries.mk
michael@0 630 endif
michael@0 631
michael@0 632 ifdef IS_TOOL_DIR
michael@0 633 # One would think "tools:: libs" would work, but it turns out that combined with
michael@0 634 # bug 907365, this makes make forget to run some rules sometimes.
michael@0 635 tools::
michael@0 636 @$(MAKE) libs
michael@0 637 endif
michael@0 638
michael@0 639 ##############################################
michael@0 640 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
michael@0 641 ifdef MOZ_PROFILE_USE
michael@0 642 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
michael@0 643 # When building with PGO, we have to make sure to re-link
michael@0 644 # in the MOZ_PROFILE_USE phase if we linked in the
michael@0 645 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
michael@0 646 # file in the link rule in the GENERATE phase to indicate
michael@0 647 # that we need a relink.
michael@0 648 ifdef SHARED_LIBRARY
michael@0 649 $(SHARED_LIBRARY): pgo.relink
michael@0 650 endif
michael@0 651 ifdef PROGRAM
michael@0 652 $(PROGRAM): pgo.relink
michael@0 653 endif
michael@0 654
michael@0 655 # In the second pass, we need to merge the pgc files into the pgd file.
michael@0 656 # The compiler would do this for us automatically if they were in the right
michael@0 657 # place, but they're in dist/bin.
michael@0 658 ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
michael@0 659 export::
michael@0 660 ifdef PROGRAM
michael@0 661 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
michael@0 662 $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
michael@0 663 endif
michael@0 664 ifdef SHARED_LIBRARY
michael@0 665 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
michael@0 666 $(SHARED_LIBRARY_NAME) $(DIST)/bin
michael@0 667 endif
michael@0 668 endif # SHARED_LIBRARY || PROGRAM
michael@0 669 endif # WINNT_
michael@0 670 endif # MOZ_PROFILE_USE
michael@0 671 ifdef MOZ_PROFILE_GENERATE
michael@0 672 # Clean up profiling data during PROFILE_GENERATE phase
michael@0 673 export::
michael@0 674 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
michael@0 675 $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
michael@0 676 else
michael@0 677 ifdef GNU_CC
michael@0 678 -$(RM) *.gcda
michael@0 679 endif
michael@0 680 endif
michael@0 681 endif
michael@0 682
michael@0 683 ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
michael@0 684 ifdef GNU_CC
michael@0 685 # Force rebuilding libraries and programs in both passes because each
michael@0 686 # pass uses different object files.
michael@0 687 $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
michael@0 688 endif
michael@0 689 endif
michael@0 690
michael@0 691 endif # NO_PROFILE_GUIDED_OPTIMIZE
michael@0 692
michael@0 693 ##############################################
michael@0 694
michael@0 695 checkout:
michael@0 696 $(MAKE) -C $(topsrcdir) -f client.mk checkout
michael@0 697
michael@0 698 clean clobber realclean clobber_all::
michael@0 699 -$(RM) $(ALL_TRASH)
michael@0 700 -$(RM) -r $(ALL_TRASH_DIRS)
michael@0 701
michael@0 702 ifdef TIERS
michael@0 703 clean clobber realclean clobber_all distclean::
michael@0 704 $(foreach dir, \
michael@0 705 $(foreach tier, $(TIERS), $(tier_$(tier)_staticdirs) $(tier_$(tier)_dirs)), \
michael@0 706 -$(call SUBMAKE,$@,$(dir)))
michael@0 707 else
michael@0 708 clean clobber realclean clobber_all distclean::
michael@0 709 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
michael@0 710 endif
michael@0 711
michael@0 712 distclean::
michael@0 713 -$(RM) -r $(ALL_TRASH_DIRS)
michael@0 714 -$(RM) $(ALL_TRASH) \
michael@0 715 Makefile .HSancillary \
michael@0 716 $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
michael@0 717 $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
michael@0 718 $(wildcard *.$(IMPORT_LIB_SUFFIX))
michael@0 719
michael@0 720 alltags:
michael@0 721 $(RM) TAGS
michael@0 722 find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
michael@0 723
michael@0 724 #
michael@0 725 # PROGRAM = Foo
michael@0 726 # creates OBJS, links with LIBS to create Foo
michael@0 727 #
michael@0 728 $(PROGRAM): $(PROGOBJS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
michael@0 729 $(REPORT_BUILD)
michael@0 730 @$(RM) $@.manifest
michael@0 731 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
michael@0 732 $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
michael@0 733 ifdef MSMANIFEST_TOOL
michael@0 734 @if test -f $@.manifest; then \
michael@0 735 if test -f '$(srcdir)/$@.manifest'; then \
michael@0 736 echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
michael@0 737 mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
michael@0 738 else \
michael@0 739 echo 'Embedding manifest from $@.manifest'; \
michael@0 740 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
michael@0 741 fi; \
michael@0 742 elif test -f '$(srcdir)/$@.manifest'; then \
michael@0 743 echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
michael@0 744 mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \
michael@0 745 fi
michael@0 746 endif # MSVC with manifest tool
michael@0 747 ifdef MOZ_PROFILE_GENERATE
michael@0 748 # touch it a few seconds into the future to work around FAT's
michael@0 749 # 2-second granularity
michael@0 750 touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
michael@0 751 endif
michael@0 752 else # !WINNT || GNU_CC
michael@0 753 $(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 754 $(call CHECK_BINARY,$@)
michael@0 755 endif # WINNT && !GNU_CC
michael@0 756
michael@0 757 ifdef ENABLE_STRIP
michael@0 758 $(STRIP) $(STRIP_FLAGS) $@
michael@0 759 endif
michael@0 760 ifdef MOZ_POST_PROGRAM_COMMAND
michael@0 761 $(MOZ_POST_PROGRAM_COMMAND) $@
michael@0 762 endif
michael@0 763
michael@0 764 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 765 $(REPORT_BUILD)
michael@0 766 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
michael@0 767 $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 768 ifdef MSMANIFEST_TOOL
michael@0 769 @if test -f $@.manifest; then \
michael@0 770 if test -f '$(srcdir)/$@.manifest'; then \
michael@0 771 echo 'Embedding manifest from $(srcdir)/$@.manifest and $@.manifest'; \
michael@0 772 mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
michael@0 773 else \
michael@0 774 echo 'Embedding manifest from $@.manifest'; \
michael@0 775 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
michael@0 776 fi; \
michael@0 777 elif test -f '$(srcdir)/$@.manifest'; then \
michael@0 778 echo 'Embedding manifest from $(srcdir)/$@.manifest'; \
michael@0 779 mt.exe -NOLOGO -MANIFEST '$(win_srcdir)/$@.manifest' -OUTPUTRESOURCE:$@\;1; \
michael@0 780 fi
michael@0 781 endif # MSVC with manifest tool
michael@0 782 else
michael@0 783 ifeq ($(HOST_CPP_PROG_LINK),1)
michael@0 784 $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 785 else
michael@0 786 $(EXPAND_LIBS_EXEC) -- $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 787 endif # HOST_CPP_PROG_LINK
michael@0 788 endif
michael@0 789
michael@0 790 #
michael@0 791 # This is an attempt to support generation of multiple binaries
michael@0 792 # in one directory, it assumes everything to compile Foo is in
michael@0 793 # Foo.o (from either Foo.c or Foo.cpp).
michael@0 794 #
michael@0 795 # SIMPLE_PROGRAMS = Foo Bar
michael@0 796 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
michael@0 797 #
michael@0 798 $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 799 $(REPORT_BUILD)
michael@0 800 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
michael@0 801 $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
michael@0 802 ifdef MSMANIFEST_TOOL
michael@0 803 @if test -f $@.manifest; then \
michael@0 804 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
michael@0 805 rm -f $@.manifest; \
michael@0 806 fi
michael@0 807 endif # MSVC with manifest tool
michael@0 808 else
michael@0 809 $(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 810 $(call CHECK_BINARY,$@)
michael@0 811 endif # WINNT && !GNU_CC
michael@0 812
michael@0 813 ifdef ENABLE_STRIP
michael@0 814 $(STRIP) $(STRIP_FLAGS) $@
michael@0 815 endif
michael@0 816 ifdef MOZ_POST_PROGRAM_COMMAND
michael@0 817 $(MOZ_POST_PROGRAM_COMMAND) $@
michael@0 818 endif
michael@0 819
michael@0 820 $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 821 $(REPORT_BUILD)
michael@0 822 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
michael@0 823 $(EXPAND_LIBS_EXEC) -- $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 824 else
michael@0 825 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
michael@0 826 $(EXPAND_LIBS_EXEC) -- $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 827 else
michael@0 828 $(EXPAND_LIBS_EXEC) -- $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
michael@0 829 endif
michael@0 830 endif
michael@0 831
michael@0 832 ifdef DTRACE_PROBE_OBJ
michael@0 833 EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
michael@0 834 OBJS += $(DTRACE_PROBE_OBJ)
michael@0 835 endif
michael@0 836
michael@0 837 $(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 838 $(REPORT_BUILD)
michael@0 839 $(RM) $(LIBRARY)
michael@0 840 $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(SHARED_LIBRARY_LIBS)
michael@0 841
michael@0 842 $(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 843 # When we only build a library descriptor, blow out any existing library
michael@0 844 $(REPORT_BUILD)
michael@0 845 $(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY) $(EXPORT_LIBRARY:%=%/$(REAL_LIBRARY)))
michael@0 846 $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(SHARED_LIBRARY_LIBS)
michael@0 847
michael@0 848 ifeq ($(OS_ARCH),WINNT)
michael@0 849 # Import libraries are created by the rules creating shared libraries.
michael@0 850 # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
michael@0 851 # but make will happily consider the import library before it is refreshed
michael@0 852 # when rebuilding the corresponding shared library. Defining an empty recipe
michael@0 853 # for import libraries forces make to wait for the shared library recipe to
michael@0 854 # have run before considering other targets that depend on the import library.
michael@0 855 # See bug 795204.
michael@0 856 $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
michael@0 857 endif
michael@0 858
michael@0 859 $(HOST_LIBRARY): $(HOST_OBJS) Makefile
michael@0 860 $(REPORT_BUILD)
michael@0 861 $(RM) $@
michael@0 862 $(EXPAND_LIBS_EXEC) --extract -- $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
michael@0 863
michael@0 864 ifdef HAVE_DTRACE
michael@0 865 ifndef XP_MACOSX
michael@0 866 ifdef DTRACE_PROBE_OBJ
michael@0 867 ifndef DTRACE_LIB_DEPENDENT
michael@0 868 NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS))
michael@0 869 $(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS)
michael@0 870 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS)
michael@0 871 endif
michael@0 872 endif
michael@0 873 endif
michael@0 874 endif
michael@0 875
michael@0 876 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
michael@0 877 # so instead of deleting .o files after repacking them into a dylib, we make
michael@0 878 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
michael@0 879 # so no need to conditionalize on OS version or debugging format.
michael@0 880
michael@0 881 $(SHARED_LIBRARY): $(OBJS) $(DEF_FILE) $(RESFILE) $(LIBRARY) $(EXTRA_DEPS) $(GLOBAL_DEPS)
michael@0 882 $(REPORT_BUILD)
michael@0 883 ifndef INCREMENTAL_LINKER
michael@0 884 $(RM) $@
michael@0 885 endif
michael@0 886 ifdef DTRACE_LIB_DEPENDENT
michael@0 887 ifndef XP_MACOSX
michael@0 888 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
michael@0 889 endif
michael@0 890 $(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 891 @$(RM) $(DTRACE_PROBE_OBJ)
michael@0 892 else # ! DTRACE_LIB_DEPENDENT
michael@0 893 $(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 894 endif # DTRACE_LIB_DEPENDENT
michael@0 895 $(call CHECK_BINARY,$@)
michael@0 896
michael@0 897 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
michael@0 898 ifdef MSMANIFEST_TOOL
michael@0 899 ifdef EMBED_MANIFEST_AT
michael@0 900 @if test -f $@.manifest; then \
michael@0 901 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
michael@0 902 rm -f $@.manifest; \
michael@0 903 fi
michael@0 904 endif # EMBED_MANIFEST_AT
michael@0 905 endif # MSVC with manifest tool
michael@0 906 ifdef MOZ_PROFILE_GENERATE
michael@0 907 touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
michael@0 908 endif
michael@0 909 endif # WINNT && !GCC
michael@0 910 @$(RM) foodummyfilefoo $(DELETE_AFTER_LINK)
michael@0 911 chmod +x $@
michael@0 912 ifdef ENABLE_STRIP
michael@0 913 $(STRIP) $(STRIP_FLAGS) $@
michael@0 914 endif
michael@0 915 ifdef MOZ_POST_DSO_LIB_COMMAND
michael@0 916 $(MOZ_POST_DSO_LIB_COMMAND) $@
michael@0 917 endif
michael@0 918
michael@0 919 ifeq ($(SOLARIS_SUNPRO_CC),1)
michael@0 920 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
michael@0 921
michael@0 922 define MAKE_DEPS_AUTO_CC
michael@0 923 if test -d $(@D); then \
michael@0 924 echo 'Building deps for $< using Sun Studio cc'; \
michael@0 925 $(CC) $(COMPILE_CFLAGS) -xM $< >$(_MDDEPFILE) ; \
michael@0 926 $(PYTHON) $(topsrcdir)/build/unix/add_phony_targets.py $(_MDDEPFILE) ; \
michael@0 927 fi
michael@0 928 endef
michael@0 929 define MAKE_DEPS_AUTO_CXX
michael@0 930 if test -d $(@D); then \
michael@0 931 echo 'Building deps for $< using Sun Studio CC'; \
michael@0 932 $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
michael@0 933 $(PYTHON) $(topsrcdir)/build/unix/add_phony_targets.py $(_MDDEPFILE) ; \
michael@0 934 fi
michael@0 935 endef
michael@0 936 endif # Sun Studio on Solaris
michael@0 937
michael@0 938 # The object file is in the current directory, and the source file can be any
michael@0 939 # relative path. This macro adds the dependency obj: src for each source file.
michael@0 940 # This dependency must be first for the $< flag to work correctly, and the
michael@0 941 # rules that have commands for these targets must not list any other
michael@0 942 # prerequisites, or they will override the $< variable.
michael@0 943 define src_objdep
michael@0 944 $(basename $2$(notdir $1)).$(OBJ_SUFFIX): $1 $$(call mkdir_deps,$$(MDDEPDIR))
michael@0 945 endef
michael@0 946 $(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f))))
michael@0 947 $(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),host_)))
michael@0 948
michael@0 949 $(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
michael@0 950
michael@0 951 # Rules for building native targets must come first because of the host_ prefix
michael@0 952 $(HOST_COBJS):
michael@0 953 $(REPORT_BUILD)
michael@0 954 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
michael@0 955
michael@0 956 $(HOST_CPPOBJS):
michael@0 957 $(REPORT_BUILD)
michael@0 958 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
michael@0 959
michael@0 960 $(HOST_CMOBJS):
michael@0 961 $(REPORT_BUILD)
michael@0 962 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
michael@0 963
michael@0 964 $(HOST_CMMOBJS):
michael@0 965 $(REPORT_BUILD)
michael@0 966 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
michael@0 967
michael@0 968 $(COBJS):
michael@0 969 $(REPORT_BUILD)
michael@0 970 @$(MAKE_DEPS_AUTO_CC)
michael@0 971 $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 972
michael@0 973 # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
michael@0 974 # 'moc' only knows about #defines it gets on the command line (-D...), not in
michael@0 975 # included headers like mozilla-config.h
michael@0 976 $(filter moc_%.cpp,$(CPPSRCS)): moc_%.cpp: %.h
michael@0 977 $(REPORT_BUILD)
michael@0 978 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
michael@0 979
michael@0 980 $(filter moc_%.cc,$(CPPSRCS)): moc_%.cc: %.cc
michael@0 981 $(REPORT_BUILD)
michael@0 982 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
michael@0 983
michael@0 984 $(filter qrc_%.cpp,$(CPPSRCS)): qrc_%.cpp: %.qrc
michael@0 985 $(REPORT_BUILD)
michael@0 986 $(ELOG) $(RCC) -name $* $< $(OUTOPTION)$@
michael@0 987
michael@0 988 ifdef ASFILES
michael@0 989 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
michael@0 990 # a '-c' flag.
michael@0 991 $(ASOBJS):
michael@0 992 $(REPORT_BUILD)
michael@0 993 $(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
michael@0 994 endif
michael@0 995
michael@0 996 $(SOBJS):
michael@0 997 $(REPORT_BUILD)
michael@0 998 $(AS) -o $@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) $(TARGET_LOCAL_INCLUDES) -c $<
michael@0 999
michael@0 1000 $(CPPOBJS):
michael@0 1001 $(REPORT_BUILD)
michael@0 1002 @$(MAKE_DEPS_AUTO_CXX)
michael@0 1003 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1004
michael@0 1005 $(CMMOBJS):
michael@0 1006 $(REPORT_BUILD)
michael@0 1007 @$(MAKE_DEPS_AUTO_CXX)
michael@0 1008 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1009
michael@0 1010 $(CMOBJS):
michael@0 1011 $(REPORT_BUILD)
michael@0 1012 @$(MAKE_DEPS_AUTO_CC)
michael@0 1013 $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1014
michael@0 1015 $(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
michael@0 1016 $(REPORT_BUILD)
michael@0 1017 $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1018
michael@0 1019 $(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
michael@0 1020 $(REPORT_BUILD)
michael@0 1021 $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1022
michael@0 1023 $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
michael@0 1024 $(REPORT_BUILD)
michael@0 1025 $(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1026
michael@0 1027 $(filter %.i,$(CPPSRCS:%.cpp=%.i)): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR))
michael@0 1028 $(REPORT_BUILD)
michael@0 1029 $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1030
michael@0 1031 $(filter %.i,$(CPPSRCS:%.cc=%.i)): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR))
michael@0 1032 $(REPORT_BUILD)
michael@0 1033 $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1034
michael@0 1035 $(filter %.i,$(CSRCS:%.c=%.i)): %.i: %.c $(call mkdir_deps,$(MDDEPDIR))
michael@0 1036 $(REPORT_BUILD)
michael@0 1037 $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1038
michael@0 1039 $(filter %.i,$(CMMSRCS:%.mm=%.i)): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR))
michael@0 1040 $(REPORT_BUILD)
michael@0 1041 $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
michael@0 1042
michael@0 1043 $(RESFILE): %.res: %.rc
michael@0 1044 $(REPORT_BUILD)
michael@0 1045 @echo Creating Resource file: $@
michael@0 1046 ifdef GNU_CC
michael@0 1047 $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
michael@0 1048 else
michael@0 1049 $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
michael@0 1050 endif
michael@0 1051
michael@0 1052 # Cancel GNU make built-in implicit rules
michael@0 1053 ifndef .PYMAKE
michael@0 1054 MAKEFLAGS += -r
michael@0 1055 endif
michael@0 1056
michael@0 1057 ifneq (,$(filter WINNT,$(OS_ARCH)))
michael@0 1058 SEP := ;
michael@0 1059 else
michael@0 1060 SEP := :
michael@0 1061 endif
michael@0 1062
michael@0 1063 EMPTY :=
michael@0 1064 SPACE := $(EMPTY) $(EMPTY)
michael@0 1065
michael@0 1066 # MSYS has its own special path form, but javac expects the source and class
michael@0 1067 # paths to be in the DOS form (i.e. e:/builds/...). This function does the
michael@0 1068 # appropriate conversion on Windows, but is a noop on other systems.
michael@0 1069 ifeq ($(HOST_OS_ARCH),WINNT)
michael@0 1070 # We use 'pwd -W' to get DOS form of the path. However, since the given path
michael@0 1071 # could be a file or a non-existent path, we cannot call 'pwd -W' directly
michael@0 1072 # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
michael@0 1073 # on it, then merge with the rest of the path.
michael@0 1074 root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\1|')
michael@0 1075 non-root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\2|')
michael@0 1076 normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
michael@0 1077 else
michael@0 1078 normalizepath = $(1)
michael@0 1079 endif
michael@0 1080
michael@0 1081 ###############################################################################
michael@0 1082 # Java rules
michael@0 1083 ###############################################################################
michael@0 1084 ifneq (,$(JAVAFILES)$(ANDROID_RESFILES)$(ANDROID_APKNAME)$(JAVA_JAR_TARGETS))
michael@0 1085 include $(topsrcdir)/config/makefiles/java-build.mk
michael@0 1086 endif
michael@0 1087
michael@0 1088 ###############################################################################
michael@0 1089 # Bunch of things that extend the 'export' rule (in order):
michael@0 1090 ###############################################################################
michael@0 1091
michael@0 1092 ifneq ($(XPI_NAME),)
michael@0 1093 $(FINAL_TARGET):
michael@0 1094 $(NSINSTALL) -D $@
michael@0 1095
michael@0 1096 export:: $(FINAL_TARGET)
michael@0 1097 endif
michael@0 1098
michael@0 1099 ################################################################################
michael@0 1100 # Copy each element of PREF_JS_EXPORTS
michael@0 1101
michael@0 1102 # The default location for PREF_JS_EXPORTS is the gre prefs directory.
michael@0 1103 PREF_DIR = defaults/pref
michael@0 1104
michael@0 1105 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
michael@0 1106 # different and that we are building app related resources. Hence,
michael@0 1107 # PREF_DIR should point to the app prefs location.
michael@0 1108 ifneq (,$(DIST_SUBDIR)$(XPI_NAME)$(LIBXUL_SDK))
michael@0 1109 PREF_DIR = defaults/preferences
michael@0 1110 endif
michael@0 1111
michael@0 1112 # on win32, pref files need CRLF line endings... see bug 206029
michael@0 1113 ifeq (WINNT,$(OS_ARCH))
michael@0 1114 PREF_PPFLAGS += --line-endings=crlf
michael@0 1115 endif
michael@0 1116
michael@0 1117 ifneq ($(PREF_JS_EXPORTS),)
michael@0 1118 ifndef NO_DIST_INSTALL
michael@0 1119 PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
michael@0 1120 PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS)
michael@0 1121 PP_TARGETS += PREF_JS_EXPORTS
michael@0 1122 endif
michael@0 1123 endif
michael@0 1124
michael@0 1125 ################################################################################
michael@0 1126 # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
michael@0 1127
michael@0 1128 ifneq ($(AUTOCFG_JS_EXPORTS),)
michael@0 1129 ifndef NO_DIST_INSTALL
michael@0 1130 AUTOCFG_JS_EXPORTS_FILES := $(AUTOCFG_JS_EXPORTS)
michael@0 1131 AUTOCFG_JS_EXPORTS_DEST := $(FINAL_TARGET)/defaults/autoconfig
michael@0 1132 AUTOCFG_JS_EXPORTS_TARGET := export
michael@0 1133 INSTALL_TARGETS += AUTOCFG_JS_EXPORTS
michael@0 1134 endif
michael@0 1135 endif
michael@0 1136
michael@0 1137 ################################################################################
michael@0 1138 # Install a linked .xpt into the appropriate place.
michael@0 1139 # This should ideally be performed by the non-recursive idl make file. Some day.
michael@0 1140 ifdef XPT_NAME #{
michael@0 1141
michael@0 1142 ifndef NO_DIST_INSTALL
michael@0 1143 _XPT_NAME_FILES := $(DEPTH)/config/makefiles/xpidl/xpt/$(XPT_NAME)
michael@0 1144 _XPT_NAME_DEST := $(FINAL_TARGET)/components
michael@0 1145 INSTALL_TARGETS += _XPT_NAME
michael@0 1146
michael@0 1147 ifndef NO_INTERFACES_MANIFEST
michael@0 1148 libs:: $(call mkdir_deps,$(FINAL_TARGET)/components)
michael@0 1149 $(call py_action,buildlist,$(FINAL_TARGET)/components/interfaces.manifest 'interfaces $(XPT_NAME)')
michael@0 1150 $(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest 'manifest components/interfaces.manifest')
michael@0 1151 endif
michael@0 1152 endif
michael@0 1153
michael@0 1154 endif #} XPT_NAME
michael@0 1155
michael@0 1156 ################################################################################
michael@0 1157 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
michael@0 1158 ifneq (,$(filter %.js,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
michael@0 1159 ifeq (,$(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
michael@0 1160 ifndef NO_JS_MANIFEST
michael@0 1161 $(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0)
michael@0 1162 endif
michael@0 1163 endif
michael@0 1164 endif
michael@0 1165
michael@0 1166 ifdef EXTRA_COMPONENTS
michael@0 1167 libs:: $(EXTRA_COMPONENTS)
michael@0 1168 ifndef NO_DIST_INSTALL
michael@0 1169 EXTRA_COMPONENTS_FILES := $(EXTRA_COMPONENTS)
michael@0 1170 EXTRA_COMPONENTS_DEST := $(FINAL_TARGET)/components
michael@0 1171 INSTALL_TARGETS += EXTRA_COMPONENTS
michael@0 1172 endif
michael@0 1173
michael@0 1174 endif
michael@0 1175
michael@0 1176 ifdef EXTRA_PP_COMPONENTS
michael@0 1177 ifndef NO_DIST_INSTALL
michael@0 1178 EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
michael@0 1179 PP_TARGETS += EXTRA_PP_COMPONENTS
michael@0 1180 endif
michael@0 1181 endif
michael@0 1182
michael@0 1183 EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
michael@0 1184 ifneq (,$(EXTRA_MANIFESTS))
michael@0 1185 libs:: $(call mkdir_deps,$(FINAL_TARGET))
michael@0 1186 $(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest $(patsubst %,'manifest components/%',$(notdir $(EXTRA_MANIFESTS))))
michael@0 1187 endif
michael@0 1188
michael@0 1189 ################################################################################
michael@0 1190 # Copy each element of EXTRA_JS_MODULES to
michael@0 1191 # $(FINAL_TARGET)/$(JS_MODULES_PATH). JS_MODULES_PATH defaults to "modules"
michael@0 1192 # if it is undefined.
michael@0 1193 JS_MODULES_PATH ?= modules
michael@0 1194 FINAL_JS_MODULES_PATH := $(FINAL_TARGET)/$(JS_MODULES_PATH)
michael@0 1195
michael@0 1196 ifdef EXTRA_JS_MODULES
michael@0 1197 ifndef NO_DIST_INSTALL
michael@0 1198 EXTRA_JS_MODULES_FILES := $(EXTRA_JS_MODULES)
michael@0 1199 EXTRA_JS_MODULES_DEST := $(FINAL_JS_MODULES_PATH)
michael@0 1200 INSTALL_TARGETS += EXTRA_JS_MODULES
michael@0 1201 endif
michael@0 1202 endif
michael@0 1203
michael@0 1204 ifdef EXTRA_PP_JS_MODULES
michael@0 1205 ifndef NO_DIST_INSTALL
michael@0 1206 EXTRA_PP_JS_MODULES_PATH := $(FINAL_JS_MODULES_PATH)
michael@0 1207 PP_TARGETS += EXTRA_PP_JS_MODULES
michael@0 1208 endif
michael@0 1209 endif
michael@0 1210
michael@0 1211 ################################################################################
michael@0 1212 # Copy testing-only JS modules to appropriate destination.
michael@0 1213 #
michael@0 1214 # For each file defined in TESTING_JS_MODULES, copy it to
michael@0 1215 # objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path
michael@0 1216 # wlll be appended to the output directory.
michael@0 1217
michael@0 1218 ifdef ENABLE_TESTS
michael@0 1219 ifdef TESTING_JS_MODULES
michael@0 1220 testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
michael@0 1221
michael@0 1222 GENERATED_DIRS += $(testmodulesdir)
michael@0 1223
michael@0 1224 ifndef NO_DIST_INSTALL
michael@0 1225 TESTING_JS_MODULES_FILES := $(TESTING_JS_MODULES)
michael@0 1226 TESTING_JS_MODULES_DEST := $(testmodulesdir)
michael@0 1227 INSTALL_TARGETS += TESTING_JS_MODULES
michael@0 1228 endif
michael@0 1229
michael@0 1230 endif
michael@0 1231 endif
michael@0 1232
michael@0 1233 ################################################################################
michael@0 1234 # SDK
michael@0 1235
michael@0 1236 ifneq (,$(SDK_LIBRARY))
michael@0 1237 ifndef NO_DIST_INSTALL
michael@0 1238 SDK_LIBRARY_FILES := $(SDK_LIBRARY)
michael@0 1239 SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
michael@0 1240 INSTALL_TARGETS += SDK_LIBRARY
michael@0 1241 endif
michael@0 1242 endif # SDK_LIBRARY
michael@0 1243
michael@0 1244 ifneq (,$(strip $(SDK_BINARY)))
michael@0 1245 ifndef NO_DIST_INSTALL
michael@0 1246 SDK_BINARY_FILES := $(SDK_BINARY)
michael@0 1247 SDK_BINARY_DEST := $(SDK_BIN_DIR)
michael@0 1248 INSTALL_TARGETS += SDK_BINARY
michael@0 1249 endif
michael@0 1250 endif # SDK_BINARY
michael@0 1251
michael@0 1252 ################################################################################
michael@0 1253 # CHROME PACKAGING
michael@0 1254
michael@0 1255 chrome::
michael@0 1256 $(MAKE) realchrome
michael@0 1257 $(LOOP_OVER_PARALLEL_DIRS)
michael@0 1258 $(LOOP_OVER_DIRS)
michael@0 1259 $(LOOP_OVER_TOOL_DIRS)
michael@0 1260
michael@0 1261 $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
michael@0 1262
michael@0 1263 ifneq (,$(JAR_MANIFEST))
michael@0 1264 ifndef NO_DIST_INSTALL
michael@0 1265
michael@0 1266 ifdef XPI_NAME
michael@0 1267 ifdef XPI_ROOT_APPID
michael@0 1268 # For add-on packaging we may specify that an application
michael@0 1269 # sub-dir should be added to the root chrome manifest with
michael@0 1270 # a specific application id.
michael@0 1271 MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)'
michael@0 1272 endif
michael@0 1273
michael@0 1274 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
michael@0 1275 # no way langpacks will get packaged right, so error out.
michael@0 1276 ifneq (,$(DIST_SUBDIR))
michael@0 1277 ifndef XPI_ROOT_APPID
michael@0 1278 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
michael@0 1279 endif
michael@0 1280 endif
michael@0 1281 endif
michael@0 1282
michael@0 1283 libs realchrome:: $(FINAL_TARGET)/chrome
michael@0 1284 $(call py_action,jar_maker,\
michael@0 1285 $(QUIET) -j $(FINAL_TARGET)/chrome \
michael@0 1286 $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
michael@0 1287 $(JAR_MANIFEST))
michael@0 1288
michael@0 1289 endif
michael@0 1290
michael@0 1291 # This is a temporary check to ensure patches relying on the old behavior
michael@0 1292 # of silently picking up jar.mn files continue to work.
michael@0 1293 else # No JAR_MANIFEST
michael@0 1294 ifneq (,$(wildcard $(srcdir)/jar.mn))
michael@0 1295 $(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 1296 endif
michael@0 1297 endif
michael@0 1298
michael@0 1299 ifneq ($(DIST_FILES),)
michael@0 1300 DIST_FILES_PATH := $(FINAL_TARGET)
michael@0 1301 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
michael@0 1302 PP_TARGETS += DIST_FILES
michael@0 1303 endif
michael@0 1304
michael@0 1305 ifneq ($(DIST_CHROME_FILES),)
michael@0 1306 DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome
michael@0 1307 DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES)
michael@0 1308 PP_TARGETS += DIST_CHROME_FILES
michael@0 1309 endif
michael@0 1310
michael@0 1311 ifneq ($(XPI_PKGNAME),)
michael@0 1312 tools realchrome::
michael@0 1313 ifdef STRIP_XPI
michael@0 1314 ifndef MOZ_DEBUG
michael@0 1315 @echo 'Stripping $(XPI_PKGNAME) package directory...'
michael@0 1316 @echo $(FINAL_TARGET)
michael@0 1317 @cd $(FINAL_TARGET) && find . ! -type d \
michael@0 1318 ! -name '*.js' \
michael@0 1319 ! -name '*.xpt' \
michael@0 1320 ! -name '*.gif' \
michael@0 1321 ! -name '*.jpg' \
michael@0 1322 ! -name '*.png' \
michael@0 1323 ! -name '*.xpm' \
michael@0 1324 ! -name '*.txt' \
michael@0 1325 ! -name '*.rdf' \
michael@0 1326 ! -name '*.sh' \
michael@0 1327 ! -name '*.properties' \
michael@0 1328 ! -name '*.dtd' \
michael@0 1329 ! -name '*.html' \
michael@0 1330 ! -name '*.xul' \
michael@0 1331 ! -name '*.css' \
michael@0 1332 ! -name '*.xml' \
michael@0 1333 ! -name '*.jar' \
michael@0 1334 ! -name '*.dat' \
michael@0 1335 ! -name '*.tbl' \
michael@0 1336 ! -name '*.src' \
michael@0 1337 ! -name '*.reg' \
michael@0 1338 $(PLATFORM_EXCLUDE_LIST) \
michael@0 1339 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
michael@0 1340 endif
michael@0 1341 endif
michael@0 1342 @echo 'Packaging $(XPI_PKGNAME).xpi...'
michael@0 1343 cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
michael@0 1344 endif
michael@0 1345
michael@0 1346 ifdef INSTALL_EXTENSION_ID
michael@0 1347 ifndef XPI_NAME
michael@0 1348 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
michael@0 1349 endif
michael@0 1350
michael@0 1351 tools::
michael@0 1352 $(RM) -r '$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
michael@0 1353 $(NSINSTALL) -D '$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
michael@0 1354 $(call copy_dir,$(FINAL_TARGET),$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))
michael@0 1355
michael@0 1356 endif
michael@0 1357
michael@0 1358 #############################################################################
michael@0 1359 # MDDEPDIR is the subdirectory where all the dependency files are placed.
michael@0 1360 # This uses a make rule (instead of a macro) to support parallel
michael@0 1361 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
michael@0 1362 # processes could simultaneously try to create the same directory.
michael@0 1363 #
michael@0 1364 # We use $(CURDIR) in the rule's target to ensure that we don't find
michael@0 1365 # a dependency directory in the source tree via VPATH (perhaps from
michael@0 1366 # a previous build in the source tree) and thus neglect to create a
michael@0 1367 # dependency directory in the object directory, where we really need
michael@0 1368 # it.
michael@0 1369
michael@0 1370 ifneq (,$(filter-out all chrome default export realchrome clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
michael@0 1371 MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_MDDEPEND_FILES) $(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS))) $(TARGETS)))))
michael@0 1372
michael@0 1373 ifneq (,$(MDDEPEND_FILES))
michael@0 1374 $(call include_deps,$(MDDEPEND_FILES))
michael@0 1375 endif
michael@0 1376
michael@0 1377 endif
michael@0 1378
michael@0 1379
michael@0 1380 ifneq (,$(filter export,$(MAKECMDGOALS)))
michael@0 1381 MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(EXTRA_EXPORT_MDDEPEND_FILES))))
michael@0 1382
michael@0 1383 ifneq (,$(MDDEPEND_FILES))
michael@0 1384 $(call include_deps,$(MDDEPEND_FILES))
michael@0 1385 endif
michael@0 1386
michael@0 1387 endif
michael@0 1388
michael@0 1389 #############################################################################
michael@0 1390
michael@0 1391 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
michael@0 1392 -include $(MY_RULES)
michael@0 1393
michael@0 1394 #
michael@0 1395 # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
michael@0 1396 # or in $(MY_RULES)
michael@0 1397 #
michael@0 1398 ifdef ETAGS
michael@0 1399 ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
michael@0 1400 all:: TAGS
michael@0 1401 TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
michael@0 1402 $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
michael@0 1403 endif
michael@0 1404 endif
michael@0 1405
michael@0 1406 ################################################################################
michael@0 1407 # Install/copy rules
michael@0 1408 #
michael@0 1409 # The INSTALL_TARGETS variable contains a list of all install target
michael@0 1410 # categories. Each category defines a list of files and executables, and an
michael@0 1411 # install destination,
michael@0 1412 #
michael@0 1413 # FOO_FILES := foo bar
michael@0 1414 # FOO_EXECUTABLES := baz
michael@0 1415 # FOO_DEST := target_path
michael@0 1416 # INSTALL_TARGETS += FOO
michael@0 1417 #
michael@0 1418 # Additionally, a FOO_TARGET variable may be added to indicate the target for
michael@0 1419 # which the files and executables are installed. Default is "libs".
michael@0 1420 #
michael@0 1421 # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
michael@0 1422 # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
michael@0 1423 # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
michael@0 1424 # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
michael@0 1425
michael@0 1426 # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
michael@0 1427 ifneq (,$(filter $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
michael@0 1428 ifeq (,$(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)))
michael@0 1429 nsinstall_is_usable = $(if $(wildcard $(DIST)/bin/nsinstall$(HOST_BIN_SUFFIX)),yes)
michael@0 1430
michael@0 1431 define install_cmd_override
michael@0 1432 $(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1)
michael@0 1433 endef
michael@0 1434 endif
michael@0 1435 endif
michael@0 1436
michael@0 1437 install_target_tier = $(or $($(1)_TARGET),libs)
michael@0 1438 INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category))))
michael@0 1439
michael@0 1440 install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2)))
michael@0 1441 install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file)))
michael@0 1442 install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file)))
michael@0 1443
michael@0 1444 # Work around a GNU make 3.81 bug where it gives $< the wrong value.
michael@0 1445 # See details in bug 934864.
michael@0 1446 define create_dependency
michael@0 1447 $(1): $(2)
michael@0 1448 $(1): $(2)
michael@0 1449 endef
michael@0 1450
michael@0 1451 define install_target_template
michael@0 1452 $(call install_cmd_override,$(2))
michael@0 1453 $(call create_dependency,$(2),$(1))
michael@0 1454 endef
michael@0 1455
michael@0 1456 $(foreach category,$(INSTALL_TARGETS),\
michael@0 1457 $(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \
michael@0 1458 $(foreach tier,$(call install_target_tier,$(category)),\
michael@0 1459 $(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \
michael@0 1460 $(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \
michael@0 1461 ) \
michael@0 1462 $(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \
michael@0 1463 $(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \
michael@0 1464 ) \
michael@0 1465 )
michael@0 1466
michael@0 1467 $(foreach tier,$(INSTALL_TARGETS_TIERS), \
michael@0 1468 $(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \
michael@0 1469 )
michael@0 1470
michael@0 1471 install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
michael@0 1472
michael@0 1473 $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))):
michael@0 1474 $(install_targets_sanity)
michael@0 1475 $(call install_cmd,$(IFLAGS1) '$<' '$(@D)')
michael@0 1476
michael@0 1477 $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))):
michael@0 1478 $(install_targets_sanity)
michael@0 1479 $(call install_cmd,$(IFLAGS2) '$<' '$(@D)')
michael@0 1480
michael@0 1481 ################################################################################
michael@0 1482 # Preprocessing rules
michael@0 1483 #
michael@0 1484 # The PP_TARGETS variable contains a list of all preprocessing target
michael@0 1485 # categories. Each category has associated variables listing input files, the
michael@0 1486 # output directory, extra preprocessor flags, and so on. For example:
michael@0 1487 #
michael@0 1488 # FOO := input-file
michael@0 1489 # FOO_PATH := target-directory
michael@0 1490 # FOO_FLAGS := -Dsome_flag
michael@0 1491 # PP_TARGETS += FOO
michael@0 1492 #
michael@0 1493 # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
michael@0 1494 # following make variables to see what to do:
michael@0 1495 #
michael@0 1496 # - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
michael@0 1497 # We search VPATH for the names given here. If an input file name ends in
michael@0 1498 # '.in', that suffix is omitted from the output file name.
michael@0 1499 #
michael@0 1500 # - <C>_PATH names the directory in which to place the preprocessed output
michael@0 1501 # files. We create this directory if it does not already exist. Setting
michael@0 1502 # this variable is optional; if unset, we install the files in $(CURDIR).
michael@0 1503 #
michael@0 1504 # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
michael@0 1505 # to the usual bunch. Setting this variable is optional.
michael@0 1506 #
michael@0 1507 # - <C>_TARGET names the 'make' target that should depend on creating the output
michael@0 1508 # files. Setting this variable is optional; if unset, we preprocess the
michael@0 1509 # files for the 'libs' target.
michael@0 1510 #
michael@0 1511 # - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
michael@0 1512 # kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
michael@0 1513 # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
michael@0 1514 # instead of $(DIST)/include/qux.h.
michael@0 1515
michael@0 1516 pp_target_tier = $(or $($(1)_TARGET),libs)
michael@0 1517 PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category))))
michael@0 1518
michael@0 1519 pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=)))
michael@0 1520 pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file)))
michael@0 1521
michael@0 1522 $(foreach category,$(PP_TARGETS), \
michael@0 1523 $(foreach tier,$(call pp_target_tier,$(category)), \
michael@0 1524 $(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \
michael@0 1525 ) \
michael@0 1526 $(foreach file,$($(category)), \
michael@0 1527 $(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \
michael@0 1528 $(file) $(GLOBAL_DEPS))) \
michael@0 1529 ) \
michael@0 1530 $(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \
michael@0 1531 )
michael@0 1532
michael@0 1533 $(foreach tier,$(PP_TARGETS_TIERS), \
michael@0 1534 $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
michael@0 1535 )
michael@0 1536
michael@0 1537 PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
michael@0 1538 $(PP_TARGETS_ALL_RESULTS):
michael@0 1539 $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS))
michael@0 1540 $(RM) '$@'
michael@0 1541 $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) '$<' -o '$@')
michael@0 1542
michael@0 1543 # The depfile is based on the filename, and we don't want conflicts. So check
michael@0 1544 # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
michael@0 1545 PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
michael@0 1546 $(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
michael@0 1547 $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
michael@0 1548 $(error Multiple preprocessing rules are creating a $(file) file) \
michael@0 1549 ) \
michael@0 1550 )
michael@0 1551
michael@0 1552 ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS)))
michael@0 1553 # If the depfile for a preprocessed file doesn't exist, add a dep to force
michael@0 1554 # re-preprocessing.
michael@0 1555 $(foreach file,$(PP_TARGETS_ALL_RESULTS), \
michael@0 1556 $(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \
michael@0 1557 , \
michael@0 1558 $(eval $(file): FORCE) \
michael@0 1559 ) \
michael@0 1560 )
michael@0 1561
michael@0 1562 MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS))))))
michael@0 1563
michael@0 1564 ifneq (,$(MDDEPEND_FILES))
michael@0 1565 $(call include_deps,$(MDDEPEND_FILES))
michael@0 1566 endif
michael@0 1567
michael@0 1568 endif
michael@0 1569
michael@0 1570 # Pull in non-recursive targets if this is a partial tree build.
michael@0 1571 ifndef TOPLEVEL_BUILD
michael@0 1572 include $(topsrcdir)/config/makefiles/nonrecursive.mk
michael@0 1573 endif
michael@0 1574
michael@0 1575 ################################################################################
michael@0 1576 # Special gmake rules.
michael@0 1577 ################################################################################
michael@0 1578
michael@0 1579
michael@0 1580 #
michael@0 1581 # Re-define the list of default suffixes, so gmake won't have to churn through
michael@0 1582 # hundreds of built-in suffix rules for stuff we don't need.
michael@0 1583 #
michael@0 1584 .SUFFIXES:
michael@0 1585
michael@0 1586 #
michael@0 1587 # Fake targets. Always run these rules, even if a file/directory with that
michael@0 1588 # name already exists.
michael@0 1589 #
michael@0 1590 .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 1591
michael@0 1592 # Used as a dependency to force targets to rebuild
michael@0 1593 FORCE:
michael@0 1594
michael@0 1595 # Delete target if error occurs when building target
michael@0 1596 .DELETE_ON_ERROR:
michael@0 1597
michael@0 1598 tags: TAGS
michael@0 1599
michael@0 1600 TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h)
michael@0 1601 -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
michael@0 1602 $(LOOP_OVER_PARALLEL_DIRS)
michael@0 1603 $(LOOP_OVER_DIRS)
michael@0 1604
michael@0 1605 ifndef INCLUDED_DEBUGMAKE_MK #{
michael@0 1606 ## Only parse when an echo* or show* target is requested
michael@0 1607 ifneq (,$(call isTargetStem,echo,show))
michael@0 1608 include $(topsrcdir)/config/makefiles/debugmake.mk
michael@0 1609 endif #}
michael@0 1610 endif #}
michael@0 1611
michael@0 1612 documentation:
michael@0 1613 @cd $(DEPTH)
michael@0 1614 $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
michael@0 1615
michael@0 1616 ifdef ENABLE_TESTS
michael@0 1617 check::
michael@0 1618 $(LOOP_OVER_PARALLEL_DIRS)
michael@0 1619 $(LOOP_OVER_DIRS)
michael@0 1620 $(LOOP_OVER_TOOL_DIRS)
michael@0 1621 endif
michael@0 1622
michael@0 1623
michael@0 1624 FREEZE_VARIABLES = \
michael@0 1625 CSRCS \
michael@0 1626 CPPSRCS \
michael@0 1627 EXPORTS \
michael@0 1628 DIRS \
michael@0 1629 LIBRARY \
michael@0 1630 MODULE \
michael@0 1631 TIERS \
michael@0 1632 EXTRA_COMPONENTS \
michael@0 1633 EXTRA_PP_COMPONENTS \
michael@0 1634 $(NULL)
michael@0 1635
michael@0 1636 $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
michael@0 1637
michael@0 1638 CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
michael@0 1639 $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
michael@0 1640
michael@0 1641 libs export::
michael@0 1642 $(CHECK_FROZEN_VARIABLES)
michael@0 1643
michael@0 1644 PURGECACHES_DIRS ?= $(DIST)/bin
michael@0 1645 ifdef MOZ_WEBAPP_RUNTIME
michael@0 1646 PURGECACHES_DIRS += $(DIST)/bin/webapprt
michael@0 1647 endif
michael@0 1648
michael@0 1649 PURGECACHES_FILES = $(addsuffix /.purgecaches,$(PURGECACHES_DIRS))
michael@0 1650
michael@0 1651 default all:: $(PURGECACHES_FILES)
michael@0 1652
michael@0 1653 $(PURGECACHES_FILES):
michael@0 1654 if test -d $(@D) ; then touch $@ ; fi
michael@0 1655
michael@0 1656 .DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default)
michael@0 1657
michael@0 1658 #############################################################################
michael@0 1659 # Derived targets and dependencies
michael@0 1660
michael@0 1661 include $(topsrcdir)/config/makefiles/autotargets.mk
michael@0 1662 ifneq ($(NULL),$(AUTO_DEPS))
michael@0 1663 default all libs tools export:: $(AUTO_DEPS)
michael@0 1664 endif
michael@0 1665
michael@0 1666 export:: $(GENERATED_FILES)
michael@0 1667
michael@0 1668 GARBAGE += $(GENERATED_FILES)

mercurial