Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / config / rules.mk
blob3675b8bc2018a488985cabf5fb14650ec943ad55
1 # vim:set ts=8 sw=8 sts=8 noet:
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
23 # Contributor(s):
24 # Chase Phillips <chase@mozilla.org>
25 # Benjamin Smedberg <benjamin@smedbergs.us>
26 # Jeff Walden <jwalden+code@mit.edu>
28 # Alternatively, the contents of this file may be used under the terms of
29 # either of the GNU General Public License Version 2 or later (the "GPL"),
30 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 # in which case the provisions of the GPL or the LGPL are applicable instead
32 # of those above. If you wish to allow use of your version of this file only
33 # under the terms of either the GPL or the LGPL, and not to allow others to
34 # use your version of this file under the terms of the MPL, indicate your
35 # decision by deleting the provisions above and replace them with the notice
36 # and other provisions required by the GPL or the LGPL. If you do not delete
37 # the provisions above, a recipient may use your version of this file under
38 # the terms of any one of the MPL, the GPL or the LGPL.
40 # ***** END LICENSE BLOCK *****
42 ifndef topsrcdir
43 $(error topsrcdir was not set))
44 endif
46 ifndef MOZILLA_DIR
47 MOZILLA_DIR = $(topsrcdir)
48 endif
50 ifndef INCLUDED_CONFIG_MK
51 include $(topsrcdir)/config/config.mk
52 endif
54 ifndef INCLUDED_VERSION_MK
55 include $(topsrcdir)/config/version.mk
56 endif
58 ifdef SDK_XPIDLSRCS
59 XPIDLSRCS += $(SDK_XPIDLSRCS)
60 endif
61 ifdef SDK_HEADERS
62 EXPORTS += $(SDK_HEADERS)
63 endif
65 REPORT_BUILD = @echo $(notdir $<)
67 ifeq ($(OS_ARCH),OS2)
68 EXEC =
69 else
70 EXEC = exec
71 endif
73 # Don't copy xulrunner files at install time, when using system xulrunner
74 ifdef SYSTEM_LIBXUL
75 SKIP_COPY_XULRUNNER=1
76 endif
78 # ELOG prints out failed command when building silently (gmake -s).
79 ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS))))
80 ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
81 else
82 ELOG :=
83 endif
85 ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
86 ifndef GNU_CC
87 _LIBNAME_RELATIVE_PATHS=1
88 endif
89 endif
91 ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
92 _VPATH_SRCS = $(abspath $<)
93 else
94 _VPATH_SRCS = $<
95 endif
97 # Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
98 VPATH += $(DIST)/lib
99 ifdef LIBXUL_SDK
100 VPATH += $(LIBXUL_SDK)/lib
101 endif
103 # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
104 # expands to foo.lib on platforms with import libs and -lfoo otherwise
106 # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
107 # expands to dir/foo.lib on platforms with import libs and
108 # -Ldir -lfoo otherwise
110 # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
111 # expands to $(DIST)/lib/foo.lib on platforms with import libs and
112 # -lfoo otherwise
114 ifdef _LIBNAME_RELATIVE_PATHS
115 EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
116 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
117 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
118 else
119 EXPAND_LIBNAME = $(addprefix -l,$(1))
120 EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
121 EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
122 endif
124 ifdef MOZ_FAKELIBS
125 # If a lib.fake is present, replace it with @lib.fake, otherwise just pass
126 # the library name through unchanged.
127 EXPAND_FAKELIBS = $(foreach f,$(1),$(if $(wildcard $(f).fake),@$(wildcard $(f).fake),$(f)))
129 # Also override EXPAND_LIBNAME_PATH and EXPAND_MOZLIBNAME on non-RELATIVE_PATH
130 # platforms, so we can shortcut linking -lfoo if we have foo.a.fake
131 ifndef _LIBNAME_RELATIVE_PATHS
132 EXPAND_LIBNAME_PATH = $(if $(wildcard $(2)/$(LIB_PREFIX)$(1).$(LIB_SUFFIX).fake),@$(2)/$(LIB_PREFIX)$(1).$(LIB_SUFFIX).fake,-L$(2) $(addprefix -l,$(1)))
133 EXPAND_MOZLIBNAME = $(if $(wildcard $(DIST)/lib/$(LIB_PREFIX)$(1).$(LIB_SUFFIX).fake),@$(DIST)/lib/$(LIB_PREFIX)$(1).$(LIB_SUFFIX).fake,$(addprefix -l,$(1)))
134 endif
135 else
136 EXPAND_FAKELIBS = $1
137 endif
139 ifdef EXTRA_DSO_LIBS
140 EXTRA_DSO_LIBS := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
141 endif
143 ################################################################################
144 # Testing frameworks support
145 ################################################################################
147 testxpcobjdir = $(DEPTH)/_tests/xpcshell
149 ifdef ENABLE_TESTS
151 ifdef XPCSHELL_TESTS
152 ifndef relativesrcdir
153 $(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
154 endif
156 # Test file installation
157 ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
158 # Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
159 TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
160 else
161 TEST_INSTALLER = $(INSTALL)
162 endif
164 define _INSTALL_TESTS
165 $(TEST_INSTALLER) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(relativesrcdir)/$(dir)
167 endef # do not remove the blank line!
169 SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
171 libs::
172 $(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
173 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py \
174 $(testxpcobjdir)/all-test-dirs.list \
175 $(addprefix $(relativesrcdir)/,$(XPCSHELL_TESTS))
177 testxpcsrcdir = $(topsrcdir)/testing/xpcshell
179 # Execute all tests in the $(XPCSHELL_TESTS) directories.
180 # See also testsuite-targets.mk 'xpcshell-tests' target for global execution.
181 xpcshell-tests:
182 $(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
183 -I$(topsrcdir)/build \
184 $(testxpcsrcdir)/runxpcshelltests.py \
185 --symbols-path=$(DIST)/crashreporter-symbols \
186 $(EXTRA_TEST_ARGS) \
187 $(DIST)/bin/xpcshell \
188 $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
190 # Execute a single test, specified in $(SOLO_FILE), but don't automatically
191 # start the test. Instead, present the xpcshell prompt so the user can
192 # attach a debugger and then start the test.
193 check-interactive:
194 $(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
195 -I$(topsrcdir)/build \
196 $(testxpcsrcdir)/runxpcshelltests.py \
197 --symbols-path=$(DIST)/crashreporter-symbols \
198 --test-path=$(SOLO_FILE) \
199 --profile-name=$(MOZ_APP_NAME) \
200 --interactive \
201 $(DIST)/bin/xpcshell \
202 $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
204 # Execute a single test, specified in $(SOLO_FILE)
205 check-one:
206 $(PYTHON) -u $(topsrcdir)/config/pythonpath.py \
207 -I$(topsrcdir)/build \
208 $(testxpcsrcdir)/runxpcshelltests.py \
209 --symbols-path=$(DIST)/crashreporter-symbols \
210 --test-path=$(SOLO_FILE) \
211 --profile-name=$(MOZ_APP_NAME) \
212 --verbose \
213 $(EXTRA_TEST_ARGS) \
214 $(DIST)/bin/xpcshell \
215 $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(relativesrcdir)/$(dir))
217 endif # XPCSHELL_TESTS
219 ifdef CPP_UNIT_TESTS
221 # Compile the tests to $(DIST)/bin. Make lots of niceties available by default
222 # through TestHarness.h, by modifying the list of includes and the libs against
223 # which stuff links.
224 CPPSRCS += $(CPP_UNIT_TESTS)
225 SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS:.cpp=$(BIN_SUFFIX))
226 INCLUDES += -I$(DIST)/include/testing
227 LIBS += $(XPCOM_GLUE_LDOPTS) $(NSPR_LIBS) -ljs_static
229 # ...and run them the usual way
230 check::
231 @$(EXIT_ON_ERROR) \
232 for f in $(subst .cpp,$(BIN_SUFFIX),$(CPP_UNIT_TESTS)); do \
233 XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f; \
234 done
236 endif # CPP_UNIT_TESTS
238 .PHONY: check xpcshell-tests check-interactive check-one
240 endif # ENABLE_TESTS
244 # Library rules
246 # If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
247 # Otherwise, build a shared library.
250 ifndef LIBRARY
251 ifdef STATIC_LIBRARY_NAME
252 LIBRARY := $(LIB_PREFIX)$(STATIC_LIBRARY_NAME).$(LIB_SUFFIX)
253 ifdef MOZ_FAKELIBS
254 ifndef SUPPRESS_FAKELIB
255 FAKE_LIBRARY = $(LIBRARY).fake
256 endif # SUPPRESS_FAKELIB
257 endif # MOZ_FAKELIBS
258 endif # STATIC_LIBRARY_NAME
259 endif # LIBRARY
261 ifndef HOST_LIBRARY
262 ifdef HOST_LIBRARY_NAME
263 HOST_LIBRARY := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
264 endif
265 endif
267 ifdef LIBRARY
268 ifneq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
269 ifdef MKSHLIB
271 ifdef LIB_IS_C_ONLY
272 MKSHLIB = $(MKCSHLIB)
273 endif
275 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
276 IMPORT_LIBRARY := $(LIB_PREFIX)$(SHARED_LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
277 endif
279 ifeq (OS2,$(OS_ARCH))
280 ifdef SHORT_LIBNAME
281 SHARED_LIBRARY_NAME := $(SHORT_LIBNAME)
282 endif
283 endif
285 ifdef MAKE_FRAMEWORK
286 SHARED_LIBRARY := $(SHARED_LIBRARY_NAME)
287 else
288 SHARED_LIBRARY := $(DLL_PREFIX)$(SHARED_LIBRARY_NAME)$(DLL_SUFFIX)
289 endif
291 ifeq ($(OS_ARCH),OS2)
292 DEF_FILE := $(SHARED_LIBRARY:.dll=.def)
293 endif
295 ifdef MOZ_ENABLE_LIBXUL
296 EMBED_MANIFEST_AT=2
297 endif
299 endif # MKSHLIB
300 endif # FORCE_SHARED_LIB && !BUILD_STATIC_LIBS
301 endif # LIBRARY
303 ifeq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
304 LIBRARY := $(NULL)
305 endif
307 ifeq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
308 SHARED_LIBRARY := $(NULL)
309 DEF_FILE := $(NULL)
310 IMPORT_LIBRARY := $(NULL)
311 endif
313 ifdef FORCE_STATIC_LIB
314 ifndef FORCE_SHARED_LIB
315 SHARED_LIBRARY := $(NULL)
316 DEF_FILE := $(NULL)
317 IMPORT_LIBRARY := $(NULL)
318 endif
319 endif
321 ifdef FORCE_SHARED_LIB
322 ifndef FORCE_STATIC_LIB
323 LIBRARY := $(NULL)
324 endif
325 endif
327 ifdef JAVA_LIBRARY_NAME
328 JAVA_LIBRARY := $(JAVA_LIBRARY_NAME).jar
329 endif
331 ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
332 ifndef GNU_CC
335 # Unless we're building SIMPLE_PROGRAMS, all C++ files share a PDB file per
336 # directory. For parallel builds, this PDB file is shared and locked by
337 # MSPDBSRV.EXE, starting with MSVC8 SP1. If you're using MSVC 7.1 or MSVC8
338 # without SP1, don't do parallel builds.
340 # The final PDB for libraries and programs is created by the linker and uses
341 # a different name from the single PDB file created by the compiler. See
342 # bug 462740.
345 ifdef SIMPLE_PROGRAMS
346 COMPILE_PDBFILE = $(basename $(@F)).pdb
347 else
348 COMPILE_PDBFILE = generated.pdb
349 endif
351 LINK_PDBFILE = $(basename $(@F)).pdb
352 ifdef MOZ_DEBUG
353 CODFILE=$(basename $(@F)).cod
354 endif
356 ifdef MOZ_MAPINFO
357 ifdef SHARED_LIBRARY_NAME
358 MAPFILE=$(SHARED_LIBRARY_NAME).map
359 else
360 MAPFILE=$(basename $(@F)).map
361 endif # SHARED_LIBRARY_NAME
362 endif # MOZ_MAPINFO
364 ifdef DEFFILE
365 OS_LDFLAGS += -DEF:$(call normalizepath,$(DEFFILE))
366 EXTRA_DEPS += $(DEFFILE)
367 endif
369 ifdef MAPFILE
370 OS_LDFLAGS += -MAP:$(MAPFILE)
371 endif
373 endif # !GNU_CC
375 ifdef ENABLE_CXX_EXCEPTIONS
376 CXXFLAGS += $(MOZ_EXCEPTIONS_FLAGS_ON) -DMOZ_CPP_EXCEPTIONS=1
377 endif # ENABLE_CXX_EXCEPTIONS
378 endif # WINNT
380 ifeq ($(SOLARIS_SUNPRO_CXX),1)
381 ifeq (86,$(findstring 86,$(OS_TEST)))
382 OS_LDFLAGS += -M $(topsrcdir)/config/solaris_ia32.map
383 endif # x86
384 endif # Solaris Sun Studio C++
386 ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH)))
387 HOST_PDBFILE=$(basename $(@F)).pdb
388 endif
390 ifndef TARGETS
391 TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
392 endif
394 ifndef OBJS
395 _OBJS = \
396 $(JRI_STUB_CFILES) \
397 $(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
398 $(CSRCS:.c=.$(OBJ_SUFFIX)) \
399 $(SSRCS:.S=.$(OBJ_SUFFIX)) \
400 $(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
401 $(CMSRCS:.m=.$(OBJ_SUFFIX)) \
402 $(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
403 $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
404 OBJS = $(strip $(_OBJS))
405 endif
407 ifndef HOST_OBJS
408 _HOST_OBJS = \
409 $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX))) \
410 $(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(HOST_CPPSRCS:.cpp=.$(OBJ_SUFFIX)))) \
411 $(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))) \
412 $(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
413 HOST_OBJS = $(strip $(_HOST_OBJS))
414 endif
416 LIBOBJS := $(addprefix \", $(OBJS))
417 LIBOBJS := $(addsuffix \", $(LIBOBJS))
419 ifndef MOZ_AUTO_DEPS
420 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
421 MDDEPFILES = $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
422 ifndef NO_GEN_XPT
423 MDDEPFILES += $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt))
424 endif
425 endif
426 endif
428 ALL_TRASH = \
429 $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
430 $(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
431 $(OBJS:.$(OBJ_SUFFIX)=.i) \
432 $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
433 $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
434 $(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
435 $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
436 $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
437 $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
438 $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
439 $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
440 ALL_TRASH_DIRS = \
441 $(GARBAGE_DIRS) /no-such-file
443 ifdef QTDIR
444 GARBAGE += $(MOCSRCS)
445 endif
447 ifdef SIMPLE_PROGRAMS
448 GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
449 endif
451 ifdef HOST_SIMPLE_PROGRAMS
452 GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
453 endif
456 # the Solaris WorkShop template repository cache. it occasionally can get
457 # out of sync, so targets like clobber should kill it.
459 ifeq ($(SOLARIS_SUNPRO_CXX),1)
460 GARBAGE_DIRS += SunWS_cache
461 endif
463 ifeq ($(OS_ARCH),OpenVMS)
464 GARBAGE += $(wildcard *.*_defines)
465 ifdef SHARED_LIBRARY
466 VMS_SYMVEC_FILE = $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt)
467 ifdef MOZ_DEBUG
468 VMS_SYMVEC_FILE_MODULE = $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_dbg_symvec.opt))
469 else
470 VMS_SYMVEC_FILE_MODULE = $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt))
471 endif
472 VMS_SYMVEC_FILE_COMP = $(topsrcdir)/build/unix/vms/component_symvec.opt
473 GARBAGE += $(VMS_SYMVEC_FILE)
474 ifdef IS_COMPONENT
475 DSO_LDOPTS := $(filter-out -auto_symvec,$(DSO_LDOPTS)) $(VMS_SYMVEC_FILE)
476 endif
477 endif
478 endif
480 XPIDL_GEN_DIR = _xpidlgen
482 ifdef MOZ_UPDATE_XTERM
483 # Its good not to have a newline at the end of the titlebar string because it
484 # makes the make -s output easier to read. Echo -n does not work on all
485 # platforms, but we can trick sed into doing it.
486 UPDATE_TITLE = sed -e "s!Y!$(1) in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(2)!" $(MOZILLA_DIR)/config/xterm.str;
487 endif
489 define SUBMAKE # $(call SUBMAKE,target,directory)
490 +@$(UPDATE_TITLE)
491 +@$(MAKE) $(if $(2),-C $(2)) $(1)
493 endef # The extra line is important here! don't delete it
495 ifneq (,$(strip $(DIRS)))
496 LOOP_OVER_DIRS = \
497 $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
498 endif
500 # we only use this for the makefiles target and other stuff that doesn't matter
501 ifneq (,$(strip $(PARALLEL_DIRS)))
502 LOOP_OVER_PARALLEL_DIRS = \
503 $(foreach dir,$(PARALLEL_DIRS),$(call SUBMAKE,$@,$(dir)))
504 endif
506 ifneq (,$(strip $(STATIC_DIRS)))
507 LOOP_OVER_STATIC_DIRS = \
508 $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,$@,$(dir)))
509 endif
511 ifneq (,$(strip $(TOOL_DIRS)))
512 LOOP_OVER_TOOL_DIRS = \
513 $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,$@,$(dir)))
514 endif
516 ifdef PARALLEL_DIRS
517 # create a bunch of fake targets for order-only processing
518 PARALLEL_DIRS_export = $(addsuffix _export,$(PARALLEL_DIRS))
519 PARALLEL_DIRS_libs = $(addsuffix _libs,$(PARALLEL_DIRS))
520 PARALLEL_DIRS_tools = $(addsuffix _tools,$(PARALLEL_DIRS))
522 .PHONY: $(PARALLEL_DIRS_export) $(PARALLEL_DIRS_libs) $(PARALLEL_DIRS_tools)
523 endif
526 # Now we can differentiate between objects used to build a library, and
527 # objects used to build an executable in the same directory.
529 ifndef PROGOBJS
530 PROGOBJS = $(OBJS)
531 endif
533 ifndef HOST_PROGOBJS
534 HOST_PROGOBJS = $(HOST_OBJS)
535 endif
537 # MAKE_DIRS: List of directories to build while looping over directories.
538 # A Makefile that needs $(MDDEPDIR) created but doesn't set any of these
539 # variables we know to check can just set NEED_MDDEPDIR explicitly.
540 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS)$(NEED_MDDEPDIR))
541 MAKE_DIRS += $(CURDIR)/$(MDDEPDIR)
542 GARBAGE_DIRS += $(MDDEPDIR)
543 endif
546 # Tags: emacs (etags), vi (ctags)
547 # TAG_PROGRAM := ctags -L -
549 TAG_PROGRAM = xargs etags -a
552 # Turn on C++ linking if we have any .cpp or .mm files
553 # (moved this from config.mk so that config.mk can be included
554 # before the CPPSRCS are defined)
556 ifneq ($(CPPSRCS)$(CMMSRCS),)
557 CPP_PROG_LINK = 1
558 endif
559 ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
560 HOST_CPP_PROG_LINK = 1
561 endif
564 # Make sure to wrap static libs inside linker specific flags to turn on & off
565 # inclusion of all symbols inside the static libs
567 ifndef NO_LD_ARCHIVE_FLAGS
568 ifdef SHARED_LIBRARY_LIBS
569 EXTRA_DSO_LDOPTS := $(MKSHLIB_FORCE_ALL) $(call EXPAND_FAKELIBS,$(SHARED_LIBRARY_LIBS)) $(MKSHLIB_UNFORCE_ALL) $(EXTRA_DSO_LDOPTS)
570 endif
571 endif
574 # This will strip out symbols that the component should not be
575 # exporting from the .dynsym section.
577 ifdef IS_COMPONENT
578 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
579 endif # IS_COMPONENT
582 # Enforce the requirement that MODULE_NAME must be set
583 # for components in static builds
585 ifdef IS_COMPONENT
586 ifdef EXPORT_LIBRARY
587 ifndef FORCE_SHARED_LIB
588 ifndef MODULE_NAME
589 $(error MODULE_NAME is required for components which may be used in static builds)
590 endif
591 endif
592 endif
593 endif
596 # MacOS X specific stuff
599 ifeq ($(OS_ARCH),Darwin)
600 ifdef SHARED_LIBRARY
601 ifdef IS_COMPONENT
602 EXTRA_DSO_LDOPTS += -bundle
603 else
604 EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
605 endif
606 endif
607 endif
610 # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be
611 # fatal symbol name clashes between components.
613 ifeq ($(OS_ARCH),NetBSD)
614 ifeq ($(DLL_SUFFIX),.so.1.0)
615 ifdef IS_COMPONENT
616 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
617 endif
618 endif
619 endif
621 ifeq ($(OS_ARCH),FreeBSD)
622 ifdef IS_COMPONENT
623 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
624 endif
625 endif
627 ifeq ($(OS_ARCH),NetBSD)
628 ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
629 ifeq ($(MODULE),layout)
630 OS_CFLAGS += -Wa,-xgot
631 OS_CXXFLAGS += -Wa,-xgot
632 endif
633 endif
634 endif
637 # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
638 # which uses internal symbols first
640 ifeq ($(OS_ARCH),HP-UX)
641 ifdef IS_COMPONENT
642 ifeq ($(GNU_CC)$(GNU_CXX),)
643 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
644 ifneq ($(HAS_EXTRAEXPORTS),1)
645 MKSHLIB += -Wl,+eNSGetModule -Wl,+eerrno
646 MKCSHLIB += +eNSGetModule +eerrno
647 ifneq ($(OS_TEST),ia64)
648 MKSHLIB += -Wl,+e_shlInit
649 MKCSHLIB += +e_shlInit
650 endif # !ia64
651 endif # !HAS_EXTRAEXPORTS
652 endif # non-gnu compilers
653 endif # IS_COMPONENT
654 endif # HP-UX
656 ifeq ($(OS_ARCH),AIX)
657 ifdef IS_COMPONENT
658 ifneq ($(HAS_EXTRAEXPORTS),1)
659 MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
660 MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
661 endif # HAS_EXTRAEXPORTS
662 endif # IS_COMPONENT
663 endif # AIX
666 # OSF1: add -B symbolic flag for components
668 ifeq ($(OS_ARCH),OSF1)
669 ifdef IS_COMPONENT
670 ifeq ($(GNU_CC)$(GNU_CXX),)
671 EXTRA_DSO_LDOPTS += -B symbolic
672 endif
673 endif
674 endif
677 # Linux: add -Bsymbolic flag for components
679 ifeq ($(OS_ARCH),Linux)
680 ifdef IS_COMPONENT
681 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
682 endif
683 endif
686 # GNU doesn't have path length limitation
689 ifeq ($(OS_ARCH),GNU)
690 OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
691 endif
694 # MINGW32
696 ifeq ($(OS_ARCH),WINNT)
697 ifdef GNU_CC
698 ifndef IS_COMPONENT
699 DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
700 endif
701 endif
702 endif
704 ifeq ($(USE_TVFS),1)
705 IFLAGS1 = -rb
706 IFLAGS2 = -rb
707 else
708 IFLAGS1 = -m 644
709 IFLAGS2 = -m 755
710 endif
712 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
713 OUTOPTION = -Fo# eol
714 else
715 OUTOPTION = -o # eol
716 endif # WINNT && !GNU_CC
717 ifneq (,$(filter WINCE,$(OS_ARCH)))
718 OUTOPTION = -Fo# eol
719 endif
721 ifeq ($(OS_ARCH), WINCE)
722 OUTOPTION = -Fo# eol
723 HOST_OUTOPTION = -Fo# eol
724 else
726 ifeq (,$(CROSS_COMPILE))
727 HOST_OUTOPTION = $(OUTOPTION)
728 else
729 HOST_OUTOPTION = -o # eol
730 endif
732 endif
733 ################################################################################
735 # SUBMAKEFILES: List of Makefiles for next level down.
736 # This is used to update or create the Makefiles before invoking them.
737 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
739 # The root makefile doesn't want to do a plain export/libs, because
740 # of the tiers and because of libxul. Suppress the default rules in favor
741 # of something else. Makefiles which use this var *must* provide a sensible
742 # default rule before including rules.mk
743 ifndef SUPPRESS_DEFAULT_RULES
744 ifdef TIERS
745 default all alldep::
746 $(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
747 else
749 default all::
750 ifneq (,$(strip $(STATIC_DIRS)))
751 $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir)))
752 endif
753 $(MAKE) export
754 $(MAKE) libs
755 $(MAKE) tools
757 # Do depend as well
758 alldep::
759 $(MAKE) export
760 $(MAKE) depend
761 $(MAKE) libs
762 $(MAKE) tools
764 endif # TIERS
765 endif # SUPPRESS_DEFAULT_RULES
767 ifeq ($(filter s,$(MAKEFLAGS)),)
768 ECHO := echo
769 QUIET :=
770 else
771 ECHO := true
772 QUIET := -q
773 endif
775 MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
777 export_tier_%:
778 @$(ECHO) "$@"
779 @$(MAKE_TIER_SUBMAKEFILES)
780 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir)))
782 libs_tier_%:
783 @$(ECHO) "$@"
784 @$(MAKE_TIER_SUBMAKEFILES)
785 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir)))
787 tools_tier_%:
788 @$(ECHO) "$@"
789 @$(MAKE_TIER_SUBMAKEFILES)
790 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir)))
792 $(foreach tier,$(TIERS),tier_$(tier))::
793 @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
794 $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir)))
795 $(MAKE) export_$@
796 $(MAKE) libs_$@
797 $(MAKE) tools_$@
799 # Do everything from scratch
800 everything::
801 $(MAKE) clean
802 $(MAKE) alldep
804 # Add dummy depend target for tinderboxes
805 depend::
807 # Target to only regenerate makefiles
808 makefiles: $(SUBMAKEFILES)
809 ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
810 $(LOOP_OVER_PARALLEL_DIRS)
811 $(LOOP_OVER_DIRS)
812 $(LOOP_OVER_TOOL_DIRS)
813 endif
815 ifdef PARALLEL_DIRS
816 export:: $(PARALLEL_DIRS_export)
818 $(PARALLEL_DIRS_export): %_export: %/Makefile
819 +@$(call SUBMAKE,export,$*)
820 endif
822 export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR))
823 $(LOOP_OVER_DIRS)
824 $(LOOP_OVER_TOOL_DIRS)
826 ifdef PARALLEL_DIRS
827 tools:: $(PARALLEL_DIRS_tools)
829 $(PARALLEL_DIRS_tools): %_tools: %/Makefile
830 +@$(call SUBMAKE,tools,$*)
831 endif
833 tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
834 $(LOOP_OVER_DIRS)
835 ifneq (,$(strip $(TOOL_DIRS)))
836 $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
837 endif
840 # Rule to create list of libraries for final link
842 export::
843 ifdef LIBRARY_NAME
844 ifdef EXPORT_LIBRARY
845 ifdef IS_COMPONENT
846 ifdef BUILD_STATIC_LIBS
847 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMPS) $(STATIC_LIBRARY_NAME)
848 ifdef MODULE_NAME
849 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
850 endif
851 endif # BUILD_STATIC_LIBS
852 else # !IS_COMPONENT
853 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_LIBS) $(STATIC_LIBRARY_NAME)
854 endif # IS_COMPONENT
855 endif # EXPORT_LIBRARY
856 endif # LIBRARY_NAME
858 # Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
859 LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
860 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
861 DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
863 ifndef _LIBNAME_RELATIVE_PATHS
865 LIBS_DEPS += $(filter -l%, $(LIBS))
866 HOST_LIBS_DEPS += $(filter -l%, $(HOST_LIBS))
867 DSO_LDOPTS_DEPS += $(filter -l%, $(EXTRA_DSO_LDOPTS))
869 _LIBDIRS = $(patsubst -L%,%,$(filter -L%, $(LIBS) $(HOST_LIBS) $(EXTRA_DSO_LDOPTS)))
870 ifneq (,$(_LIBDIRS))
871 vpath $(LIB_PREFIX)%.$(LIB_SUFFIX) $(_LIBDIRS)
872 ifdef IMPORT_LIB_SUFFIX
873 vpath $(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX) $(_LIBDIRS)
874 endif # IMPORT_LIB_SUFFIX
875 vpath $(DLL_PREFIX)%$(DLL_SUFFIX) $(_LIBDIRS)
876 endif # _LIBDIRS
878 endif # _LIBNAME_RELATIVE_PATHS
880 # Dependencies which, if modified, should cause everything to rebuild
881 GLOBAL_DEPS += Makefile Makefile.in $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
883 ##############################################
884 ifdef PARALLEL_DIRS
885 libs:: $(PARALLEL_DIRS_libs)
887 $(PARALLEL_DIRS_libs): %_libs: %/Makefile
888 +@$(call SUBMAKE,libs,$*)
889 endif
891 libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
892 ifndef NO_DIST_INSTALL
893 ifdef LIBRARY
894 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
895 ifdef IS_COMPONENT
896 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(FAKE_LIBRARY) $(DEPTH)/staticlib/components
897 else
898 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(FAKE_LIBRARY) $(DEPTH)/staticlib
899 endif
900 endif # EXPORT_LIBRARY
901 ifdef DIST_INSTALL
902 ifdef IS_COMPONENT
903 $(error Shipping static component libs makes no sense.)
904 else
905 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib
906 endif
907 endif # DIST_INSTALL
908 endif # LIBRARY
909 ifdef SHARED_LIBRARY
910 ifdef IS_COMPONENT
911 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
912 $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
913 ifndef NO_COMPONENTS_MANIFEST
914 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest"
915 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)"
916 endif
917 ifdef BEOS_ADDON_WORKAROUND
918 ( cd $(FINAL_TARGET)/components && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
919 endif
920 else # ! IS_COMPONENT
921 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
922 $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
923 else
924 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
925 endif
926 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
927 ifdef BEOS_ADDON_WORKAROUND
928 ( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
929 endif
930 endif # IS_COMPONENT
931 endif # SHARED_LIBRARY
932 ifdef PROGRAM
933 $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET)
934 endif
935 ifdef SIMPLE_PROGRAMS
936 $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET)
937 endif
938 ifdef HOST_PROGRAM
939 $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin
940 endif
941 ifdef HOST_SIMPLE_PROGRAMS
942 $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin
943 endif
944 ifdef HOST_LIBRARY
945 $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib
946 endif
947 ifdef JAVA_LIBRARY
948 ifdef IS_COMPONENT
949 $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components
950 else
951 $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)
952 endif
953 endif # JAVA_LIBRARY
954 endif # !NO_DIST_INSTALL
955 $(LOOP_OVER_DIRS)
957 ##############################################
959 ifndef NO_PROFILE_GUIDED_OPTIMIZE
960 ifdef MOZ_PROFILE_USE
961 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
962 # When building with PGO, we have to make sure to re-link
963 # in the MOZ_PROFILE_USE phase if we linked in the
964 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
965 # file in the link rule in the GENERATE phase to indicate
966 # that we need a relink.
967 ifdef SHARED_LIBRARY
968 $(SHARED_LIBRARY): pgo.relink
969 endif
970 ifdef PROGRAM
971 $(PROGRAM): pgo.relink
972 endif
974 # In the second pass, we need to merge the pgc files into the pgd file.
975 # The compiler would do this for us automatically if they were in the right
976 # place, but they're in dist/bin.
977 ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
978 export::
979 ifdef PROGRAM
980 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
981 $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/$(MOZ_APP_NAME)
982 endif
983 ifdef SHARED_LIBRARY
984 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
985 $(SHARED_LIBRARY_NAME) $(DIST)/$(MOZ_APP_NAME)
986 endif
987 endif # SHARED_LIBRARY || PROGRAM
988 endif # WINNT_
989 endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
990 endif # NO_PROFILE_GUIDED_OPTIMIZE
992 ##############################################
994 checkout:
995 $(MAKE) -C $(topsrcdir) -f client.mk checkout
997 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
998 -rm -f $(ALL_TRASH)
999 -rm -rf $(ALL_TRASH_DIRS)
1000 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
1002 distclean:: $(SUBMAKEFILES)
1003 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
1004 -rm -rf $(ALL_TRASH_DIRS)
1005 -rm -f $(ALL_TRASH) \
1006 Makefile .HSancillary \
1007 $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
1008 $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
1009 $(wildcard *.$(IMPORT_LIB_SUFFIX))
1010 ifeq ($(OS_ARCH),OS2)
1011 -rm -f $(PROGRAM:.exe=.map)
1012 endif
1014 alltags:
1015 rm -f TAGS
1016 find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
1019 # PROGRAM = Foo
1020 # creates OBJS, links with LIBS to create Foo
1022 $(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
1023 @rm -f $@.manifest
1024 ifeq (WINCE,$(OS_ARCH))
1025 $(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1026 else
1027 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1028 $(LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1029 ifdef MSMANIFEST_TOOL
1030 @if test -f $@.manifest; then \
1031 if test -f "$(srcdir)/$@.manifest"; then \
1032 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
1033 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
1034 else \
1035 echo "Embedding manifest from $@.manifest"; \
1036 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1037 fi; \
1038 elif test -f "$(srcdir)/$@.manifest"; then \
1039 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
1040 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
1042 endif # MSVC with manifest tool
1043 ifdef MOZ_PROFILE_GENERATE
1044 # touch it a few seconds into the future to work around FAT's
1045 # 2-second granularity
1046 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
1047 endif
1048 else # !WINNT || GNU_CC
1049 ifeq ($(CPP_PROG_LINK),1)
1050 $(CCC) -o $@ $(CXXFLAGS) $(WRAP_MALLOC_CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(call EXPAND_FAKELIBS,$(LIBS) $(OS_LIBS) $(EXTRA_LIBS)) $(BIN_FLAGS) $(call EXPAND_FAKELIBS,$(WRAP_MALLOC_LIB)) $(EXE_DEF_FILE)
1051 else # ! CPP_PROG_LINK
1052 $(CC) -o $@ $(CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(call EXPAND_FAKELIBS,$(LIBS) $(OS_LIBS) $(EXTRA_LIBS)) $(BIN_FLAGS) $(EXE_DEF_FILE)
1053 endif # CPP_PROG_LINK
1054 endif # WINNT && !GNU_CC
1055 endif # WINCE
1057 ifdef ENABLE_STRIP
1058 $(STRIP) $@
1059 endif
1060 ifdef MOZ_POST_PROGRAM_COMMAND
1061 $(MOZ_POST_PROGRAM_COMMAND) $@
1062 endif
1063 ifeq ($(OS_ARCH),BeOS)
1064 ifdef BEOS_PROGRAM_RESOURCE
1065 xres -o $@ $(BEOS_PROGRAM_RESOURCE)
1066 mimeset $@
1067 endif
1068 endif # BeOS
1070 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
1071 ifeq (WINCE,$(OS_ARCH))
1072 $(HOST_LD) -NOLOGO -OUT:$@ $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1073 else
1074 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
1075 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1076 ifdef MSMANIFEST_TOOL
1077 @if test -f $@.manifest; then \
1078 if test -f "$(srcdir)/$@.manifest"; then \
1079 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
1080 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
1081 else \
1082 echo "Embedding manifest from $@.manifest"; \
1083 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1084 fi; \
1085 elif test -f "$(srcdir)/$@.manifest"; then \
1086 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
1087 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
1089 endif # MSVC with manifest tool
1090 else
1091 ifeq ($(HOST_CPP_PROG_LINK),1)
1092 $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1093 else
1094 $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1095 endif # HOST_CPP_PROG_LINK
1096 endif
1097 endif
1100 # This is an attempt to support generation of multiple binaries
1101 # in one directory, it assumes everything to compile Foo is in
1102 # Foo.o (from either Foo.c or Foo.cpp).
1104 # SIMPLE_PROGRAMS = Foo Bar
1105 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
1107 $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
1108 ifeq (WINCE,$(OS_ARCH))
1109 $(LD) -nologo -entry:mainACRTStartup -out:$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1110 else
1111 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1112 $(LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1113 ifdef MSMANIFEST_TOOL
1114 @if test -f $@.manifest; then \
1115 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1116 rm -f $@.manifest; \
1118 endif # MSVC with manifest tool
1119 else
1120 ifeq ($(CPP_PROG_LINK),1)
1121 $(CCC) $(WRAP_MALLOC_CFLAGS) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(call EXPAND_FAKELIBS,$(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB)) $(BIN_FLAGS)
1122 else
1123 $(CC) $(WRAP_MALLOC_CFLAGS) $(CFLAGS) $(OUTOPTION)$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(call EXPAND_FAKELIBS,$(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB)) $(BIN_FLAGS)
1124 endif # CPP_PROG_LINK
1125 endif # WINNT && !GNU_CC
1126 endif # WINCE
1128 ifdef ENABLE_STRIP
1129 $(STRIP) $@
1130 endif
1131 ifdef MOZ_POST_PROGRAM_COMMAND
1132 $(MOZ_POST_PROGRAM_COMMAND) $@
1133 endif
1135 $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
1136 ifeq (WINCE,$(OS_ARCH))
1137 $(HOST_LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1138 else
1139 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
1140 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1141 else
1142 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
1143 $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1144 else
1145 $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1146 endif
1147 endif
1148 endif
1151 # Purify target. Solaris/sparc only to start.
1152 # Purify does not recognize "egcs" or "c++" so we go with
1153 # "gcc" and "g++" for now.
1155 pure: $(PROGRAM)
1156 ifeq ($(CPP_PROG_LINK),1)
1157 $(PURIFY) $(CCC) -o $^.pure $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1158 else
1159 $(PURIFY) $(CC) -o $^.pure $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1160 endif
1161 ifndef NO_DIST_INSTALL
1162 $(INSTALL) $(IFLAGS2) $^.pure $(FINAL_TARGET)
1163 endif
1165 quantify: $(PROGRAM)
1166 ifeq ($(CPP_PROG_LINK),1)
1167 $(QUANTIFY) $(CCC) -o $^.quantify $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1168 else
1169 $(QUANTIFY) $(CC) -o $^.quantify $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1170 endif
1171 ifndef NO_DIST_INSTALL
1172 $(INSTALL) $(IFLAGS2) $^.quantify $(FINAL_TARGET)
1173 endif
1176 # This allows us to create static versions of the shared libraries
1177 # that are built using other static libraries. Confused...?
1179 ifdef SHARED_LIBRARY_LIBS
1180 ifeq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1181 ifneq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
1182 LOBJS += $(SHARED_LIBRARY_LIBS)
1183 endif
1184 else
1185 NONFAKE_SHARED_LIBRARY_LIBS = $(filter-out %.fake,$(call EXPAND_FAKELIBS,$(SHARED_LIBRARY_LIBS)))
1186 ifeq (,$(NONFAKE_SHARED_LIBRARY_LIBS))
1187 # All of our SHARED_LIBRARY_LIBS have fake equivalents. Score!
1188 # Just pass the original object files around.
1189 # For shared libraries, these are already included in EXTRA_DSO_LDOPTS
1190 # above.
1191 ifndef SHARED_LIBRARY
1192 LOBJS += $(shell cat $(addsuffix .fake,$(SHARED_LIBRARY_LIBS)))
1193 endif
1194 SKIP_SUB_LOBJS := 1
1195 else
1196 ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH)))
1197 CLEANUP1 := | egrep -v '(________64ELEL_|__.SYMDEF)'
1198 CLEANUP2 := rm -f ________64ELEL_ __.SYMDEF
1199 else
1200 CLEANUP2 := true
1201 endif
1202 SUB_LOBJS = $(shell for lib in $(SHARED_LIBRARY_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1203 endif # EXPAND_FAKELIBS
1204 endif # SHARED_LIBRARY_LIBS
1205 endif
1206 ifdef MOZILLA_PROBE_LIBS
1207 PROBE_LOBJS = $(shell for lib in $(MOZILLA_PROBE_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1208 endif
1209 ifdef DTRACE_PROBE_OBJ
1210 EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
1211 endif
1213 $(LIBRARY): $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
1214 rm -f $@
1215 ifndef SKIP_SUB_LOBJS
1216 ifneq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1217 ifdef SHARED_LIBRARY_LIBS
1218 @rm -f $(SUB_LOBJS)
1219 @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1220 endif
1221 endif
1222 endif # SKIP_SUB_LOBJS
1223 $(AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SUB_LOBJS)
1224 $(RANLIB) $@
1225 ifndef MOZ_FAKELIBS
1226 # Don't clean these up if we're building a fake lib, because then
1227 # we'll reference nonexistent object files in our fake lib.
1228 @rm -f foodummyfilefoo $(SUB_LOBJS)
1229 endif
1230 # Also produce a .fake file that just contains the names of the object files.
1231 # This can be used as a response file to the linker later instead of
1232 # linking the actual static library.
1233 ifdef MOZ_FAKELIBS
1234 ifndef SUPPRESS_FAKELIB
1235 ifeq (WINNT_,$(HOST_OS_ARCH)_$(.PYMAKE))
1236 echo "$(strip $(foreach f,$(OBJS) $(SEPARATE_OBJS) $(LOBJS) $(SUB_LOBJS),$(subst \,\\,$(call core_winabspath,$(f))))) " > $@.fake
1237 else
1238 echo "$(strip $(foreach f,$(OBJS) $(SEPARATE_OBJS) $(LOBJS) $(SUB_LOBJS),$(call core_abspath,$(f)))) " > $@.fake
1239 endif
1240 endif
1241 endif
1243 ifeq (,$(filter-out WINNT WINCE, $(OS_ARCH)))
1244 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1245 endif
1247 ifeq ($(OS_ARCH),OS2)
1248 $(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
1249 rm -f $@
1250 echo LIBRARY $(SHARED_LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
1251 echo PROTMODE >> $@
1252 echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@
1253 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
1254 echo EXPORTS >> $@
1256 $(ADD_TO_DEF_FILE)
1258 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1259 rm -f $@
1260 $(IMPLIB) $@ $^
1261 $(RANLIB) $@
1262 endif # OS/2
1264 $(HOST_LIBRARY): $(HOST_OBJS) Makefile
1265 rm -f $@
1266 $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
1267 $(HOST_RANLIB) $@
1269 ifdef NO_LD_ARCHIVE_FLAGS
1270 SUB_SHLOBJS = $(SUB_LOBJS)
1271 endif
1273 ifdef HAVE_DTRACE
1274 ifndef XP_MACOSX
1275 ifdef DTRACE_PROBE_OBJ
1276 ifndef DTRACE_LIB_DEPENDENT
1277 $(DTRACE_PROBE_OBJ): $(OBJS)
1278 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
1279 endif
1280 endif
1281 endif
1282 endif
1284 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
1285 # so instead of deleting .o files after repacking them into a dylib, we make
1286 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
1287 # so no need to conditionalize on OS version or debugging format.
1289 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(LIBRARY) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
1290 ifndef INCREMENTAL_LINKER
1291 rm -f $@
1292 endif
1293 ifeq ($(OS_ARCH),OpenVMS)
1294 @if test ! -f $(VMS_SYMVEC_FILE); then \
1295 if test -f $(VMS_SYMVEC_FILE_MODULE); then \
1296 echo Creating specific component options file $(VMS_SYMVEC_FILE); \
1297 cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
1298 fi; \
1300 ifdef IS_COMPONENT
1301 @if test ! -f $(VMS_SYMVEC_FILE); then \
1302 echo Creating generic component options file $(VMS_SYMVEC_FILE); \
1303 cp $(VMS_SYMVEC_FILE_COMP) $(VMS_SYMVEC_FILE); \
1305 endif
1306 endif # OpenVMS
1307 ifdef NO_LD_ARCHIVE_FLAGS
1308 ifdef SHARED_LIBRARY_LIBS
1309 @rm -f $(SUB_SHLOBJS)
1310 @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1311 ifeq ($(OS_ARCH),Darwin)
1312 @echo Making symlinks to the original object files in the archive libraries $(SHARED_LIBRARY_LIBS)
1313 @for lib in $(SHARED_LIBRARY_LIBS); do \
1314 libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
1315 ofiles=`$(AR_LIST) $${lib}`; \
1316 for ofile in $$ofiles; do \
1317 if [ -f $$libdir/$$ofile ]; then \
1318 rm -f $$ofile; \
1319 ln -s $$libdir/$$ofile $$ofile; \
1320 fi; \
1321 done; \
1322 done
1323 endif
1324 endif # SHARED_LIBRARY_LIBS
1325 endif # NO_LD_ARCHIVE_FLAGS
1326 ifdef DTRACE_LIB_DEPENDENT
1327 @rm -f $(PROBE_LOBJS)
1328 @for lib in $(MOZILLA_PROBE_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1329 ifndef XP_MACOSX
1330 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS)
1331 endif
1332 @for lib in $(MOZILLA_PROBE_LIBS); do \
1333 ofiles=`$(AR_LIST) $${lib}`; \
1334 $(AR_DELETE) $${lib} $$ofiles; \
1335 done
1336 $(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(call EXPAND_FAKELIBS,$(OS_LIBS) $(EXTRA_LIBS)) $(DEF_FILE) $(SHLIB_LDENDFILE)
1337 @rm -f $(PROBE_LOBJS)
1338 @rm -f $(DTRACE_PROBE_OBJ)
1339 @for lib in $(MOZILLA_PROBE_LIBS); do \
1340 if [ -L $${lib} ]; then rm -f `readlink $${lib}`; fi; \
1341 done
1342 @rm -f $(MOZILLA_PROBE_LIBS)
1344 else # ! DTRACE_LIB_DEPENDENT
1345 $(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(DTRACE_PROBE_OBJ) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(call EXPAND_FAKELIBS,$(OS_LIBS) $(EXTRA_LIBS)) $(DEF_FILE) $(SHLIB_LDENDFILE)
1346 endif # DTRACE_LIB_DEPENDENT
1348 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1349 ifdef MSMANIFEST_TOOL
1350 ifdef EMBED_MANIFEST_AT
1351 @if test -f $@.manifest; then \
1352 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
1353 rm -f $@.manifest; \
1355 endif # EMBED_MANIFEST_AT
1356 endif # MSVC with manifest tool
1357 ifdef MOZ_PROFILE_GENERATE
1358 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
1359 endif
1360 endif # WINNT && !GCC
1361 ifneq ($(OS_ARCH),Darwin)
1362 @rm -f $(SUB_SHLOBJS)
1363 endif # Darwin
1364 @rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
1365 chmod +x $@
1366 ifdef ENABLE_STRIP
1367 $(STRIP) $@
1368 endif
1369 ifdef MOZ_POST_DSO_LIB_COMMAND
1370 $(MOZ_POST_DSO_LIB_COMMAND) $@
1371 endif
1373 ifdef MOZ_AUTO_DEPS
1374 ifdef COMPILER_DEPEND
1375 ifeq ($(SOLARIS_SUNPRO_CC),1)
1376 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1378 define MAKE_DEPS_AUTO_CC
1379 if test -d $(@D); then \
1380 echo "Building deps for $< using Sun Studio cc"; \
1381 $(CC) $(COMPILE_CFLAGS) -xM $< >$(_MDDEPFILE) ; \
1383 endef
1384 define MAKE_DEPS_AUTO_CXX
1385 if test -d $(@D); then \
1386 echo "Building deps for $< using Sun Studio CC"; \
1387 $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
1389 endef
1390 endif # Sun Studio on Solaris
1391 else # COMPILER_DEPEND
1393 # Generate dependencies on the fly
1395 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1397 define MAKE_DEPS_AUTO
1398 if test -d $(@D); then \
1399 echo "Building deps for $<"; \
1400 $(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
1402 endef
1404 MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
1405 MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
1407 endif # COMPILER_DEPEND
1409 endif # MOZ_AUTO_DEPS
1411 # Rules for building native targets must come first because of the host_ prefix
1412 host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
1413 $(REPORT_BUILD)
1414 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1416 host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
1417 $(REPORT_BUILD)
1418 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1420 host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
1421 $(REPORT_BUILD)
1422 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1424 host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
1425 $(REPORT_BUILD)
1426 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1428 host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
1429 $(REPORT_BUILD)
1430 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1432 %:: %.c $(GLOBAL_DEPS)
1433 $(REPORT_BUILD)
1434 @$(MAKE_DEPS_AUTO_CC)
1435 $(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
1437 %.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
1438 $(REPORT_BUILD)
1439 @$(MAKE_DEPS_AUTO_CC)
1440 $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1442 # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
1443 # 'moc' only knows about #defines it gets on the command line (-D...), not in
1444 # included headers like mozilla-config.h
1445 moc_%.cpp: %.h $(GLOBAL_DEPS)
1446 $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
1448 moc_%.cc: %.cc $(GLOBAL_DEPS)
1449 $(REPORT_BUILD)
1450 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
1452 ifdef ASFILES
1453 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
1454 # a '-c' flag.
1455 %.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) $(GLOBAL_DEPS)
1456 $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
1457 endif
1459 %.$(OBJ_SUFFIX): %.S $(GLOBAL_DEPS)
1460 $(AS) -o $@ $(ASFLAGS) -c $<
1462 %:: %.cpp $(GLOBAL_DEPS)
1463 @$(MAKE_DEPS_AUTO_CXX)
1464 $(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
1467 # Please keep the next two rules in sync.
1469 %.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
1470 $(REPORT_BUILD)
1471 @$(MAKE_DEPS_AUTO_CXX)
1472 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1474 %.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
1475 $(REPORT_BUILD)
1476 @$(MAKE_DEPS_AUTO_CXX)
1477 ifdef STRICT_CPLUSPLUS_SUFFIX
1478 echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
1479 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
1480 rm -f t_$*.cc
1481 else
1482 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1483 endif #STRICT_CPLUSPLUS_SUFFIX
1485 $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
1486 $(REPORT_BUILD)
1487 @$(MAKE_DEPS_AUTO_CXX)
1488 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
1490 $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
1491 $(REPORT_BUILD)
1492 @$(MAKE_DEPS_AUTO_CC)
1493 $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
1495 %.s: %.cpp
1496 $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1498 %.s: %.cc
1499 $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1501 %.s: %.c
1502 $(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1504 %.i: %.cpp
1505 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1507 %.i: %.cc
1508 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1510 %.i: %.c
1511 $(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
1513 %.i: %.mm
1514 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
1516 %.res: %.rc
1517 @echo Creating Resource file: $@
1518 ifeq ($(OS_ARCH),OS2)
1519 $(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
1520 else
1521 ifdef GNU_CC
1522 $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
1523 else
1524 $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
1525 endif
1526 endif
1528 # need 3 separate lines for OS/2
1529 %:: %.pl
1530 rm -f $@
1531 cp $< $@
1532 chmod +x $@
1534 %:: %.sh
1535 rm -f $@; cp $< $@; chmod +x $@
1537 # Cancel these implicit rules
1539 %: %,v
1541 %: RCS/%,v
1543 %: s.%
1545 %: SCCS/s.%
1547 ###############################################################################
1548 # Java rules
1549 ###############################################################################
1550 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
1551 SEP := ;
1552 else
1553 SEP := :
1554 endif
1556 EMPTY :=
1557 SPACE := $(EMPTY) $(EMPTY)
1559 # Cygwin and MSYS have their own special path form, but javac expects the source
1560 # and class paths to be in the DOS form (i.e. e:/builds/...). This function
1561 # does the appropriate conversion on Windows, but is a noop on other systems.
1562 ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
1563 ifdef CYGWIN_WRAPPER
1564 normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
1565 else
1566 # assume MSYS
1567 # We use 'pwd -W' to get DOS form of the path. However, since the given path
1568 # could be a file or a non-existent path, we cannot call 'pwd -W' directly
1569 # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
1570 # on it, then merge with the rest of the path.
1571 root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
1572 non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
1573 normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
1574 endif
1575 else
1576 normalizepath = $(1)
1577 endif
1579 _srcdir = $(call normalizepath,$(srcdir))
1580 ifdef JAVA_SOURCEPATH
1581 SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
1582 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
1583 else
1584 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
1585 endif
1587 ifdef JAVA_CLASSPATH
1588 CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
1589 _JAVA_CLASSPATH = ".$(SEP)$(CP)"
1590 else
1591 _JAVA_CLASSPATH = .
1592 endif
1594 _JAVA_DIR = _java
1595 $(_JAVA_DIR)::
1596 $(NSINSTALL) -D $@
1598 $(_JAVA_DIR)/%.class: %.java $(GLOBAL_DEPS) $(_JAVA_DIR)
1599 $(CYGWIN_WRAPPER) $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
1600 -sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
1602 $(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) $(GLOBAL_DEPS)
1603 $(JAR) cf $@ -C $(_JAVA_DIR) .
1605 GARBAGE_DIRS += $(_JAVA_DIR)
1607 ###############################################################################
1608 # Update Makefiles
1609 ###############################################################################
1611 # In GNU make 3.80, makefiles must use the /cygdrive syntax, even if we're
1612 # processing them with AS perl. See bug 232003
1613 ifdef AS_PERL
1614 CYGWIN_TOPSRCDIR = -nowrap -p $(topsrcdir) -wrap
1615 endif
1617 # Note: Passing depth to make-makefile is optional.
1618 # It saves the script some work, though.
1619 Makefile: Makefile.in
1620 @$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR)
1622 ifdef SUBMAKEFILES
1623 # VPATH does not work on some machines in this case, so add $(srcdir)
1624 $(SUBMAKEFILES): % : $(srcdir)/%.in
1625 $(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $@
1626 endif
1628 ifdef AUTOUPDATE_CONFIGURE
1629 $(topsrcdir)/configure: $(topsrcdir)/configure.in
1630 (cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
1631 endif
1633 ###############################################################################
1634 # Bunch of things that extend the 'export' rule (in order):
1635 ###############################################################################
1637 ################################################################################
1638 # Copy each element of EXPORTS to $(DIST)/include
1640 ifdef MOZ_JAVAXPCOM
1641 ifneq ($(XPIDLSRCS),)
1642 $(JAVA_DIST_DIR)::
1643 $(NSINSTALL) -D $@
1644 endif
1645 endif
1647 ifneq ($(XPI_NAME),)
1648 $(FINAL_TARGET):
1649 $(NSINSTALL) -D $@
1651 export:: $(FINAL_TARGET)
1652 endif
1654 ifndef NO_DIST_INSTALL
1655 ifneq (,$(EXPORTS))
1656 export:: $(EXPORTS)
1657 $(INSTALL) $(IFLAGS1) $^ $(DIST)/include
1658 endif
1659 endif # NO_DIST_INSTALL
1661 define EXPORT_NAMESPACE_RULE
1662 ifndef NO_DIST_INSTALL
1663 export:: $(EXPORTS_$(namespace))
1664 $(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
1665 endif # NO_DIST_INSTALL
1666 endef
1668 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
1670 ################################################################################
1671 # Copy each element of PREF_JS_EXPORTS
1673 ifdef GRE_MODULE
1674 PREF_DIR = greprefs
1675 else
1676 ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
1677 PREF_DIR = defaults/preferences
1678 else
1679 PREF_DIR = defaults/pref
1680 endif
1681 endif
1683 ifneq ($(PREF_JS_EXPORTS),)
1684 # on win32, pref files need CRLF line endings... see bug 206029
1685 ifeq (WINNT,$(OS_ARCH))
1686 PREF_PPFLAGS = --line-endings=crlf
1687 endif
1689 ifndef NO_DIST_INSTALL
1690 $(FINAL_TARGET)/$(PREF_DIR):
1691 $(NSINSTALL) -D $@
1693 libs:: $(FINAL_TARGET)/$(PREF_DIR) $(PREF_JS_EXPORTS)
1694 $(EXIT_ON_ERROR) \
1695 for i in $(PREF_JS_EXPORTS); do \
1696 dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
1697 $(RM) -f $$dest; \
1698 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1699 done
1700 endif
1701 endif
1703 ################################################################################
1704 # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
1706 ifneq ($(AUTOCFG_JS_EXPORTS),)
1707 $(FINAL_TARGET)/defaults/autoconfig::
1708 $(NSINSTALL) -D $@
1710 ifndef NO_DIST_INSTALL
1711 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
1712 $(INSTALL) $(IFLAGS1) $^
1713 endif
1715 endif
1716 ################################################################################
1717 # Export the elements of $(XPIDLSRCS)
1718 # generating .h and .xpt files and moving them to the appropriate places.
1720 ifneq ($(XPIDLSRCS),)
1722 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
1724 ifndef XPIDL_MODULE
1725 XPIDL_MODULE = $(MODULE)
1726 endif
1728 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
1729 export:: FORCE
1730 @echo
1731 @echo "*** Error processing XPIDLSRCS:"
1732 @echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
1733 @echo "so we have a module name to use when creating MODULE.xpt."
1734 @echo; sleep 2; false
1735 endif
1737 $(IDL_DIR)::
1738 $(NSINSTALL) -D $@
1740 # generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
1741 # warn against overriding existing .h file.
1742 $(XPIDL_GEN_DIR)/.done:
1743 @if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
1744 @touch $@
1746 # don't depend on $(XPIDL_GEN_DIR), because the modification date changes
1747 # with any addition to the directory, regenerating all .h files -> everything.
1749 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1750 $(REPORT_BUILD)
1751 $(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
1752 @if test -n "$(findstring $*.h, $(EXPORTS))"; \
1753 then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
1755 ifndef NO_GEN_XPT
1756 # generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
1757 # into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
1758 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1759 $(REPORT_BUILD)
1760 $(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
1762 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
1763 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
1764 $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
1765 $(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
1766 endif # XPIDL_MODULE.xpt != XPIDLSRCS
1768 libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
1769 ifndef NO_DIST_INSTALL
1770 $(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
1771 ifndef NO_INTERFACES_MANIFEST
1772 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
1773 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
1774 endif
1775 endif
1777 endif # NO_GEN_XPT
1779 GARBAGE_DIRS += $(XPIDL_GEN_DIR)
1781 endif # XPIDLSRCS
1783 ifneq ($(XPIDLSRCS),)
1784 # export .idl files to $(IDL_DIR)
1785 ifndef NO_DIST_INSTALL
1786 export:: $(XPIDLSRCS) $(IDL_DIR)
1787 $(INSTALL) $(IFLAGS1) $^
1789 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
1790 $(INSTALL) $(IFLAGS1) $^
1791 endif # NO_DIST_INSTALL
1793 endif # XPIDLSRCS
1798 # General rules for exporting idl files.
1800 # WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
1801 # Bug to fix idl dependency problems w/o this extra build pass is
1802 # http://bugzilla.mozilla.org/show_bug.cgi?id=145777
1804 $(IDL_DIR)::
1805 $(NSINSTALL) -D $@
1807 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
1809 ifneq ($(XPIDLSRCS),)
1810 ifndef NO_DIST_INSTALL
1811 export-idl:: $(XPIDLSRCS) $(IDL_DIR)
1812 $(INSTALL) $(IFLAGS1) $^
1813 endif
1814 endif
1815 $(LOOP_OVER_PARALLEL_DIRS)
1816 $(LOOP_OVER_DIRS)
1817 $(LOOP_OVER_TOOL_DIRS)
1819 ifdef MOZ_JAVAXPCOM
1820 ifneq ($(XPIDLSRCS),)
1822 JAVA_XPIDLSRCS = $(XPIDLSRCS)
1824 # A single IDL file can contain multiple interfaces, which result in multiple
1825 # Java interface files. So use hidden dependency files.
1826 JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
1828 $(JAVA_GEN_DIR):
1829 $(NSINSTALL) -D $@
1830 GARBAGE_DIRS += $(JAVA_GEN_DIR)
1832 # generate .java files into _javagen/[package name dirs]
1833 _JAVA_GEN_DIR = $(JAVA_GEN_DIR)/$(JAVA_IFACES_PKG_NAME)
1834 $(_JAVA_GEN_DIR):
1835 $(NSINSTALL) -D $@
1837 $(JAVA_GEN_DIR)/.%.java.pp: %.idl $(XPIDL_COMPILE) $(_JAVA_GEN_DIR)
1838 $(REPORT_BUILD)
1839 $(ELOG) $(XPIDL_COMPILE) -m java -w $(XPIDL_FLAGS) -I$(srcdir) -I$(IDL_DIR) -o $(_JAVA_GEN_DIR)/$* $(_VPATH_SRCS)
1840 @touch $@
1842 # "Install" generated Java interfaces. We segregate them based on the XPI_NAME.
1843 # If XPI_NAME is not set, install into the "default" directory.
1844 ifneq ($(XPI_NAME),)
1845 JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/$(XPI_NAME)
1846 else
1847 JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/default
1848 endif
1850 $(JAVA_INSTALL_DIR):
1851 $(NSINSTALL) -D $@
1853 export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
1854 (cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
1856 endif # XPIDLSRCS
1857 endif # MOZ_JAVAXPCOM
1859 ################################################################################
1860 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
1861 ifneq (,$(filter %.js,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1862 ifeq (,$(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1863 ifndef NO_JS_MANIFEST
1864 $(error .js component without matching .manifest. See https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0)
1865 endif
1866 endif
1867 endif
1869 ifdef EXTRA_COMPONENTS
1870 libs:: $(EXTRA_COMPONENTS)
1871 ifndef NO_DIST_INSTALL
1872 $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
1873 endif
1875 endif
1877 ifdef EXTRA_PP_COMPONENTS
1878 libs:: $(EXTRA_PP_COMPONENTS)
1879 ifndef NO_DIST_INSTALL
1880 $(EXIT_ON_ERROR) \
1881 $(NSINSTALL) -D $(FINAL_TARGET)/components; \
1882 for i in $^; do \
1883 fname=`basename $$i`; \
1884 dest=$(FINAL_TARGET)/components/$${fname}; \
1885 $(RM) -f $$dest; \
1886 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1887 done
1888 endif
1889 endif
1891 EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
1892 ifneq (,$(EXTRA_MANIFESTS))
1893 libs::
1894 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
1895 endif
1897 ################################################################################
1898 # Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
1899 ifdef EXTRA_JS_MODULES
1900 libs:: $(EXTRA_JS_MODULES)
1901 ifndef NO_DIST_INSTALL
1902 $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
1903 endif
1905 endif
1907 ifdef EXTRA_PP_JS_MODULES
1908 libs:: $(EXTRA_PP_JS_MODULES)
1909 ifndef NO_DIST_INSTALL
1910 $(EXIT_ON_ERROR) \
1911 $(NSINSTALL) -D $(FINAL_TARGET)/modules; \
1912 for i in $^; do \
1913 dest=$(FINAL_TARGET)/modules/`basename $$i`; \
1914 $(RM) -f $$dest; \
1915 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1916 done
1917 endif
1919 endif
1921 ################################################################################
1922 # SDK
1924 ifneq (,$(SDK_LIBRARY))
1925 $(SDK_LIB_DIR)::
1926 $(NSINSTALL) -D $@
1928 ifndef NO_DIST_INSTALL
1929 libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
1930 $(INSTALL) $(IFLAGS2) $^
1931 endif
1933 endif # SDK_LIBRARY
1935 ifneq (,$(SDK_BINARY))
1936 $(SDK_BIN_DIR)::
1937 $(NSINSTALL) -D $@
1939 ifndef NO_DIST_INSTALL
1940 libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
1941 $(INSTALL) $(IFLAGS2) $^
1942 endif
1944 endif # SDK_BINARY
1946 ################################################################################
1947 # CHROME PACKAGING
1949 JAR_MANIFEST := $(srcdir)/jar.mn
1951 chrome::
1952 $(MAKE) realchrome
1953 $(LOOP_OVER_PARALLEL_DIRS)
1954 $(LOOP_OVER_DIRS)
1955 $(LOOP_OVER_TOOL_DIRS)
1957 $(FINAL_TARGET)/chrome:
1958 $(NSINSTALL) -D $@
1960 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
1961 ifneq (,$(wildcard $(JAR_MANIFEST)))
1962 ifndef NO_DIST_INSTALL
1963 $(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
1964 $(QUIET) -j $(FINAL_TARGET)/chrome \
1965 $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
1966 $(JAR_MANIFEST)
1967 endif
1968 endif
1970 ifneq ($(DIST_FILES),)
1971 $(DIST)/bin:
1972 $(NSINSTALL) -D $@
1974 libs:: $(DIST_FILES) $(DIST)/bin
1975 @$(EXIT_ON_ERROR) \
1976 for f in $(DIST_FILES); do \
1977 dest=$(FINAL_TARGET)/`basename $$f`; \
1978 $(RM) -f $$dest; \
1979 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
1980 $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
1981 $(srcdir)/$$f > $$dest; \
1982 done
1983 endif
1985 ifneq ($(DIST_CHROME_FILES),)
1986 libs:: $(DIST_CHROME_FILES)
1987 @$(EXIT_ON_ERROR) \
1988 for f in $(DIST_CHROME_FILES); do \
1989 dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
1990 $(RM) -f $$dest; \
1991 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
1992 $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
1993 $(srcdir)/$$f > $$dest; \
1994 done
1995 endif
1997 ifneq ($(XPI_PKGNAME),)
1998 libs realchrome::
1999 ifdef STRIP_XPI
2000 ifndef MOZ_DEBUG
2001 @echo "Stripping $(XPI_PKGNAME) package directory..."
2002 @echo $(FINAL_TARGET)
2003 @cd $(FINAL_TARGET) && find . ! -type d \
2004 ! -name "*.js" \
2005 ! -name "*.xpt" \
2006 ! -name "*.gif" \
2007 ! -name "*.jpg" \
2008 ! -name "*.png" \
2009 ! -name "*.xpm" \
2010 ! -name "*.txt" \
2011 ! -name "*.rdf" \
2012 ! -name "*.sh" \
2013 ! -name "*.properties" \
2014 ! -name "*.dtd" \
2015 ! -name "*.html" \
2016 ! -name "*.xul" \
2017 ! -name "*.css" \
2018 ! -name "*.xml" \
2019 ! -name "*.jar" \
2020 ! -name "*.dat" \
2021 ! -name "*.tbl" \
2022 ! -name "*.src" \
2023 ! -name "*.reg" \
2024 $(PLATFORM_EXCLUDE_LIST) \
2025 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
2026 endif
2027 endif
2028 @echo "Packaging $(XPI_PKGNAME).xpi..."
2029 cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
2030 endif
2032 ifdef INSTALL_EXTENSION_ID
2033 ifndef XPI_NAME
2034 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
2035 endif
2037 libs::
2038 $(RM) -rf "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
2039 $(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
2040 cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
2042 endif
2044 ifneq (,$(filter flat symlink,$(MOZ_CHROME_FILE_FORMAT)))
2045 _JAR_REGCHROME_DISABLE_JAR=1
2046 else
2047 _JAR_REGCHROME_DISABLE_JAR=0
2048 endif
2050 REGCHROME = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
2051 $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
2052 $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(FINAL_TARGET)/chrome/installed-chrome.txt \
2053 $(_JAR_REGCHROME_DISABLE_JAR)
2055 REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
2056 $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
2057 $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
2058 $(_JAR_REGCHROME_DISABLE_JAR)
2061 #############################################################################
2062 # Dependency system
2063 #############################################################################
2064 ifdef COMPILER_DEPEND
2065 depend::
2066 @echo "$(MAKE): No need to run depend target.\
2067 Using compiler-based depend." 1>&2
2068 ifeq ($(GNU_CC)$(GNU_CXX),)
2069 # Non-GNU compilers
2070 @echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
2071 '(Compiler-based depend was turned on by "--enable-md".)' 1>&2
2072 else
2073 # GNU compilers
2074 @space="`echo '$(MAKE): '|sed 's/./ /g'`";\
2075 echo "$$space"'Since you are using a GNU compiler,\
2076 it is on by default.' 1>&2; \
2077 echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
2078 endif
2080 else # ! COMPILER_DEPEND
2082 ifndef MOZ_AUTO_DEPS
2084 define MAKE_DEPS_NOAUTO
2085 $(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
2086 endef
2088 $(MDDEPDIR)/%.pp: %.c
2089 $(REPORT_BUILD)
2090 @$(MAKE_DEPS_NOAUTO)
2092 $(MDDEPDIR)/%.pp: %.cpp
2093 $(REPORT_BUILD)
2094 @$(MAKE_DEPS_NOAUTO)
2096 $(MDDEPDIR)/%.pp: %.s
2097 $(REPORT_BUILD)
2098 @$(MAKE_DEPS_NOAUTO)
2100 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
2101 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
2102 else
2103 depend:: $(SUBMAKEFILES)
2104 endif
2105 $(LOOP_OVER_PARALLEL_DIRS)
2106 $(LOOP_OVER_DIRS)
2107 $(LOOP_OVER_TOOL_DIRS)
2109 dependclean:: $(SUBMAKEFILES)
2110 rm -f $(MDDEPFILES)
2111 $(LOOP_OVER_PARALLEL_DIRS)
2112 $(LOOP_OVER_DIRS)
2113 $(LOOP_OVER_TOOL_DIRS)
2115 endif # MOZ_AUTO_DEPS
2117 endif # COMPILER_DEPEND
2120 #############################################################################
2121 # MDDEPDIR is the subdirectory where all the dependency files are placed.
2122 # This uses a make rule (instead of a macro) to support parallel
2123 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
2124 # processes could simultaneously try to create the same directory.
2126 # We use $(CURDIR) in the rule's target to ensure that we don't find
2127 # a dependency directory in the source tree via VPATH (perhaps from
2128 # a previous build in the source tree) and thus neglect to create a
2129 # dependency directory in the object directory, where we really need
2130 # it.
2132 $(CURDIR)/$(MDDEPDIR):
2133 @if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
2135 ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
2136 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
2137 MDDEPEND_FILES := $(strip $(wildcard $(MDDEPDIR)/*.pp))
2139 ifneq (,$(MDDEPEND_FILES))
2140 # The script mddepend.pl checks the dependencies and writes to stdout
2141 # one rule to force out-of-date objects. For example,
2142 # foo.o boo.o: FORCE
2143 # The script has an advantage over including the *.pp files directly
2144 # because it handles the case when header files are removed from the build.
2145 # 'make' would complain that there is no way to build missing headers.
2146 ALL_PP_RESULTS = $(shell $(PERL) $(BUILD_TOOLS)/mddepend.pl - $(MDDEPEND_FILES))
2147 $(eval $(ALL_PP_RESULTS))
2148 endif
2150 endif
2151 endif
2152 #############################################################################
2154 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
2155 -include $(MY_RULES)
2158 # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
2159 # or in $(MY_RULES)
2161 ifdef ETAGS
2162 ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
2163 all:: TAGS
2164 TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
2165 $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
2166 endif
2167 endif
2169 ################################################################################
2170 # Special gmake rules.
2171 ################################################################################
2175 # Disallow parallel builds with MSVC < 8
2177 ifneq (,$(filter 1200 1300 1310,$(_MSC_VER)))
2178 .NOTPARALLEL:
2179 endif
2182 # Re-define the list of default suffixes, so gmake won't have to churn through
2183 # hundreds of built-in suffix rules for stuff we don't need.
2185 .SUFFIXES:
2188 # Fake targets. Always run these rules, even if a file/directory with that
2189 # name already exists.
2191 .PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
2193 # Used as a dependency to force targets to rebuild
2194 FORCE:
2196 # Delete target if error occurs when building target
2197 .DELETE_ON_ERROR:
2199 # Properly set LIBPATTERNS for the platform
2200 .LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX)
2202 tags: TAGS
2204 TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2205 -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2206 $(LOOP_OVER_PARALLEL_DIRS)
2207 $(LOOP_OVER_DIRS)
2209 echo-variable-%:
2210 @echo "$($*)"
2212 echo-tiers:
2213 @echo $(TIERS)
2215 echo-tier-dirs:
2216 @$(foreach tier,$(TIERS),echo '$(tier):'; echo ' dirs: $(tier_$(tier)_dirs)'; echo ' staticdirs: $(tier_$(tier)_staticdirs)'; )
2218 echo-dirs:
2219 @echo $(DIRS)
2221 echo-module:
2222 @echo $(MODULE)
2224 echo-requires:
2225 @echo $(REQUIRES)
2227 echo-depth-path:
2228 @$(topsrcdir)/build/unix/print-depth-path.sh
2230 echo-module-name:
2231 @$(topsrcdir)/build/package/rpm/print-module-name.sh
2233 echo-module-filelist:
2234 @$(topsrcdir)/build/package/rpm/print-module-filelist.sh
2236 showtargs:
2237 ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
2238 @echo --------------------------------------------------------------------------------
2239 @echo "PROGRAM = $(PROGRAM)"
2240 @echo "SIMPLE_PROGRAMS = $(SIMPLE_PROGRAMS)"
2241 @echo "LIBRARY = $(LIBRARY)"
2242 @echo "SHARED_LIBRARY = $(SHARED_LIBRARY)"
2243 @echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
2244 @echo "LIBS = $(LIBS)"
2245 @echo "DEF_FILE = $(DEF_FILE)"
2246 @echo "IMPORT_LIBRARY = $(IMPORT_LIBRARY)"
2247 @echo "STATIC_LIBS = $(STATIC_LIBS)"
2248 @echo "SHARED_LIBS = $(SHARED_LIBS)"
2249 @echo "EXTRA_DSO_LIBS = $(EXTRA_DSO_LIBS)"
2250 @echo "EXTRA_DSO_LDOPTS = $(EXTRA_DSO_LDOPTS)"
2251 @echo "DEPENDENT_LIBS = $(DEPENDENT_LIBS)"
2252 @echo --------------------------------------------------------------------------------
2253 endif
2254 $(LOOP_OVER_PARALLEL_DIRS)
2255 $(LOOP_OVER_DIRS)
2257 showbuild:
2258 @echo "MOZ_BUILD_ROOT = $(MOZ_BUILD_ROOT)"
2259 @echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
2260 @echo "CC = $(CC)"
2261 @echo "CXX = $(CXX)"
2262 @echo "CCC = $(CCC)"
2263 @echo "CPP = $(CPP)"
2264 @echo "LD = $(LD)"
2265 @echo "AR = $(AR)"
2266 @echo "IMPLIB = $(IMPLIB)"
2267 @echo "FILTER = $(FILTER)"
2268 @echo "MKSHLIB = $(MKSHLIB)"
2269 @echo "MKCSHLIB = $(MKCSHLIB)"
2270 @echo "RC = $(RC)"
2271 @echo "CFLAGS = $(CFLAGS)"
2272 @echo "OS_CFLAGS = $(OS_CFLAGS)"
2273 @echo "COMPILE_CFLAGS = $(COMPILE_CFLAGS)"
2274 @echo "CXXFLAGS = $(CXXFLAGS)"
2275 @echo "OS_CXXFLAGS = $(OS_CXXFLAGS)"
2276 @echo "COMPILE_CXXFLAGS = $(COMPILE_CXXFLAGS)"
2277 @echo "COMPILE_CMFLAGS = $(COMPILE_CMFLAGS)"
2278 @echo "COMPILE_CMMFLAGS = $(COMPILE_CMMFLAGS)"
2279 @echo "LDFLAGS = $(LDFLAGS)"
2280 @echo "OS_LDFLAGS = $(OS_LDFLAGS)"
2281 @echo "DSO_LDOPTS = $(DSO_LDOPTS)"
2282 @echo "OS_INCLUDES = $(OS_INCLUDES)"
2283 @echo "OS_LIBS = $(OS_LIBS)"
2284 @echo "EXTRA_LIBS = $(EXTRA_LIBS)"
2285 @echo "BIN_FLAGS = $(BIN_FLAGS)"
2286 @echo "INCLUDES = $(INCLUDES)"
2287 @echo "DEFINES = $(DEFINES)"
2288 @echo "ACDEFINES = $(ACDEFINES)"
2289 @echo "BIN_SUFFIX = $(BIN_SUFFIX)"
2290 @echo "LIB_SUFFIX = $(LIB_SUFFIX)"
2291 @echo "DLL_SUFFIX = $(DLL_SUFFIX)"
2292 @echo "IMPORT_LIB_SUFFIX = $(IMPORT_LIB_SUFFIX)"
2293 @echo "INSTALL = $(INSTALL)"
2295 showhost:
2296 @echo "HOST_CC = $(HOST_CC)"
2297 @echo "HOST_CXX = $(HOST_CXX)"
2298 @echo "HOST_CFLAGS = $(HOST_CFLAGS)"
2299 @echo "HOST_LDFLAGS = $(HOST_LDFLAGS)"
2300 @echo "HOST_LIBS = $(HOST_LIBS)"
2301 @echo "HOST_EXTRA_LIBS = $(HOST_EXTRA_LIBS)"
2302 @echo "HOST_EXTRA_DEPS = $(HOST_EXTRA_DEPS)"
2303 @echo "HOST_PROGRAM = $(HOST_PROGRAM)"
2304 @echo "HOST_OBJS = $(HOST_OBJS)"
2305 @echo "HOST_PROGOBJS = $(HOST_PROGOBJS)"
2306 @echo "HOST_LIBRARY = $(HOST_LIBRARY)"
2308 showbuildmods::
2309 @echo "Build Modules = $(BUILD_MODULES)"
2310 @echo "Module dirs = $(BUILD_MODULE_DIRS)"
2312 documentation:
2313 @cd $(DEPTH)
2314 $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
2316 ifdef ENABLE_TESTS
2317 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
2318 $(LOOP_OVER_PARALLEL_DIRS)
2319 $(LOOP_OVER_DIRS)
2320 $(LOOP_OVER_TOOL_DIRS)
2321 endif
2324 FREEZE_VARIABLES = \
2325 CSRCS \
2326 CPPSRCS \
2327 EXPORTS \
2328 XPIDLSRCS \
2329 DIRS \
2330 LIBRARY \
2331 MODULE \
2332 REQUIRES \
2333 SHORT_LIBNAME \
2334 TIERS \
2335 EXTRA_COMPONENTS \
2336 EXTRA_PP_COMPONENTS \
2337 $(NULL)
2339 $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
2341 CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
2342 $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
2344 libs export libs::
2345 $(CHECK_FROZEN_VARIABLES)
2347 default all::
2348 if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi