Bug 849918 - Initial support for PannerNode's 3D positional audio (equalpower panning...
[gecko.git] / config / rules.mk
blobb774958dd3277e74aab2f9ff52eca1ed61fc4081
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 # Integrate with mozbuild-generated make files. We first verify that no
14 # variables provided by the automatically generated .mk files are
15 # present. If they are, this is a violation of the separation of
16 # responsibility between Makefile.in and mozbuild files.
17 _MOZBUILD_EXTERNAL_VARIABLES := \
18 DIRS \
19 MODULE \
20 PARALLEL_DIRS \
21 TEST_DIRS \
22 TIERS \
23 TOOL_DIRS \
24 XPIDL_MODULE \
25 $(NULL)
27 ifndef EXTERNALLY_MANAGED_MAKE_FILE
28 # Using $(firstword) may not be perfect. But it should be good enough for most
29 # scenarios.
30 _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST))
32 $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(if $($(var)),\
33 $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\
36 ifneq (,$(XPIDLSRCS)$(SDK_XPIDLSRCS))
37 $(error XPIDLSRCS and SDK_XPIDLSRCS have been merged and moved to moz.build files as the XPIDL_SOURCES variable. You must move these variables out of $(_current_makefile))
38 endif
40 # Import the automatically generated backend file. If this file doesn't exist,
41 # the backend hasn't been properly configured. We want this to be a fatal
42 # error, hence not using "-include".
43 ifndef STANDALONE_MAKEFILE
44 GLOBAL_DEPS += backend.mk
45 include backend.mk
46 endif
47 endif
49 ifdef TIERS
50 DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
51 STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
52 endif
54 ifndef MOZILLA_DIR
55 MOZILLA_DIR = $(topsrcdir)
56 endif
58 ifndef INCLUDED_CONFIG_MK
59 include $(topsrcdir)/config/config.mk
60 endif
62 ifndef INCLUDED_VERSION_MK
63 include $(topsrcdir)/config/version.mk
64 endif
66 USE_AUTOTARGETS_MK = 1
67 include $(topsrcdir)/config/makefiles/makeutils.mk
69 ifdef SDK_HEADERS
70 _EXTRA_EXPORTS := $(filter-out $(EXPORTS),$(SDK_HEADERS))
71 EXPORTS += $(_EXTRA_EXPORTS)
72 endif
74 REPORT_BUILD = $(info $(notdir $<))
76 ifeq ($(OS_ARCH),OS2)
77 EXEC =
78 else
79 EXEC = exec
80 endif
82 # Don't copy xulrunner files at install time, when using system xulrunner
83 ifdef SYSTEM_LIBXUL
84 SKIP_COPY_XULRUNNER=1
85 endif
87 # ELOG prints out failed command when building silently (gmake -s). Pymake
88 # prints out failed commands anyway, so ELOG just makes things worse by
89 # forcing shell invocations.
90 ifndef .PYMAKE
91 ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
92 ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
93 else
94 ELOG :=
95 endif # -s
96 else
97 ELOG :=
98 endif # ifndef .PYMAKE
100 _VPATH_SRCS = $(abspath $<)
102 ifdef EXTRA_DSO_LIBS
103 EXTRA_DSO_LIBS := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
104 endif
106 ################################################################################
107 # Testing frameworks support
108 ################################################################################
110 testxpcobjdir = $(DEPTH)/_tests/xpcshell
112 ifdef ENABLE_TESTS
114 # Add test directories to the regular directories list. TEST_DIRS should
115 # arguably have the same status as TOOL_DIRS and other *_DIRS variables. It is
116 # coded this way until Makefiles stop using the "ifdef ENABLE_TESTS; DIRS +="
117 # convention.
119 # The current developer workflow expects tests to be updated when processing
120 # the default target. If we ever change this implementation, the behavior
121 # should be preserved or the change should be widely communicated. A
122 # consequence of not processing test dir targets during the default target is
123 # that changes to tests may not be updated and code could assume to pass
124 # locally against non-current test code.
125 DIRS += $(TEST_DIRS)
127 ifndef INCLUDED_TESTS_XPCSHELL_MK #{
128 include $(topsrcdir)/config/makefiles/xpcshell.mk
129 endif #}
131 ifndef INCLUDED_TESTS_MOCHITEST_MK #{
132 include $(topsrcdir)/config/makefiles/mochitest.mk
133 endif #}
135 ifdef MOZ_ENABLE_GTEST
136 ifdef GTEST_CPPSRCS
137 CPPSRCS += $(GTEST_CPPSRCS)
138 endif
140 ifdef GTEST_CSRCS
141 CSRCS += $(GTEST_CSRCS)
142 endif
144 ifdef GTEST_CMMSRCS
145 CMMSRCS += $(GTEST_CMMSRCS)
146 endif
147 endif
149 ifdef CPP_UNIT_TESTS
151 # Compile the tests to $(DIST)/bin. Make lots of niceties available by default
152 # through TestHarness.h, by modifying the list of includes and the libs against
153 # which stuff links.
154 CPPSRCS += $(CPP_UNIT_TESTS)
155 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
156 INCLUDES += -I$(DIST)/include/testing
157 LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS) $(MOZ_JS_LIBS) $(if $(JS_SHARED_LIBRARY),,$(MOZ_ZLIB_LIBS))
159 check::
160 @$(PYTHON) $(topsrcdir)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS))
162 cppunittests-remote: DM_TRANS?=adb
163 cppunittests-remote:
164 @if [ "${TEST_DEVICE}" != "" -o "$(DM_TRANS)" = "adb" ]; then \
165 $(PYTHON) -u $(topsrcdir)/testing/remotecppunittests.py \
166 --xre-path=$(DEPTH)/dist/bin \
167 --localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
168 --dm_trans=$(DM_TRANS) \
169 --deviceIP=${TEST_DEVICE} \
170 $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)) $(EXTRA_TEST_ARGS); \
171 else \
172 echo "please prepare your host with environment variables for TEST_DEVICE"; \
175 endif # CPP_UNIT_TESTS
177 .PHONY: check
179 ifdef PYTHON_UNIT_TESTS
181 RUN_PYTHON_UNIT_TESTS := $(addprefix run-,$(PYTHON_UNIT_TESTS))
183 .PHONY: $(RUN_PYTHON_UNIT_TESTS)
185 check:: $(RUN_PYTHON_UNIT_TESTS)
187 $(RUN_PYTHON_UNIT_TESTS): run-%: %
188 @PYTHONDONTWRITEBYTECODE=1 $(PYTHON) $<
190 endif # PYTHON_UNIT_TESTS
192 endif # ENABLE_TESTS
196 # Library rules
198 # If FORCE_STATIC_LIB is set, build a static library.
199 # Otherwise, build a shared library.
202 ifndef LIBRARY
203 ifdef STATIC_LIBRARY_NAME
204 REAL_LIBRARY := $(LIB_PREFIX)$(STATIC_LIBRARY_NAME).$(LIB_SUFFIX)
205 # Only build actual library if it is installed in DIST/lib or SDK
206 ifeq (,$(SDK_LIBRARY)$(DIST_INSTALL)$(NO_EXPAND_LIBS))
207 LIBRARY := $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
208 else
209 LIBRARY := $(REAL_LIBRARY) $(REAL_LIBRARY).$(LIBS_DESC_SUFFIX)
210 endif
211 endif # STATIC_LIBRARY_NAME
212 endif # LIBRARY
214 ifndef HOST_LIBRARY
215 ifdef HOST_LIBRARY_NAME
216 HOST_LIBRARY := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
217 endif
218 endif
220 ifdef LIBRARY
221 ifdef FORCE_SHARED_LIB
222 ifdef MKSHLIB
224 ifdef LIB_IS_C_ONLY
225 MKSHLIB = $(MKCSHLIB)
226 endif
228 ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
229 IMPORT_LIBRARY := $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
230 endif
232 ifeq (OS2,$(OS_ARCH))
233 ifdef SHORT_LIBNAME
234 SHARED_LIBRARY_NAME := $(SHORT_LIBNAME)
235 endif
236 endif
238 ifdef MAKE_FRAMEWORK
239 SHARED_LIBRARY := $(SHARED_LIBRARY_NAME)
240 else
241 SHARED_LIBRARY := $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX)
242 endif
244 ifeq ($(OS_ARCH),OS2)
245 DEF_FILE := $(SHARED_LIBRARY:.dll=.def)
246 endif
248 EMBED_MANIFEST_AT=2
250 endif # MKSHLIB
251 endif # FORCE_SHARED_LIB
252 endif # LIBRARY
254 ifdef FORCE_STATIC_LIB
255 ifndef FORCE_SHARED_LIB
256 SHARED_LIBRARY := $(NULL)
257 DEF_FILE := $(NULL)
258 IMPORT_LIBRARY := $(NULL)
259 endif
260 endif
262 ifdef FORCE_SHARED_LIB
263 ifndef FORCE_STATIC_LIB
264 LIBRARY := $(NULL)
265 endif
266 endif
268 ifdef JAVA_LIBRARY_NAME
269 JAVA_LIBRARY := $(JAVA_LIBRARY_NAME).jar
270 endif
272 ifeq ($(OS_ARCH),WINNT)
273 ifndef GNU_CC
276 # Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per
277 # directory. For parallel builds, this PDB file is shared and locked by
278 # MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8
279 # without SP1, don't do parallel builds.
281 # The final PDB for libraries and programs is created by the linker and uses
282 # a different name from the single PDB file created by the compiler. See
283 # bug 462740.
286 ifdef SIMPLE_PROGRAMS
287 COMPILE_PDBFILE = $(basename $(@F)).pdb
288 else
289 COMPILE_PDBFILE = generated.pdb
290 endif
292 LINK_PDBFILE = $(basename $(@F)).pdb
293 ifdef MOZ_DEBUG
294 CODFILE=$(basename $(@F)).cod
295 endif
297 ifdef MOZ_MAPINFO
298 ifdef SHARED_LIBRARY_NAME
299 MAPFILE=$(SHARED_LIBRARY_NAME).map
300 else
301 MAPFILE=$(basename $(@F)).map
302 endif # SHARED_LIBRARY_NAME
303 endif # MOZ_MAPINFO
305 ifdef DEFFILE
306 OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
307 EXTRA_DEPS += $(DEFFILE)
308 endif
310 ifdef MAPFILE
311 OS_LDFLAGS += -MAP:$(MAPFILE)
312 endif
314 else #!GNU_CC
316 ifdef DEFFILE
317 OS_LDFLAGS += $(call normalizepath,$(DEFFILE))
318 EXTRA_DEPS += $(DEFFILE)
319 endif
321 endif # !GNU_CC
323 endif # WINNT
325 ifeq ($(SOLARIS_SUNPRO_CXX),1)
326 ifeq (86,$(findstring 86,$(OS_TEST)))
327 OS_LDFLAGS += -M $(topsrcdir)/config/solaris_ia32.map
328 endif # x86
329 endif # Solaris Sun Studio C++
331 ifeq ($(HOST_OS_ARCH),WINNT)
332 HOST_PDBFILE=$(basename $(@F)).pdb
333 endif
335 # Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass
336 ifdef MOZ_PROFILE_GENERATE
337 SIMPLE_PROGRAMS :=
338 endif
340 ifndef TARGETS
341 TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
342 endif
344 COBJS = $(CSRCS:.c=.$(OBJ_SUFFIX))
345 SOBJS = $(SSRCS:.S=.$(OBJ_SUFFIX))
346 CCOBJS = $(patsubst %.cc,%.$(OBJ_SUFFIX),$(filter %.cc,$(CPPSRCS)))
347 CPPOBJS = $(patsubst %.cpp,%.$(OBJ_SUFFIX),$(filter %.cpp,$(CPPSRCS)))
348 CMOBJS = $(CMSRCS:.m=.$(OBJ_SUFFIX))
349 CMMOBJS = $(CMMSRCS:.mm=.$(OBJ_SUFFIX))
350 ASOBJS = $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
351 ifndef OBJS
352 _OBJS = $(COBJS) $(SOBJS) $(CCOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS)
353 OBJS = $(strip $(_OBJS))
354 endif
356 HOST_COBJS = $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX)))
357 HOST_CCOBJS = $(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(filter %.cc,$(HOST_CPPSRCS))))
358 HOST_CPPOBJS = $(addprefix host_,$(patsubst %.cpp,%.$(OBJ_SUFFIX),$(filter %.cpp,$(HOST_CPPSRCS))))
359 HOST_CMOBJS = $(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX)))
360 HOST_CMMOBJS = $(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
361 ifndef HOST_OBJS
362 _HOST_OBJS = $(HOST_COBJS) $(HOST_CCOBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
363 HOST_OBJS = $(strip $(_HOST_OBJS))
364 endif
366 ALL_TRASH = \
367 $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
368 $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
369 $(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
370 $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
371 $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
372 $(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
373 $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
374 $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
375 $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
376 $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
377 $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
378 ALL_TRASH_DIRS = \
379 $(GARBAGE_DIRS) /no-such-file
381 ifdef QTDIR
382 GARBAGE += $(MOCSRCS)
383 GARBAGE += $(RCCSRCS)
384 endif
386 ifdef SIMPLE_PROGRAMS
387 GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
388 endif
390 ifdef HOST_SIMPLE_PROGRAMS
391 GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
392 endif
395 # the Solaris WorkShop template repository cache. it occasionally can get
396 # out of sync, so targets like clobber should kill it.
398 ifeq ($(SOLARIS_SUNPRO_CXX),1)
399 GARBAGE_DIRS += SunWS_cache
400 endif
402 XPIDL_GEN_DIR = _xpidlgen
404 ifdef MOZ_UPDATE_XTERM
405 # Its good not to have a newline at the end of the titlebar string because it
406 # makes the make -s output easier to read. Echo -n does not work on all
407 # platforms, but we can trick printf into doing it.
408 UPDATE_TITLE = printf "\033]0;%s in %s\007" $(1) $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2) ;
409 endif
411 define SUBMAKE # $(call SUBMAKE,target,directory)
412 +@$(UPDATE_TITLE)
413 +$(MAKE) $(if $(2),-C $(2)) $(1)
415 endef # The extra line is important here! don't delete it
417 ifneq (,$(strip $(DIRS)))
418 LOOP_OVER_DIRS = \
419 $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
420 endif
422 # we only use this for the makefiles target and other stuff that doesn't matter
423 ifneq (,$(strip $(PARALLEL_DIRS)))
424 LOOP_OVER_PARALLEL_DIRS = \
425 $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir)))
426 endif
428 ifneq (,$(strip $(STATIC_DIRS)))
429 LOOP_OVER_STATIC_DIRS = \
430 $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir)))
431 endif
433 ifneq (,$(strip $(TOOL_DIRS)))
434 LOOP_OVER_TOOL_DIRS = \
435 $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir)))
436 endif
439 # Now we can differentiate between objects used to build a library, and
440 # objects used to build an executable in the same directory.
442 ifndef PROGOBJS
443 PROGOBJS = $(OBJS)
444 endif
446 ifndef HOST_PROGOBJS
447 HOST_PROGOBJS = $(HOST_OBJS)
448 endif
450 GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
453 # Tags: emacs (etags), vi (ctags)
454 # TAG_PROGRAM := ctags -L -
456 TAG_PROGRAM = xargs etags -a
459 # Turn on C++ linking if we have any .cpp or .mm files
460 # (moved this from config.mk so that config.mk can be included
461 # before the CPPSRCS are defined)
463 ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
464 HOST_CPP_PROG_LINK = 1
465 endif
468 # This will strip out symbols that the component should not be
469 # exporting from the .dynsym section.
471 ifdef IS_COMPONENT
472 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
473 endif # IS_COMPONENT
476 # Enforce the requirement that MODULE_NAME must be set
477 # for components in static builds
479 ifdef IS_COMPONENT
480 ifdef EXPORT_LIBRARY
481 ifndef FORCE_SHARED_LIB
482 ifndef MODULE_NAME
483 $(error MODULE_NAME is required for components which may be used in static builds)
484 endif
485 endif
486 endif
487 endif
490 # MacOS X specific stuff
493 ifeq ($(OS_ARCH),Darwin)
494 ifdef SHARED_LIBRARY
495 ifdef IS_COMPONENT
496 EXTRA_DSO_LDOPTS += -bundle
497 else
498 EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
499 endif
500 endif
501 endif
504 # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be
505 # fatal symbol name clashes between components.
507 ifeq ($(OS_ARCH),NetBSD)
508 ifeq ($(DLL_SUFFIX),.so.1.0)
509 ifdef IS_COMPONENT
510 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
511 endif
512 endif
513 endif
515 ifeq ($(OS_ARCH),FreeBSD)
516 ifdef IS_COMPONENT
517 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
518 endif
519 endif
521 ifeq ($(OS_ARCH),NetBSD)
522 ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
523 ifeq ($(MODULE),layout)
524 OS_CFLAGS += -Wa,-xgot
525 OS_CXXFLAGS += -Wa,-xgot
526 endif
527 endif
528 endif
531 # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
532 # which uses internal symbols first
534 ifeq ($(OS_ARCH),HP-UX)
535 ifdef IS_COMPONENT
536 ifeq ($(GNU_CC)$(GNU_CXX),)
537 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
538 ifneq ($(HAS_EXTRAEXPORTS),1)
539 MKSHLIB += -Wl,+eNSGetModule -Wl,+eerrno
540 MKCSHLIB += +eNSGetModule +eerrno
541 ifneq ($(OS_TEST),ia64)
542 MKSHLIB += -Wl,+e_shlInit
543 MKCSHLIB += +e_shlInit
544 endif # !ia64
545 endif # !HAS_EXTRAEXPORTS
546 endif # non-gnu compilers
547 endif # IS_COMPONENT
548 endif # HP-UX
550 ifeq ($(OS_ARCH),AIX)
551 ifdef IS_COMPONENT
552 ifneq ($(HAS_EXTRAEXPORTS),1)
553 MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
554 MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
555 endif # HAS_EXTRAEXPORTS
556 endif # IS_COMPONENT
557 endif # AIX
560 # Linux: add -Bsymbolic flag for components
562 ifeq ($(OS_ARCH),Linux)
563 ifdef IS_COMPONENT
564 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
565 endif
566 endif
569 # GNU doesn't have path length limitation
572 ifeq ($(OS_ARCH),GNU)
573 OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
574 endif
577 # MINGW32
579 ifeq ($(OS_ARCH),WINNT)
580 ifdef GNU_CC
581 ifndef IS_COMPONENT
582 DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
583 endif
584 endif
585 endif
587 ifeq ($(USE_TVFS),1)
588 IFLAGS1 = -rb
589 IFLAGS2 = -rb
590 else
591 IFLAGS1 = -m 644
592 IFLAGS2 = -m 755
593 endif
595 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
596 OUTOPTION = -Fo# eol
597 else
598 OUTOPTION = -o # eol
599 endif # WINNT && !GNU_CC
601 ifneq (,$(filter ml%,$(AS)))
602 ASOUTOPTION = -Fo# eol
603 else
604 ASOUTOPTION = -o # eol
605 endif
607 ifeq (,$(CROSS_COMPILE))
608 HOST_OUTOPTION = $(OUTOPTION)
609 else
610 HOST_OUTOPTION = -o # eol
611 endif
612 ################################################################################
614 # SUBMAKEFILES: List of Makefiles for next level down.
615 # This is used to update or create the Makefiles before invoking them.
616 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
618 # The root makefile doesn't want to do a plain export/libs, because
619 # of the tiers and because of libxul. Suppress the default rules in favor
620 # of something else. Makefiles which use this var *must* provide a sensible
621 # default rule before including rules.mk
622 ifndef SUPPRESS_DEFAULT_RULES
623 ifdef TIERS
624 default all alldep::
625 $(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
626 else
628 default all::
629 ifneq (,$(strip $(STATIC_DIRS)))
630 $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir)))
631 endif
632 $(MAKE) export
633 $(MAKE) libs
634 $(MAKE) tools
636 # Do depend as well
637 alldep::
638 $(MAKE) export
639 $(MAKE) depend
640 $(MAKE) libs
641 $(MAKE) tools
643 endif # TIERS
644 endif # SUPPRESS_DEFAULT_RULES
646 ifeq ($(filter s,$(MAKEFLAGS)),)
647 ECHO := echo
648 QUIET :=
649 else
650 ECHO := true
651 QUIET := -q
652 endif
654 MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
656 $(foreach tier,$(TIERS),tier_$(tier))::
657 @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
658 $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir)))
659 $(MAKE) export_$@
660 $(MAKE) libs_$@
661 $(MAKE) tools_$@
663 # Do everything from scratch
664 everything::
665 $(MAKE) clean
666 $(MAKE) alldep
668 # Add dummy depend target for tinderboxes
669 depend::
671 # Target to only regenerate makefiles
672 makefiles: $(SUBMAKEFILES)
673 ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
674 $(LOOP_OVER_PARALLEL_DIRS)
675 $(LOOP_OVER_DIRS)
676 $(LOOP_OVER_TOOL_DIRS)
677 endif
679 include $(topsrcdir)/config/makefiles/target_export.mk
680 include $(topsrcdir)/config/makefiles/target_tools.mk
682 ifneq (,$(filter-out %.$(LIB_SUFFIX),$(SHARED_LIBRARY_LIBS)))
683 $(error SHARED_LIBRARY_LIBS must contain .$(LIB_SUFFIX) files only)
684 endif
686 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX),$(HOST_LIBS))
688 # Dependencies which, if modified, should cause everything to rebuild
689 GLOBAL_DEPS += Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
690 ifndef NO_MAKEFILE_RULE
691 GLOBAL_DEPS += Makefile.in
692 endif
694 ##############################################
695 include $(topsrcdir)/config/makefiles/target_libs.mk
697 ##############################################
698 ifndef NO_PROFILE_GUIDED_OPTIMIZE
699 ifdef MOZ_PROFILE_USE
700 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
701 # When building with PGO, we have to make sure to re-link
702 # in the MOZ_PROFILE_USE phase if we linked in the
703 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
704 # file in the link rule in the GENERATE phase to indicate
705 # that we need a relink.
706 ifdef SHARED_LIBRARY
707 $(SHARED_LIBRARY): pgo.relink
708 endif
709 ifdef PROGRAM
710 $(PROGRAM): pgo.relink
711 endif
713 # In the second pass, we need to merge the pgc files into the pgd file.
714 # The compiler would do this for us automatically if they were in the right
715 # place, but they're in dist/bin.
716 ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
717 export::
718 ifdef PROGRAM
719 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
720 $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
721 endif
722 ifdef SHARED_LIBRARY
723 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
724 $(SHARED_LIBRARY_NAME) $(DIST)/bin
725 endif
726 endif # SHARED_LIBRARY || PROGRAM
727 endif # WINNT_
728 endif # MOZ_PROFILE_USE
729 ifdef MOZ_PROFILE_GENERATE
730 # Clean up profiling data during PROFILE_GENERATE phase
731 export::
732 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
733 $(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
734 else
735 ifdef GNU_CC
736 -$(RM) *.gcda
737 endif
738 endif
739 endif
741 ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
742 ifdef GNU_CC
743 # Force rebuilding libraries and programs in both passes because each
744 # pass uses different object files.
745 $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
746 endif
747 endif
749 endif # NO_PROFILE_GUIDED_OPTIMIZE
751 ##############################################
753 checkout:
754 $(MAKE) -C $(topsrcdir) -f client.mk checkout
756 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
757 -$(RM) $(ALL_TRASH)
758 -$(RM) -r $(ALL_TRASH_DIRS)
759 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
761 distclean:: $(SUBMAKEFILES)
762 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
763 -$(RM) -r $(ALL_TRASH_DIRS)
764 -$(RM) $(ALL_TRASH) \
765 Makefile .HSancillary \
766 $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
767 $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
768 $(wildcard *.$(IMPORT_LIB_SUFFIX))
769 ifeq ($(OS_ARCH),OS2)
770 -$(RM) $(PROGRAM:.exe=.map)
771 endif
773 alltags:
774 $(RM) TAGS
775 find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
778 # PROGRAM = Foo
779 # creates OBJS, links with LIBS to create Foo
781 $(PROGRAM): $(PROGOBJS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
782 @$(RM) $@.manifest
783 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
784 $(EXPAND_LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
785 ifdef MSMANIFEST_TOOL
786 @if test -f $@.manifest; then \
787 if test -f "$(srcdir)/$@.manifest"; then \
788 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
789 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
790 else \
791 echo "Embedding manifest from $@.manifest"; \
792 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
793 fi; \
794 elif test -f "$(srcdir)/$@.manifest"; then \
795 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
796 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
798 endif # MSVC with manifest tool
799 ifdef MOZ_PROFILE_GENERATE
800 # touch it a few seconds into the future to work around FAT's
801 # 2-second granularity
802 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
803 endif
804 else # !WINNT || GNU_CC
805 $(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)
806 @$(call CHECK_STDCXX,$@)
807 endif # WINNT && !GNU_CC
809 ifdef ENABLE_STRIP
810 $(STRIP) $@
811 endif
812 ifdef MOZ_POST_PROGRAM_COMMAND
813 $(MOZ_POST_PROGRAM_COMMAND) $@
814 endif
816 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
817 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
818 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
819 ifdef MSMANIFEST_TOOL
820 @if test -f $@.manifest; then \
821 if test -f "$(srcdir)/$@.manifest"; then \
822 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
823 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
824 else \
825 echo "Embedding manifest from $@.manifest"; \
826 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
827 fi; \
828 elif test -f "$(srcdir)/$@.manifest"; then \
829 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
830 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
832 endif # MSVC with manifest tool
833 else
834 ifeq ($(HOST_CPP_PROG_LINK),1)
835 $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
836 else
837 $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
838 endif # HOST_CPP_PROG_LINK
839 endif
842 # This is an attempt to support generation of multiple binaries
843 # in one directory, it assumes everything to compile Foo is in
844 # Foo.o (from either Foo.c or Foo.cpp).
846 # SIMPLE_PROGRAMS = Foo Bar
847 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
849 $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(EXTRA_DEPS) $(GLOBAL_DEPS)
850 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
851 $(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
852 ifdef MSMANIFEST_TOOL
853 @if test -f $@.manifest; then \
854 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
855 rm -f $@.manifest; \
857 endif # MSVC with manifest tool
858 else
859 $(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS)
860 @$(call CHECK_STDCXX,$@)
861 endif # WINNT && !GNU_CC
863 ifdef ENABLE_STRIP
864 $(STRIP) $@
865 endif
866 ifdef MOZ_POST_PROGRAM_COMMAND
867 $(MOZ_POST_PROGRAM_COMMAND) $@
868 endif
870 $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
871 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
872 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
873 else
874 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
875 $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
876 else
877 $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
878 endif
879 endif
881 ifdef DTRACE_PROBE_OBJ
882 EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
883 OBJS += $(DTRACE_PROBE_OBJ)
884 endif
886 $(filter %.$(LIB_SUFFIX),$(LIBRARY)): $(OBJS) $(LOBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
887 $(RM) $(LIBRARY)
888 $(EXPAND_AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS)
889 $(RANLIB) $@
891 $(filter-out %.$(LIB_SUFFIX),$(LIBRARY)): $(filter %.$(LIB_SUFFIX),$(LIBRARY)) $(OBJS) $(LOBJS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
892 # When we only build a library descriptor, blow out any existing library
893 $(if $(filter %.$(LIB_SUFFIX),$(LIBRARY)),,$(RM) $(REAL_LIBRARY) $(EXPORT_LIBRARY:%=%/$(REAL_LIBRARY)))
894 $(EXPAND_LIBS_GEN) -o $@ $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS)
896 ifeq ($(OS_ARCH),WINNT)
897 # Import libraries are created by the rules creating shared libraries.
898 # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
899 # but make will happily consider the import library before it is refreshed
900 # when rebuilding the corresponding shared library. Defining an empty recipe
901 # for import libraries forces make to wait for the shared library recipe to
902 # have run before considering other targets that depend on the import library.
903 # See bug 795204.
904 $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
905 endif
907 ifeq ($(OS_ARCH),OS2)
908 $(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
909 $(RM) $@
910 echo LIBRARY $(SHARED_LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
911 echo PROTMODE >> $@
912 echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@
913 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
914 echo EXPORTS >> $@
916 $(ADD_TO_DEF_FILE)
918 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
919 $(RM) $@
920 $(IMPLIB) $@ $^
921 $(RANLIB) $@
922 endif # OS/2
924 $(HOST_LIBRARY): $(HOST_OBJS) Makefile
925 $(RM) $@
926 $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
927 $(HOST_RANLIB) $@
929 ifdef HAVE_DTRACE
930 ifndef XP_MACOSX
931 ifdef DTRACE_PROBE_OBJ
932 ifndef DTRACE_LIB_DEPENDENT
933 NON_DTRACE_OBJS := $(filter-out $(DTRACE_PROBE_OBJ),$(OBJS))
934 $(DTRACE_PROBE_OBJ): $(NON_DTRACE_OBJS)
935 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(NON_DTRACE_OBJS)
936 endif
937 endif
938 endif
939 endif
941 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
942 # so instead of deleting .o files after repacking them into a dylib, we make
943 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
944 # so no need to conditionalize on OS version or debugging format.
946 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(LIBRARY) $(EXTRA_DEPS) $(GLOBAL_DEPS)
947 ifndef INCREMENTAL_LINKER
948 $(RM) $@
949 endif
950 ifdef DTRACE_LIB_DEPENDENT
951 ifndef XP_MACOSX
952 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
953 endif
954 $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(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)
955 @$(RM) $(DTRACE_PROBE_OBJ)
956 else # ! DTRACE_LIB_DEPENDENT
957 $(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
958 endif # DTRACE_LIB_DEPENDENT
959 @$(call CHECK_STDCXX,$@)
961 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
962 ifdef MSMANIFEST_TOOL
963 ifdef EMBED_MANIFEST_AT
964 @if test -f $@.manifest; then \
965 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
966 rm -f $@.manifest; \
968 endif # EMBED_MANIFEST_AT
969 endif # MSVC with manifest tool
970 ifdef MOZ_PROFILE_GENERATE
971 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
972 endif
973 endif # WINNT && !GCC
974 @$(RM) foodummyfilefoo $(DELETE_AFTER_LINK)
975 chmod +x $@
976 ifdef ENABLE_STRIP
977 $(STRIP) $@
978 endif
979 ifdef MOZ_POST_DSO_LIB_COMMAND
980 $(MOZ_POST_DSO_LIB_COMMAND) $@
981 endif
983 ifeq ($(SOLARIS_SUNPRO_CC),1)
984 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
986 define MAKE_DEPS_AUTO_CC
987 if test -d $(@D); then \
988 echo "Building deps for $< using Sun Studio cc"; \
989 $(CC) $(COMPILE_CFLAGS) -xM $< >$(_MDDEPFILE) ; \
991 endef
992 define MAKE_DEPS_AUTO_CXX
993 if test -d $(@D); then \
994 echo "Building deps for $< using Sun Studio CC"; \
995 $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
997 endef
998 endif # Sun Studio on Solaris
1000 $(OBJS) $(HOST_OBJS): $(GLOBAL_DEPS)
1002 # Rules for building native targets must come first because of the host_ prefix
1003 $(HOST_COBJS): host_%.$(OBJ_SUFFIX): %.c
1004 $(REPORT_BUILD)
1005 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1007 $(HOST_CPPOBJS): host_%.$(OBJ_SUFFIX): %.cpp
1008 $(REPORT_BUILD)
1009 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1011 $(HOST_CCOBJS): host_%.$(OBJ_SUFFIX): %.cc
1012 $(REPORT_BUILD)
1013 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1015 $(HOST_CMOBJS): host_%.$(OBJ_SUFFIX): %.m
1016 $(REPORT_BUILD)
1017 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1019 $(HOST_CMMOBJS): host_%.$(OBJ_SUFFIX): %.mm
1020 $(REPORT_BUILD)
1021 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1023 $(COBJS): %.$(OBJ_SUFFIX): %.c $(call mkdir_deps,$(MDDEPDIR))
1024 $(REPORT_BUILD)
1025 @$(MAKE_DEPS_AUTO_CC)
1026 $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1028 # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
1029 # 'moc' only knows about #defines it gets on the command line (-D...), not in
1030 # included headers like mozilla-config.h
1031 moc_%.cpp: %.h
1032 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
1034 moc_%.cc: %.cc
1035 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
1037 qrc_%.cpp: %.qrc
1038 $(ELOG) $(RCC) -name $* $< $(OUTOPTION)$@
1040 ifdef ASFILES
1041 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
1042 # a '-c' flag.
1043 $(ASOBJS): %.$(OBJ_SUFFIX): %.$(ASM_SUFFIX)
1044 $(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
1045 endif
1047 $(SOBJS): %.$(OBJ_SUFFIX): %.S
1048 $(AS) -o $@ $(ASFLAGS) $(LOCAL_INCLUDES) $(TARGET_LOCAL_INCLUDES) -c $<
1051 # Please keep the next two rules in sync.
1053 $(CCOBJS): %.$(OBJ_SUFFIX): %.cc $(call mkdir_deps,$(MDDEPDIR))
1054 $(REPORT_BUILD)
1055 @$(MAKE_DEPS_AUTO_CXX)
1056 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1058 $(CPPOBJS): %.$(OBJ_SUFFIX): %.cpp $(call mkdir_deps,$(MDDEPDIR))
1059 $(REPORT_BUILD)
1060 @$(MAKE_DEPS_AUTO_CXX)
1061 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1063 $(CMMOBJS): $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(call mkdir_deps,$(MDDEPDIR))
1064 $(REPORT_BUILD)
1065 @$(MAKE_DEPS_AUTO_CXX)
1066 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1068 $(CMOBJS): $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(call mkdir_deps,$(MDDEPDIR))
1069 $(REPORT_BUILD)
1070 @$(MAKE_DEPS_AUTO_CC)
1071 $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1073 %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
1074 $(CCC) -S $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1076 %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
1077 $(CCC) -S $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1079 %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
1080 $(CC) -S $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS)
1082 %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR))
1083 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i
1085 %.i: %.cc $(call mkdir_deps,$(MDDEPDIR))
1086 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i
1088 %.i: %.c $(call mkdir_deps,$(MDDEPDIR))
1089 $(CC) -C -E $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i
1091 %.i: %.mm $(call mkdir_deps,$(MDDEPDIR))
1092 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i
1094 %.res: %.rc
1095 @echo Creating Resource file: $@
1096 ifeq ($(OS_ARCH),OS2)
1097 $(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
1098 else
1099 ifdef GNU_CC
1100 $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
1101 else
1102 $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
1103 endif
1104 endif
1106 # need 3 separate lines for OS/2
1107 %:: %.pl
1108 $(RM) $@
1109 cp $< $@
1110 chmod +x $@
1112 %:: %.sh
1113 $(RM) $@
1114 cp $< $@
1115 chmod +x $@
1117 # Cancel these implicit rules
1119 %: %,v
1121 %: RCS/%,v
1123 %: s.%
1125 %: SCCS/s.%
1127 ###############################################################################
1128 # Java rules
1129 ###############################################################################
1130 ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
1131 SEP := ;
1132 else
1133 SEP := :
1134 endif
1136 EMPTY :=
1137 SPACE := $(EMPTY) $(EMPTY)
1139 # MSYS has its own special path form, but javac expects the source and class
1140 # paths to be in the DOS form (i.e. e:/builds/...). This function does the
1141 # appropriate conversion on Windows, but is a noop on other systems.
1142 ifeq ($(HOST_OS_ARCH),WINNT)
1143 # We use 'pwd -W' to get DOS form of the path. However, since the given path
1144 # could be a file or a non-existent path, we cannot call 'pwd -W' directly
1145 # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
1146 # on it, then merge with the rest of the path.
1147 root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
1148 non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
1149 normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
1150 else
1151 normalizepath = $(1)
1152 endif
1154 ifneq (,$(value JAVAFILES)$(value RESFILES))
1155 include $(topsrcdir)/config/makefiles/java-build.mk
1156 endif
1158 _srcdir = $(call normalizepath,$(srcdir))
1159 ifdef JAVA_SOURCEPATH
1160 SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
1161 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
1162 else
1163 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
1164 endif
1166 ifdef JAVA_CLASSPATH
1167 CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
1168 _JAVA_CLASSPATH = ".$(SEP)$(CP)"
1169 else
1170 _JAVA_CLASSPATH = .
1171 endif
1173 _JAVA_DIR = _java
1174 $(_JAVA_DIR)::
1175 $(NSINSTALL) -D $@
1177 $(_JAVA_DIR)/%.class: %.java $(GLOBAL_DEPS) $(_JAVA_DIR)
1178 $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
1179 -sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
1181 $(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) $(GLOBAL_DEPS)
1182 $(JAR) cf $@ -C $(_JAVA_DIR) .
1184 GARBAGE_DIRS += $(_JAVA_DIR)
1186 ###############################################################################
1187 # Update Files Managed by Build Backend
1188 ###############################################################################
1190 ifdef MOZBUILD_DERIVED
1192 # If this Makefile is derived from moz.build files, substitution for all .in
1193 # files is handled by SUBSTITUTE_FILES. This includes Makefile.in.
1194 ifneq ($(SUBSTITUTE_FILES),,)
1195 $(SUBSTITUTE_FILES): % : $(srcdir)/%.in $(DEPTH)/config/autoconf.mk
1196 @$(PYTHON) $(DEPTH)/config.status -n --file=$@
1197 @$(TOUCH) $@
1198 endif
1200 # Detect when the backend.mk needs rebuilt. This will cause a full scan and
1201 # rebuild. While relatively expensive, it should only occur once per recursion.
1202 ifneq ($(BACKEND_INPUT_FILES),,)
1203 backend.mk: $(BACKEND_INPUT_FILES)
1204 @$(PYTHON) $(DEPTH)/config.status -n
1205 @$(TOUCH) $@
1206 endif
1208 endif # MOZBUILD_DERIVED
1210 ifndef NO_MAKEFILE_RULE
1211 Makefile: Makefile.in
1212 @$(PYTHON) $(DEPTH)/config.status -n --file=Makefile
1213 @$(TOUCH) $@
1214 endif
1216 ifndef NO_SUBMAKEFILES_RULE
1217 ifdef SUBMAKEFILES
1218 # VPATH does not work on some machines in this case, so add $(srcdir)
1219 $(SUBMAKEFILES): % : $(srcdir)/%.in
1220 $(PYTHON) $(DEPTH)$(addprefix /,$(subsrcdir))/config.status -n --file="$@"
1221 @$(TOUCH) "$@"
1222 endif
1223 endif
1225 ifdef AUTOUPDATE_CONFIGURE
1226 $(topsrcdir)/configure: $(topsrcdir)/configure.in
1227 (cd $(topsrcdir) && $(AUTOCONF)) && $(PYTHON) $(DEPTH)/config.status -n --recheck
1228 endif
1230 $(DEPTH)/config/autoconf.mk: $(topsrcdir)/config/autoconf.mk.in
1231 $(PYTHON) $(DEPTH)/config.status -n --file=$(DEPTH)/config/autoconf.mk
1232 $(TOUCH) $@
1234 ###############################################################################
1235 # Bunch of things that extend the 'export' rule (in order):
1236 ###############################################################################
1238 ################################################################################
1239 # Copy each element of EXPORTS to $(DIST)/include
1241 ifneq ($(XPI_NAME),)
1242 $(FINAL_TARGET):
1243 $(NSINSTALL) -D $@
1245 export:: $(FINAL_TARGET)
1246 endif
1248 ifndef NO_DIST_INSTALL
1249 ifneq (,$(EXPORTS))
1250 EXPORTS_FILES := $(EXPORTS)
1251 EXPORTS_DEST := $(DIST)/include
1252 EXPORTS_TARGET := export
1253 INSTALL_TARGETS += EXPORTS
1254 endif
1255 endif # NO_DIST_INSTALL
1257 define EXPORT_NAMESPACE_RULE
1258 ifndef NO_DIST_INSTALL
1259 EXPORTS_$(namespace)_FILES := $$(EXPORTS_$(namespace))
1260 EXPORTS_$(namespace)_DEST := $$(DIST)/include/$(namespace)
1261 EXPORTS_$(namespace)_TARGET := export
1262 INSTALL_TARGETS += EXPORTS_$(namespace)
1263 endif # NO_DIST_INSTALL
1264 endef
1266 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
1268 ################################################################################
1269 # Copy each element of PREF_JS_EXPORTS
1271 # The default location for PREF_JS_EXPORTS is the gre prefs directory.
1272 PREF_DIR = defaults/pref
1274 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
1275 # different and that we are building app related resources. Hence,
1276 # PREF_DIR should point to the app prefs location.
1277 ifneq (,$(DIST_SUBDIR)$(XPI_NAME)$(LIBXUL_SDK))
1278 PREF_DIR = defaults/preferences
1279 endif
1281 # on win32, pref files need CRLF line endings... see bug 206029
1282 ifeq (WINNT,$(OS_ARCH))
1283 PREF_PPFLAGS += --line-endings=crlf
1284 endif
1286 # Set a flag that can be used in pref files to disable features if
1287 # we are not building for Aurora or Nightly.
1288 ifeq (,$(findstring a,$(GRE_MILESTONE)))
1289 PREF_PPFLAGS += -DRELEASE_BUILD
1290 endif
1292 ifneq ($(PREF_JS_EXPORTS),)
1293 ifndef NO_DIST_INSTALL
1294 PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
1295 PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS)
1296 PP_TARGETS += PREF_JS_EXPORTS
1297 endif
1298 endif
1300 ################################################################################
1301 # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
1303 ifneq ($(AUTOCFG_JS_EXPORTS),)
1304 ifndef NO_DIST_INSTALL
1305 AUTOCFG_JS_EXPORTS_FILES := $(AUTOCFG_JS_EXPORTS)
1306 AUTOCFG_JS_EXPORTS_DEST := $(FINAL_TARGET)/defaults/autoconfig
1307 AUTOCFG_JS_EXPORTS_TARGET := export
1308 INSTALL_TARGETS += AUTOCFG_JS_EXPORTS
1309 endif
1310 endif
1312 ################################################################################
1313 # Export the elements of $(XPIDLSRCS)
1314 # generating .h and .xpt files and moving them to the appropriate places.
1316 ifneq ($(XPIDLSRCS),) #{
1318 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
1320 ifndef XPIDL_MODULE
1321 XPIDL_MODULE = $(MODULE)
1322 endif
1324 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
1325 export:: FORCE
1326 @echo
1327 @echo "*** Error processing XPIDLSRCS:"
1328 @echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
1329 @echo "so we have a module name to use when creating MODULE.xpt."
1330 @echo; sleep 2; false
1331 endif
1333 # generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
1334 # warn against overriding existing .h file.
1336 XPIDL_DEPS = \
1337 $(LIBXUL_DIST)/sdk/bin/header.py \
1338 $(LIBXUL_DIST)/sdk/bin/typelib.py \
1339 $(LIBXUL_DIST)/sdk/bin/xpidl.py \
1340 $(NULL)
1342 xpidl-preqs = \
1343 $(call mkdir_deps,$(XPIDL_GEN_DIR)) \
1344 $(call mkdir_deps,$(MDDEPDIR)) \
1345 $(NULL)
1347 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
1348 $(REPORT_BUILD)
1349 $(PYTHON_PATH) \
1350 $(PLY_INCLUDE) \
1351 $(LIBXUL_DIST)/sdk/bin/header.py $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
1352 @if test -n "$(findstring $*.h, $(EXPORTS))"; \
1353 then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
1355 # generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
1356 # into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
1357 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
1358 $(REPORT_BUILD)
1359 $(PYTHON_PATH) \
1360 $(PLY_INCLUDE) \
1361 -I$(topsrcdir)/xpcom/typelib/xpt/tools \
1362 $(LIBXUL_DIST)/sdk/bin/typelib.py $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
1364 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
1365 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
1366 XPT_PY = $(filter %/xpt.py,$(XPIDL_LINK))
1368 xpidl-idl2xpt = $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
1369 xpidl-module-deps = $(xpidl-idl2xpt) $(GLOBAL_DEPS) $(XPT_PY)
1371 $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(xpidl-module-deps)
1372 $(XPIDL_LINK) $@ $(xpidl-idl2xpt)
1374 $(XPT_PY):
1375 $(MAKE) -C $(DEPTH)/xpcom/typelib/xpt/tools libs
1377 endif # XPIDL_MODULE.xpt != XPIDLSRCS
1379 ifndef NO_DIST_INSTALL
1380 XPIDL_MODULE_FILES := $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
1381 XPIDL_MODULE_DEST := $(FINAL_TARGET)/components
1382 INSTALL_TARGETS += XPIDL_MODULE
1384 ifndef NO_INTERFACES_MANIFEST
1385 libs:: $(call mkdir_deps,$(FINAL_TARGET)/components)
1386 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
1387 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
1388 endif
1389 endif
1391 GARBAGE_DIRS += $(XPIDL_GEN_DIR)
1393 ifndef NO_DIST_INSTALL
1394 XPIDL_HEADERS_FILES := $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
1395 XPIDL_HEADERS_DEST := $(DIST)/include
1396 XPIDL_HEADERS_TARGET := export
1397 INSTALL_TARGETS += XPIDL_HEADERS
1399 XPIDLSRCS_FILES := $(XPIDLSRCS)
1400 XPIDLSRCS_DEST := $(IDL_DIR)
1401 XPIDLSRCS_TARGET := export
1402 INSTALL_TARGETS += XPIDLSRCS
1403 endif
1404 endif #} XPIDLSRCS
1406 ################################################################################
1407 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
1408 ifneq (,$(filter %.js,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1409 ifeq (,$(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1410 ifndef NO_JS_MANIFEST
1411 $(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0)
1412 endif
1413 endif
1414 endif
1416 ifdef EXTRA_COMPONENTS
1417 libs:: $(EXTRA_COMPONENTS)
1418 ifndef NO_DIST_INSTALL
1419 EXTRA_COMPONENTS_FILES := $(EXTRA_COMPONENTS)
1420 EXTRA_COMPONENTS_DEST := $(FINAL_TARGET)/components
1421 INSTALL_TARGETS += EXTRA_COMPONENTS
1422 endif
1424 endif
1426 ifdef EXTRA_PP_COMPONENTS
1427 ifndef NO_DIST_INSTALL
1428 EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
1429 PP_TARGETS += EXTRA_PP_COMPONENTS
1430 endif
1431 endif
1433 EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
1434 ifneq (,$(EXTRA_MANIFESTS))
1435 libs:: $(call mkdir_deps,$(FINAL_TARGET))
1436 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
1437 endif
1439 ################################################################################
1440 # Copy each element of EXTRA_JS_MODULES to JS_MODULES_PATH, or
1441 # $(FINAL_TARGET)/modules if that isn't defined.
1442 JS_MODULES_PATH ?= $(FINAL_TARGET)/modules
1444 ifdef EXTRA_JS_MODULES
1445 ifndef NO_DIST_INSTALL
1446 EXTRA_JS_MODULES_FILES := $(EXTRA_JS_MODULES)
1447 EXTRA_JS_MODULES_DEST := $(JS_MODULES_PATH)
1448 INSTALL_TARGETS += EXTRA_JS_MODULES
1449 endif
1450 endif
1452 ifdef EXTRA_PP_JS_MODULES
1453 ifndef NO_DIST_INSTALL
1454 EXTRA_PP_JS_MODULES_PATH := $(JS_MODULES_PATH)
1455 PP_TARGETS += EXTRA_PP_JS_MODULES
1456 endif
1457 endif
1459 ################################################################################
1460 # Copy testing-only JS modules to appropriate destination.
1462 # For each file defined in TESTING_JS_MODULES, copy it to
1463 # objdir/_tests/modules/. If TESTING_JS_MODULE_DIR is defined, that path
1464 # wlll be appended to the output directory.
1466 ifdef ENABLE_TESTS
1467 ifdef TESTING_JS_MODULES
1468 testmodulesdir = $(DEPTH)/_tests/modules/$(TESTING_JS_MODULE_DIR)
1470 GENERATED_DIRS += $(testmodulesdir)
1472 ifndef NO_DIST_INSTALL
1473 TESTING_JS_MODULES_FILES := $(TESTING_JS_MODULES)
1474 TESTING_JS_MODULES_DEST := $(testmodulesdir)
1475 INSTALL_TARGETS += TESTING_JS_MODULES
1476 endif
1478 endif
1479 endif
1481 ################################################################################
1482 # SDK
1484 ifneq (,$(SDK_LIBRARY))
1485 ifndef NO_DIST_INSTALL
1486 SDK_LIBRARY_FILES := $(SDK_LIBRARY)
1487 SDK_LIBRARY_DEST := $(SDK_LIB_DIR)
1488 INSTALL_TARGETS += SDK_LIBRARY
1489 endif
1490 endif # SDK_LIBRARY
1492 ifneq (,$(strip $(SDK_BINARY)))
1493 ifndef NO_DIST_INSTALL
1494 SDK_BINARY_FILES := $(SDK_BINARY)
1495 SDK_BINARY_DEST := $(SDK_BIN_DIR)
1496 INSTALL_TARGETS += SDK_BINARY
1497 endif
1498 endif # SDK_BINARY
1500 ################################################################################
1501 # CHROME PACKAGING
1503 JAR_MANIFEST := $(srcdir)/jar.mn
1505 chrome::
1506 $(MAKE) realchrome
1507 $(LOOP_OVER_PARALLEL_DIRS)
1508 $(LOOP_OVER_DIRS)
1509 $(LOOP_OVER_TOOL_DIRS)
1511 $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
1513 ifneq (,$(wildcard $(JAR_MANIFEST)))
1514 ifndef NO_DIST_INSTALL
1516 ifdef XPI_NAME
1517 ifdef XPI_ROOT_APPID
1518 # For add-on packaging we may specify that an application
1519 # sub-dir should be added to the root chrome manifest with
1520 # a specific application id.
1521 MAKE_JARS_FLAGS += --root-manifest-entry-appid="$(XPI_ROOT_APPID)"
1522 endif
1524 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
1525 # no way langpacks will get packaged right, so error out.
1526 ifneq (,$(DIST_SUBDIR))
1527 ifndef XPI_ROOT_APPID
1528 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
1529 endif
1530 endif
1531 endif
1533 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
1534 $(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
1535 $(QUIET) -j $(FINAL_TARGET)/chrome \
1536 $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
1537 $(JAR_MANIFEST)
1539 endif
1540 endif
1542 ifneq ($(DIST_FILES),)
1543 DIST_FILES_PATH := $(FINAL_TARGET)
1544 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
1545 PP_TARGETS += DIST_FILES
1546 endif
1548 ifneq ($(DIST_CHROME_FILES),)
1549 DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome
1550 DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES)
1551 PP_TARGETS += DIST_CHROME_FILES
1552 endif
1554 ifneq ($(XPI_PKGNAME),)
1555 libs realchrome::
1556 ifdef STRIP_XPI
1557 ifndef MOZ_DEBUG
1558 @echo "Stripping $(XPI_PKGNAME) package directory..."
1559 @echo $(FINAL_TARGET)
1560 @cd $(FINAL_TARGET) && find . ! -type d \
1561 ! -name "*.js" \
1562 ! -name "*.xpt" \
1563 ! -name "*.gif" \
1564 ! -name "*.jpg" \
1565 ! -name "*.png" \
1566 ! -name "*.xpm" \
1567 ! -name "*.txt" \
1568 ! -name "*.rdf" \
1569 ! -name "*.sh" \
1570 ! -name "*.properties" \
1571 ! -name "*.dtd" \
1572 ! -name "*.html" \
1573 ! -name "*.xul" \
1574 ! -name "*.css" \
1575 ! -name "*.xml" \
1576 ! -name "*.jar" \
1577 ! -name "*.dat" \
1578 ! -name "*.tbl" \
1579 ! -name "*.src" \
1580 ! -name "*.reg" \
1581 $(PLATFORM_EXCLUDE_LIST) \
1582 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
1583 endif
1584 endif
1585 @echo "Packaging $(XPI_PKGNAME).xpi..."
1586 cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
1587 endif
1589 ifdef INSTALL_EXTENSION_ID
1590 ifndef XPI_NAME
1591 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
1592 endif
1594 libs::
1595 $(RM) -r "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
1596 $(NSINSTALL) -D "$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)"
1597 $(call copy_dir,$(FINAL_TARGET),$(DIST)/bin$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))
1599 endif
1601 #############################################################################
1602 # MDDEPDIR is the subdirectory where all the dependency files are placed.
1603 # This uses a make rule (instead of a macro) to support parallel
1604 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
1605 # processes could simultaneously try to create the same directory.
1607 # We use $(CURDIR) in the rule's target to ensure that we don't find
1608 # a dependency directory in the source tree via VPATH (perhaps from
1609 # a previous build in the source tree) and thus neglect to create a
1610 # dependency directory in the object directory, where we really need
1611 # it.
1613 ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
1614 MDDEPEND_FILES := $(strip $(wildcard $(foreach file,$(OBJS) $(PROGOBJS) $(HOST_OBJS) $(HOST_PROGOBJS) $(TARGETS) $(XPIDLSRCS:.idl=.h) $(XPIDLSRCS:.idl=.xpt),$(MDDEPDIR)/$(notdir $(file)).pp) $(addprefix $(MDDEPDIR)/,$(EXTRA_MDDEPEND_FILES))))
1616 ifneq (,$(MDDEPEND_FILES))
1617 # The script mddepend.pl checks the dependencies and writes to stdout
1618 # one rule to force out-of-date objects. For example,
1619 # foo.o boo.o: FORCE
1620 # The script has an advantage over including the *.pp files directly
1621 # because it handles the case when header files are removed from the build.
1622 # 'make' would complain that there is no way to build missing headers.
1623 ALL_PP_RESULTS = $(shell $(PERL) $(BUILD_TOOLS)/mddepend.pl - $(MDDEPEND_FILES))
1624 $(eval $(ALL_PP_RESULTS))
1625 endif
1627 endif
1628 #############################################################################
1630 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
1631 -include $(MY_RULES)
1634 # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
1635 # or in $(MY_RULES)
1637 ifdef ETAGS
1638 ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
1639 all:: TAGS
1640 TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
1641 $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
1642 endif
1643 endif
1645 ################################################################################
1646 # Install/copy rules
1648 # The INSTALL_TARGETS variable contains a list of all install target
1649 # categories. Each category defines a list of files and executables, and an
1650 # install destination,
1652 # FOO_FILES := foo bar
1653 # FOO_EXECUTABLES := baz
1654 # FOO_DEST := target_path
1655 # INSTALL_TARGETS += FOO
1657 # Additionally, a FOO_TARGET variable may be added to indicate the target for
1658 # which the files and executables are installed. Default is "libs".
1660 # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
1661 ifneq (,$(filter $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
1662 ifeq (,$(wildcard $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)))
1663 nsinstall_is_usable = $(if $(wildcard $(CONFIG_TOOLS)/nsinstall$(HOST_BIN_SUFFIX)),yes)
1665 define install_cmd_override
1666 $(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY)) $$(1)
1667 endef
1668 endif
1669 endif
1671 define install_file_template
1672 $(or $(3),libs):: $(2)/$(notdir $(1))
1673 $(call install_cmd_override,$(2)/$(notdir $(1)))
1674 $(2)/$(notdir $(1)): $(1)
1675 $$(call install_cmd,$(4) "$$<" "$${@D}")
1676 endef
1677 $(foreach category,$(INSTALL_TARGETS),\
1678 $(if $($(category)_DEST),,$(error Missing $(category)_DEST))\
1679 $(foreach file,$($(category)_FILES),\
1680 $(eval $(call install_file_template,$(file),$($(category)_DEST),$($(category)_TARGET),$(IFLAGS1)))\
1682 $(foreach file,$($(category)_EXECUTABLES),\
1683 $(eval $(call install_file_template,$(file),$($(category)_DEST),$($(category)_TARGET),$(IFLAGS2)))\
1687 ################################################################################
1688 # Preprocessing rules
1690 # The PP_TARGETS variable contains a list of all preprocessing target
1691 # categories. Each category has associated variables listing input files, the
1692 # output directory, extra preprocessor flags, and so on. For example:
1694 # FOO := input-file
1695 # FOO_PATH := target-directory
1696 # FOO_FLAGS := -Dsome_flag
1697 # PP_TARGETS += FOO
1699 # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
1700 # following make variables to see what to do:
1702 # - <C> lists input files to be preprocessed with config/Preprocessor.py. We
1703 # search VPATH for the names given here. If an input file name ends in '.in',
1704 # that suffix is omitted from the output file name.
1706 # - <C>_PATH names the directory in which to place the preprocessed output
1707 # files. We create this directory if it does not already exist. Setting
1708 # this variable is optional; if unset, we install the files in $(CURDIR).
1710 # - <C>_FLAGS lists flags to pass to Preprocessor.py, in addition to the usual
1711 # bunch. Setting this variable is optional.
1713 # - <C>_TARGET names the 'make' target that should depend on creating the output
1714 # files. Setting this variable is optional; if unset, we preprocess the
1715 # files for the 'libs' target.
1717 # preprocess_file_template defines preprocessing rules.
1718 # $(call preprocess_file_template, source_file, output_file,
1719 # makefile_target, extra_flags)
1720 define preprocess_file_template
1721 $(2): $(1) $$(GLOBAL_DEPS)
1722 $$(RM) "$$@"
1723 $$(PYTHON) $$(topsrcdir)/config/Preprocessor.py $(4) $$(DEFINES) $$(ACDEFINES) $$(XULPPFLAGS) "$$<" -o "$$@"
1724 $(3):: $(2)
1725 endef
1727 $(foreach category,$(PP_TARGETS), \
1728 $(foreach file,$($(category)), \
1729 $(eval $(call preprocess_file_template, \
1730 $(file), \
1731 $(or $($(category)_PATH),$(CURDIR))/$(notdir $(file:.in=)), \
1732 $(or $($(category)_TARGET),libs), \
1733 $($(category)_FLAGS))) \
1737 ################################################################################
1738 # Special gmake rules.
1739 ################################################################################
1743 # Re-define the list of default suffixes, so gmake won't have to churn through
1744 # hundreds of built-in suffix rules for stuff we don't need.
1746 .SUFFIXES:
1749 # Fake targets. Always run these rules, even if a file/directory with that
1750 # name already exists.
1752 .PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
1754 # Used as a dependency to force targets to rebuild
1755 FORCE:
1757 # Delete target if error occurs when building target
1758 .DELETE_ON_ERROR:
1760 tags: TAGS
1762 TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1763 -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1764 $(LOOP_OVER_PARALLEL_DIRS)
1765 $(LOOP_OVER_DIRS)
1767 ifndef INCLUDED_DEBUGMAKE_MK #{
1768 ## Only parse when an echo* or show* target is requested
1769 ifneq (,$(call isTargetStem,echo,show))
1770 include $(topsrcdir)/config/makefiles/debugmake.mk
1771 endif #}
1772 endif #}
1774 documentation:
1775 @cd $(DEPTH)
1776 $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
1778 ifdef ENABLE_TESTS
1779 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
1780 $(LOOP_OVER_PARALLEL_DIRS)
1781 $(LOOP_OVER_DIRS)
1782 $(LOOP_OVER_TOOL_DIRS)
1783 endif
1786 FREEZE_VARIABLES = \
1787 CSRCS \
1788 CPPSRCS \
1789 EXPORTS \
1790 XPIDLSRCS \
1791 DIRS \
1792 LIBRARY \
1793 MODULE \
1794 SHORT_LIBNAME \
1795 TIERS \
1796 EXTRA_COMPONENTS \
1797 EXTRA_PP_COMPONENTS \
1798 MOCHITEST_FILES \
1799 MOCHITEST_FILES_PARTS \
1800 MOCHITEST_CHROME_FILES \
1801 MOCHITEST_BROWSER_FILES \
1802 MOCHITEST_BROWSER_FILES_PARTS \
1803 MOCHITEST_A11Y_FILES \
1804 MOCHITEST_ROBOCOP_FILES \
1805 MOCHITEST_WEBAPPRT_CHROME_FILES \
1806 $(NULL)
1808 $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
1810 CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
1811 $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
1813 libs export::
1814 $(CHECK_FROZEN_VARIABLES)
1816 PURGECACHES_DIRS ?= $(DIST)/bin
1817 ifdef MOZ_WEBAPP_RUNTIME
1818 PURGECACHES_DIRS += $(DIST)/bin/webapprt
1819 endif
1821 PURGECACHES_FILES = $(addsuffix /.purgecaches,$(PURGECACHES_DIRS))
1823 default all:: $(PURGECACHES_FILES)
1825 $(PURGECACHES_FILES):
1826 if test -d $(@D) ; then touch $@ ; fi
1828 .DEFAULT_GOAL ?= default
1830 #############################################################################
1831 # Derived targets and dependencies
1833 include $(topsrcdir)/config/makefiles/autotargets.mk
1834 ifneq ($(NULL),$(AUTO_DEPS))
1835 default all libs tools export:: $(AUTO_DEPS)
1836 endif