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