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