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