Bug 588735 - Mirror glass caption buttons for rtl windows. r=roc, a=blocking-betaN.
[mozilla-central.git] / config / rules.mk
blobfcb7709ba56745288e0b1c0962a563b0fef0cbd2
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,$(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 ifdef ENABLE_TESTS
149 ifdef XPCSHELL_TESTS
150 #ifndef MODULE
151 #$(error Must define MODULE when defining XPCSHELL_TESTS.)
152 #endif
154 testxpcobjdir = $(DEPTH)/_tests/xpcshell
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)
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
561 # Make sure to wrap static libs inside linker specific flags to turn on & off
562 # inclusion of all symbols inside the static libs
564 ifndef NO_LD_ARCHIVE_FLAGS
565 ifdef SHARED_LIBRARY_LIBS
566 EXTRA_DSO_LDOPTS := $(MKSHLIB_FORCE_ALL) $(call EXPAND_FAKELIBS,$(SHARED_LIBRARY_LIBS)) $(MKSHLIB_UNFORCE_ALL) $(EXTRA_DSO_LDOPTS)
567 endif
568 endif
571 # This will strip out symbols that the component should not be
572 # exporting from the .dynsym section.
574 ifdef IS_COMPONENT
575 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
576 endif # IS_COMPONENT
579 # Enforce the requirement that MODULE_NAME must be set
580 # for components in static builds
582 ifdef IS_COMPONENT
583 ifdef EXPORT_LIBRARY
584 ifndef FORCE_SHARED_LIB
585 ifndef MODULE_NAME
586 $(error MODULE_NAME is required for components which may be used in static builds)
587 endif
588 endif
589 endif
590 endif
593 # MacOS X specific stuff
596 ifeq ($(OS_ARCH),Darwin)
597 ifdef SHARED_LIBRARY
598 ifdef IS_COMPONENT
599 EXTRA_DSO_LDOPTS += -bundle
600 else
601 EXTRA_DSO_LDOPTS += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
602 endif
603 endif
604 endif
607 # On NetBSD a.out systems, use -Bsymbolic. This fixes what would otherwise be
608 # fatal symbol name clashes between components.
610 ifeq ($(OS_ARCH),NetBSD)
611 ifeq ($(DLL_SUFFIX),.so.1.0)
612 ifdef IS_COMPONENT
613 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
614 endif
615 endif
616 endif
618 ifeq ($(OS_ARCH),FreeBSD)
619 ifdef IS_COMPONENT
620 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
621 endif
622 endif
624 ifeq ($(OS_ARCH),NetBSD)
625 ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
626 ifeq ($(MODULE),layout)
627 OS_CFLAGS += -Wa,-xgot
628 OS_CXXFLAGS += -Wa,-xgot
629 endif
630 endif
631 endif
634 # HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
635 # which uses internal symbols first
637 ifeq ($(OS_ARCH),HP-UX)
638 ifdef IS_COMPONENT
639 ifeq ($(GNU_CC)$(GNU_CXX),)
640 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
641 ifneq ($(HAS_EXTRAEXPORTS),1)
642 MKSHLIB += -Wl,+eNSGetModule -Wl,+eerrno
643 MKCSHLIB += +eNSGetModule +eerrno
644 ifneq ($(OS_TEST),ia64)
645 MKSHLIB += -Wl,+e_shlInit
646 MKCSHLIB += +e_shlInit
647 endif # !ia64
648 endif # !HAS_EXTRAEXPORTS
649 endif # non-gnu compilers
650 endif # IS_COMPONENT
651 endif # HP-UX
653 ifeq ($(OS_ARCH),AIX)
654 ifdef IS_COMPONENT
655 ifneq ($(HAS_EXTRAEXPORTS),1)
656 MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
657 MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
658 endif # HAS_EXTRAEXPORTS
659 endif # IS_COMPONENT
660 endif # AIX
663 # OSF1: add -B symbolic flag for components
665 ifeq ($(OS_ARCH),OSF1)
666 ifdef IS_COMPONENT
667 ifeq ($(GNU_CC)$(GNU_CXX),)
668 EXTRA_DSO_LDOPTS += -B symbolic
669 endif
670 endif
671 endif
674 # Linux: add -Bsymbolic flag for components
676 ifeq ($(OS_ARCH),Linux)
677 ifdef IS_COMPONENT
678 EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
679 endif
680 endif
683 # GNU doesn't have path length limitation
686 ifeq ($(OS_ARCH),GNU)
687 OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
688 endif
691 # MINGW32
693 ifeq ($(OS_ARCH),WINNT)
694 ifdef GNU_CC
695 ifndef IS_COMPONENT
696 DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
697 endif
698 endif
699 endif
701 ifeq ($(USE_TVFS),1)
702 IFLAGS1 = -rb
703 IFLAGS2 = -rb
704 else
705 IFLAGS1 = -m 644
706 IFLAGS2 = -m 755
707 endif
709 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
710 OUTOPTION = -Fo# eol
711 else
712 OUTOPTION = -o # eol
713 endif # WINNT && !GNU_CC
714 ifneq (,$(filter WINCE,$(OS_ARCH)))
715 OUTOPTION = -Fo# eol
716 endif
718 ifeq ($(OS_ARCH), WINCE)
719 OUTOPTION = -Fo# eol
720 HOST_OUTOPTION = -Fo# eol
721 else
723 ifeq (,$(CROSS_COMPILE))
724 HOST_OUTOPTION = $(OUTOPTION)
725 else
726 HOST_OUTOPTION = -o # eol
727 endif
729 endif
730 ################################################################################
732 # SUBMAKEFILES: List of Makefiles for next level down.
733 # This is used to update or create the Makefiles before invoking them.
734 SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS) $(PARALLEL_DIRS))
736 # The root makefile doesn't want to do a plain export/libs, because
737 # of the tiers and because of libxul. Suppress the default rules in favor
738 # of something else. Makefiles which use this var *must* provide a sensible
739 # default rule before including rules.mk
740 ifndef SUPPRESS_DEFAULT_RULES
741 ifdef TIERS
742 default all alldep::
743 $(foreach tier,$(TIERS),$(call SUBMAKE,tier_$(tier)))
744 else
746 default all::
747 ifneq (,$(strip $(STATIC_DIRS)))
748 $(foreach dir,$(STATIC_DIRS),$(call SUBMAKE,,$(dir)))
749 endif
750 $(MAKE) export
751 $(MAKE) libs
752 $(MAKE) tools
754 # Do depend as well
755 alldep::
756 $(MAKE) export
757 $(MAKE) depend
758 $(MAKE) libs
759 $(MAKE) tools
761 endif # TIERS
762 endif # SUPPRESS_DEFAULT_RULES
764 ifeq ($(filter s,$(MAKEFLAGS)),)
765 ECHO := echo
766 QUIET :=
767 else
768 ECHO := true
769 QUIET := -q
770 endif
772 MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
774 export_tier_%:
775 @$(ECHO) "$@"
776 @$(MAKE_TIER_SUBMAKEFILES)
777 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,export,$(dir)))
779 libs_tier_%:
780 @$(ECHO) "$@"
781 @$(MAKE_TIER_SUBMAKEFILES)
782 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,libs,$(dir)))
784 tools_tier_%:
785 @$(ECHO) "$@"
786 @$(MAKE_TIER_SUBMAKEFILES)
787 $(foreach dir,$(tier_$*_dirs),$(call SUBMAKE,tools,$(dir)))
789 $(foreach tier,$(TIERS),tier_$(tier))::
790 @$(ECHO) "$@: $($@_staticdirs) $($@_dirs)"
791 $(foreach dir,$($@_staticdirs),$(call SUBMAKE,,$(dir)))
792 $(MAKE) export_$@
793 $(MAKE) libs_$@
794 $(MAKE) tools_$@
796 # Do everything from scratch
797 everything::
798 $(MAKE) clean
799 $(MAKE) alldep
801 # Add dummy depend target for tinderboxes
802 depend::
804 # Target to only regenerate makefiles
805 makefiles: $(SUBMAKEFILES)
806 ifneq (,$(DIRS)$(TOOL_DIRS)$(PARALLEL_DIRS))
807 $(LOOP_OVER_PARALLEL_DIRS)
808 $(LOOP_OVER_DIRS)
809 $(LOOP_OVER_TOOL_DIRS)
810 endif
812 ifdef PARALLEL_DIRS
813 export:: $(PARALLEL_DIRS_export)
815 $(PARALLEL_DIRS_export): %_export: %/Makefile
816 +@$(call SUBMAKE,export,$*)
817 endif
819 export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(XPIDLSRCS),$(IDL_DIR))
820 $(LOOP_OVER_DIRS)
821 $(LOOP_OVER_TOOL_DIRS)
823 ifdef PARALLEL_DIRS
824 tools:: $(PARALLEL_DIRS_tools)
826 $(PARALLEL_DIRS_tools): %_tools: %/Makefile
827 +@$(call SUBMAKE,tools,$*)
828 endif
830 tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
831 $(LOOP_OVER_DIRS)
832 ifneq (,$(strip $(TOOL_DIRS)))
833 $(foreach dir,$(TOOL_DIRS),$(call SUBMAKE,libs,$(dir)))
834 endif
837 # Rule to create list of libraries for final link
839 export::
840 ifdef LIBRARY_NAME
841 ifdef EXPORT_LIBRARY
842 ifdef IS_COMPONENT
843 ifdef BUILD_STATIC_LIBS
844 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMPS) $(STATIC_LIBRARY_NAME)
845 ifdef MODULE_NAME
846 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
847 endif
848 endif # BUILD_STATIC_LIBS
849 else # !IS_COMPONENT
850 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_LINK_LIBS) $(STATIC_LIBRARY_NAME)
851 endif # IS_COMPONENT
852 endif # EXPORT_LIBRARY
853 endif # LIBRARY_NAME
855 # Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
856 LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
857 HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
858 DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
860 ifndef _LIBNAME_RELATIVE_PATHS
862 LIBS_DEPS += $(filter -l%, $(LIBS))
863 HOST_LIBS_DEPS += $(filter -l%, $(HOST_LIBS))
864 DSO_LDOPTS_DEPS += $(filter -l%, $(EXTRA_DSO_LDOPTS))
866 _LIBDIRS = $(patsubst -L%,%,$(filter -L%, $(LIBS) $(HOST_LIBS) $(EXTRA_DSO_LDOPTS)))
867 ifneq (,$(_LIBDIRS))
868 vpath $(LIB_PREFIX)%.$(LIB_SUFFIX) $(_LIBDIRS)
869 ifdef IMPORT_LIB_SUFFIX
870 vpath $(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX) $(_LIBDIRS)
871 endif # IMPORT_LIB_SUFFIX
872 vpath $(DLL_PREFIX)%$(DLL_SUFFIX) $(_LIBDIRS)
873 endif # _LIBDIRS
875 endif # _LIBNAME_RELATIVE_PATHS
877 # Dependancies which, if modified, should cause everything to rebuild
878 GLOBAL_DEPS += Makefile Makefile.in $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk
880 ##############################################
881 ifdef PARALLEL_DIRS
882 libs:: $(PARALLEL_DIRS_libs)
884 $(PARALLEL_DIRS_libs): %_libs: %/Makefile
885 +@$(call SUBMAKE,libs,$*)
886 endif
888 libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
889 ifndef NO_DIST_INSTALL
890 ifdef LIBRARY
891 ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
892 ifdef IS_COMPONENT
893 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(FAKE_LIBRARY) $(DEPTH)/staticlib/components
894 else
895 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(FAKE_LIBRARY) $(DEPTH)/staticlib
896 endif
897 endif # EXPORT_LIBRARY
898 ifdef DIST_INSTALL
899 ifdef IS_COMPONENT
900 $(error Shipping static component libs makes no sense.)
901 else
902 $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib
903 endif
904 endif # DIST_INSTALL
905 endif # LIBRARY
906 ifdef SHARED_LIBRARY
907 ifdef IS_COMPONENT
908 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
909 $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
910 ifndef NO_COMPONENTS_MANIFEST
911 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest"
912 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)"
913 endif
914 ifdef BEOS_ADDON_WORKAROUND
915 ( cd $(FINAL_TARGET)/components && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
916 endif
917 else # ! IS_COMPONENT
918 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
919 $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
920 else
921 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
922 endif
923 $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
924 ifdef BEOS_ADDON_WORKAROUND
925 ( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
926 endif
927 endif # IS_COMPONENT
928 endif # SHARED_LIBRARY
929 ifdef PROGRAM
930 $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET)
931 endif
932 ifdef SIMPLE_PROGRAMS
933 $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET)
934 endif
935 ifdef HOST_PROGRAM
936 $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin
937 endif
938 ifdef HOST_SIMPLE_PROGRAMS
939 $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin
940 endif
941 ifdef HOST_LIBRARY
942 $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib
943 endif
944 ifdef JAVA_LIBRARY
945 ifdef IS_COMPONENT
946 $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components
947 else
948 $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)
949 endif
950 endif # JAVA_LIBRARY
951 endif # !NO_DIST_INSTALL
952 $(LOOP_OVER_DIRS)
954 ##############################################
956 ifndef NO_PROFILE_GUIDED_OPTIMIZE
957 ifdef MOZ_PROFILE_USE
958 ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
959 # When building with PGO, we have to make sure to re-link
960 # in the MOZ_PROFILE_USE phase if we linked in the
961 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
962 # file in the link rule in the GENERATE phase to indicate
963 # that we need a relink.
964 ifdef SHARED_LIBRARY
965 $(SHARED_LIBRARY): pgo.relink
966 endif
967 ifdef PROGRAM
968 $(PROGRAM): pgo.relink
969 endif
971 # In the second pass, we need to merge the pgc files into the pgd file.
972 # The compiler would do this for us automatically if they were in the right
973 # place, but they're in dist/bin.
974 ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
975 export::
976 ifdef PROGRAM
977 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
978 $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
979 endif
980 ifdef SHARED_LIBRARY
981 $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
982 $(SHARED_LIBRARY_NAME) $(DIST)/bin
983 endif
984 endif # SHARED_LIBRARY || PROGRAM
985 endif # WINNT_
986 endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
987 endif # NO_PROFILE_GUIDED_OPTIMIZE
989 ##############################################
991 checkout:
992 $(MAKE) -C $(topsrcdir) -f client.mk checkout
994 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
995 -rm -f $(ALL_TRASH)
996 -rm -rf $(ALL_TRASH_DIRS)
997 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
999 distclean:: $(SUBMAKEFILES)
1000 $(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
1001 -rm -rf $(ALL_TRASH_DIRS)
1002 -rm -f $(ALL_TRASH) \
1003 Makefile .HSancillary \
1004 $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
1005 $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
1006 $(wildcard *.$(IMPORT_LIB_SUFFIX))
1007 ifeq ($(OS_ARCH),OS2)
1008 -rm -f $(PROGRAM:.exe=.map)
1009 endif
1011 alltags:
1012 rm -f TAGS
1013 find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
1016 # PROGRAM = Foo
1017 # creates OBJS, links with LIBS to create Foo
1019 $(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) $(GLOBAL_DEPS)
1020 @rm -f $@.manifest
1021 ifeq (WINCE,$(OS_ARCH))
1022 $(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1023 else
1024 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1025 $(LD) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1026 ifdef MSMANIFEST_TOOL
1027 @if test -f $@.manifest; then \
1028 if test -f "$(srcdir)/$@.manifest"; then \
1029 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
1030 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
1031 else \
1032 echo "Embedding manifest from $@.manifest"; \
1033 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1034 fi; \
1035 elif test -f "$(srcdir)/$@.manifest"; then \
1036 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
1037 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
1039 endif # MSVC with manifest tool
1040 ifdef MOZ_PROFILE_GENERATE
1041 # touch it a few seconds into the future to work around FAT's
1042 # 2-second granularity
1043 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
1044 endif
1045 else # !WINNT || GNU_CC
1046 ifeq ($(CPP_PROG_LINK),1)
1047 $(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)
1048 else # ! CPP_PROG_LINK
1049 $(CC) -o $@ $(CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(call EXPAND_FAKELIBS,$(LIBS) $(OS_LIBS) $(EXTRA_LIBS)) $(BIN_FLAGS) $(EXE_DEF_FILE)
1050 endif # CPP_PROG_LINK
1051 endif # WINNT && !GNU_CC
1052 endif # WINCE
1054 ifdef ENABLE_STRIP
1055 $(STRIP) $@
1056 endif
1057 ifdef MOZ_POST_PROGRAM_COMMAND
1058 $(MOZ_POST_PROGRAM_COMMAND) $@
1059 endif
1060 ifeq ($(OS_ARCH),BeOS)
1061 ifdef BEOS_PROGRAM_RESOURCE
1062 xres -o $@ $(BEOS_PROGRAM_RESOURCE)
1063 mimeset $@
1064 endif
1065 endif # BeOS
1067 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
1068 ifeq (WINCE,$(OS_ARCH))
1069 $(HOST_LD) -NOLOGO -OUT:$@ $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1070 else
1071 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
1072 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1073 ifdef MSMANIFEST_TOOL
1074 @if test -f $@.manifest; then \
1075 if test -f "$(srcdir)/$@.manifest"; then \
1076 echo "Embedding manifest from $(srcdir)/$@.manifest and $@.manifest"; \
1077 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
1078 else \
1079 echo "Embedding manifest from $@.manifest"; \
1080 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1081 fi; \
1082 elif test -f "$(srcdir)/$@.manifest"; then \
1083 echo "Embedding manifest from $(srcdir)/$@.manifest"; \
1084 mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" -OUTPUTRESOURCE:$@\;1; \
1086 endif # MSVC with manifest tool
1087 else
1088 ifeq ($(CPP_PROG_LINK),1)
1089 $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1090 else
1091 $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1092 endif # CPP_PROG_LINK
1093 endif
1094 endif
1097 # This is an attempt to support generation of multiple binaries
1098 # in one directory, it assumes everything to compile Foo is in
1099 # Foo.o (from either Foo.c or Foo.cpp).
1101 # SIMPLE_PROGRAMS = Foo Bar
1102 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
1104 $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(LIBS_DEPS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
1105 ifeq (WINCE,$(OS_ARCH))
1106 $(LD) -nologo -entry:mainACRTStartup -out:$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1107 else
1108 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1109 $(LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(call EXPAND_FAKELIBS,$(LIBS) $(EXTRA_LIBS) $(OS_LIBS))
1110 ifdef MSMANIFEST_TOOL
1111 @if test -f $@.manifest; then \
1112 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
1113 rm -f $@.manifest; \
1115 endif # MSVC with manifest tool
1116 else
1117 ifeq ($(CPP_PROG_LINK),1)
1118 $(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)
1119 else
1120 $(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)
1121 endif # CPP_PROG_LINK
1122 endif # WINNT && !GNU_CC
1123 endif # WINCE
1125 ifdef ENABLE_STRIP
1126 $(STRIP) $@
1127 endif
1128 ifdef MOZ_POST_PROGRAM_COMMAND
1129 $(MOZ_POST_PROGRAM_COMMAND) $@
1130 endif
1132 $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
1133 ifeq (WINCE,$(OS_ARCH))
1134 $(HOST_LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1135 else
1136 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
1137 $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1138 else
1139 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
1140 $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1141 else
1142 $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
1143 endif
1144 endif
1145 endif
1148 # Purify target. Solaris/sparc only to start.
1149 # Purify does not recognize "egcs" or "c++" so we go with
1150 # "gcc" and "g++" for now.
1152 pure: $(PROGRAM)
1153 ifeq ($(CPP_PROG_LINK),1)
1154 $(PURIFY) $(CCC) -o $^.pure $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1155 else
1156 $(PURIFY) $(CC) -o $^.pure $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1157 endif
1158 ifndef NO_DIST_INSTALL
1159 $(INSTALL) $(IFLAGS2) $^.pure $(FINAL_TARGET)
1160 endif
1162 quantify: $(PROGRAM)
1163 ifeq ($(CPP_PROG_LINK),1)
1164 $(QUANTIFY) $(CCC) -o $^.quantify $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1165 else
1166 $(QUANTIFY) $(CC) -o $^.quantify $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1167 endif
1168 ifndef NO_DIST_INSTALL
1169 $(INSTALL) $(IFLAGS2) $^.quantify $(FINAL_TARGET)
1170 endif
1173 # This allows us to create static versions of the shared libraries
1174 # that are built using other static libraries. Confused...?
1176 ifdef SHARED_LIBRARY_LIBS
1177 ifeq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1178 ifneq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
1179 LOBJS += $(SHARED_LIBRARY_LIBS)
1180 endif
1181 else
1182 NONFAKE_SHARED_LIBRARY_LIBS = $(filter-out %.fake,$(call EXPAND_FAKELIBS,$(SHARED_LIBRARY_LIBS)))
1183 ifeq (,$(NONFAKE_SHARED_LIBRARY_LIBS))
1184 # All of our SHARED_LIBRARY_LIBS have fake equivalents. Score!
1185 # Just pass the original object files around.
1186 # For shared libraries, these are already included in EXTRA_DSO_LDOPTS
1187 # above.
1188 ifndef SHARED_LIBRARY
1189 LOBJS += $(shell cat $(addsuffix .fake,$(SHARED_LIBRARY_LIBS)))
1190 endif
1191 SKIP_SUB_LOBJS := 1
1192 else
1193 ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH)))
1194 CLEANUP1 := | egrep -v '(________64ELEL_|__.SYMDEF)'
1195 CLEANUP2 := rm -f ________64ELEL_ __.SYMDEF
1196 else
1197 CLEANUP2 := true
1198 endif
1199 SUB_LOBJS = $(shell for lib in $(SHARED_LIBRARY_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1200 endif # EXPAND_FAKELIBS
1201 endif # SHARED_LIBARY_LIBS
1202 endif
1203 ifdef MOZILLA_PROBE_LIBS
1204 PROBE_LOBJS = $(shell for lib in $(MOZILLA_PROBE_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1205 endif
1206 ifdef DTRACE_PROBE_OBJ
1207 EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
1208 endif
1210 $(LIBRARY): $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
1211 rm -f $@
1212 ifndef SKIP_SUB_LOBJS
1213 ifneq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1214 ifdef SHARED_LIBRARY_LIBS
1215 @rm -f $(SUB_LOBJS)
1216 @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1217 endif
1218 endif
1219 endif # SKIP_SUB_LOBJS
1220 $(AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SUB_LOBJS)
1221 $(RANLIB) $@
1222 ifndef MOZ_FAKELIBS
1223 # Don't clean these up if we're building a fake lib, because then
1224 # we'll reference nonexistent object files in our fake lib.
1225 @rm -f foodummyfilefoo $(SUB_LOBJS)
1226 endif
1227 # Also produce a .fake file that just contains the names of the object files.
1228 # This can be used as a response file to the linker later instead of
1229 # linking the actual static library.
1230 ifdef MOZ_FAKELIBS
1231 ifndef SUPPRESS_FAKELIB
1232 ifeq (WINNT_,$(HOST_OS_ARCH)_$(.PYMAKE))
1233 echo "$(strip $(foreach f,$(OBJS) $(SEPARATE_OBJS) $(LOBJS) $(SUB_LOBJS),$(subst \,\\,$(call core_winabspath,$(f))))) " > $@.fake
1234 else
1235 echo "$(strip $(foreach f,$(OBJS) $(SEPARATE_OBJS) $(LOBJS) $(SUB_LOBJS),$(call core_abspath,$(f)))) " > $@.fake
1236 endif
1237 endif
1238 endif
1240 ifeq (,$(filter-out WINNT WINCE, $(OS_ARCH)))
1241 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1242 endif
1244 ifeq ($(OS_ARCH),OS2)
1245 $(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
1246 rm -f $@
1247 echo LIBRARY $(SHARED_LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
1248 echo PROTMODE >> $@
1249 echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@
1250 echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
1251 echo EXPORTS >> $@
1252 ifeq ($(IS_COMPONENT),1)
1253 ifeq ($(HAS_EXTRAEXPORTS),1)
1254 ifndef MOZ_OS2_USE_DECLSPEC
1255 $(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
1256 endif
1257 else
1258 echo _NSModule >> $@
1259 endif
1260 else
1261 ifndef MOZ_OS2_USE_DECLSPEC
1262 $(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
1263 endif
1264 endif
1265 $(ADD_TO_DEF_FILE)
1267 ifdef MOZ_OS2_USE_DECLSPEC
1268 $(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1269 else
1270 $(IMPORT_LIBRARY): $(DEF_FILE)
1271 endif
1272 rm -f $@
1273 $(IMPLIB) $@ $^
1274 $(RANLIB) $@
1275 endif # OS/2
1277 $(HOST_LIBRARY): $(HOST_OBJS) Makefile
1278 rm -f $@
1279 $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
1280 $(HOST_RANLIB) $@
1282 ifdef NO_LD_ARCHIVE_FLAGS
1283 SUB_SHLOBJS = $(SUB_LOBJS)
1284 endif
1286 ifdef HAVE_DTRACE
1287 ifndef XP_MACOSX
1288 ifdef DTRACE_PROBE_OBJ
1289 ifndef DTRACE_LIB_DEPENDENT
1290 $(DTRACE_PROBE_OBJ): $(OBJS)
1291 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
1292 endif
1293 endif
1294 endif
1295 endif
1297 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
1298 # so instead of deleting .o files after repacking them into a dylib, we make
1299 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
1300 # so no need to conditionalize on OS version or debugging format.
1302 $(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(LIBRARY) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) $(GLOBAL_DEPS)
1303 ifndef INCREMENTAL_LINKER
1304 rm -f $@
1305 endif
1306 ifeq ($(OS_ARCH),OpenVMS)
1307 @if test ! -f $(VMS_SYMVEC_FILE); then \
1308 if test -f $(VMS_SYMVEC_FILE_MODULE); then \
1309 echo Creating specific component options file $(VMS_SYMVEC_FILE); \
1310 cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
1311 fi; \
1313 ifdef IS_COMPONENT
1314 @if test ! -f $(VMS_SYMVEC_FILE); then \
1315 echo Creating generic component options file $(VMS_SYMVEC_FILE); \
1316 cp $(VMS_SYMVEC_FILE_COMP) $(VMS_SYMVEC_FILE); \
1318 endif
1319 endif # OpenVMS
1320 ifdef NO_LD_ARCHIVE_FLAGS
1321 ifdef SHARED_LIBRARY_LIBS
1322 @rm -f $(SUB_SHLOBJS)
1323 @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1324 ifeq ($(OS_ARCH),Darwin)
1325 @echo Making symlinks to the original object files in the archive libraries $(SHARED_LIBRARY_LIBS)
1326 @for lib in $(SHARED_LIBRARY_LIBS); do \
1327 libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
1328 ofiles=`$(AR_LIST) $${lib}`; \
1329 for ofile in $$ofiles; do \
1330 if [ -f $$libdir/$$ofile ]; then \
1331 rm -f $$ofile; \
1332 ln -s $$libdir/$$ofile $$ofile; \
1333 fi; \
1334 done; \
1335 done
1336 endif
1337 endif # SHARED_LIBRARY_LIBS
1338 endif # NO_LD_ARCHIVE_FLAGS
1339 ifdef DTRACE_LIB_DEPENDENT
1340 @rm -f $(PROBE_LOBJS)
1341 @for lib in $(MOZILLA_PROBE_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1342 ifndef XP_MACOSX
1343 dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS)
1344 endif
1345 @for lib in $(MOZILLA_PROBE_LIBS); do \
1346 ofiles=`$(AR_LIST) $${lib}`; \
1347 $(AR_DELETE) $${lib} $$ofiles; \
1348 done
1349 $(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)
1350 @rm -f $(PROBE_LOBJS)
1351 @rm -f $(DTRACE_PROBE_OBJ)
1352 @for lib in $(MOZILLA_PROBE_LIBS); do \
1353 if [ -L $${lib} ]; then rm -f `readlink $${lib}`; fi; \
1354 done
1355 @rm -f $(MOZILLA_PROBE_LIBS)
1357 else # ! DTRACE_LIB_DEPENDENT
1358 $(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)
1359 endif # DTRACE_LIB_DEPENDENT
1361 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1362 ifdef MSMANIFEST_TOOL
1363 ifdef EMBED_MANIFEST_AT
1364 @if test -f $@.manifest; then \
1365 mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
1366 rm -f $@.manifest; \
1368 endif # EMBED_MANIFEST_AT
1369 endif # MSVC with manifest tool
1370 ifdef MOZ_PROFILE_GENERATE
1371 touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
1372 endif
1373 endif # WINNT && !GCC
1374 ifneq ($(OS_ARCH),Darwin)
1375 @rm -f $(SUB_SHLOBJS)
1376 endif # Darwin
1377 @rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
1378 chmod +x $@
1379 ifdef ENABLE_STRIP
1380 $(STRIP) $@
1381 endif
1382 ifdef MOZ_POST_DSO_LIB_COMMAND
1383 $(MOZ_POST_DSO_LIB_COMMAND) $@
1384 endif
1386 ifdef MOZ_AUTO_DEPS
1387 ifdef COMPILER_DEPEND
1388 ifeq ($(SOLARIS_SUNPRO_CC),1)
1389 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1391 define MAKE_DEPS_AUTO_CC
1392 if test -d $(@D); then \
1393 echo "Building deps for $< using Sun Studio cc"; \
1394 $(CC) $(COMPILE_CFLAGS) -xM $< >$(_MDDEPFILE) ; \
1396 endef
1397 define MAKE_DEPS_AUTO_CXX
1398 if test -d $(@D); then \
1399 echo "Building deps for $< using Sun Studio CC"; \
1400 $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
1402 endef
1403 endif # Sun Studio on Solaris
1404 else # COMPILER_DEPEND
1406 # Generate dependencies on the fly
1408 _MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1410 define MAKE_DEPS_AUTO
1411 if test -d $(@D); then \
1412 echo "Building deps for $<"; \
1413 $(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
1415 endef
1417 MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
1418 MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
1420 endif # COMPILER_DEPEND
1422 endif # MOZ_AUTO_DEPS
1424 # Rules for building native targets must come first because of the host_ prefix
1425 host_%.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
1426 $(REPORT_BUILD)
1427 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1429 host_%.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
1430 $(REPORT_BUILD)
1431 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1433 host_%.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
1434 $(REPORT_BUILD)
1435 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1437 host_%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
1438 $(REPORT_BUILD)
1439 $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1441 host_%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
1442 $(REPORT_BUILD)
1443 $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1445 %:: %.c $(GLOBAL_DEPS)
1446 $(REPORT_BUILD)
1447 @$(MAKE_DEPS_AUTO_CC)
1448 $(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
1450 %.$(OBJ_SUFFIX): %.c $(GLOBAL_DEPS)
1451 $(REPORT_BUILD)
1452 @$(MAKE_DEPS_AUTO_CC)
1453 $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1455 # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
1456 # 'moc' only knows about #defines it gets on the command line (-D...), not in
1457 # included headers like mozilla-config.h
1458 moc_%.cpp: %.h $(GLOBAL_DEPS)
1459 $(MOC) $(DEFINES) $(ACDEFINES) $< $(OUTOPTION)$@
1461 moc_%.cc: %.cc $(GLOBAL_DEPS)
1462 $(REPORT_BUILD)
1463 $(ELOG) $(MOC) $(DEFINES) $(ACDEFINES) $(_VPATH_SRCS:.cc=.h) $(OUTOPTION)$@
1465 ifdef ASFILES
1466 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
1467 # a '-c' flag.
1468 %.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) $(GLOBAL_DEPS)
1469 $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
1470 endif
1472 %.$(OBJ_SUFFIX): %.S $(GLOBAL_DEPS)
1473 $(AS) -o $@ $(ASFLAGS) -c $<
1475 %:: %.cpp $(GLOBAL_DEPS)
1476 @$(MAKE_DEPS_AUTO_CXX)
1477 $(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
1480 # Please keep the next two rules in sync.
1482 %.$(OBJ_SUFFIX): %.cc $(GLOBAL_DEPS)
1483 $(REPORT_BUILD)
1484 @$(MAKE_DEPS_AUTO_CXX)
1485 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1487 %.$(OBJ_SUFFIX): %.cpp $(GLOBAL_DEPS)
1488 $(REPORT_BUILD)
1489 @$(MAKE_DEPS_AUTO_CXX)
1490 ifdef STRICT_CPLUSPLUS_SUFFIX
1491 echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
1492 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
1493 rm -f t_$*.cc
1494 else
1495 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1496 endif #STRICT_CPLUSPLUS_SUFFIX
1498 $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm $(GLOBAL_DEPS)
1499 $(REPORT_BUILD)
1500 @$(MAKE_DEPS_AUTO_CXX)
1501 $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
1503 $(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m $(GLOBAL_DEPS)
1504 $(REPORT_BUILD)
1505 @$(MAKE_DEPS_AUTO_CC)
1506 $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
1508 %.s: %.cpp
1509 $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1511 %.s: %.cc
1512 $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1514 %.s: %.c
1515 $(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1517 %.i: %.cpp
1518 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1520 %.i: %.cc
1521 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1523 %.i: %.c
1524 $(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
1526 %.i: %.mm
1527 $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
1529 %.res: %.rc
1530 @echo Creating Resource file: $@
1531 ifeq ($(OS_ARCH),OS2)
1532 $(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
1533 else
1534 ifdef GNU_CC
1535 $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
1536 else
1537 $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
1538 endif
1539 endif
1541 # need 3 separate lines for OS/2
1542 %:: %.pl
1543 rm -f $@
1544 cp $< $@
1545 chmod +x $@
1547 %:: %.sh
1548 rm -f $@; cp $< $@; chmod +x $@
1550 # Cancel these implicit rules
1552 %: %,v
1554 %: RCS/%,v
1556 %: s.%
1558 %: SCCS/s.%
1560 ###############################################################################
1561 # Java rules
1562 ###############################################################################
1563 ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
1564 SEP := ;
1565 else
1566 SEP := :
1567 endif
1569 EMPTY :=
1570 SPACE := $(EMPTY) $(EMPTY)
1572 # Cygwin and MSYS have their own special path form, but javac expects the source
1573 # and class paths to be in the DOS form (i.e. e:/builds/...). This function
1574 # does the appropriate conversion on Windows, but is a noop on other systems.
1575 ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
1576 ifdef CYGWIN_WRAPPER
1577 normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
1578 else
1579 # assume MSYS
1580 # We use 'pwd -W' to get DOS form of the path. However, since the given path
1581 # could be a file or a nonexistent path, we cannot call 'pwd -W' directly
1582 # on the path. Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
1583 # on it, then merge with the rest of the path.
1584 root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
1585 non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
1586 normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
1587 endif
1588 else
1589 normalizepath = $(1)
1590 endif
1592 _srcdir = $(call normalizepath,$(srcdir))
1593 ifdef JAVA_SOURCEPATH
1594 SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
1595 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
1596 else
1597 _JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
1598 endif
1600 ifdef JAVA_CLASSPATH
1601 CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
1602 _JAVA_CLASSPATH = ".$(SEP)$(CP)"
1603 else
1604 _JAVA_CLASSPATH = .
1605 endif
1607 _JAVA_DIR = _java
1608 $(_JAVA_DIR)::
1609 $(NSINSTALL) -D $@
1611 $(_JAVA_DIR)/%.class: %.java $(GLOBAL_DEPS) $(_JAVA_DIR)
1612 $(CYGWIN_WRAPPER) $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
1613 -sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
1615 $(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) $(GLOBAL_DEPS)
1616 $(JAR) cf $@ -C $(_JAVA_DIR) .
1618 GARBAGE_DIRS += $(_JAVA_DIR)
1620 ###############################################################################
1621 # Update Makefiles
1622 ###############################################################################
1624 # In GNU make 3.80, makefiles must use the /cygdrive syntax, even if we're
1625 # processing them with AS perl. See bug 232003
1626 ifdef AS_PERL
1627 CYGWIN_TOPSRCDIR = -nowrap -p $(topsrcdir) -wrap
1628 endif
1630 # Note: Passing depth to make-makefile is optional.
1631 # It saves the script some work, though.
1632 Makefile: Makefile.in
1633 @$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR)
1635 ifdef SUBMAKEFILES
1636 # VPATH does not work on some machines in this case, so add $(srcdir)
1637 $(SUBMAKEFILES): % : $(srcdir)/%.in
1638 $(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $@
1639 endif
1641 ifdef AUTOUPDATE_CONFIGURE
1642 $(topsrcdir)/configure: $(topsrcdir)/configure.in
1643 (cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
1644 endif
1646 ###############################################################################
1647 # Bunch of things that extend the 'export' rule (in order):
1648 ###############################################################################
1650 ################################################################################
1651 # Copy each element of EXPORTS to $(DIST)/include
1653 ifdef MOZ_JAVAXPCOM
1654 ifneq ($(XPIDLSRCS),)
1655 $(JAVA_DIST_DIR)::
1656 $(NSINSTALL) -D $@
1657 endif
1658 endif
1660 ifneq ($(XPI_NAME),)
1661 $(FINAL_TARGET):
1662 $(NSINSTALL) -D $@
1664 export:: $(FINAL_TARGET)
1665 endif
1667 ifndef NO_DIST_INSTALL
1668 ifneq (,$(EXPORTS))
1669 export:: $(EXPORTS)
1670 $(INSTALL) $(IFLAGS1) $^ $(DIST)/include
1671 endif
1672 endif # NO_DIST_INSTALL
1674 define EXPORT_NAMESPACE_RULE
1675 ifndef NO_DIST_INSTALL
1676 export:: $(EXPORTS_$(namespace))
1677 $(INSTALL) $(IFLAGS1) $$^ $(DIST)/include/$(namespace)
1678 endif # NO_DIST_INSTALL
1679 endef
1681 $(foreach namespace,$(EXPORTS_NAMESPACES),$(eval $(EXPORT_NAMESPACE_RULE)))
1683 ################################################################################
1684 # Copy each element of PREF_JS_EXPORTS
1686 ifdef GRE_MODULE
1687 PREF_DIR = greprefs
1688 else
1689 ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
1690 PREF_DIR = defaults/preferences
1691 else
1692 PREF_DIR = defaults/pref
1693 endif
1694 endif
1696 ifneq ($(PREF_JS_EXPORTS),)
1697 # on win32, pref files need CRLF line endings... see bug 206029
1698 ifeq (WINNT,$(OS_ARCH))
1699 PREF_PPFLAGS = --line-endings=crlf
1700 endif
1702 ifndef NO_DIST_INSTALL
1703 $(FINAL_TARGET)/$(PREF_DIR):
1704 $(NSINSTALL) -D $@
1706 libs:: $(FINAL_TARGET)/$(PREF_DIR) $(PREF_JS_EXPORTS)
1707 $(EXIT_ON_ERROR) \
1708 for i in $(PREF_JS_EXPORTS); do \
1709 dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
1710 $(RM) -f $$dest; \
1711 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1712 done
1713 endif
1714 endif
1716 ################################################################################
1717 # Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
1719 ifneq ($(AUTOCFG_JS_EXPORTS),)
1720 $(FINAL_TARGET)/defaults/autoconfig::
1721 $(NSINSTALL) -D $@
1723 ifndef NO_DIST_INSTALL
1724 export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
1725 $(INSTALL) $(IFLAGS1) $^
1726 endif
1728 endif
1729 ################################################################################
1730 # Export the elements of $(XPIDLSRCS)
1731 # generating .h and .xpt files and moving them to the appropriate places.
1733 ifneq ($(XPIDLSRCS),)
1735 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
1737 ifndef XPIDL_MODULE
1738 XPIDL_MODULE = $(MODULE)
1739 endif
1741 ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
1742 export:: FORCE
1743 @echo
1744 @echo "*** Error processing XPIDLSRCS:"
1745 @echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
1746 @echo "so we have a module name to use when creating MODULE.xpt."
1747 @echo; sleep 2; false
1748 endif
1750 $(IDL_DIR)::
1751 $(NSINSTALL) -D $@
1753 # generate .h files from into $(XPIDL_GEN_DIR), then export to $(DIST)/include;
1754 # warn against overriding existing .h file.
1755 $(XPIDL_GEN_DIR)/.done:
1756 @if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
1757 @touch $@
1759 # don't depend on $(XPIDL_GEN_DIR), because the modification date changes
1760 # with any addition to the directory, regenerating all .h files -> everything.
1762 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1763 $(REPORT_BUILD)
1764 $(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
1765 @if test -n "$(findstring $*.h, $(EXPORTS))"; \
1766 then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
1768 ifndef NO_GEN_XPT
1769 # generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
1770 # into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
1771 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1772 $(REPORT_BUILD)
1773 $(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
1775 # no need to link together if XPIDLSRCS contains only XPIDL_MODULE
1776 ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
1777 $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS)) $(GLOBAL_DEPS) $(XPIDL_LINK)
1778 $(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS))
1779 endif # XPIDL_MODULE.xpt != XPIDLSRCS
1781 libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
1782 ifndef NO_DIST_INSTALL
1783 $(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
1784 ifndef NO_INTERFACES_MANIFEST
1785 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
1786 @$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
1787 endif
1788 endif
1790 endif # NO_GEN_XPT
1792 GARBAGE_DIRS += $(XPIDL_GEN_DIR)
1794 endif # XPIDLSRCS
1796 ifneq ($(XPIDLSRCS),)
1797 # export .idl files to $(IDL_DIR)
1798 ifndef NO_DIST_INSTALL
1799 export:: $(XPIDLSRCS) $(IDL_DIR)
1800 $(INSTALL) $(IFLAGS1) $^
1802 export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(DIST)/include
1803 $(INSTALL) $(IFLAGS1) $^
1804 endif # NO_DIST_INSTALL
1806 endif # XPIDLSRCS
1811 # General rules for exporting idl files.
1813 # WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
1814 # Bug to fix idl dependency problems w/o this extra build pass is
1815 # http://bugzilla.mozilla.org/show_bug.cgi?id=145777
1817 $(IDL_DIR)::
1818 $(NSINSTALL) -D $@
1820 export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
1822 ifneq ($(XPIDLSRCS),)
1823 ifndef NO_DIST_INSTALL
1824 export-idl:: $(XPIDLSRCS) $(IDL_DIR)
1825 $(INSTALL) $(IFLAGS1) $^
1826 endif
1827 endif
1828 $(LOOP_OVER_PARALLEL_DIRS)
1829 $(LOOP_OVER_DIRS)
1830 $(LOOP_OVER_TOOL_DIRS)
1832 ifdef MOZ_JAVAXPCOM
1833 ifneq ($(XPIDLSRCS),)
1835 JAVA_XPIDLSRCS = $(XPIDLSRCS)
1837 # A single IDL file can contain multiple interfaces, which result in multiple
1838 # Java interface files. So use hidden dependency files.
1839 JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
1841 $(JAVA_GEN_DIR):
1842 $(NSINSTALL) -D $@
1843 GARBAGE_DIRS += $(JAVA_GEN_DIR)
1845 # generate .java files into _javagen/[package name dirs]
1846 _JAVA_GEN_DIR = $(JAVA_GEN_DIR)/$(JAVA_IFACES_PKG_NAME)
1847 $(_JAVA_GEN_DIR):
1848 $(NSINSTALL) -D $@
1850 $(JAVA_GEN_DIR)/.%.java.pp: %.idl $(XPIDL_COMPILE) $(_JAVA_GEN_DIR)
1851 $(REPORT_BUILD)
1852 $(ELOG) $(XPIDL_COMPILE) -m java -w $(XPIDL_FLAGS) -I$(srcdir) -I$(IDL_DIR) -o $(_JAVA_GEN_DIR)/$* $(_VPATH_SRCS)
1853 @touch $@
1855 # "Install" generated Java interfaces. We segregate them based on the XPI_NAME.
1856 # If XPI_NAME is not set, install into the "default" directory.
1857 ifneq ($(XPI_NAME),)
1858 JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/$(XPI_NAME)
1859 else
1860 JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/default
1861 endif
1863 $(JAVA_INSTALL_DIR):
1864 $(NSINSTALL) -D $@
1866 export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
1867 (cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
1869 endif # XPIDLSRCS
1870 endif # MOZ_JAVAXPCOM
1872 ################################################################################
1873 # Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
1874 ifneq (,$(filter %.js,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1875 ifeq (,$(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS)))
1876 ifndef NO_JS_MANIFEST
1877 $(error .js component without matching .manifest)
1878 endif
1879 endif
1880 endif
1882 ifdef EXTRA_COMPONENTS
1883 libs:: $(EXTRA_COMPONENTS)
1884 ifndef NO_DIST_INSTALL
1885 $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
1886 endif
1888 endif
1890 ifdef EXTRA_PP_COMPONENTS
1891 libs:: $(EXTRA_PP_COMPONENTS)
1892 ifndef NO_DIST_INSTALL
1893 $(EXIT_ON_ERROR) \
1894 $(NSINSTALL) -D $(FINAL_TARGET)/components; \
1895 for i in $^; do \
1896 fname=`basename $$i`; \
1897 dest=$(FINAL_TARGET)/components/$${fname}; \
1898 $(RM) -f $$dest; \
1899 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1900 done
1901 endif
1902 endif
1904 EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
1905 ifneq (,$(EXTRA_MANIFESTS))
1906 libs::
1907 $(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
1908 endif
1910 ################################################################################
1911 # Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
1912 ifdef EXTRA_JS_MODULES
1913 libs:: $(EXTRA_JS_MODULES)
1914 ifndef NO_DIST_INSTALL
1915 $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
1916 endif
1918 endif
1920 ifdef EXTRA_PP_JS_MODULES
1921 libs:: $(EXTRA_PP_JS_MODULES)
1922 ifndef NO_DIST_INSTALL
1923 $(EXIT_ON_ERROR) \
1924 $(NSINSTALL) -D $(FINAL_TARGET)/modules; \
1925 for i in $^; do \
1926 dest=$(FINAL_TARGET)/modules/`basename $$i`; \
1927 $(RM) -f $$dest; \
1928 $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1929 done
1930 endif
1932 endif
1934 ################################################################################
1935 # SDK
1937 ifneq (,$(SDK_LIBRARY))
1938 $(SDK_LIB_DIR)::
1939 $(NSINSTALL) -D $@
1941 ifndef NO_DIST_INSTALL
1942 libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
1943 $(INSTALL) $(IFLAGS2) $^
1944 endif
1946 endif # SDK_LIBRARY
1948 ifneq (,$(SDK_BINARY))
1949 $(SDK_BIN_DIR)::
1950 $(NSINSTALL) -D $@
1952 ifndef NO_DIST_INSTALL
1953 libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
1954 $(INSTALL) $(IFLAGS2) $^
1955 endif
1957 endif # SDK_BINARY
1959 ################################################################################
1960 # CHROME PACKAGING
1962 JAR_MANIFEST := $(srcdir)/jar.mn
1964 chrome::
1965 $(MAKE) realchrome
1966 $(LOOP_OVER_PARALLEL_DIRS)
1967 $(LOOP_OVER_DIRS)
1968 $(LOOP_OVER_TOOL_DIRS)
1970 $(FINAL_TARGET)/chrome:
1971 $(NSINSTALL) -D $@
1973 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
1974 ifneq (,$(wildcard $(JAR_MANIFEST)))
1975 ifndef NO_DIST_INSTALL
1976 $(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
1977 $(QUIET) -j $(FINAL_TARGET)/chrome \
1978 $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
1979 $(JAR_MANIFEST)
1980 endif
1981 endif
1983 ifneq ($(DIST_FILES),)
1984 $(DIST)/bin:
1985 $(NSINSTALL) -D $@
1987 libs:: $(DIST_FILES) $(DIST)/bin
1988 @$(EXIT_ON_ERROR) \
1989 for f in $(DIST_FILES); do \
1990 dest=$(FINAL_TARGET)/`basename $$f`; \
1991 $(RM) -f $$dest; \
1992 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
1993 $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
1994 $(srcdir)/$$f > $$dest; \
1995 done
1996 endif
1998 ifneq ($(DIST_CHROME_FILES),)
1999 libs:: $(DIST_CHROME_FILES)
2000 @$(EXIT_ON_ERROR) \
2001 for f in $(DIST_CHROME_FILES); do \
2002 dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
2003 $(RM) -f $$dest; \
2004 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
2005 $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
2006 $(srcdir)/$$f > $$dest; \
2007 done
2008 endif
2010 ifneq ($(XPI_PKGNAME),)
2011 libs realchrome::
2012 ifdef STRIP_XPI
2013 ifndef MOZ_DEBUG
2014 @echo "Stripping $(XPI_PKGNAME) package directory..."
2015 @echo $(FINAL_TARGET)
2016 @cd $(FINAL_TARGET) && find . ! -type d \
2017 ! -name "*.js" \
2018 ! -name "*.xpt" \
2019 ! -name "*.gif" \
2020 ! -name "*.jpg" \
2021 ! -name "*.png" \
2022 ! -name "*.xpm" \
2023 ! -name "*.txt" \
2024 ! -name "*.rdf" \
2025 ! -name "*.sh" \
2026 ! -name "*.properties" \
2027 ! -name "*.dtd" \
2028 ! -name "*.html" \
2029 ! -name "*.xul" \
2030 ! -name "*.css" \
2031 ! -name "*.xml" \
2032 ! -name "*.jar" \
2033 ! -name "*.dat" \
2034 ! -name "*.tbl" \
2035 ! -name "*.src" \
2036 ! -name "*.reg" \
2037 $(PLATFORM_EXCLUDE_LIST) \
2038 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
2039 endif
2040 endif
2041 @echo "Packaging $(XPI_PKGNAME).xpi..."
2042 cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
2043 endif
2045 ifdef INSTALL_EXTENSION_ID
2046 ifndef XPI_NAME
2047 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
2048 endif
2050 libs::
2051 $(RM) -rf "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
2052 $(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
2053 cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
2055 endif
2057 ifneq (,$(filter flat symlink,$(MOZ_CHROME_FILE_FORMAT)))
2058 _JAR_REGCHROME_DISABLE_JAR=1
2059 else
2060 _JAR_REGCHROME_DISABLE_JAR=0
2061 endif
2063 REGCHROME = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
2064 $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
2065 $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(FINAL_TARGET)/chrome/installed-chrome.txt \
2066 $(_JAR_REGCHROME_DISABLE_JAR)
2068 REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
2069 $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
2070 $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
2071 $(_JAR_REGCHROME_DISABLE_JAR)
2074 #############################################################################
2075 # Dependency system
2076 #############################################################################
2077 ifdef COMPILER_DEPEND
2078 depend::
2079 @echo "$(MAKE): No need to run depend target.\
2080 Using compiler-based depend." 1>&2
2081 ifeq ($(GNU_CC)$(GNU_CXX),)
2082 # Non-GNU compilers
2083 @echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
2084 '(Compiler-based depend was turned on by "--enable-md".)' 1>&2
2085 else
2086 # GNU compilers
2087 @space="`echo '$(MAKE): '|sed 's/./ /g'`";\
2088 echo "$$space"'Since you are using a GNU compiler,\
2089 it is on by default.' 1>&2; \
2090 echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
2091 endif
2093 else # ! COMPILER_DEPEND
2095 ifndef MOZ_AUTO_DEPS
2097 define MAKE_DEPS_NOAUTO
2098 $(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
2099 endef
2101 $(MDDEPDIR)/%.pp: %.c
2102 $(REPORT_BUILD)
2103 @$(MAKE_DEPS_NOAUTO)
2105 $(MDDEPDIR)/%.pp: %.cpp
2106 $(REPORT_BUILD)
2107 @$(MAKE_DEPS_NOAUTO)
2109 $(MDDEPDIR)/%.pp: %.s
2110 $(REPORT_BUILD)
2111 @$(MAKE_DEPS_NOAUTO)
2113 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
2114 depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
2115 else
2116 depend:: $(SUBMAKEFILES)
2117 endif
2118 $(LOOP_OVER_PARALLEL_DIRS)
2119 $(LOOP_OVER_DIRS)
2120 $(LOOP_OVER_TOOL_DIRS)
2122 dependclean:: $(SUBMAKEFILES)
2123 rm -f $(MDDEPFILES)
2124 $(LOOP_OVER_PARALLEL_DIRS)
2125 $(LOOP_OVER_DIRS)
2126 $(LOOP_OVER_TOOL_DIRS)
2128 endif # MOZ_AUTO_DEPS
2130 endif # COMPILER_DEPEND
2133 #############################################################################
2134 # MDDEPDIR is the subdirectory where all the dependency files are placed.
2135 # This uses a make rule (instead of a macro) to support parallel
2136 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
2137 # processes could simultaneously try to create the same directory.
2139 # We use $(CURDIR) in the rule's target to ensure that we don't find
2140 # a dependency directory in the source tree via VPATH (perhaps from
2141 # a previous build in the source tree) and thus neglect to create a
2142 # dependency directory in the object directory, where we really need
2143 # it.
2145 $(CURDIR)/$(MDDEPDIR):
2146 @if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
2148 ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
2149 ifneq (,$(OBJS)$(XPIDLSRCS)$(SIMPLE_PROGRAMS))
2150 MDDEPEND_FILES := $(strip $(wildcard $(MDDEPDIR)/*.pp))
2152 ifneq (,$(MDDEPEND_FILES))
2153 # The script mddepend.pl checks the dependencies and writes to stdout
2154 # one rule to force out-of-date objects. For example,
2155 # foo.o boo.o: FORCE
2156 # The script has an advantage over including the *.pp files directly
2157 # because it handles the case when header files are removed from the build.
2158 # 'make' would complain that there is no way to build missing headers.
2159 ALL_PP_RESULTS = $(shell $(PERL) $(BUILD_TOOLS)/mddepend.pl - $(MDDEPEND_FILES))
2160 $(eval $(ALL_PP_RESULTS))
2161 endif
2163 endif
2164 endif
2165 #############################################################################
2167 -include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
2168 -include $(MY_RULES)
2171 # Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
2172 # or in $(MY_RULES)
2174 ifdef ETAGS
2175 ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
2176 all:: TAGS
2177 TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
2178 $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
2179 endif
2180 endif
2182 ################################################################################
2183 # Special gmake rules.
2184 ################################################################################
2188 # Disallow parallel builds with MSVC < 8
2190 ifneq (,$(filter 1200 1300 1310,$(_MSC_VER)))
2191 .NOTPARALLEL:
2192 endif
2195 # Re-define the list of default suffixes, so gmake won't have to churn through
2196 # hundreds of built-in suffix rules for stuff we don't need.
2198 .SUFFIXES:
2201 # Fake targets. Always run these rules, even if a file/directory with that
2202 # name already exists.
2204 .PHONY: all alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE
2206 # Used as a dependency to force targets to rebuild
2207 FORCE:
2209 # Delete target if error occurs when building target
2210 .DELETE_ON_ERROR:
2212 # Properly set LIBPATTERNS for the platform
2213 .LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX)
2215 tags: TAGS
2217 TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2218 -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2219 $(LOOP_OVER_PARALLEL_DIRS)
2220 $(LOOP_OVER_DIRS)
2222 echo-variable-%:
2223 @echo "$($*)"
2225 echo-tiers:
2226 @echo $(TIERS)
2228 echo-tier-dirs:
2229 @$(foreach tier,$(TIERS),echo '$(tier):'; echo ' dirs: $(tier_$(tier)_dirs)'; echo ' staticdirs: $(tier_$(tier)_staticdirs)'; )
2231 echo-dirs:
2232 @echo $(DIRS)
2234 echo-module:
2235 @echo $(MODULE)
2237 echo-requires:
2238 @echo $(REQUIRES)
2240 echo-depth-path:
2241 @$(topsrcdir)/build/unix/print-depth-path.sh
2243 echo-module-name:
2244 @$(topsrcdir)/build/package/rpm/print-module-name.sh
2246 echo-module-filelist:
2247 @$(topsrcdir)/build/package/rpm/print-module-filelist.sh
2249 showtargs:
2250 ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
2251 @echo --------------------------------------------------------------------------------
2252 @echo "PROGRAM = $(PROGRAM)"
2253 @echo "SIMPLE_PROGRAMS = $(SIMPLE_PROGRAMS)"
2254 @echo "LIBRARY = $(LIBRARY)"
2255 @echo "SHARED_LIBRARY = $(SHARED_LIBRARY)"
2256 @echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
2257 @echo "LIBS = $(LIBS)"
2258 @echo "DEF_FILE = $(DEF_FILE)"
2259 @echo "IMPORT_LIBRARY = $(IMPORT_LIBRARY)"
2260 @echo "STATIC_LIBS = $(STATIC_LIBS)"
2261 @echo "SHARED_LIBS = $(SHARED_LIBS)"
2262 @echo "EXTRA_DSO_LIBS = $(EXTRA_DSO_LIBS)"
2263 @echo "EXTRA_DSO_LDOPTS = $(EXTRA_DSO_LDOPTS)"
2264 @echo "DEPENDENT_LIBS = $(DEPENDENT_LIBS)"
2265 @echo --------------------------------------------------------------------------------
2266 endif
2267 $(LOOP_OVER_PARALLEL_DIRS)
2268 $(LOOP_OVER_DIRS)
2270 showbuild:
2271 @echo "MOZ_BUILD_ROOT = $(MOZ_BUILD_ROOT)"
2272 @echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
2273 @echo "CC = $(CC)"
2274 @echo "CXX = $(CXX)"
2275 @echo "CCC = $(CCC)"
2276 @echo "CPP = $(CPP)"
2277 @echo "LD = $(LD)"
2278 @echo "AR = $(AR)"
2279 @echo "IMPLIB = $(IMPLIB)"
2280 @echo "FILTER = $(FILTER)"
2281 @echo "MKSHLIB = $(MKSHLIB)"
2282 @echo "MKCSHLIB = $(MKCSHLIB)"
2283 @echo "RC = $(RC)"
2284 @echo "CFLAGS = $(CFLAGS)"
2285 @echo "OS_CFLAGS = $(OS_CFLAGS)"
2286 @echo "COMPILE_CFLAGS = $(COMPILE_CFLAGS)"
2287 @echo "CXXFLAGS = $(CXXFLAGS)"
2288 @echo "OS_CXXFLAGS = $(OS_CXXFLAGS)"
2289 @echo "COMPILE_CXXFLAGS = $(COMPILE_CXXFLAGS)"
2290 @echo "COMPILE_CMFLAGS = $(COMPILE_CMFLAGS)"
2291 @echo "COMPILE_CMMFLAGS = $(COMPILE_CMMFLAGS)"
2292 @echo "LDFLAGS = $(LDFLAGS)"
2293 @echo "OS_LDFLAGS = $(OS_LDFLAGS)"
2294 @echo "DSO_LDOPTS = $(DSO_LDOPTS)"
2295 @echo "OS_INCLUDES = $(OS_INCLUDES)"
2296 @echo "OS_LIBS = $(OS_LIBS)"
2297 @echo "EXTRA_LIBS = $(EXTRA_LIBS)"
2298 @echo "BIN_FLAGS = $(BIN_FLAGS)"
2299 @echo "INCLUDES = $(INCLUDES)"
2300 @echo "DEFINES = $(DEFINES)"
2301 @echo "ACDEFINES = $(ACDEFINES)"
2302 @echo "BIN_SUFFIX = $(BIN_SUFFIX)"
2303 @echo "LIB_SUFFIX = $(LIB_SUFFIX)"
2304 @echo "DLL_SUFFIX = $(DLL_SUFFIX)"
2305 @echo "IMPORT_LIB_SUFFIX = $(IMPORT_LIB_SUFFIX)"
2306 @echo "INSTALL = $(INSTALL)"
2308 showhost:
2309 @echo "HOST_CC = $(HOST_CC)"
2310 @echo "HOST_CXX = $(HOST_CXX)"
2311 @echo "HOST_CFLAGS = $(HOST_CFLAGS)"
2312 @echo "HOST_LDFLAGS = $(HOST_LDFLAGS)"
2313 @echo "HOST_LIBS = $(HOST_LIBS)"
2314 @echo "HOST_EXTRA_LIBS = $(HOST_EXTRA_LIBS)"
2315 @echo "HOST_EXTRA_DEPS = $(HOST_EXTRA_DEPS)"
2316 @echo "HOST_PROGRAM = $(HOST_PROGRAM)"
2317 @echo "HOST_OBJS = $(HOST_OBJS)"
2318 @echo "HOST_PROGOBJS = $(HOST_PROGOBJS)"
2319 @echo "HOST_LIBRARY = $(HOST_LIBRARY)"
2321 showbuildmods::
2322 @echo "Build Modules = $(BUILD_MODULES)"
2323 @echo "Module dirs = $(BUILD_MODULE_DIRS)"
2325 documentation:
2326 @cd $(DEPTH)
2327 $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
2329 ifdef ENABLE_TESTS
2330 check:: $(SUBMAKEFILES) $(MAKE_DIRS)
2331 $(LOOP_OVER_PARALLEL_DIRS)
2332 $(LOOP_OVER_DIRS)
2333 $(LOOP_OVER_TOOL_DIRS)
2334 endif
2337 FREEZE_VARIABLES = \
2338 CSRCS \
2339 CPPSRCS \
2340 EXPORTS \
2341 XPIDLSRCS \
2342 DIRS \
2343 LIBRARY \
2344 MODULE \
2345 REQUIRES \
2346 SHORT_LIBNAME \
2347 TIERS \
2348 EXTRA_COMPONENTS \
2349 EXTRA_PP_COMPONENTS \
2350 $(NULL)
2352 $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
2354 CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
2355 $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
2357 libs export libs::
2358 $(CHECK_FROZEN_VARIABLES)
2360 default::
2361 if test -d $(DIST)/bin ; then touch $(DIST)/bin/.purgecaches ; fi