source: pkg/viola/main/xulrunner/branches/upstream/current/config/rules.mk @ 4081

Revision 4081, 63.9 KB checked in by alanbach-guest, 6 years ago (diff)

[svn-inject] Installing original source of xulrunner

Line 
1# vim:set ts=8 sw=8 sts=8 noet:
2#
3# ***** BEGIN LICENSE BLOCK *****
4# Version: MPL 1.1/GPL 2.0/LGPL 2.1
5#
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/
10#
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.
15#
16# The Original Code is mozilla.org code.
17#
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.
22#
23# Contributor(s):
24#  Chase Phillips <chase@mozilla.org>
25#  Benjamin Smedberg <benjamin@smedbergs.us>
26#  Jeff Walden <jwalden+code@mit.edu>
27#
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.
39#
40# ***** END LICENSE BLOCK *****
41ifndef topsrcdir
42topsrcdir               = $(DEPTH)
43endif
44
45ifndef MOZILLA_DIR
46MOZILLA_DIR = $(topsrcdir)
47endif
48
49ifndef INCLUDED_CONFIG_MK
50include $(topsrcdir)/config/config.mk
51endif
52
53ifndef INCLUDED_VERSION_MK
54include $(topsrcdir)/config/version.mk
55endif
56
57REPORT_BUILD = @echo $(notdir $<)
58
59ifeq ($(OS_ARCH),OS2)
60EXEC                    =
61else
62EXEC                    = exec
63endif
64
65# ELOG prints out failed command when building silently (gmake -s).
66ifneq (,$(findstring -s,$(MAKEFLAGS)))
67  ELOG := $(EXEC) sh $(BUILD_TOOLS)/print-failed-commands.sh
68else
69  ELOG :=
70endif
71
72ifeq ($(MOZ_OS2_TOOLS),VACPP)
73_LIBNAME_RELATIVE_PATHS=1
74else
75ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
76ifndef GNU_CC
77_LIBNAME_RELATIVE_PATHS=1
78endif
79endif
80endif
81
82ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
83PWD := $(shell pwd)
84_VPATH_SRCS = $(if $(filter /%,$<),$<,$(PWD)/$<)
85else
86_VPATH_SRCS = $<
87endif
88
89# Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
90VPATH += $(DIST)/lib
91ifdef LIBXUL_SDK
92VPATH += $(LIBXUL_SDK)/lib
93endif
94
95# EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
96# expands to foo.lib on platforms with import libs and -lfoo otherwise
97
98# EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
99# expands to dir/foo.lib on platforms with import libs and
100# -Ldir -lfoo otherwise
101
102# EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
103# expands to $(DIST)/lib/foo.lib on platforms with import libs and
104# -lfoo otherwise
105
106ifdef _LIBNAME_RELATIVE_PATHS
107EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
108EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
109EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
110else
111EXPAND_LIBNAME = $(addprefix -l,$(1))
112EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
113EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
114endif
115
116ifdef EXTRA_DSO_LIBS
117EXTRA_DSO_LIBS  := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
118endif
119
120#
121# Library rules
122#
123# If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
124# Otherwise, build a shared library.
125#
126
127ifndef LIBRARY
128ifdef LIBRARY_NAME
129ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
130ifdef SHORT_LIBNAME
131LIBRARY_NAME            := $(SHORT_LIBNAME)
132endif
133endif
134LIBRARY                 := $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
135endif
136endif
137
138ifndef HOST_LIBRARY
139ifdef HOST_LIBRARY_NAME
140HOST_LIBRARY            := $(LIB_PREFIX)$(HOST_LIBRARY_NAME).$(LIB_SUFFIX)
141endif
142endif
143
144ifdef LIBRARY
145ifneq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
146ifdef MKSHLIB
147
148ifdef LIB_IS_C_ONLY
149MKSHLIB                 = $(MKCSHLIB)
150endif
151
152ifdef MAKE_FRAMEWORK
153SHARED_LIBRARY          := $(LIBRARY_NAME)
154else
155SHARED_LIBRARY          := $(DLL_PREFIX)$(LIBRARY_NAME)$(DLL_SUFFIX)
156endif
157
158ifeq ($(OS_ARCH),OS2)
159DEF_FILE                := $(SHARED_LIBRARY:.dll=.def)
160endif
161
162ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
163IMPORT_LIBRARY          := $(LIB_PREFIX)$(LIBRARY_NAME).$(IMPORT_LIB_SUFFIX)
164endif
165
166ifdef MOZ_ENABLE_LIBXUL
167EMBED_MANIFEST_AT=2
168endif
169
170endif # MKSHLIB
171endif # FORCE_SHARED_LIB && !BUILD_STATIC_LIBS
172endif # LIBRARY
173
174ifeq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
175LIBRARY                 := $(NULL)
176endif
177
178ifeq (_1,$(FORCE_SHARED_LIB)_$(BUILD_STATIC_LIBS))
179SHARED_LIBRARY          := $(NULL)
180DEF_FILE                := $(NULL)
181IMPORT_LIBRARY          := $(NULL)
182endif
183
184ifdef FORCE_STATIC_LIB
185ifndef FORCE_SHARED_LIB
186SHARED_LIBRARY          := $(NULL)
187DEF_FILE                := $(NULL)
188IMPORT_LIBRARY          := $(NULL)
189endif
190endif
191
192ifdef FORCE_SHARED_LIB
193ifndef FORCE_STATIC_LIB
194LIBRARY                 := $(NULL)
195endif
196endif
197
198ifdef JAVA_LIBRARY_NAME
199JAVA_LIBRARY := $(JAVA_LIBRARY_NAME).jar
200endif
201
202ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
203ifndef GNU_CC
204
205# Previously when possible we wrote to $LIBRARY_NAME.pdb.  This broke parallel
206# make builds on Windows.  Now we just write to a pdb file per compiled file.
207# See bug 286179 <https://bugzilla.mozilla.org/show_bug.cgi?id=286179> for
208# details. -- chase@mozilla.org
209#
210# Changes to the PDBFILE naming scheme should also be reflected in HOST_PDBFILE
211#
212ifdef LIBRARY_NAME
213PDBFILE=$(LIBRARY_NAME).pdb
214ifdef MOZ_DEBUG
215CODFILE=$(LIBRARY_NAME).cod
216endif
217else
218PDBFILE=$(basename $(@F)).pdb
219ifdef MOZ_DEBUG
220CODFILE=$(basename $(@F)).cod
221endif
222endif # LIBRARY_NAME
223
224ifdef MOZ_MAPINFO
225ifdef LIBRARY_NAME
226MAPFILE=$(LIBRARY_NAME).map
227else
228MAPFILE=$(basename $(@F)).map
229endif # LIBRARY_NAME
230endif # MOZ_MAPINFO
231
232ifdef DEFFILE
233OS_LDFLAGS += -DEF:$(DEFFILE)
234endif
235
236ifdef MAPFILE
237OS_LDFLAGS += -MAP:$(MAPFILE)
238#CFLAGS += -Fm$(MAPFILE)
239#CXXFLAGS += -Fm$(MAPFILE)
240endif
241
242#ifdef CODFILE
243#CFLAGS += -Fa$(CODFILE) -FAsc
244#CFLAGS += -Fa$(CODFILE) -FAsc
245#endif
246
247endif # !GNU_CC
248
249ifdef ENABLE_CXX_EXCEPTIONS
250ifdef GNU_CC
251CXXFLAGS                += -fexceptions
252else
253ifeq (,$(filter-out 1200 1300 1310,$(_MSC_VER)))
254CXXFLAGS                += -GX
255else
256CXXFLAGS                += -EHsc
257endif # _MSC_VER
258endif # GNU_CC
259endif # ENABLE_CXX_EXCEPTIONS
260endif # WINNT
261
262ifeq (,$(filter-out WINNT WINCE,$(HOST_OS_ARCH)))
263HOST_PDBFILE=$(basename $(@F)).pdb
264endif
265
266ifndef TARGETS
267TARGETS                 = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
268endif
269
270ifndef OBJS
271_OBJS                   = \
272        $(JRI_STUB_CFILES) \
273        $(addsuffix .$(OBJ_SUFFIX), $(JMC_GEN)) \
274        $(CSRCS:.c=.$(OBJ_SUFFIX)) \
275        $(patsubst %.cc,%.$(OBJ_SUFFIX),$(CPPSRCS:.cpp=.$(OBJ_SUFFIX))) \
276        $(CMSRCS:.m=.$(OBJ_SUFFIX)) \
277        $(CMMSRCS:.mm=.$(OBJ_SUFFIX)) \
278        $(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))
279OBJS    = $(strip $(_OBJS))
280endif
281
282ifndef HOST_OBJS
283_HOST_OBJS              = \
284        $(addprefix host_,$(HOST_CSRCS:.c=.$(OBJ_SUFFIX))) \
285        $(addprefix host_,$(patsubst %.cc,%.$(OBJ_SUFFIX),$(HOST_CPPSRCS:.cpp=.$(OBJ_SUFFIX)))) \
286        $(addprefix host_,$(HOST_CMSRCS:.m=.$(OBJ_SUFFIX))) \
287        $(addprefix host_,$(HOST_CMMSRCS:.mm=.$(OBJ_SUFFIX)))
288HOST_OBJS = $(strip $(_HOST_OBJS))
289endif
290
291ifeq ($(MOZ_OS2_TOOLS),VACPP)
292LIBOBJS                 := $(OBJS)
293else
294LIBOBJS                 := $(addprefix \", $(OBJS))
295LIBOBJS                 := $(addsuffix \", $(LIBOBJS))
296endif
297
298ifndef MOZ_AUTO_DEPS
299ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
300MDDEPFILES              = $(addprefix $(MDDEPDIR)/,$(OBJS:.$(OBJ_SUFFIX)=.pp))
301ifndef NO_GEN_XPT
302MDDEPFILES              += $(addprefix $(MDDEPDIR)/,$(XPIDLSRCS:.idl=.xpt)) \
303                           $(addprefix $(MDDEPDIR)/,$(SDK_XPIDLSRCS:.idl=.xpt))
304endif
305endif
306endif
307
308ALL_TRASH = \
309        $(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
310        $(OBJS:.$(OBJ_SUFFIX)=.s) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
311        $(OBJS:.$(OBJ_SUFFIX)=.i) \
312        $(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) $(DEF_FILE)\
313        $(EXE_DEF_FILE) so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
314        $(wildcard *.pdb) $(CODFILE) $(MAPFILE) $(IMPORT_LIBRARY) \
315        $(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
316        $(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
317        $(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
318        $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
319        $(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
320ALL_TRASH_DIRS = \
321        $(GARBAGE_DIRS) /no-such-file
322
323ifdef SIMPLE_PROGRAMS
324GARBAGE                 += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
325endif
326
327ifdef HOST_SIMPLE_PROGRAMS
328GARBAGE                 += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
329endif
330
331#
332# the Solaris WorkShop template repository cache.  it occasionally can get
333# out of sync, so targets like clobber should kill it.
334#
335ifeq ($(OS_ARCH),SunOS)
336ifeq ($(GNU_CXX),)
337GARBAGE_DIRS += SunWS_cache
338endif
339endif
340
341ifeq ($(OS_ARCH),OpenVMS)
342GARBAGE                 += $(wildcard *.*_defines)
343ifdef SHARED_LIBRARY
344VMS_SYMVEC_FILE         = $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt)
345ifdef MOZ_DEBUG
346VMS_SYMVEC_FILE_MODULE  = $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_dbg_symvec.opt))
347else
348VMS_SYMVEC_FILE_MODULE  = $(topsrcdir)/build/unix/vms/$(notdir $(SHARED_LIBRARY:$(DLL_SUFFIX)=_symvec.opt))
349endif
350VMS_SYMVEC_FILE_COMP    = $(topsrcdir)/build/unix/vms/component_symvec.opt
351GARBAGE                 += $(VMS_SYMVEC_FILE)
352ifdef IS_COMPONENT
353DSO_LDOPTS := $(filter-out -auto_symvec,$(DSO_LDOPTS)) $(VMS_SYMVEC_FILE)
354endif
355endif
356endif
357
358XPIDL_GEN_DIR           = _xpidlgen
359
360ifdef MOZ_UPDATE_XTERM
361# Its good not to have a newline at the end of the titlebar string because it
362# makes the make -s output easier to read.  Echo -n does not work on all
363# platforms, but we can trick sed into doing it.
364UPDATE_TITLE = sed -e "s!Y!$@ in $(shell $(BUILD_TOOLS)/print-depth-path.sh)/$(dir)!" $(MOZILLA_DIR)/config/xterm.str;
365endif
366
367LOOP_OVER_DIRS = \
368    @$(EXIT_ON_ERROR) \
369    $(foreach dir,$(DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
370
371LOOP_OVER_STATIC_DIRS = \
372    @$(EXIT_ON_ERROR) \
373    $(foreach dir,$(STATIC_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
374
375LOOP_OVER_TOOL_DIRS = \
376    @$(EXIT_ON_ERROR) \
377    $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) $@; ) true
378
379#
380# Now we can differentiate between objects used to build a library, and
381# objects used to build an executable in the same directory.
382#
383ifndef PROGOBJS
384PROGOBJS                = $(OBJS)
385endif
386
387ifndef HOST_PROGOBJS
388HOST_PROGOBJS           = $(HOST_OBJS)
389endif
390
391# MAKE_DIRS: List of directories to build while looping over directories.
392ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
393MAKE_DIRS               += $(MDDEPDIR)
394GARBAGE_DIRS            += $(MDDEPDIR)
395endif
396
397#
398# Tags: emacs (etags), vi (ctags)
399# TAG_PROGRAM := ctags -L -
400#
401TAG_PROGRAM             = xargs etags -a
402
403#
404# Turn on C++ linking if we have any .cpp or .mm files
405# (moved this from config.mk so that config.mk can be included
406#  before the CPPSRCS are defined)
407#
408ifneq ($(CPPSRCS)$(CMMSRCS),)
409CPP_PROG_LINK           = 1
410endif
411
412#
413# Make sure to wrap static libs inside linker specific flags to turn on & off
414# inclusion of all symbols inside the static libs
415#
416ifndef NO_LD_ARCHIVE_FLAGS
417ifdef SHARED_LIBRARY_LIBS
418EXTRA_DSO_LDOPTS := $(MKSHLIB_FORCE_ALL) $(SHARED_LIBRARY_LIBS) $(MKSHLIB_UNFORCE_ALL) $(EXTRA_DSO_LDOPTS)
419endif
420endif
421
422#
423# This will strip out symbols that the component should not be
424# exporting from the .dynsym section.
425#
426ifdef IS_COMPONENT
427EXTRA_DSO_LDOPTS += $(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
428endif # IS_COMPONENT
429
430#
431# Enforce the requirement that MODULE_NAME must be set
432# for components in static builds
433#
434ifdef IS_COMPONENT
435ifdef EXPORT_LIBRARY
436ifndef FORCE_SHARED_LIB
437ifndef MODULE_NAME
438$(error MODULE_NAME is required for components which may be used in static builds)
439endif
440endif
441endif
442endif
443
444#
445# MacOS X specific stuff
446#
447
448ifeq ($(OS_ARCH),Darwin)
449ifdef SHARED_LIBRARY
450ifdef IS_COMPONENT
451EXTRA_DSO_LDOPTS        += -bundle
452else
453EXTRA_DSO_LDOPTS        += -dynamiclib -install_name @executable_path/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
454endif
455endif
456endif
457
458#
459# On NetBSD a.out systems, use -Bsymbolic.  This fixes what would otherwise be
460# fatal symbol name clashes between components.
461#
462ifeq ($(OS_ARCH),NetBSD)
463ifeq ($(DLL_SUFFIX),.so.1.0)
464ifdef IS_COMPONENT
465EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
466endif
467endif
468endif
469
470ifeq ($(OS_ARCH),FreeBSD)
471ifdef IS_COMPONENT
472EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
473endif
474endif
475
476ifeq ($(OS_ARCH),NetBSD)
477ifneq (,$(filter arc cobalt hpcmips mipsco newsmips pmax sgimips,$(OS_TEST)))
478ifeq ($(MODULE),layout)
479OS_CFLAGS += -Wa,-xgot
480OS_CXXFLAGS += -Wa,-xgot
481endif
482endif
483endif
484
485ifeq ($(OS_ARCH),Linux)
486ifneq (,$(filter mips mipsel,$(OS_TEST)))
487ifeq ($(MODULE),layout)
488OS_CFLAGS += -Wa,-xgot
489OS_CXXFLAGS += -Wa,-xgot
490endif
491endif
492endif
493
494#
495# HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
496# which uses internal symbols first
497#
498ifeq ($(OS_ARCH),HP-UX)
499ifdef IS_COMPONENT
500ifeq ($(GNU_CC)$(GNU_CXX),)
501EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
502ifneq ($(HAS_EXTRAEXPORTS),1)
503MKSHLIB  += -Wl,+eNSGetModule -Wl,+eerrno
504MKCSHLIB += +eNSGetModule +eerrno
505ifneq ($(OS_TEST),ia64)
506MKSHLIB  += -Wl,+e_shlInit
507MKCSHLIB += +e_shlInit
508endif # !ia64
509endif # !HAS_EXTRAEXPORTS
510endif # non-gnu compilers
511endif # IS_COMPONENT
512endif # HP-UX
513
514ifeq ($(OS_ARCH),AIX)
515ifdef IS_COMPONENT
516ifneq ($(HAS_EXTRAEXPORTS),1)
517MKSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
518MKCSHLIB += -bE:$(MOZILLA_DIR)/build/unix/aix.exp -bnoexpall
519endif # HAS_EXTRAEXPORTS
520endif # IS_COMPONENT
521endif # AIX
522
523#
524# OSF1: add -B symbolic flag for components
525#
526ifeq ($(OS_ARCH),OSF1)
527ifdef IS_COMPONENT
528ifeq ($(GNU_CC)$(GNU_CXX),)
529EXTRA_DSO_LDOPTS += -B symbolic
530endif 
531endif 
532endif
533
534#
535# Linux: add -Bsymbolic flag for components
536#
537ifeq ($(OS_ARCH),Linux)
538ifdef IS_COMPONENT
539EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
540endif
541endif
542
543#
544# MINGW32
545#
546ifeq ($(OS_ARCH),WINNT)
547ifdef GNU_CC
548ifndef IS_COMPONENT
549DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
550endif
551endif
552endif
553
554ifeq ($(USE_TVFS),1)
555IFLAGS1 = -rb
556IFLAGS2 = -rb
557else
558IFLAGS1 = -m 644
559IFLAGS2 = -m 755
560endif
561
562ifeq ($(MOZ_OS2_TOOLS),VACPP)
563OUTOPTION = -Fo# eol
564else
565ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
566OUTOPTION = -Fo# eol
567else
568OUTOPTION = -o # eol
569endif # WINNT && !GNU_CC
570endif # VACPP
571ifneq (,$(filter WINCE,$(OS_ARCH)))
572OUTOPTION = -Fo# eol
573endif
574
575ifeq ($(OS_TARGET), WINCE)
576OUTOPTION = -Fo# eol
577HOST_OUTOPTION = -Fo# eol
578else
579
580ifeq (,$(CROSS_COMPILE))
581HOST_OUTOPTION = $(OUTOPTION)
582else
583HOST_OUTOPTION = -o # eol
584endif
585
586endif
587################################################################################
588
589# SUBMAKEFILES: List of Makefiles for next level down.
590#   This is used to update or create the Makefiles before invoking them.
591SUBMAKEFILES += $(addsuffix /Makefile, $(DIRS) $(TOOL_DIRS))
592
593# The root makefile doesn't want to do a plain export/libs, because
594# of the tiers and because of libxul. Suppress the default rules in favor
595# of something else. Makefiles which use this var *must* provide a sensible
596# default rule before including rules.mk
597ifndef SUPPRESS_DEFAULT_RULES
598ifdef TIERS
599
600DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_dirs))
601STATIC_DIRS += $(foreach tier,$(TIERS),$(tier_$(tier)_staticdirs))
602
603default all alldep::
604        $(EXIT_ON_ERROR) \
605        $(foreach tier,$(TIERS),$(MAKE) tier_$(tier); ) true
606
607else
608
609default all::
610        @$(EXIT_ON_ERROR) \
611        $(foreach dir,$(STATIC_DIRS),$(MAKE) -C $(dir); ) true
612        $(MAKE) export
613        $(MAKE) libs
614        $(MAKE) tools
615
616# Do depend as well
617alldep::
618        $(MAKE) export
619        $(MAKE) depend
620        $(MAKE) libs
621        $(MAKE) tools
622
623endif # TIERS
624endif # SUPPRESS_DEFAULT_RULES
625
626MAKE_TIER_SUBMAKEFILES = +$(if $(tier_$*_dirs),$(MAKE) $(addsuffix /Makefile,$(tier_$*_dirs)))
627
628export_tier_%:
629        @echo "$@"
630        @$(MAKE_TIER_SUBMAKEFILES)
631        @$(EXIT_ON_ERROR) \
632        $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) export; ) true
633
634libs_tier_%:
635        @echo "$@"
636        @$(MAKE_TIER_SUBMAKEFILES)
637        @$(EXIT_ON_ERROR) \
638        $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) libs; ) true
639
640tools_tier_%:
641        @echo "$@"
642        @$(MAKE_TIER_SUBMAKEFILES)
643        @$(EXIT_ON_ERROR) \
644        $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) tools; ) true
645
646$(foreach tier,$(TIERS),tier_$(tier))::
647        @echo "$@: $($@_staticdirs) $($@_dirs)"
648        @$(EXIT_ON_ERROR) \
649        $(foreach dir,$($@_staticdirs),$(MAKE) -C $(dir); ) true
650        $(MAKE) export_$@
651        $(MAKE) libs_$@
652
653# Do everything from scratch
654everything::
655        $(MAKE) clean
656        $(MAKE) alldep
657
658# Add dummy depend target for tinderboxes
659depend::
660
661ifdef ALL_PLATFORMS
662all_platforms:: $(NFSPWD)
663        @d=`$(NFSPWD)`;                                                 \
664        if test ! -d LOGS; then rm -rf LOGS; mkdir LOGS; else true; fi; \
665        for h in $(PLATFORM_HOSTS); do                                  \
666                echo "On $$h: $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log";\
667                rsh $$h -n "(chdir $$d;                                 \
668                             $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log;  \
669                             echo DONE) &" 2>&1 > LOGS/$$h.pid &        \
670                sleep 1;                                                \
671        done
672
673$(NFSPWD):
674        cd $(@D); $(MAKE) $(@F)
675endif
676
677# Target to only regenerate makefiles
678makefiles: $(SUBMAKEFILES)
679ifneq (,$(DIRS)$(TOOL_DIRS))
680        +$(LOOP_OVER_DIRS)
681        +$(LOOP_OVER_TOOL_DIRS)
682endif
683
684export:: $(SUBMAKEFILES) $(MAKE_DIRS) $(if $(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),$(PUBLIC)) $(if $(SDK_HEADERS)$(SDK_XPIDLSRCS),$(SDK_PUBLIC)) $(if $(XPIDLSRCS),$(IDL_DIR)) $(if $(SDK_XPIDLSRCS),$(SDK_IDL_DIR))
685        +$(LOOP_OVER_DIRS)
686        +$(LOOP_OVER_TOOL_DIRS)
687
688tools:: $(SUBMAKEFILES) $(MAKE_DIRS)
689        +$(LOOP_OVER_DIRS)
690ifdef TOOL_DIRS
691        @$(EXIT_ON_ERROR) \
692        $(foreach dir,$(TOOL_DIRS),$(UPDATE_TITLE) $(MAKE) -C $(dir) libs; ) true
693endif
694
695#
696# Rule to create list of libraries for final link
697#
698export::
699ifdef LIBRARY_NAME
700ifdef EXPORT_LIBRARY
701ifdef IS_COMPONENT
702ifdef BUILD_STATIC_LIBS
703        @$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMPS) $(LIBRARY_NAME)
704ifdef MODULE_NAME
705        @$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_COMP_NAMES) $(MODULE_NAME)
706endif
707endif
708else
709        $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl $(FINAL_LINK_LIBS) $(LIBRARY_NAME)
710endif # IS_COMPONENT
711endif # EXPORT_LIBRARY
712endif # LIBRARY_NAME
713
714# Create dependencies on static (and shared EXTRA_DSO_LIBS) libraries
715LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(LIBS))
716HOST_LIBS_DEPS = $(filter %.$(LIB_SUFFIX), $(HOST_LIBS))
717DSO_LDOPTS_DEPS = $(EXTRA_DSO_LIBS) $(filter %.$(LIB_SUFFIX), $(EXTRA_DSO_LDOPTS))
718
719##############################################
720libs:: $(SUBMAKEFILES) $(MAKE_DIRS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) $(HOST_PROGRAM) $(PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(SIMPLE_PROGRAMS) $(JAVA_LIBRARY)
721ifndef NO_DIST_INSTALL
722ifdef LIBRARY
723ifdef EXPORT_LIBRARY # Stage libs that will be linked into a static build
724ifdef IS_COMPONENT
725        $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib/components
726else
727        $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DEPTH)/staticlib
728endif
729endif # EXPORT_LIBRARY
730ifdef DIST_INSTALL
731ifdef IS_COMPONENT
732        $(error Shipping static component libs makes no sense.)
733else
734        $(INSTALL) $(IFLAGS1) $(LIBRARY) $(DIST)/lib
735endif
736endif # DIST_INSTALL
737endif # LIBRARY
738ifdef SHARED_LIBRARY
739ifdef IS_COMPONENT
740        $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
741        $(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
742ifdef BEOS_ADDON_WORKAROUND
743        ( cd $(FINAL_TARGET)/components && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
744endif
745else # ! IS_COMPONENT
746ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
747        $(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(DIST)/lib
748else
749        $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(DIST)/lib
750endif
751        $(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)
752ifdef BEOS_ADDON_WORKAROUND
753        ( cd $(FINAL_TARGET) && $(CC) -nostart -o $(SHARED_LIBRARY).stub $(SHARED_LIBRARY) )
754endif
755endif # IS_COMPONENT
756endif # SHARED_LIBRARY
757ifdef PROGRAM
758        $(INSTALL) $(IFLAGS2) $(PROGRAM) $(FINAL_TARGET)
759endif
760ifdef SIMPLE_PROGRAMS
761        $(INSTALL) $(IFLAGS2) $(SIMPLE_PROGRAMS) $(FINAL_TARGET)
762endif
763ifdef HOST_PROGRAM
764        $(INSTALL) $(IFLAGS2) $(HOST_PROGRAM) $(DIST)/host/bin
765endif
766ifdef HOST_SIMPLE_PROGRAMS
767        $(INSTALL) $(IFLAGS2) $(HOST_SIMPLE_PROGRAMS) $(DIST)/host/bin
768endif
769ifdef HOST_LIBRARY
770        $(INSTALL) $(IFLAGS1) $(HOST_LIBRARY) $(DIST)/host/lib
771endif
772ifdef JAVA_LIBRARY
773ifdef IS_COMPONENT
774        $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)/components
775else
776        $(INSTALL) $(IFLAGS1) $(JAVA_LIBRARY) $(FINAL_TARGET)
777endif
778endif # JAVA_LIBRARY
779endif # !NO_DIST_INSTALL
780        +$(LOOP_OVER_DIRS)
781
782##############################################
783
784ifndef NO_PROFILE_GUIDED_OPTIMIZE
785ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
786ifeq ($(OS_ARCH)_$(GNU_CC)$(INTERNAL_TOOLS), WINNT_)
787# Force re-linking when building with PGO, since
788# the MSVC linker does all the work.  We force re-link
789# in both stages so you can do depend builds with PGO.
790ifdef SHARED_LIBRARY
791$(SHARED_LIBRARY): FORCE
792BINARY_BASENAME = $(SHARED_LIBRARY:$(DLL_SUFFIX)=)
793endif
794ifdef PROGRAM
795$(PROGRAM): FORCE
796BINARY_BASENAME = $(PROGRAM:$(BIN_SUFFIX)=)
797endif
798
799ifdef MOZ_PROFILE_USE
800# In the second pass, we need to merge the pgc files into the pgd file.
801# The compiler would do this for us automatically if they were in the right
802# place, but they're in dist/bin.
803ifdef BINARY_BASENAME
804export::
805        $(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
806          $(BINARY_BASENAME) $(DIST)/bin
807endif
808endif # MOZ_PROFILE_USE
809endif # WINNT_
810endif # MOZ_PROFILE_GENERATE || MOZ_PROFILE_USE
811endif # NO_PROFILE_GUIDED_OPTIMIZE
812
813##############################################
814
815checkout:
816        $(MAKE) -C $(topsrcdir) -f client.mk checkout
817
818run_viewer: $(FINAL_TARGET)/viewer
819        cd $(FINAL_TARGET); \
820        MOZILLA_FIVE_HOME=`pwd` \
821        LD_LIBRARY_PATH=".:$(LIBS_PATH):$$LD_LIBRARY_PATH" \
822        viewer
823
824clean clobber realclean clobber_all:: $(SUBMAKEFILES)
825        -rm -f $(ALL_TRASH)
826        -rm -rf $(ALL_TRASH_DIRS)
827        +-$(LOOP_OVER_DIRS)
828        +-$(LOOP_OVER_STATIC_DIRS)
829        +-$(LOOP_OVER_TOOL_DIRS)
830
831distclean:: $(SUBMAKEFILES)
832        +-$(LOOP_OVER_DIRS)
833        +-$(LOOP_OVER_STATIC_DIRS)
834        +-$(LOOP_OVER_TOOL_DIRS)
835        -rm -rf $(ALL_TRASH_DIRS) 
836        -rm -f $(ALL_TRASH)  \
837        Makefile .HSancillary \
838        $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
839        $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
840        $(wildcard *.$(IMPORT_LIB_SUFFIX))
841ifeq ($(MOZ_OS2_TOOLS),VACPP)
842        -rm -f $(PROGRAM:.exe=.map)
843endif
844
845alltags:
846        rm -f TAGS
847        find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
848
849#
850# PROGRAM = Foo
851# creates OBJS, links with LIBS to create Foo
852#
853$(PROGRAM): $(PROGOBJS) $(LIBS_DEPS) $(EXTRA_DEPS) $(EXE_DEF_FILE) $(RESFILE) Makefile Makefile.in
854ifeq (WINCE,$(OS_ARCH))
855        $(LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
856else
857ifeq ($(MOZ_OS2_TOOLS),VACPP)
858        $(LD) -OUT:$@ $(LDFLAGS) $(PROGOBJS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(EXE_DEF_FILE) -ST:0x100000
859else
860
861ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
862        $(LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(PROGOBJS) $(RESFILE) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
863ifdef MSMANIFEST_TOOL
864        @if test -f $@.manifest; then \
865                if test -f "$(srcdir)/$@.manifest"; then \
866                        mt.exe -NOLOGO -MANIFEST "$(win_srcdir)/$@.manifest" $@.manifest -OUTPUTRESOURCE:$@\;1; \
867                else \
868                        mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
869                fi; \
870                rm -f $@.manifest; \
871        fi
872endif   # MSVC with manifest tool
873else
874ifeq ($(CPP_PROG_LINK),1)
875        $(CCC) -o $@ $(CXXFLAGS) $(WRAP_MALLOC_CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(EXE_DEF_FILE)
876else # ! CPP_PROG_LINK
877        $(CC) -o $@ $(CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
878endif # CPP_PROG_LINK
879endif # WINNT && !GNU_CC
880endif # OS2
881endif # WINCE
882
883ifdef ENABLE_STRIP
884        $(STRIP) $@
885endif
886ifdef MOZ_POST_PROGRAM_COMMAND
887        $(MOZ_POST_PROGRAM_COMMAND) $@
888endif
889ifeq ($(OS_ARCH),BeOS)
890ifdef BEOS_PROGRAM_RESOURCE
891        xres -o $@ $(BEOS_PROGRAM_RESOURCE)
892        mimeset $@
893endif
894endif # BeOS
895
896$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) Makefile Makefile.in
897ifeq ($(MOZ_OS2_TOOLS),VACPP)
898        $(LD) -OUT:$@ $(LDFLAGS) $(HOST_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) -ST:0x100000
899else
900ifeq (WINCE,$(OS_ARCH))
901        $(HOST_LD) -NOLOGO -OUT:$@ $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
902else
903ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
904        $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $(HOST_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
905ifdef MSMANIFEST_TOOL
906        @if test -f $@.manifest; then \
907                mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
908                rm -f $@.manifest; \
909        fi
910endif   # MSVC with manifest tool
911else
912ifeq ($(CPP_PROG_LINK),1)
913        $(HOST_CXX) -o $@ $(HOST_CXXFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
914else
915        $(HOST_CC) -o $@ $(HOST_CFLAGS) $(HOST_LDFLAGS) $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
916endif # CPP_PROG_LINK
917endif
918endif
919endif
920
921#
922# This is an attempt to support generation of multiple binaries
923# in one directory, it assumes everything to compile Foo is in
924# Foo.o (from either Foo.c or Foo.cpp).
925#
926# SIMPLE_PROGRAMS = Foo Bar
927# creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
928#
929$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(LIBS_DEPS) $(EXTRA_DEPS) Makefile Makefile.in
930ifeq (WINCE,$(OS_ARCH))
931        $(LD) -nologo  -entry:main -out:$@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
932else
933ifeq ($(MOZ_OS2_TOOLS),VACPP)
934        $(LD) -Out:$@ $< $(LDFLAGS) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS)
935else
936ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
937        $(LD) -nologo -out:$@ -pdb:$(PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
938ifdef MSMANIFEST_TOOL
939        @if test -f $@.manifest; then \
940                mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
941                rm -f $@.manifest; \
942        fi
943endif   # MSVC with manifest tool
944else
945ifeq ($(CPP_PROG_LINK),1)
946        $(CCC) $(WRAP_MALLOC_CFLAGS) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
947else
948        $(CC) $(WRAP_MALLOC_CFLAGS) $(CFLAGS) $(OUTOPTION)$@ $< $(WIN32_EXE_LDFLAGS) $(SOLARIS_JEMALLOC_LDFLAGS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS) $(WRAP_MALLOC_LIB) $(PROFILER_LIBS) $(BIN_FLAGS)
949endif # CPP_PROG_LINK
950endif # WINNT && !GNU_CC
951endif # OS/2 VACPP
952endif # WINCE
953
954ifdef ENABLE_STRIP
955        $(STRIP) $@
956endif
957ifdef MOZ_POST_PROGRAM_COMMAND
958        $(MOZ_POST_PROGRAM_COMMAND) $@
959endif
960
961$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): host_%.$(OBJ_SUFFIX) $(HOST_LIBS_DEPS) $(HOST_EXTRA_DEPS) Makefile Makefile.in
962ifeq ($(MOZ_OS2_TOOLS),VACPP)
963        $(HOST_LD) -OUT:$@ $< $(LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS) -ST:0x100000
964else
965ifeq (WINCE,$(OS_ARCH))
966        $(HOST_LD) -NOLOGO -OUT:$@ $(WIN32_EXE_LDFLAGS) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
967else
968ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
969        $(HOST_LD) -NOLOGO -OUT:$@ -PDB:$(PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
970else
971ifdef HOST_CPPSRCS
972        $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXXFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
973else
974        $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_CFLAGS) $(INCLUDES) $< $(HOST_LIBS) $(HOST_EXTRA_LIBS)
975endif
976endif
977endif
978endif
979
980#
981# Purify target.  Solaris/sparc only to start.
982# Purify does not recognize "egcs" or "c++" so we go with
983# "gcc" and "g++" for now.
984#
985pure:   $(PROGRAM)
986ifeq ($(CPP_PROG_LINK),1)
987        $(PURIFY) $(CCC) -o $^.pure $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
988else
989        $(PURIFY) $(CC) -o $^.pure $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
990endif
991ifndef NO_DIST_INSTALL
992        $(INSTALL) $(IFLAGS2) $^.pure $(FINAL_TARGET)
993endif
994
995quantify: $(PROGRAM)
996ifeq ($(CPP_PROG_LINK),1)
997        $(QUANTIFY) $(CCC) -o $^.quantify $(CXXFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
998else
999        $(QUANTIFY) $(CC) -o $^.quantify $(CFLAGS) $(PROGOBJS) $(LDFLAGS) $(LIBS_DIR) $(LIBS) $(OS_LIBS) $(EXTRA_LIBS)
1000endif
1001ifndef NO_DIST_INSTALL
1002        $(INSTALL) $(IFLAGS2) $^.quantify $(FINAL_TARGET)
1003endif
1004
1005#
1006# This allows us to create static versions of the shared libraries
1007# that are built using other static libraries.  Confused...?
1008#
1009ifdef SHARED_LIBRARY_LIBS
1010ifeq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1011ifneq (,$(BUILD_STATIC_LIBS)$(FORCE_STATIC_LIB))
1012LOBJS   += $(SHARED_LIBRARY_LIBS)
1013endif
1014else
1015ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH)))
1016CLEANUP1        := | egrep -v '(________64ELEL_|__.SYMDEF)'
1017CLEANUP2        := rm -f ________64ELEL_ __.SYMDEF
1018else
1019CLEANUP2        := true
1020endif
1021SUB_LOBJS       = $(shell for lib in $(SHARED_LIBRARY_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1022endif
1023endif
1024ifdef MOZILLA_PROBE_LIBS
1025PROBE_LOBJS     = $(shell for lib in $(MOZILLA_PROBE_LIBS); do $(AR_LIST) $${lib} $(CLEANUP1); done;)
1026endif
1027ifdef DTRACE_PROBE_OBJ
1028EXTRA_DEPS += $(DTRACE_PROBE_OBJ)
1029endif
1030
1031$(LIBRARY): $(OBJS) $(LOBJS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) Makefile Makefile.in
1032        rm -f $@
1033ifneq (,$(GNU_LD)$(filter-out OS2 WINNT WINCE, $(OS_ARCH)))
1034ifdef SHARED_LIBRARY_LIBS
1035        @rm -f $(SUB_LOBJS)
1036        @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1037endif
1038endif
1039        $(AR) $(AR_FLAGS) $(OBJS) $(LOBJS) $(SUB_LOBJS)
1040        $(RANLIB) $@
1041        @rm -f foodummyfilefoo $(SUB_LOBJS)
1042
1043ifeq (,$(filter-out WINNT WINCE, $(OS_ARCH)))
1044$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1045endif
1046
1047ifeq ($(OS_ARCH),OS2)
1048$(DEF_FILE): $(OBJS) $(SHARED_LIBRARY_LIBS)
1049        rm -f $@
1050        echo LIBRARY $(LIBRARY_NAME) INITINSTANCE TERMINSTANCE > $@
1051        echo PROTMODE >> $@
1052        echo CODE    LOADONCALL MOVEABLE DISCARDABLE >> $@
1053        echo DATA    PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
1054        echo EXPORTS >> $@
1055ifeq ($(IS_COMPONENT),1)
1056ifeq ($(HAS_EXTRAEXPORTS),1)
1057ifndef MOZ_OS2_USE_DECLSPEC
1058        $(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
1059endif   
1060else
1061        echo    _NSGetModule >> $@
1062endif
1063else
1064ifndef MOZ_OS2_USE_DECLSPEC
1065        $(FILTER) $(OBJS) $(SHARED_LIBRARY_LIBS) >> $@
1066endif   
1067endif
1068        $(ADD_TO_DEF_FILE)
1069
1070ifdef MOZ_OS2_USE_DECLSPEC
1071$(IMPORT_LIBRARY): $(SHARED_LIBRARY)
1072else
1073$(IMPORT_LIBRARY): $(DEF_FILE)
1074endif
1075        rm -f $@
1076        $(IMPLIB) $@ $^
1077        $(RANLIB) $@
1078endif # OS/2
1079
1080$(HOST_LIBRARY): $(HOST_OBJS) Makefile
1081        rm -f $@
1082        $(HOST_AR) $(HOST_AR_FLAGS) $(HOST_OBJS)
1083        $(HOST_RANLIB) $@
1084
1085ifdef NO_LD_ARCHIVE_FLAGS
1086SUB_SHLOBJS = $(SUB_LOBJS)
1087endif
1088
1089ifdef HAVE_DTRACE
1090ifndef XP_MACOSX
1091ifdef DTRACE_PROBE_OBJ
1092ifndef DTRACE_LIB_DEPENDENT
1093$(DTRACE_PROBE_OBJ): $(OBJS)
1094        dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o $(DTRACE_PROBE_OBJ) $(OBJS)
1095endif
1096endif
1097endif
1098endif
1099
1100# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
1101# so instead of deleting .o files after repacking them into a dylib, we make
1102# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
1103# so no need to conditionalize on OS version or debugging format.
1104
1105$(SHARED_LIBRARY): $(OBJS) $(LOBJS) $(DEF_FILE) $(RESFILE) $(SHARED_LIBRARY_LIBS) $(EXTRA_DEPS) $(DSO_LDOPTS_DEPS) Makefile Makefile.in
1106ifndef INCREMENTAL_LINKER
1107        rm -f $@
1108endif
1109ifneq ($(MOZ_OS2_TOOLS),VACPP)
1110ifeq ($(OS_ARCH),OpenVMS)
1111        @if test ! -f $(VMS_SYMVEC_FILE); then \
1112          if test -f $(VMS_SYMVEC_FILE_MODULE); then \
1113            echo Creating specific component options file $(VMS_SYMVEC_FILE); \
1114            cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
1115          fi; \
1116        fi
1117ifdef IS_COMPONENT
1118        @if test ! -f $(VMS_SYMVEC_FILE); then \
1119          echo Creating generic component options file $(VMS_SYMVEC_FILE); \
1120          cp $(VMS_SYMVEC_FILE_COMP) $(VMS_SYMVEC_FILE); \
1121        fi
1122endif
1123endif
1124ifdef NO_LD_ARCHIVE_FLAGS
1125ifdef SHARED_LIBRARY_LIBS
1126        @rm -f $(SUB_SHLOBJS)
1127        @for lib in $(SHARED_LIBRARY_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1128ifeq ($(OS_ARCH),Darwin)
1129        @echo Making symlinks to the original object files in the archive libraries $(SHARED_LIBRARY_LIBS)
1130        @for lib in $(SHARED_LIBRARY_LIBS); do \
1131                libdir=`echo $$lib|sed -e 's,/[^/]*\.a,,'`; \
1132                ofiles=`$(AR_LIST) $${lib}`; \
1133                for ofile in $$ofiles; do \
1134                        if [ -f $$libdir/$$ofile ]; then \
1135                                rm -f $$ofile; \
1136                                ln -s $$libdir/$$ofile $$ofile; \
1137                        fi; \
1138                done; \
1139        done
1140endif
1141endif # SHARED_LIBRARY_LIBS
1142endif # NO_LD_ARCHIVE_FLAGS
1143ifdef DTRACE_LIB_DEPENDENT
1144        @rm -f $(PROBE_LOBJS)
1145        @for lib in $(MOZILLA_PROBE_LIBS); do $(AR_EXTRACT) $${lib}; $(CLEANUP2); done
1146ifndef XP_MACOSX
1147        dtrace -G -C -32 -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS)
1148endif
1149        @for lib in $(MOZILLA_PROBE_LIBS); do \
1150                ofiles=`$(AR_LIST) $${lib}`; \
1151                $(AR_DELETE) $${lib} $$ofiles; \
1152        done
1153        $(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(PROBE_LOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
1154        @rm -f $(PROBE_LOBJS)
1155        @rm -f $(DTRACE_PROBE_OBJ)
1156        @for lib in $(MOZILLA_PROBE_LIBS); do \
1157                if [ -L $${lib} ]; then rm -f `readlink $${lib}`; fi; \
1158        done
1159        @rm -f $(MOZILLA_PROBE_LIBS)
1160
1161else
1162        $(MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(DTRACE_PROBE_OBJ) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
1163endif # DTRACE_LIB_DEPENDENT
1164
1165ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
1166ifdef MSMANIFEST_TOOL
1167ifdef EMBED_MANIFEST_AT
1168        @if test -f $@.manifest; then \
1169                mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
1170                rm -f $@.manifest; \
1171        fi
1172endif   # EMBED_MANIFEST_AT
1173endif   # MSVC with manifest tool
1174endif   # WINNT && !GCC
1175ifeq ($(OS_ARCH),Darwin)
1176else # non-Darwin
1177        @rm -f $(SUB_SHLOBJS)
1178endif # Darwin
1179        @rm -f foodummyfilefoo $(DELETE_AFTER_LINK)
1180else # os2 vacpp
1181        $(MKSHLIB) -O:$@ -DLL -INC:_dllentry $(LDFLAGS) $(OBJS) $(LOBJS) $(EXTRA_DSO_LDOPTS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE)
1182endif # !os2 vacpp
1183        chmod +x $@
1184ifdef ENABLE_STRIP
1185        $(STRIP) $@
1186endif
1187ifdef MOZ_POST_DSO_LIB_COMMAND
1188        $(MOZ_POST_DSO_LIB_COMMAND) $@
1189endif
1190
1191ifdef MOZ_AUTO_DEPS
1192ifdef COMPILER_DEPEND
1193ifeq (__SunOS,$(GNU_CC)_$(GNU_CXX)_$(OS_ARCH))
1194_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1195
1196define MAKE_DEPS_AUTO_CC
1197if test -d $(@D); then \
1198        echo "Building deps for $< using Sun Studio cc"; \
1199        $(CC) $(COMPILE_CFLAGS) -xM  $< >$(_MDDEPFILE) ; \
1200fi
1201endef
1202define MAKE_DEPS_AUTO_CXX
1203if test -d $(@D); then \
1204        echo "Building deps for $< using Sun Studio CC"; \
1205        $(CXX) $(COMPILE_CXXFLAGS) -xM $< >$(_MDDEPFILE) ; \
1206fi
1207endef
1208endif # Sun Studio on Solaris
1209else # COMPILER_DEPEND
1210#
1211# Generate dependencies on the fly
1212#
1213_MDDEPFILE = $(MDDEPDIR)/$(@F).pp
1214
1215define MAKE_DEPS_AUTO
1216if test -d $(@D); then \
1217        echo "Building deps for $<"; \
1218        $(MKDEPEND) -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $(_MDDEPFILE) ; \
1219fi
1220endef
1221
1222MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
1223MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
1224
1225endif # COMPILER_DEPEND
1226
1227endif # MOZ_AUTO_DEPS
1228
1229ifdef MOZ_MEMORY
1230ifeq ($(OS_ARCH),SunOS)
1231SOLARIS_JEMALLOC_LDFLAGS = $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib)
1232endif
1233endif
1234
1235# Rules for building native targets must come first because of the host_ prefix
1236host_%.$(OBJ_SUFFIX): %.c Makefile Makefile.in
1237        $(REPORT_BUILD)
1238        $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1239
1240host_%.$(OBJ_SUFFIX): %.cpp Makefile Makefile.in
1241        $(REPORT_BUILD)
1242        $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1243
1244host_%.$(OBJ_SUFFIX): %.cc Makefile Makefile.in
1245        $(REPORT_BUILD)
1246        $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1247
1248host_%.$(OBJ_SUFFIX): %.m Makefile Makefile.in
1249        $(REPORT_BUILD)
1250        $(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(HOST_CMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1251
1252host_%.$(OBJ_SUFFIX): %.mm Makefile Makefile.in
1253        $(REPORT_BUILD)
1254        $(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
1255
1256%: %.c Makefile Makefile.in
1257        $(REPORT_BUILD)
1258        @$(MAKE_DEPS_AUTO_CC)
1259        $(ELOG) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTOPTION)$@ $(_VPATH_SRCS)
1260
1261%.$(OBJ_SUFFIX): %.c Makefile Makefile.in
1262        $(REPORT_BUILD)
1263        @$(MAKE_DEPS_AUTO_CC)
1264        $(ELOG) $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1265
1266moc_%.cpp: %.h Makefile Makefile.in
1267        $(MOC) $< $(OUTOPTION)$@ 
1268
1269ifdef ASFILES
1270# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
1271# a '-c' flag.
1272%.$(OBJ_SUFFIX): %.$(ASM_SUFFIX) Makefile Makefile.in
1273ifeq ($(MOZ_OS2_TOOLS),VACPP)
1274        $(AS) -Fdo:./$(OBJDIR) -Feo:.$(OBJ_SUFFIX) $(ASFLAGS) $(AS_DASH_C_FLAG) $<
1275else
1276        $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
1277endif
1278endif
1279
1280%.$(OBJ_SUFFIX): %.S Makefile Makefile.in
1281        $(AS) -o $@ $(ASFLAGS) -c $<
1282
1283%: %.cpp Makefile Makefile.in
1284        @$(MAKE_DEPS_AUTO_CXX)
1285        $(CCC) $(OUTOPTION)$@ $(CXXFLAGS) $(_VPATH_SRCS) $(LDFLAGS)
1286
1287#
1288# Please keep the next two rules in sync.
1289#
1290%.$(OBJ_SUFFIX): %.cc Makefile Makefile.in
1291        $(REPORT_BUILD)
1292        @$(MAKE_DEPS_AUTO_CXX)
1293        $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1294
1295%.$(OBJ_SUFFIX): %.cpp Makefile Makefile.in
1296        $(REPORT_BUILD)
1297        @$(MAKE_DEPS_AUTO_CXX)
1298ifdef STRICT_CPLUSPLUS_SUFFIX
1299        echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > t_$*.cc
1300        $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) t_$*.cc
1301        rm -f t_$*.cc
1302else
1303        $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1304endif #STRICT_CPLUSPLUS_SUFFIX
1305
1306$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.mm Makefile Makefile.in
1307        $(REPORT_BUILD)
1308        @$(MAKE_DEPS_AUTO_CXX)
1309        $(ELOG) $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS)
1310
1311$(OBJ_PREFIX)%.$(OBJ_SUFFIX): %.m Makefile Makefile.in
1312        $(REPORT_BUILD)
1313        @$(MAKE_DEPS_AUTO_CC)
1314        $(ELOG) $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $(_VPATH_SRCS)
1315
1316%.s: %.cpp
1317        $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1318
1319%.s: %.cc
1320        $(CCC) -S $(COMPILE_CXXFLAGS) $(_VPATH_SRCS)
1321
1322%.s: %.c
1323        $(CC) -S $(COMPILE_CFLAGS) $(_VPATH_SRCS)
1324
1325%.i: %.cpp
1326        $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1327
1328%.i: %.cc
1329        $(CCC) -C -E $(COMPILE_CXXFLAGS) $(_VPATH_SRCS) > $*.i
1330
1331%.i: %.c
1332        $(CC) -C -E $(COMPILE_CFLAGS) $(_VPATH_SRCS) > $*.i
1333
1334%.i: %.mm
1335        $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(_VPATH_SRCS) > $*.i
1336
1337%.res: %.rc
1338        @echo Creating Resource file: $@
1339ifeq ($(OS_ARCH),OS2)
1340        $(RC) $(RCFLAGS:-D%=-d %) -i $(subst /,\,$(srcdir)) -r $< $@
1341else
1342ifdef GNU_CC
1343        $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
1344else
1345        $(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
1346endif
1347endif
1348
1349# need 3 separate lines for OS/2
1350%: %.pl
1351        rm -f $@
1352        cp $< $@
1353        chmod +x $@
1354
1355%: %.sh
1356        rm -f $@; cp $< $@; chmod +x $@
1357
1358# Cancel these implicit rules
1359#
1360%: %,v
1361
1362%: RCS/%,v
1363
1364%: s.%
1365
1366%: SCCS/s.%
1367
1368###############################################################################
1369# Java rules
1370###############################################################################
1371ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
1372SEP := ;
1373else
1374SEP := :
1375endif
1376
1377EMPTY :=
1378SPACE := $(EMPTY) $(EMPTY)
1379
1380# Cygwin and MSYS have their own special path form, but javac expects the source
1381# and class paths to be in the DOS form (i.e. e:/builds/...).  This function
1382# does the appropriate conversion on Windows, but is a noop on other systems.
1383ifeq (,$(filter-out WINNT WINCE, $(HOST_OS_ARCH)))
1384ifdef CYGWIN_WRAPPER
1385normalizepath = $(foreach p,$(1),$(shell cygpath -m $(p)))
1386else
1387# assume MSYS
1388#  We use 'pwd -W' to get DOS form of the path.  However, since the given path
1389#  could be a file or a non-existent path, we cannot call 'pwd -W' directly
1390#  on the path.  Instead, we extract the root path (i.e. "c:/"), call 'pwd -W'
1391#  on it, then merge with the rest of the path.
1392root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\1|")
1393non-root-path = $(shell echo $(1) | sed -e "s|\(/[^/]*\)/\?\(.*\)|\2|")
1394normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(shell cd $(call root-path,$(1)) && pwd -W)$(call non-root-path,$(1)),$(1)))
1395endif
1396else
1397normalizepath = $(1)
1398endif
1399
1400_srcdir = $(call normalizepath,$(srcdir))
1401ifdef JAVA_SOURCEPATH
1402SP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_SOURCEPATH))))
1403_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)$(SEP)$(SP)"
1404else
1405_JAVA_SOURCEPATH = ".$(SEP)$(_srcdir)"
1406endif
1407
1408ifdef JAVA_CLASSPATH
1409CP = $(subst $(SPACE),$(SEP),$(call normalizepath,$(strip $(JAVA_CLASSPATH))))
1410_JAVA_CLASSPATH = ".$(SEP)$(CP)"
1411else
1412_JAVA_CLASSPATH = .
1413endif
1414
1415_JAVA_DIR = _java
1416$(_JAVA_DIR)::
1417        $(NSINSTALL) -D $@
1418
1419$(_JAVA_DIR)/%.class: %.java Makefile Makefile.in $(_JAVA_DIR)
1420        $(CYGWIN_WRAPPER) $(JAVAC) $(JAVAC_FLAGS) -classpath $(_JAVA_CLASSPATH) \
1421                        -sourcepath $(_JAVA_SOURCEPATH) -d $(_JAVA_DIR) $(_VPATH_SRCS)
1422
1423$(JAVA_LIBRARY): $(addprefix $(_JAVA_DIR)/,$(JAVA_SRCS:.java=.class)) Makefile Makefile.in
1424        $(JAR) cf $@ -C $(_JAVA_DIR) .
1425
1426GARBAGE_DIRS += $(_JAVA_DIR)
1427
1428###############################################################################
1429# Update Makefiles
1430###############################################################################
1431
1432# In GNU make 3.80, makefiles must use the /cygdrive syntax, even if we're
1433# processing them with AS perl. See bug 232003
1434ifdef AS_PERL
1435CYGWIN_TOPSRCDIR = -nowrap -p $(topsrcdir) -wrap
1436endif
1437
1438# Note: Passing depth to make-makefile is optional.
1439#       It saves the script some work, though.
1440Makefile: Makefile.in
1441        @$(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR)
1442
1443ifdef SUBMAKEFILES
1444# VPATH does not work on some machines in this case, so add $(srcdir)
1445$(SUBMAKEFILES): % : $(srcdir)/%.in
1446        $(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $@
1447endif
1448
1449ifdef AUTOUPDATE_CONFIGURE
1450$(topsrcdir)/configure: $(topsrcdir)/configure.in
1451        (cd $(topsrcdir) && $(AUTOCONF)) && (cd $(DEPTH) && ./config.status --recheck)
1452endif
1453
1454###############################################################################
1455# Bunch of things that extend the 'export' rule (in order):
1456###############################################################################
1457
1458################################################################################
1459# Copy each element of EXPORTS to $(PUBLIC)
1460
1461ifneq ($(EXPORTS)$(XPIDLSRCS)$(SDK_HEADERS)$(SDK_XPIDLSRCS),)
1462$(SDK_PUBLIC) $(PUBLIC)::
1463        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1464endif
1465
1466ifdef MOZ_JAVAXPCOM
1467ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
1468$(JAVA_DIST_DIR)::
1469        $(NSINSTALL) -D $@
1470endif
1471endif
1472
1473ifneq ($(XPI_NAME),)
1474export::
1475        @if test ! -d $(FINAL_TARGET); then echo Creating $(FINAL_TARGET); rm -fr $(FINAL_TARGET); $(NSINSTALL) -D $(FINAL_TARGET); else true; fi
1476endif
1477
1478ifndef NO_DIST_INSTALL
1479ifneq ($(EXPORTS),)
1480export:: $(EXPORTS) $(PUBLIC)
1481        $(INSTALL) $(IFLAGS1) $^
1482endif
1483
1484ifneq ($(SDK_HEADERS),)
1485export:: $(SDK_HEADERS) $(SDK_PUBLIC)
1486        $(INSTALL) $(IFLAGS1) $^
1487
1488export:: $(SDK_HEADERS) $(PUBLIC)
1489        $(INSTALL) $(IFLAGS1) $^
1490endif
1491endif # NO_DIST_INSTALL
1492
1493################################################################################
1494# Copy each element of PREF_JS_EXPORTS
1495
1496ifdef GRE_MODULE
1497PREF_DIR = greprefs
1498else
1499ifneq (,$(XPI_NAME)$(LIBXUL_SDK))
1500PREF_DIR = defaults/preferences
1501else
1502PREF_DIR = defaults/pref
1503endif
1504endif
1505
1506ifneq ($(PREF_JS_EXPORTS),)
1507# on win32, pref files need CRLF line endings... see bug 206029
1508ifeq (WINNT,$(OS_ARCH))
1509PREF_PPFLAGS = --line-endings=crlf
1510endif
1511
1512ifndef NO_DIST_INSTALL
1513libs:: $(PREF_JS_EXPORTS)
1514        if test ! -d $(FINAL_TARGET)/$(PREF_DIR); then $(NSINSTALL) -D $(FINAL_TARGET)/$(PREF_DIR); fi
1515        $(EXIT_ON_ERROR)  \
1516        for i in $(PREF_JS_EXPORTS); do \
1517          dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
1518          $(RM) -f $$dest; \
1519          $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1520        done
1521endif
1522endif
1523
1524################################################################################
1525# Copy each element of AUTOCFG_JS_EXPORTS to $(FINAL_TARGET)/defaults/autoconfig
1526
1527ifneq ($(AUTOCFG_JS_EXPORTS),)
1528$(FINAL_TARGET)/defaults/autoconfig::
1529        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1530
1531ifndef NO_DIST_INSTALL
1532export:: $(AUTOCFG_JS_EXPORTS) $(FINAL_TARGET)/defaults/autoconfig
1533        $(INSTALL) $(IFLAGS1) $^
1534endif
1535
1536endif
1537################################################################################
1538# Export the elements of $(XPIDLSRCS) & $(SDK_XPIDLSRCS),
1539# generating .h and .xpt files and moving them to the appropriate places.
1540
1541ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
1542
1543export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS))
1544
1545ifndef XPIDL_MODULE
1546XPIDL_MODULE            = $(MODULE)
1547endif
1548
1549ifeq ($(XPIDL_MODULE),) # we need $(XPIDL_MODULE) to make $(XPIDL_MODULE).xpt
1550export:: FORCE
1551        @echo
1552        @echo "*** Error processing XPIDLSRCS:"
1553        @echo "Please define MODULE or XPIDL_MODULE when defining XPIDLSRCS,"
1554        @echo "so we have a module name to use when creating MODULE.xpt."
1555        @echo; sleep 2; false
1556endif
1557
1558$(SDK_IDL_DIR) $(IDL_DIR)::
1559        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1560
1561# generate .h files from into $(XPIDL_GEN_DIR), then export to $(PUBLIC);
1562# warn against overriding existing .h file.
1563$(XPIDL_GEN_DIR)/.done:
1564        @if test ! -d $(XPIDL_GEN_DIR); then echo Creating $(XPIDL_GEN_DIR)/.done; rm -rf $(XPIDL_GEN_DIR); mkdir $(XPIDL_GEN_DIR); fi
1565        @touch $@
1566
1567# don't depend on $(XPIDL_GEN_DIR), because the modification date changes
1568# with any addition to the directory, regenerating all .h files -> everything.
1569
1570$(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1571        $(REPORT_BUILD)
1572        $(ELOG) $(XPIDL_COMPILE) -m header -w $(XPIDL_FLAGS) -o $(XPIDL_GEN_DIR)/$* $(_VPATH_SRCS)
1573        @if test -n "$(findstring $*.h, $(EXPORTS) $(SDK_HEADERS))"; \
1574          then echo "*** WARNING: file $*.h generated from $*.idl overrides $(srcdir)/$*.h"; else true; fi
1575
1576ifndef NO_GEN_XPT
1577# generate intermediate .xpt files into $(XPIDL_GEN_DIR), then link
1578# into $(XPIDL_MODULE).xpt and export it to $(FINAL_TARGET)/components.
1579$(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_COMPILE) $(XPIDL_GEN_DIR)/.done
1580        $(REPORT_BUILD)
1581        $(ELOG) $(XPIDL_COMPILE) -m typelib -w $(XPIDL_FLAGS) -e $@ -d $(MDDEPDIR)/$*.pp $(_VPATH_SRCS)
1582
1583# no need to link together if XPIDLSRCS contains only XPIDL_MODULE
1584ifneq ($(XPIDL_MODULE).idl,$(strip $(XPIDLSRCS)))
1585$(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) Makefile.in Makefile $(XPIDL_LINK)
1586        $(XPIDL_LINK) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.xpt,$(XPIDLSRCS) $(SDK_XPIDLSRCS)) 
1587endif # XPIDL_MODULE.xpt != XPIDLSRCS
1588
1589libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
1590ifndef NO_DIST_INSTALL
1591        $(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
1592endif
1593
1594endif # NO_GEN_XPT
1595
1596GARBAGE_DIRS            += $(XPIDL_GEN_DIR)
1597
1598endif # XPIDLSRCS || SDK_XPIDLSRCS
1599
1600ifneq ($(XPIDLSRCS),)
1601# export .idl files to $(IDL_DIR)
1602ifndef NO_DIST_INSTALL
1603export:: $(XPIDLSRCS) $(IDL_DIR)
1604        $(INSTALL) $(IFLAGS1) $^
1605
1606export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(XPIDLSRCS)) $(PUBLIC)
1607        $(INSTALL) $(IFLAGS1) $^ 
1608endif # NO_DIST_INSTALL
1609
1610endif # XPIDLSRCS
1611
1612
1613
1614#
1615# General rules for exporting idl files.
1616#
1617# WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build.
1618# Bug to fix idl dependency problems w/o this extra build pass is
1619#   http://bugzilla.mozilla.org/show_bug.cgi?id=145777
1620#
1621$(IDL_DIR)::
1622        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1623
1624export-idl:: $(SUBMAKEFILES) $(MAKE_DIRS)
1625
1626ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
1627ifndef NO_DIST_INSTALL
1628export-idl:: $(XPIDLSRCS) $(SDK_XPIDLSRCS) $(IDL_DIR)
1629        $(INSTALL) $(IFLAGS1) $^
1630endif
1631endif
1632        +$(LOOP_OVER_DIRS)
1633        +$(LOOP_OVER_TOOL_DIRS)
1634
1635
1636
1637
1638ifneq ($(SDK_XPIDLSRCS),)
1639# export .idl files to $(IDL_DIR) & $(SDK_IDL_DIR)
1640ifndef NO_DIST_INSTALL
1641export:: $(SDK_XPIDLSRCS) $(IDL_DIR)
1642        $(INSTALL) $(IFLAGS1) $^
1643
1644export:: $(SDK_XPIDLSRCS) $(SDK_IDL_DIR)
1645        $(INSTALL) $(IFLAGS1) $^
1646
1647export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(PUBLIC)
1648        $(INSTALL) $(IFLAGS1) $^
1649
1650export:: $(patsubst %.idl,$(XPIDL_GEN_DIR)/%.h, $(SDK_XPIDLSRCS)) $(SDK_PUBLIC)
1651        $(INSTALL) $(IFLAGS1) $^
1652endif
1653
1654endif # SDK_XPIDLSRCS
1655
1656
1657
1658ifdef MOZ_JAVAXPCOM
1659ifneq ($(XPIDLSRCS)$(SDK_XPIDLSRCS),)
1660
1661JAVA_XPIDLSRCS = $(XPIDLSRCS) $(SDK_XPIDLSRCS)
1662
1663# A single IDL file can contain multiple interfaces, which result in multiple
1664# Java interface files.  So use hidden dependency files.
1665JAVADEPFILES = $(addprefix $(JAVA_GEN_DIR)/.,$(JAVA_XPIDLSRCS:.idl=.java.pp))
1666
1667$(JAVA_GEN_DIR):
1668        $(NSINSTALL) -D $@
1669GARBAGE_DIRS += $(JAVA_GEN_DIR)
1670
1671# generate .java files into _javagen/[package name dirs]
1672_JAVA_GEN_DIR = $(JAVA_GEN_DIR)/$(JAVA_IFACES_PKG_NAME)
1673$(_JAVA_GEN_DIR):
1674        $(NSINSTALL) -D $@
1675
1676$(JAVA_GEN_DIR)/.%.java.pp: %.idl $(XPIDL_COMPILE) $(_JAVA_GEN_DIR)
1677        $(REPORT_BUILD)
1678        $(ELOG) $(XPIDL_COMPILE) -m java -w -I$(srcdir) -I$(IDL_DIR) -o $(_JAVA_GEN_DIR)/$* $(_VPATH_SRCS)
1679        @touch $@
1680
1681# "Install" generated Java interfaces.  We segregate them based on the XPI_NAME.
1682# If XPI_NAME is not set, install into the "default" directory.
1683ifneq ($(XPI_NAME),)
1684JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/$(XPI_NAME)
1685else
1686JAVA_INSTALL_DIR = $(JAVA_DIST_DIR)/default
1687endif
1688
1689$(JAVA_INSTALL_DIR):
1690        $(NSINSTALL) -D $@
1691
1692export:: $(JAVA_DIST_DIR) $(JAVADEPFILES) $(JAVA_INSTALL_DIR)
1693        (cd $(JAVA_GEN_DIR) && tar $(TAR_CREATE_FLAGS) - .) | (cd $(JAVA_INSTALL_DIR) && tar -xf -)
1694
1695endif # XPIDLSRCS || SDK_XPIDLSRCS
1696endif # MOZ_JAVAXPCOM
1697
1698################################################################################
1699# Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
1700ifdef EXTRA_COMPONENTS
1701libs:: $(EXTRA_COMPONENTS)
1702ifndef NO_DIST_INSTALL
1703        $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/components
1704endif
1705
1706endif
1707
1708ifdef EXTRA_PP_COMPONENTS
1709libs:: $(EXTRA_PP_COMPONENTS)
1710ifndef NO_DIST_INSTALL
1711        $(EXIT_ON_ERROR) \
1712        $(NSINSTALL) -D $(FINAL_TARGET)/components; \
1713        for i in $^; do \
1714          dest=$(FINAL_TARGET)/components/`basename $$i`; \
1715          $(RM) -f $$dest; \
1716          $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1717        done
1718endif
1719
1720endif
1721
1722################################################################################
1723# Copy each element of EXTRA_JS_MODULES to $(FINAL_TARGET)/modules
1724ifdef EXTRA_JS_MODULES
1725libs:: $(EXTRA_JS_MODULES)
1726ifndef NO_DIST_INSTALL
1727        $(INSTALL) $(IFLAGS1) $^ $(FINAL_TARGET)/modules
1728endif
1729
1730endif
1731
1732ifdef EXTRA_PP_JS_MODULES
1733libs:: $(EXTRA_PP_JS_MODULES)
1734ifndef NO_DIST_INSTALL
1735        $(EXIT_ON_ERROR) \
1736        $(NSINSTALL) -D $(FINAL_TARGET)/modules; \
1737        for i in $^; do \
1738          dest=$(FINAL_TARGET)/modules/`basename $$i`; \
1739          $(RM) -f $$dest; \
1740          $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
1741        done
1742endif
1743
1744endif
1745
1746################################################################################
1747# SDK
1748
1749ifneq (,$(SDK_LIBRARY))
1750$(SDK_LIB_DIR)::
1751        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1752
1753ifndef NO_DIST_INSTALL
1754libs:: $(SDK_LIBRARY) $(SDK_LIB_DIR)
1755        $(INSTALL) $(IFLAGS2) $^
1756endif
1757
1758endif # SDK_LIBRARY
1759
1760ifneq (,$(SDK_BINARY))
1761$(SDK_BIN_DIR)::
1762        @if test ! -d $@; then echo Creating $@; rm -rf $@; $(NSINSTALL) -D $@; else true; fi
1763
1764ifndef NO_DIST_INSTALL
1765libs:: $(SDK_BINARY) $(SDK_BIN_DIR)
1766        $(INSTALL) $(IFLAGS2) $^
1767endif
1768
1769endif # SDK_BINARY
1770
1771################################################################################
1772# CHROME PACKAGING
1773
1774JAR_MANIFEST := $(srcdir)/jar.mn
1775
1776chrome::
1777        $(MAKE) realchrome
1778        +$(LOOP_OVER_DIRS)
1779        +$(LOOP_OVER_TOOL_DIRS)
1780
1781libs realchrome:: $(CHROME_DEPS)
1782ifndef NO_DIST_INSTALL
1783        @$(EXIT_ON_ERROR) \
1784        if test -f $(JAR_MANIFEST); then \
1785          if test ! -d $(FINAL_TARGET)/chrome; then $(NSINSTALL) -D $(FINAL_TARGET)/chrome; fi; \
1786          if test ! -d $(MAKE_JARS_TARGET)/chrome; then $(NSINSTALL) -D $(MAKE_JARS_TARGET)/chrome; fi; \
1787          $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
1788            $(JAR_MANIFEST) | \
1789          $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/make-jars.pl \
1790            -d $(MAKE_JARS_TARGET)/chrome -j $(FINAL_TARGET)/chrome \
1791            $(MAKE_JARS_FLAGS) -- "$(XULPPFLAGS) $(DEFINES) $(ACDEFINES)"; \
1792        fi
1793endif
1794
1795ifneq ($(DIST_FILES),)
1796libs:: $(DIST_FILES)
1797        @$(EXIT_ON_ERROR) \
1798        for f in $(DIST_FILES); do \
1799          dest=$(FINAL_TARGET)/`basename $$f`; \
1800          $(RM) -f $$dest; \
1801          $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
1802            $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
1803            $(srcdir)/$$f > $$dest; \
1804        done
1805endif
1806
1807ifneq ($(DIST_CHROME_FILES),)
1808libs:: $(DIST_CHROME_FILES)
1809        @$(EXIT_ON_ERROR) \
1810        for f in $(DIST_CHROME_FILES); do \
1811          dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
1812          $(RM) -f $$dest; \
1813          $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
1814            $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
1815            $(srcdir)/$$f > $$dest; \
1816        done
1817endif
1818
1819ifneq ($(XPI_PKGNAME),)
1820libs realchrome::
1821ifdef STRIP_XPI
1822ifndef MOZ_DEBUG
1823        @echo "Stripping $(XPI_PKGNAME) package directory..."
1824        @echo $(FINAL_TARGET)
1825        @cd $(FINAL_TARGET) && find . ! -type d \
1826                        ! -name "*.js" \
1827                        ! -name "*.xpt" \
1828                        ! -name "*.gif" \
1829                        ! -name "*.jpg" \
1830                        ! -name "*.png" \
1831                        ! -name "*.xpm" \
1832                        ! -name "*.txt" \
1833                        ! -name "*.rdf" \
1834                        ! -name "*.sh" \
1835                        ! -name "*.properties" \
1836                        ! -name "*.dtd" \
1837                        ! -name "*.html" \
1838                        ! -name "*.xul" \
1839                        ! -name "*.css" \
1840                        ! -name "*.xml" \
1841                        ! -name "*.jar" \
1842                        ! -name "*.dat" \
1843                        ! -name "*.tbl" \
1844                        ! -name "*.src" \
1845                        ! -name "*.reg" \
1846                        $(PLATFORM_EXCLUDE_LIST) \
1847                        -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
1848endif
1849endif
1850        @echo "Packaging $(XPI_PKGNAME).xpi..."
1851        cd $(FINAL_TARGET) && $(ZIP) -qr ../$(XPI_PKGNAME).xpi *
1852endif
1853
1854ifdef INSTALL_EXTENSION_ID
1855ifndef XPI_NAME
1856$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
1857endif
1858
1859libs::
1860        $(RM) -rf "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
1861        $(NSINSTALL) -D "$(DIST)/bin/extensions/$(INSTALL_EXTENSION_ID)"
1862        cd $(FINAL_TARGET) && tar $(TAR_CREATE_FLAGS) - . | (cd "../../bin/extensions/$(INSTALL_EXTENSION_ID)" && tar -xf -)
1863
1864endif
1865
1866ifneq (,$(filter flat symlink,$(MOZ_CHROME_FILE_FORMAT)))
1867_JAR_REGCHROME_DISABLE_JAR=1
1868else
1869_JAR_REGCHROME_DISABLE_JAR=0
1870endif
1871
1872REGCHROME = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
1873        $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
1874        $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(FINAL_TARGET)/chrome/installed-chrome.txt \
1875        $(_JAR_REGCHROME_DISABLE_JAR)
1876
1877REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
1878        $(if $(filter gtk2,$(MOZ_WIDGET_TOOLKIT)),-x) \
1879        $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \
1880        $(_JAR_REGCHROME_DISABLE_JAR)
1881
1882
1883################################################################################
1884# Testing frameworks support
1885################################################################################
1886
1887ifdef ENABLE_TESTS
1888
1889ifdef XPCSHELL_TESTS
1890ifndef MODULE
1891$(error Must define MODULE when defining XPCSHELL_TESTS.)
1892endif
1893
1894# Test file installation
1895libs::
1896        @$(EXIT_ON_ERROR) \
1897        for testdir in $(XPCSHELL_TESTS); do \
1898          $(INSTALL) \
1899            $(srcdir)/$$testdir/*.js \
1900            $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
1901        done
1902
1903# Path formats on Windows are hard.  We require a topsrcdir formatted so that
1904# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
1905# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
1906# We require a forward-slashed path to topsrcdir so that it may be combined
1907# with a relative forward-slashed path for loading scripts, both dynamically
1908# and statically for head/test/tail JS files.  Of course, on non-Windows none
1909# of this matters, and things will work correctly because everything's
1910# forward-slashed, everywhere, always.
1911ifdef CYGWIN_WRAPPER
1912NATIVE_TOPSRCDIR   := `cygpath -wa $(topsrcdir)`
1913FWDSLASH_TOPSRCDIR := `cygpath -ma $(topsrcdir)`
1914else
1915FWDSLASH_TOPSRCDIR := $(topsrcdir)
1916ifeq ($(HOST_OS_ARCH),WINNT)
1917NATIVE_TOPSRCDIR   := $(subst /,\\,$(WIN_TOP_SRC))
1918else
1919NATIVE_TOPSRCDIR   := $(topsrcdir)
1920endif
1921endif # CYGWIN_WRAPPER
1922
1923# Test execution
1924check::
1925        @$(EXIT_ON_ERROR) \
1926        for testdir in $(XPCSHELL_TESTS); do \
1927          $(RUN_TEST_PROGRAM) \
1928            $(topsrcdir)/tools/test-harness/xpcshell-simple/test_all.sh \
1929              $(DIST)/bin/xpcshell \
1930              $(FWDSLASH_TOPSRCDIR) \
1931              $(NATIVE_TOPSRCDIR) \
1932              $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \
1933        done
1934
1935# Test execution
1936check-interactive::
1937        @$(EXIT_ON_ERROR) \
1938        $(RUN_TEST_PROGRAM) \
1939          $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
1940            $(DIST)/bin/xpcshell \
1941            $(FWDSLASH_TOPSRCDIR) \
1942            $(NATIVE_TOPSRCDIR) \
1943            $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
1944            $(SOLO_FILE) 1;
1945
1946# Test execution
1947check-one::
1948        @$(EXIT_ON_ERROR) \
1949        $(RUN_TEST_PROGRAM) \
1950          $(topsrcdir)/tools/test-harness/xpcshell-simple/test_one.sh \
1951            $(DIST)/bin/xpcshell \
1952            $(FWDSLASH_TOPSRCDIR) \
1953            $(NATIVE_TOPSRCDIR) \
1954            $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir \
1955            $(SOLO_FILE) 0;
1956
1957endif # XPCSHELL_TESTS
1958
1959endif # ENABLE_TESTS
1960
1961
1962#############################################################################
1963# Dependency system
1964#############################################################################
1965ifdef COMPILER_DEPEND
1966depend::
1967        @echo "$(MAKE): No need to run depend target.\
1968                        Using compiler-based depend." 1>&2
1969ifeq ($(GNU_CC)$(GNU_CXX),)
1970# Non-GNU compilers
1971        @echo "`echo '$(MAKE):'|sed 's/./ /g'`"\
1972        '(Compiler-based depend was turned on by "--enable-md".)' 1>&2
1973else
1974# GNU compilers
1975        @space="`echo '$(MAKE): '|sed 's/./ /g'`";\
1976        echo "$$space"'Since you are using a GNU compiler,\
1977                it is on by default.' 1>&2; \
1978        echo "$$space"'To turn it off, pass --disable-md to configure.' 1>&2
1979endif
1980
1981else # ! COMPILER_DEPEND
1982
1983ifndef MOZ_AUTO_DEPS
1984
1985define MAKE_DEPS_NOAUTO
1986        $(MKDEPEND) -w1024 -o'.$(OBJ_SUFFIX)' -f- $(DEFINES) $(ACDEFINES) $(INCLUDES) $< 2>/dev/null | sed -e "s|^[^ ]*/||" > $@
1987endef
1988
1989$(MDDEPDIR)/%.pp: %.c
1990        $(REPORT_BUILD)
1991        @$(MAKE_DEPS_NOAUTO)
1992
1993$(MDDEPDIR)/%.pp: %.cpp
1994        $(REPORT_BUILD)
1995        @$(MAKE_DEPS_NOAUTO)
1996
1997$(MDDEPDIR)/%.pp: %.s
1998        $(REPORT_BUILD)
1999        @$(MAKE_DEPS_NOAUTO)
2000
2001ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
2002depend:: $(SUBMAKEFILES) $(MAKE_DIRS) $(MDDEPFILES)
2003else
2004depend:: $(SUBMAKEFILES)
2005endif
2006        +$(LOOP_OVER_DIRS)
2007        +$(LOOP_OVER_TOOL_DIRS)
2008
2009dependclean:: $(SUBMAKEFILES)
2010        rm -f $(MDDEPFILES)
2011        +$(LOOP_OVER_DIRS)
2012        +$(LOOP_OVER_TOOL_DIRS)
2013
2014endif # MOZ_AUTO_DEPS
2015
2016endif # COMPILER_DEPEND
2017
2018
2019#############################################################################
2020# MDDEPDIR is the subdirectory where all the dependency files are placed.
2021#   This uses a make rule (instead of a macro) to support parallel
2022#   builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
2023#   processes could simultaneously try to create the same directory.
2024#
2025$(MDDEPDIR):
2026        @if test ! -d $@; then echo Creating $@; rm -rf $@; mkdir $@; else true; fi
2027
2028ifneq (,$(filter-out all chrome default export realchrome tools clean clobber clobber_all distclean realclean,$(MAKECMDGOALS)))
2029ifneq (,$(OBJS)$(XPIDLSRCS)$(SDK_XPIDLSRCS)$(SIMPLE_PROGRAMS))
2030MDDEPEND_FILES          := $(strip $(wildcard $(MDDEPDIR)/*.pp))
2031
2032ifneq (,$(MDDEPEND_FILES))
2033ifdef PERL
2034# The script mddepend.pl checks the dependencies and writes to stdout
2035# one rule to force out-of-date objects. For example,
2036#   foo.o boo.o: FORCE
2037# The script has an advantage over including the *.pp files directly
2038# because it handles the case when header files are removed from the build.
2039# 'make' would complain that there is no way to build missing headers.
2040ifeq (,$(MAKE_RESTARTS))
2041$(MDDEPDIR)/.all.pp: FORCE
2042        @$(PERL) $(BUILD_TOOLS)/mddepend.pl $@ $(MDDEPEND_FILES)
2043endif
2044-include $(MDDEPDIR)/.all.pp
2045else
2046include $(MDDEPEND_FILES)
2047endif
2048endif
2049
2050endif
2051endif
2052#############################################################################
2053
2054-include $(topsrcdir)/$(MOZ_BUILD_APP)/app-rules.mk
2055-include $(MY_RULES)
2056
2057#
2058# This speeds up gmake's processing if these files don't exist.
2059#
2060$(MY_CONFIG) $(MY_RULES):
2061        @touch $@
2062
2063#
2064# Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
2065# or in $(MY_RULES)
2066#
2067ifdef ETAGS
2068ifneq ($(CSRCS)$(CPPSRCS)$(HEADERS),)
2069all:: TAGS
2070TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
2071        $(ETAGS) $(CSRCS) $(CPPSRCS) $(HEADERS)
2072endif
2073endif
2074
2075################################################################################
2076# Special gmake rules.
2077################################################################################
2078
2079
2080#
2081# Disallow parallel builds with MSVC < 8
2082#
2083ifneq (,$(filter 1200 1300 1310,$(_MSC_VER)))
2084.NOTPARALLEL:
2085endif
2086
2087#
2088# Re-define the list of default suffixes, so gmake won't have to churn through
2089# hundreds of built-in suffix rules for stuff we don't need.
2090#
2091.SUFFIXES:
2092
2093#
2094# Fake targets.  Always run these rules, even if a file/directory with that
2095# name already exists.
2096#
2097.PHONY: all all_platforms alltags boot checkout chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_viewer run_apprunner tools $(DIRS) $(TOOL_DIRS) FORCE check check-interactive check-one
2098
2099# Used as a dependency to force targets to rebuild
2100FORCE:
2101
2102# Delete target if error occurs when building target
2103.DELETE_ON_ERROR:
2104
2105# Properly set LIBPATTERNS for the platform
2106.LIBPATTERNS = $(if $(IMPORT_LIB_SUFFIX),$(LIB_PREFIX)%.$(IMPORT_LIB_SUFFIX)) $(LIB_PREFIX)%.$(LIB_SUFFIX) $(DLL_PREFIX)%$(DLL_SUFFIX) 
2107
2108tags: TAGS
2109
2110TAGS: $(SUBMAKEFILES) $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2111        -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
2112        +$(LOOP_OVER_DIRS)
2113
2114echo-variable-%:
2115        @echo $($*)
2116
2117echo-tiers:
2118        @echo $(TIERS)
2119
2120echo-dirs:
2121        @echo $(DIRS)
2122
2123echo-module:
2124        @echo $(MODULE)
2125
2126echo-requires:
2127        @echo $(REQUIRES)
2128
2129echo-requires-recursive::
2130ifdef _REPORT_ALL_DIRS
2131        @echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES)
2132else
2133        @$(if $(REQUIRES),echo $(subst $(topsrcdir)/,,$(srcdir)): $(MODULE): $(REQUIRES))
2134endif
2135        +$(LOOP_OVER_DIRS)
2136
2137echo-depth-path:
2138        @$(topsrcdir)/build/unix/print-depth-path.sh
2139
2140echo-module-name:
2141        @$(topsrcdir)/build/package/rpm/print-module-name.sh
2142
2143echo-module-filelist:
2144        @$(topsrcdir)/build/package/rpm/print-module-filelist.sh
2145
2146showtargs:
2147ifneq (,$(filter $(PROGRAM) $(HOST_PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_LIBRARY) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
2148        @echo --------------------------------------------------------------------------------
2149        @echo "PROGRAM             = $(PROGRAM)"
2150        @echo "SIMPLE_PROGRAMS     = $(SIMPLE_PROGRAMS)"
2151        @echo "LIBRARY             = $(LIBRARY)"
2152        @echo "SHARED_LIBRARY      = $(SHARED_LIBRARY)"
2153        @echo "SHARED_LIBRARY_LIBS = $(SHARED_LIBRARY_LIBS)"
2154        @echo "LIBS                = $(LIBS)"
2155        @echo "DEF_FILE            = $(DEF_FILE)"
2156        @echo "IMPORT_LIBRARY      = $(IMPORT_LIBRARY)"
2157        @echo "STATIC_LIBS         = $(STATIC_LIBS)"
2158        @echo "SHARED_LIBS         = $(SHARED_LIBS)"
2159        @echo "EXTRA_DSO_LIBS      = $(EXTRA_DSO_LIBS)"
2160        @echo "EXTRA_DSO_LDOPTS    = $(EXTRA_DSO_LDOPTS)"
2161        @echo "DEPENDENT_LIBS      = $(DEPENDENT_LIBS)"
2162        @echo --------------------------------------------------------------------------------
2163endif
2164        +$(LOOP_OVER_DIRS)
2165
2166showbuild:
2167        @echo "MOZ_BUILD_ROOT     = $(MOZ_BUILD_ROOT)"
2168        @echo "MOZ_WIDGET_TOOLKIT = $(MOZ_WIDGET_TOOLKIT)"
2169        @echo "CC                 = $(CC)"
2170        @echo "CXX                = $(CXX)"
2171        @echo "CCC                = $(CCC)"
2172        @echo "CPP                = $(CPP)"
2173        @echo "LD                 = $(LD)"
2174        @echo "AR                 = $(AR)"
2175        @echo "IMPLIB             = $(IMPLIB)"
2176        @echo "FILTER             = $(FILTER)"
2177        @echo "MKSHLIB            = $(MKSHLIB)"
2178        @echo "MKCSHLIB           = $(MKCSHLIB)"
2179        @echo "RC                 = $(RC)"
2180        @echo "CFLAGS             = $(CFLAGS)"
2181        @echo "OS_CFLAGS          = $(OS_CFLAGS)"
2182        @echo "COMPILE_CFLAGS     = $(COMPILE_CFLAGS)"
2183        @echo "CXXFLAGS           = $(CXXFLAGS)"
2184        @echo "OS_CXXFLAGS        = $(OS_CXXFLAGS)"
2185        @echo "COMPILE_CXXFLAGS   = $(COMPILE_CXXFLAGS)"
2186        @echo "COMPILE_CMFLAGS    = $(COMPILE_CMFLAGS)"
2187        @echo "COMPILE_CMMFLAGS   = $(COMPILE_CMMFLAGS)"
2188        @echo "LDFLAGS            = $(LDFLAGS)"
2189        @echo "OS_LDFLAGS         = $(OS_LDFLAGS)"
2190        @echo "DSO_LDOPTS         = $(DSO_LDOPTS)"
2191        @echo "OS_INCLUDES        = $(OS_INCLUDES)"
2192        @echo "OS_LIBS            = $(OS_LIBS)"
2193        @echo "EXTRA_LIBS         = $(EXTRA_LIBS)"
2194        @echo "BIN_FLAGS          = $(BIN_FLAGS)"
2195        @echo "INCLUDES           = $(INCLUDES)"
2196        @echo "DEFINES            = $(DEFINES)"
2197        @echo "ACDEFINES          = $(ACDEFINES)"
2198        @echo "BIN_SUFFIX         = $(BIN_SUFFIX)"
2199        @echo "LIB_SUFFIX         = $(LIB_SUFFIX)"
2200        @echo "DLL_SUFFIX         = $(DLL_SUFFIX)"
2201        @echo "IMPORT_LIB_SUFFIX  = $(IMPORT_LIB_SUFFIX)"
2202        @echo "INSTALL            = $(INSTALL)"
2203
2204showhost:
2205        @echo "HOST_CC            = $(HOST_CC)"
2206        @echo "HOST_CXX           = $(HOST_CXX)"
2207        @echo "HOST_CFLAGS        = $(HOST_CFLAGS)"
2208        @echo "HOST_LDFLAGS       = $(HOST_LDFLAGS)"
2209        @echo "HOST_LIBS          = $(HOST_LIBS)"
2210        @echo "HOST_EXTRA_LIBS    = $(HOST_EXTRA_LIBS)"
2211        @echo "HOST_EXTRA_DEPS    = $(HOST_EXTRA_DEPS)"
2212        @echo "HOST_PROGRAM       = $(HOST_PROGRAM)"
2213        @echo "HOST_OBJS          = $(HOST_OBJS)"
2214        @echo "HOST_PROGOBJS      = $(HOST_PROGOBJS)"
2215        @echo "HOST_LIBRARY       = $(HOST_LIBRARY)"
2216
2217showbuildmods::
2218        @echo "Build Modules    = $(BUILD_MODULES)"
2219        @echo "Module dirs      = $(BUILD_MODULE_DIRS)"
2220
2221zipmakes:
2222ifneq (,$(filter $(PROGRAM) $(SIMPLE_PROGRAMS) $(LIBRARY) $(SHARED_LIBRARY),$(TARGETS)))
2223        zip $(DEPTH)/makefiles $(subst $(topsrcdir),$(MOZ_SRC)/mozilla,$(srcdir)/Makefile.in)
2224endif
2225        +$(LOOP_OVER_DIRS)
2226
2227documentation:
2228        @cd $(DEPTH)
2229        $(DOXYGEN) $(DEPTH)/config/doxygen.cfg
2230
2231check:: $(SUBMAKEFILES) $(MAKE_DIRS)
2232        +$(LOOP_OVER_DIRS)
2233        +$(LOOP_OVER_TOOL_DIRS)
Note: See TracBrowser for help on using the repository browser.