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