Source code

Revision control

Other Tools

1
# -*- makefile -*-
2
# vim:set ts=8 sw=8 sts=8 noet:
3
#
4
# This Source Code Form is subject to the terms of the Mozilla Public
5
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
6
# You can obtain one at http://mozilla.org/MPL/2.0/.
7
#
8
9
ifndef topsrcdir
10
$(error topsrcdir was not set))
11
endif
12
13
# Define an include-at-most-once flag
14
ifdef INCLUDED_RULES_MK
15
$(error Do not include rules.mk twice!)
16
endif
17
INCLUDED_RULES_MK = 1
18
19
ifndef INCLUDED_CONFIG_MK
20
include $(topsrcdir)/config/config.mk
21
endif
22
23
ifndef INCLUDED_VERSION_MK
24
include $(MOZILLA_DIR)/config/version.mk
25
endif
26
27
USE_AUTOTARGETS_MK = 1
28
include $(MOZILLA_DIR)/config/makefiles/makeutils.mk
29
30
ifdef REBUILD_CHECK
31
REPORT_BUILD = $(info $(shell $(PYTHON) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^))
32
REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
33
else
34
REPORT_BUILD = $(info $(relativesrcdir)/$(notdir $@))
35
36
ifdef BUILD_VERBOSE_LOG
37
REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
38
else
39
REPORT_BUILD_VERBOSE = $(call BUILDSTATUS,BUILD_VERBOSE $(relativesrcdir))
40
endif
41
42
endif
43
44
EXEC = exec
45
46
_VPATH_SRCS = $(abspath $<)
47
48
################################################################################
49
# Testing frameworks support
50
################################################################################
51
52
testxpcobjdir = $(DEPTH)/_tests/xpcshell
53
54
ifdef ENABLE_TESTS
55
ifdef CPP_UNIT_TESTS
56
ifdef COMPILE_ENVIRONMENT
57
58
# Compile the tests to $(DIST)/bin. Make lots of niceties available by default
59
# through TestHarness.h, by modifying the list of includes and the libs against
60
# which stuff links.
61
SIMPLE_PROGRAMS += $(CPP_UNIT_TESTS)
62
63
ifndef MOZ_PROFILE_GENERATE
64
CPP_UNIT_TESTS_FILES = $(CPP_UNIT_TESTS)
65
CPP_UNIT_TESTS_DEST = $(DIST)/cppunittests
66
CPP_UNIT_TESTS_TARGET = target
67
INSTALL_TARGETS += CPP_UNIT_TESTS
68
endif
69
70
run-cppunittests::
71
@$(PYTHON) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
72
73
cppunittests-remote:
74
$(PYTHON) -u $(MOZILLA_DIR)/testing/remotecppunittests.py \
75
--xre-path=$(DEPTH)/dist/bin \
76
--localLib=$(DEPTH)/dist/$(MOZ_APP_NAME) \
77
--deviceIP=${TEST_DEVICE} \
78
$(CPP_UNIT_TESTS) $(EXTRA_TEST_ARGS); \
79
80
endif # COMPILE_ENVIRONMENT
81
endif # CPP_UNIT_TESTS
82
endif # ENABLE_TESTS
83
84
85
#
86
# Library rules
87
#
88
# If FORCE_STATIC_LIB is set, build a static library.
89
# Otherwise, build a shared library.
90
#
91
92
ifndef LIBRARY
93
ifdef REAL_LIBRARY
94
ifdef NO_EXPAND_LIBS
95
# Only build actual library if it is requested.
96
LIBRARY := $(REAL_LIBRARY)
97
endif
98
endif
99
endif
100
101
ifdef FORCE_SHARED_LIB
102
ifdef MKSHLIB
103
104
ifdef LIB_IS_C_ONLY
105
MKSHLIB = $(MKCSHLIB)
106
endif
107
108
EMBED_MANIFEST_AT=2
109
110
endif # MKSHLIB
111
endif # FORCE_SHARED_LIB
112
113
ifeq ($(OS_ARCH),WINNT)
114
115
#
116
# This next line captures both the default (non-MOZ_COPY_PDBS)
117
# case as well as the MOZ_COPY_PDBS-for-mingwclang case.
118
#
119
# For the default case, placing the pdb in the build
120
# directory is needed.
121
#
122
# For the MOZ_COPY_PDBS, non-mingwclang case - we need to
123
# build the pdb next to the executable (handled in the if
124
# statement immediately below.)
125
#
126
# For the MOZ_COPY_PDBS, mingwclang case - we also need to
127
# build the pdb next to the executable, but this macro doesn't
128
# work for jsapi-tests which is a little special, so we specify
129
# the output directory below with MOZ_PROGRAM_LDFLAGS.
130
#
131
LINK_PDBFILE ?= $(basename $(@F)).pdb
132
133
ifdef MOZ_COPY_PDBS
134
ifneq ($(CC_TYPE),clang)
135
LINK_PDBFILE = $(basename $@).pdb
136
endif
137
endif
138
139
ifndef GNU_CC
140
141
ifdef SIMPLE_PROGRAMS
142
COMPILE_PDB_FLAG ?= -Fd$(basename $(@F)).pdb
143
COMPILE_CFLAGS += $(COMPILE_PDB_FLAG)
144
COMPILE_CXXFLAGS += $(COMPILE_PDB_FLAG)
145
endif
146
147
ifdef MOZ_DEBUG
148
CODFILE=$(basename $(@F)).cod
149
endif
150
151
endif # !GNU_CC
152
endif # WINNT
153
154
ifeq (arm-Darwin,$(CPU_ARCH)-$(OS_TARGET))
155
ifdef PROGRAM
156
MOZ_PROGRAM_LDFLAGS += -Wl,-rpath -Wl,@executable_path/Frameworks
157
endif
158
endif
159
160
ifeq ($(OS_ARCH),WINNT)
161
ifeq ($(CC_TYPE),clang)
162
MOZ_PROGRAM_LDFLAGS += -Wl,-pdb,$(dir $@)/$(LINK_PDBFILE)
163
endif
164
endif
165
166
ifeq ($(HOST_OS_ARCH),WINNT)
167
HOST_PDBFILE=$(basename $(@F)).pdb
168
HOST_PDB_FLAG ?= -Fd$(HOST_PDBFILE)
169
HOST_C_LDFLAGS += $(HOST_PDB_FLAG)
170
HOST_CXX_LDFLAGS += $(HOST_PDB_FLAG)
171
endif
172
173
# Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass, and do not
174
# attempt to install them
175
ifdef MOZ_PROFILE_GENERATE
176
$(foreach category,$(INSTALL_TARGETS),\
177
$(eval $(category)_FILES := $(foreach file,$($(category)_FILES),$(if $(filter $(SIMPLE_PROGRAMS),$(notdir $(file))),,$(file)))))
178
SIMPLE_PROGRAMS :=
179
endif
180
181
ifdef COMPILE_ENVIRONMENT
182
ifndef TARGETS
183
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_SHARED_LIBRARY)
184
endif
185
186
COBJS = $(notdir $(CSRCS:.c=.$(OBJ_SUFFIX)))
187
SOBJS = $(notdir $(SSRCS:.S=.$(OBJ_SUFFIX)))
188
# CPPSRCS can have different extensions (eg: .cpp, .cc)
189
CPPOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(CPPSRCS))))
190
CMOBJS = $(notdir $(CMSRCS:.m=.$(OBJ_SUFFIX)))
191
CMMOBJS = $(notdir $(CMMSRCS:.mm=.$(OBJ_SUFFIX)))
192
# ASFILES can have different extensions (.s, .asm)
193
ASOBJS = $(notdir $(addsuffix .$(OBJ_SUFFIX),$(basename $(ASFILES))))
194
RS_STATICLIB_CRATE_OBJ = $(addprefix lib,$(notdir $(RS_STATICLIB_CRATE_SRC:.rs=.$(LIB_SUFFIX))))
195
ifndef OBJS
196
_OBJS = $(COBJS) $(SOBJS) $(CPPOBJS) $(CMOBJS) $(CMMOBJS) $(ASOBJS)
197
OBJS = $(strip $(_OBJS))
198
endif
199
200
HOST_COBJS = $(addprefix host_,$(notdir $(HOST_CSRCS:.c=.$(_OBJ_SUFFIX))))
201
# HOST_CPPOBJS can have different extensions (eg: .cpp, .cc)
202
HOST_CPPOBJS = $(addprefix host_,$(notdir $(addsuffix .$(_OBJ_SUFFIX),$(basename $(HOST_CPPSRCS)))))
203
HOST_CMOBJS = $(addprefix host_,$(notdir $(HOST_CMSRCS:.m=.$(_OBJ_SUFFIX))))
204
HOST_CMMOBJS = $(addprefix host_,$(notdir $(HOST_CMMSRCS:.mm=.$(_OBJ_SUFFIX))))
205
ifndef HOST_OBJS
206
_HOST_OBJS = $(HOST_COBJS) $(HOST_CPPOBJS) $(HOST_CMOBJS) $(HOST_CMMOBJS)
207
HOST_OBJS = $(strip $(_HOST_OBJS))
208
endif
209
else
210
LIBRARY :=
211
SHARED_LIBRARY :=
212
IMPORT_LIBRARY :=
213
REAL_LIBRARY :=
214
PROGRAM :=
215
SIMPLE_PROGRAMS :=
216
HOST_SHARED_LIBRARY :=
217
HOST_PROGRAM :=
218
HOST_SIMPLE_PROGRAMS :=
219
endif
220
221
ALL_TRASH = \
222
$(GARBAGE) $(TARGETS) $(OBJS) $(PROGOBJS) LOGS TAGS a.out \
223
$(filter-out $(ASFILES),$(OBJS:.$(OBJ_SUFFIX)=.s)) $(OBJS:.$(OBJ_SUFFIX)=.ii) \
224
$(OBJS:.$(OBJ_SUFFIX)=.i) $(OBJS:.$(OBJ_SUFFIX)=.i_o) \
225
$(HOST_PROGOBJS) $(HOST_OBJS) $(IMPORT_LIBRARY) \
226
so_locations _gen _stubs $(wildcard *.res) $(wildcard *.RES) \
227
$(wildcard *.pdb) $(CODFILE) $(IMPORT_LIBRARY) \
228
$(SHARED_LIBRARY:$(DLL_SUFFIX)=.exp) $(wildcard *.ilk) \
229
$(PROGRAM:$(BIN_SUFFIX)=.exp) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.exp) \
230
$(PROGRAM:$(BIN_SUFFIX)=.lib) $(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.lib) \
231
$(SIMPLE_PROGRAMS:$(BIN_SUFFIX)=.$(OBJ_SUFFIX)) \
232
$(wildcard gts_tmp_*) $(LIBRARY:%.a=.%.timestamp)
233
ALL_TRASH_DIRS = \
234
$(GARBAGE_DIRS) /no-such-file
235
236
ifdef QTDIR
237
GARBAGE += $(MOCSRCS)
238
endif
239
240
ifdef SIMPLE_PROGRAMS
241
GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
242
endif
243
244
ifdef HOST_SIMPLE_PROGRAMS
245
GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(_OBJ_SUFFIX))
246
endif
247
248
ifdef MACH
249
ifndef NO_BUILDSTATUS_MESSAGES
250
define BUILDSTATUS
251
@echo 'BUILDSTATUS $1'
252
253
endef
254
endif
255
endif
256
257
define SUBMAKE # $(call SUBMAKE,target,directory,static)
258
+@$(MAKE) $(if $(2),-C $(2)) $(1)
259
260
endef # The extra line is important here! don't delete it
261
262
define TIER_DIR_SUBMAKE
263
$(call SUBMAKE,$(4),$(3),$(5))
264
265
endef # Ths empty line is important.
266
267
ifneq (,$(strip $(DIRS)))
268
LOOP_OVER_DIRS = \
269
$(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
270
endif
271
272
#
273
# Now we can differentiate between objects used to build a library, and
274
# objects used to build an executable in the same directory.
275
#
276
ifndef PROGOBJS
277
PROGOBJS = $(OBJS)
278
endif
279
280
ifndef HOST_PROGOBJS
281
HOST_PROGOBJS = $(HOST_OBJS)
282
endif
283
284
GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
285
286
#
287
# Tags: emacs (etags), vi (ctags)
288
# TAG_PROGRAM := ctags -L -
289
#
290
TAG_PROGRAM = xargs etags -a
291
292
#
293
# Turn on C++ linking if we have any .cpp or .mm files
294
# (moved this from config.mk so that config.mk can be included
295
# before the CPPSRCS are defined)
296
#
297
ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
298
HOST_CPP_PROG_LINK = 1
299
endif
300
301
#
302
# MacOS X specific stuff
303
#
304
305
ifeq ($(OS_ARCH),Darwin)
306
ifdef SHARED_LIBRARY
307
ifdef MOZ_IOS
308
_LOADER_PATH := @rpath
309
else
310
_LOADER_PATH := @executable_path
311
endif
312
EXTRA_DSO_LDOPTS += -dynamiclib -install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
313
endif
314
endif
315
316
#
317
# GNU doesn't have path length limitation
318
#
319
320
ifeq ($(OS_ARCH),GNU)
321
OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
322
endif
323
324
#
325
# MINGW32
326
#
327
ifeq ($(OS_ARCH),WINNT)
328
ifdef GNU_CC
329
DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
330
endif
331
endif
332
333
ifeq ($(USE_TVFS),1)
334
IFLAGS1 = -rb
335
IFLAGS2 = -rb
336
else
337
IFLAGS1 = -m 644
338
IFLAGS2 = -m 755
339
endif
340
341
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
342
OUTOPTION = -Fo# eol
343
else
344
OUTOPTION = -o # eol
345
endif # WINNT && !GNU_CC
346
347
ifeq (,$(CROSS_COMPILE))
348
HOST_OUTOPTION = $(OUTOPTION)
349
else
350
# Windows-to-Windows cross compiles should always use MSVC-style options for
351
# host compiles.
352
ifeq (WINNT_WINNT,$(HOST_OS_ARCH)_$(OS_ARCH))
353
ifneq (,$(filter-out clang-cl,$(HOST_CC_TYPE)))
354
$(error MSVC-style compilers should be used for host compilations!)
355
endif
356
HOST_OUTOPTION = -Fo# eol
357
else
358
HOST_OUTOPTION = -o # eol
359
endif
360
endif
361
################################################################################
362
363
# Ensure the build config is up to date. This is done automatically when builds
364
# are performed through |mach build|. The check here is to catch people not
365
# using mach. If we ever enforce builds through mach, this code can be removed.
366
ifndef MOZBUILD_BACKEND_CHECKED
367
ifndef MACH
368
ifndef TOPLEVEL_BUILD
369
BUILD_BACKEND_FILES := $(addprefix $(DEPTH)/backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
370
$(DEPTH)/backend.%Backend:
371
$(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
372
373
define build_backend_rule
374
$(1): $$(shell cat $(1).in)
375
376
endef
377
$(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))
378
379
default:: $(BUILD_BACKEND_FILES)
380
381
export MOZBUILD_BACKEND_CHECKED=1
382
endif
383
endif
384
endif
385
386
# The root makefile doesn't want to do a plain export/libs, because
387
# of the tiers and because of libxul. Suppress the default rules in favor
388
# of something else. Makefiles which use this var *must* provide a sensible
389
# default rule before including rules.mk
390
default all::
391
$(foreach tier,$(TIERS),$(call SUBMAKE,$(tier)))
392
393
ifdef BUILD_VERBOSE_LOG
394
ECHO := echo
395
QUIET :=
396
else
397
ECHO := true
398
QUIET := -q
399
endif
400
401
# Do everything from scratch
402
everything::
403
$(MAKE) clean
404
$(MAKE) all
405
406
# Dependencies which, if modified, should cause everything to rebuild
407
GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk
408
409
##############################################
410
ifdef COMPILE_ENVIRONMENT
411
compile:: host target
412
413
host:: $(HOST_OBJS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_RUST_PROGRAMS) $(HOST_RUST_LIBRARY_FILE) $(HOST_SHARED_LIBRARY)
414
415
target:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS),$(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE) $(RUST_PROGRAMS))
416
417
ifndef LIBRARY
418
ifdef OBJS
419
target:: $(OBJS)
420
endif
421
endif
422
423
target-objects: $(OBJS) $(PROGOBJS)
424
host-objects: $(HOST_OBJS) $(HOST_PROGOBJS)
425
426
syms::
427
428
include $(MOZILLA_DIR)/config/makefiles/target_binaries.mk
429
endif
430
431
##############################################
432
ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
433
ifdef MOZ_1TIER_PGO
434
ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
435
# When building with PGO, we have to make sure to re-link
436
# in the MOZ_PROFILE_USE phase if we linked in the
437
# MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
438
# file in the link rule in the GENERATE phase to indicate
439
# that we need a relink.
440
ifdef SHARED_LIBRARY
441
$(SHARED_LIBRARY): pgo.relink
442
endif
443
ifdef PROGRAM
444
$(PROGRAM): pgo.relink
445
endif
446
447
# In the second pass, we need to merge the pgc files into the pgd file.
448
# The compiler would do this for us automatically if they were in the right
449
# place, but they're in dist/bin.
450
ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
451
export::
452
ifdef PROGRAM
453
$(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \
454
$(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
455
endif
456
ifdef SHARED_LIBRARY
457
$(PYTHON) $(MOZILLA_DIR)/build/win32/pgomerge.py \
458
$(patsubst $(DLL_PREFIX)%$(DLL_SUFFIX),%,$(SHARED_LIBRARY)) $(DIST)/bin
459
endif
460
endif # SHARED_LIBRARY || PROGRAM
461
endif # WINNT_
462
endif # MOZ_PROFILE_USE
463
ifdef MOZ_PROFILE_GENERATE
464
# Clean up profiling data during PROFILE_GENERATE phase
465
export::
466
ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
467
$(foreach pgd,$(wildcard *.pgd),pgomgr -clear $(pgd);)
468
else
469
ifdef GNU_CC
470
-$(RM) *.gcda
471
endif
472
endif
473
endif
474
475
ifneq (,$(MOZ_PROFILE_GENERATE)$(MOZ_PROFILE_USE))
476
ifneq (,$(filter target,$(MAKECMDGOALS)))
477
ifdef GNU_CC
478
# Force rebuilding libraries and programs in both passes because each
479
# pass uses different object files.
480
$(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
481
endif
482
endif
483
endif
484
485
endif # NO_PROFILE_GUIDED_OPTIMIZE
486
487
##############################################
488
489
clean clobber realclean clobber_all::
490
-$(RM) $(ALL_TRASH)
491
-$(RM) -r $(ALL_TRASH_DIRS)
492
493
clean clobber realclean clobber_all distclean::
494
$(foreach dir,$(DIRS),-$(call SUBMAKE,$@,$(dir)))
495
496
distclean::
497
-$(RM) -r $(ALL_TRASH_DIRS)
498
-$(RM) $(ALL_TRASH) \
499
Makefile .HSancillary \
500
$(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
501
$(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
502
$(wildcard *.$(IMPORT_LIB_SUFFIX))
503
504
alltags:
505
$(RM) TAGS
506
find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
507
508
define EXPAND_CC_OR_CXX
509
$(if $(PROG_IS_C_ONLY_$(1)),$(CC),$(CCC))
510
endef
511
512
#
513
# PROGRAM = Foo
514
# creates OBJS, links with LIBS to create Foo
515
#
516
$(PROGRAM): $(PROGOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(RESFILE) $(GLOBAL_DEPS) $(call mkdir_deps,$(FINAL_TARGET))
517
$(REPORT_BUILD)
518
@$(RM) $@.manifest
519
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
520
$(LINKER) -NOLOGO -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
521
ifdef MSMANIFEST_TOOL
522
@if test -f $@.manifest; then \
523
if test -f '$(srcdir)/$(notdir $@).manifest'; then \
524
echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest and $@.manifest'; \
525
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
526
else \
527
echo 'Embedding manifest from $@.manifest'; \
528
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
529
fi; \
530
elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
531
echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
532
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
533
fi
534
endif # MSVC with manifest tool
535
ifdef MOZ_PROFILE_GENERATE
536
# touch it a few seconds into the future to work around FAT's
537
# 2-second granularity
538
touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
539
endif
540
else # !WINNT || GNU_CC
541
$(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
542
$(call py_action,check_binary,--target $@)
543
endif # WINNT && !GNU_CC
544
545
ifdef ENABLE_STRIP
546
$(STRIP) $(STRIP_FLAGS) $@
547
endif
548
ifdef MOZ_POST_PROGRAM_COMMAND
549
$(MOZ_POST_PROGRAM_COMMAND) $@
550
endif
551
552
$(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) $(call mkdir_deps,$(DEPTH)/dist/host/bin)
553
$(REPORT_BUILD)
554
ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
555
$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
556
ifdef MSMANIFEST_TOOL
557
@if test -f $@.manifest; then \
558
if test -f '$(srcdir)/$(notdir $@).manifest'; then \
559
echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest and $@.manifest'; \
560
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' $@.manifest -OUTPUTRESOURCE:$@\;1; \
561
else \
562
echo 'Embedding manifest from $@.manifest'; \
563
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
564
fi; \
565
elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
566
echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
567
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
568
fi
569
endif # MSVC with manifest tool
570
else
571
ifeq ($(HOST_CPP_PROG_LINK),1)
572
$(HOST_CXX) -o $@ $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
573
else
574
$(HOST_CC) -o $@ $(HOST_C_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
575
endif # HOST_CPP_PROG_LINK
576
endif
577
ifndef CROSS_COMPILE
578
$(call py_action,check_binary,--host $@)
579
endif
580
581
#
582
# This is an attempt to support generation of multiple binaries
583
# in one directory, it assumes everything to compile Foo is in
584
# Foo.o (from either Foo.c or Foo.cpp).
585
#
586
# SIMPLE_PROGRAMS = Foo Bar
587
# creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
588
#
589
$(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
590
$(REPORT_BUILD)
591
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
592
$(LINKER) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $($@_$(OBJS_VAR_SUFFIX)) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
593
ifdef MSMANIFEST_TOOL
594
@if test -f $@.manifest; then \
595
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
596
rm -f $@.manifest; \
597
elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
598
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
599
fi
600
endif # MSVC with manifest tool
601
else
602
$(call EXPAND_CC_OR_CXX,$@) $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) -o $@ $($@_$(OBJS_VAR_SUFFIX)) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
603
$(call py_action,check_binary,--target $@)
604
endif # WINNT && !GNU_CC
605
606
ifdef ENABLE_STRIP
607
$(STRIP) $(STRIP_FLAGS) $@
608
endif
609
ifdef MOZ_POST_PROGRAM_COMMAND
610
$(MOZ_POST_PROGRAM_COMMAND) $@
611
endif
612
613
$(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
614
$(REPORT_BUILD)
615
ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
616
$(HOST_LINKER) -NOLOGO -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
617
else
618
ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
619
$(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXX_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
620
else
621
$(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_C_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
622
endif
623
endif
624
ifndef CROSS_COMPILE
625
$(call py_action,check_binary,--host $@)
626
endif
627
628
$(LIBRARY): $(OBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
629
$(REPORT_BUILD)
630
$(RM) $(REAL_LIBRARY)
631
$(AR) $(AR_FLAGS) $($@_$(OBJS_VAR_SUFFIX))
632
633
ifeq ($(OS_ARCH),WINNT)
634
# Import libraries are created by the rules creating shared libraries.
635
# The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
636
# but make will happily consider the import library before it is refreshed
637
# when rebuilding the corresponding shared library. Defining an empty recipe
638
# for import libraries forces make to wait for the shared library recipe to
639
# have run before considering other targets that depend on the import library.
640
# See bug 795204.
641
$(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
642
endif
643
644
$(HOST_SHARED_LIBRARY): Makefile
645
$(REPORT_BUILD)
646
$(RM) $@
647
ifneq (,$(filter clang-cl,$(HOST_CC_TYPE)))
648
$(HOST_LINKER) -NOLOGO -DLL -OUT:$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
649
else
650
$(HOST_CXX) $(HOST_OUTOPTION)$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
651
endif
652
653
# On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
654
# so instead of deleting .o files after repacking them into a dylib, we make
655
# symlinks back to the originals. The symlinks are a no-op for stabs debugging,
656
# so no need to conditionalize on OS version or debugging format.
657
658
$(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
659
$(REPORT_BUILD)
660
ifndef INCREMENTAL_LINKER
661
$(RM) $@
662
endif
663
$(MKSHLIB) $($@_$(OBJS_VAR_SUFFIX)) $(RESFILE) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS)
664
$(call py_action,check_binary,--target $@)
665
666
ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
667
ifdef MSMANIFEST_TOOL
668
ifdef EMBED_MANIFEST_AT
669
@if test -f $@.manifest; then \
670
if test -f '$(srcdir)/$@.manifest'; then \
671
echo 'Embedding manifest from $(srcdir_rel)/$@.manifest and $@.manifest'; \
672
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$@.manifest' $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
673
else \
674
echo 'Embedding manifest from $@.manifest'; \
675
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
676
fi; \
677
elif test -f '$(srcdir)/$@.manifest'; then \
678
echo 'Embedding manifest from $(srcdir_rel)/$@.manifest'; \
679
$(MT) -NOLOGO -MANIFEST '$(srcdir_rel)/$@.manifest' -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
680
fi
681
endif # EMBED_MANIFEST_AT
682
endif # MSVC with manifest tool
683
ifdef MOZ_PROFILE_GENERATE
684
touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
685
endif
686
endif # WINNT && !GCC
687
chmod +x $@
688
ifdef ENABLE_STRIP
689
$(STRIP) $(STRIP_FLAGS) $@
690
endif
691
692
# The object file is in the current directory, and the source file can be any
693
# relative path. This macro adds the dependency obj: src for each source file.
694
# This dependency must be first for the $< flag to work correctly, and the
695
# rules that have commands for these targets must not list any other
696
# prerequisites, or they will override the $< variable.
697
define src_objdep
698
$(basename $3$(notdir $1)).$2: $1 $$(call mkdir_deps,$$(MDDEPDIR))
699
endef
700
$(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX))))
701
$(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),$(_OBJ_SUFFIX),host_)))
702
703
# The Rust compiler only outputs library objects, and so we need different
704
# mangling to generate dependency rules for it.
705
mk_global_crate_libname = $(basename lib$(notdir $1)).$(LIB_SUFFIX)
706
crate_src_libdep = $(call mk_global_crate_libname,$1): $1 $$(call mkdir_deps,$$(MDDEPDIR))
707
$(foreach f,$(RS_STATICLIB_CRATE_SRC),$(eval $(call crate_src_libdep,$(f))))
708
709
$(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
710
711
# Rules for building native targets must come first because of the host_ prefix
712
$(HOST_COBJS):
713
$(REPORT_BUILD_VERBOSE)
714
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
715
716
$(HOST_CPPOBJS):
717
$(REPORT_BUILD_VERBOSE)
718
$(call BUILDSTATUS,OBJECT_FILE $@)
719
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
720
721
$(HOST_CMOBJS):
722
$(REPORT_BUILD_VERBOSE)
723
$(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
724
725
$(HOST_CMMOBJS):
726
$(REPORT_BUILD_VERBOSE)
727
$(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(NSPR_CFLAGS) $(_VPATH_SRCS)
728
729
$(COBJS):
730
$(REPORT_BUILD_VERBOSE)
731
$(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
732
733
ifdef ASFILES
734
# The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
735
# a '-c' flag.
736
$(ASOBJS):
737
$(REPORT_BUILD_VERBOSE)
738
$(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
739
endif
740
741
define syms_template
742
syms:: $(2)
743
$(2): $(1)
744
ifdef MOZ_CRASHREPORTER
745
$$(call py_action,dumpsymbols,$$(abspath $$<) $$(abspath $$@) $$(DUMP_SYMBOLS_FLAGS))
746
endif
747
endef
748
749
ifndef MOZ_PROFILE_GENERATE
750
ifneq (,$(filter $(DIST)/bin%,$(FINAL_TARGET)))
751
DUMP_SYMS_TARGETS := $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS)
752
endif
753
endif
754
755
ifdef MOZ_AUTOMATION
756
ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS)))
757
DUMP_SYMS_TARGETS :=
758
endif
759
endif
760
761
ifdef MOZ_COPY_PDBS
762
MAIN_PDB_FILES = $(addsuffix .pdb,$(basename $(DUMP_SYMS_TARGETS)))
763
MAIN_PDB_DEST ?= $(FINAL_TARGET)
764
MAIN_PDB_TARGET = syms
765
INSTALL_TARGETS += MAIN_PDB
766
767
ifdef CPP_UNIT_TESTS
768
CPP_UNIT_TESTS_PDB_FILES = $(addsuffix .pdb,$(basename $(CPP_UNIT_TESTS)))
769
CPP_UNIT_TESTS_PDB_DEST = $(DIST)/cppunittests
770
CPP_UNIT_TESTS_PDB_TARGET = syms
771
INSTALL_TARGETS += CPP_UNIT_TESTS_PDB
772
endif
773
774
else ifdef MOZ_CRASHREPORTER
775
$(foreach file,$(DUMP_SYMS_TARGETS),$(eval $(call syms_template,$(file),$(notdir $(file))_syms.track)))
776
endif
777
778
ifneq (,$(RUST_TESTS)$(RUST_LIBRARY_FILE)$(HOST_RUST_LIBRARY_FILE)$(RUST_PROGRAMS)$(HOST_RUST_PROGRAMS))
779
include $(MOZILLA_DIR)/config/makefiles/rust.mk
780
endif
781
782
$(SOBJS):
783
$(REPORT_BUILD)
784
$(AS) $(ASOUTOPTION)$@ $(SFLAGS) $($(notdir $<)_FLAGS) -c $<
785
786
$(CPPOBJS):
787
$(REPORT_BUILD_VERBOSE)
788
$(call BUILDSTATUS,OBJECT_FILE $@)
789
$(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
790
791
$(CMMOBJS):
792
$(REPORT_BUILD_VERBOSE)
793
$(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
794
795
$(CMOBJS):
796
$(REPORT_BUILD_VERBOSE)
797
$(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
798
799
$(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
800
$(REPORT_BUILD_VERBOSE)
801
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
802
803
$(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
804
$(REPORT_BUILD_VERBOSE)
805
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
806
807
$(filter %.s,$(CPPSRCS:%.cxx=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
808
$(REPORT_BUILD_VERBOSE)
809
$(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
810
811
$(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
812
$(REPORT_BUILD_VERBOSE)
813
$(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $(_VPATH_SRCS)
814
815
ifneq (,$(filter %.i,$(MAKECMDGOALS)))
816
# Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
817
# of the full sources, as well as the $(notdir) version. So:
818
# foo.cpp sub/bar.cpp
819
# becomes:
820
# foo.cpp sub/bar.cpp bar.cpp
821
#
822
# This way we can match both 'make sub/bar.i' and 'make bar.i'
823
_group_srcs = $(sort $(patsubst %.$1,%.i,$(filter %.$1,$2 $(notdir $2))))
824
825
define PREPROCESS_RULES
826
_PREPROCESSED_$1_FILES := $$(call _group_srcs,$1,$$($2))
827
# Make preprocessed files PHONY so they are always executed, since they are
828
# manual targets and we don't necessarily write to $@.
829
.PHONY: $$(_PREPROCESSED_$1_FILES)
830
831
# Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
832
# reach $(srcdir)/frontend/Parser.i
833
vpath %.$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
834
vpath %.$1 $$(addprefix $$(CURDIR)/,$$(sort $$(dir $$($2))))
835
836
$$(_PREPROCESSED_$1_FILES): _DEPEND_CFLAGS=
837
$$(_PREPROCESSED_$1_FILES): %.i: %.$1
838
$$(REPORT_BUILD_VERBOSE)
839
$$(addprefix $$(MKDIR) -p ,$$(filter-out .,$$(@D)))
840
$$($3) -C $$(PREPROCESS_OPTION)$$@ $(foreach var,$4,$$($(var))) $$($$(notdir $$<)_FLAGS) $$(_VPATH_SRCS)
841
842
endef
843
844
$(eval $(call PREPROCESS_RULES,cpp,CPPSRCS,CCC,COMPILE_CXXFLAGS))
845
$(eval $(call PREPROCESS_RULES,cc,CPPSRCS,CCC,COMPILE_CXXFLAGS))
846
$(eval $(call PREPROCESS_RULES,cxx,CPPSRCS,CCC,COMPILE_CXXFLAGS))
847
$(eval $(call PREPROCESS_RULES,c,CSRCS,CC,COMPILE_CFLAGS))
848
$(eval $(call PREPROCESS_RULES,mm,CMMSRCS,CCC,COMPILE_CXXFLAGS COMPILE_CMMFLAGS))
849
850
# Default to pre-processing the actual unified file. This can be overridden
851
# at the command-line to pre-process only the individual source file.
852
PP_UNIFIED ?= 1
853
854
# PP_REINVOKE gets set on the sub-make to prevent us from going in an
855
# infinite loop if the filename doesn't exist in the unified source files.
856
ifndef PP_REINVOKE
857
858
MATCH_cpp = \(cpp\|cc|cxx\)
859
UPPER_c = C
860
UPPER_cpp = CPP
861
UPPER_mm = CMM
862
863
# When building with PP_UNIFIED=0, we also have to look in the Unified files to
864
# find a matching pathname.
865
_get_all_sources = $1 $(if $(filter Unified%,$1),$(shell sed -n 's/\#include "\(.*\)"$$/\1/p' $(filter Unified%,$1)))
866
all_cpp_sources := $(call _get_all_sources,$(CPPSRCS))
867
all_mm_sources := $(call _get_all_sources,$(CMMSRCS))
868
all_c_sources := $(call _get_all_sources,$(CSRCS))
869
all_sources := $(all_cpp_sources) $(all_cmm_sources) $(all_c_sources)
870
871
# The catch-all %.i rule runs when we pass in a .i filename that doesn't match
872
# one of the *SRCS variables. The two code paths depend on whether or not
873
# we are requesting a unified file (PP_UNIFIED=1, the default) or not:
874
#
875
# PP_UNIFIED=1:
876
# - Look for it in any of the Unified files, and re-exec make with
877
# Unified_foo0.i as the target. This gets us the full unified preprocessed
878
# file.
879
#
880
# PP_UNIFIED=0:
881
# - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
882
# make with that filename as the target. The *SRCS variables are modified
883
# to have the Unified sources appended to them so that the static pattern
884
# rules will match.
885
%.i: FORCE
886
ifeq ($(PP_UNIFIED),1)
887
@$(MAKE) PP_REINVOKE=1 \
888
$(or $(addsuffix .i, \
889
$(foreach type,c cpp mm, \
890
$(if $(filter Unified%,$($(UPPER_$(type))SRCS)), \
891
$(shell grep -l '#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified*.$(type) | sed 's/\.$(type)$$//') \
892
))),$(error "File not found for preprocessing: $@"))
893
else
894
@$(MAKE) PP_REINVOKE=1 $@ \
895
$(foreach type,c cpp mm,$(UPPER_$(type))SRCS="$(all_$(type)_sources)")
896
endif
897
898
endif
899
900
endif
901
902
$(RESFILE): %.res: %.rc
903
$(REPORT_BUILD)
904
@echo Creating Resource file: $@
905
ifdef GNU_CC
906
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $(_VPATH_SRCS)
907
else
908
$(RC) $(RCFLAGS) -r $(DEFINES) $(INCLUDES) $(OUTOPTION)$@ $(_VPATH_SRCS)
909
endif
910
911
# Cancel GNU make built-in implicit rules
912
MAKEFLAGS += -r
913
914
ifneq (,$(filter WINNT,$(OS_ARCH)))
915
SEP := ;
916
else
917
SEP := :
918
endif
919
920
EMPTY :=
921
SPACE := $(EMPTY) $(EMPTY)
922
923
###############################################################################
924
# Bunch of things that extend the 'export' rule (in order):
925
###############################################################################
926
927
ifneq ($(XPI_NAME),)
928
$(FINAL_TARGET):
929
$(NSINSTALL) -D $@
930
931
export:: $(FINAL_TARGET)
932
endif
933
934
################################################################################
935
# The default location for prefs is the gre prefs directory.
936
# PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
937
PREF_DIR = defaults/pref
938
939
# If DIST_SUBDIR is defined it indicates that app and gre dirs are
940
# different and that we are building app related resources. Hence,
941
# PREF_DIR should point to the app prefs location.
942
ifneq (,$(DIST_SUBDIR)$(XPI_NAME))
943
PREF_DIR = defaults/preferences
944
endif
945
946
################################################################################
947
# CHROME PACKAGING
948
949
chrome::
950
$(MAKE) realchrome
951
$(LOOP_OVER_DIRS)
952
953
$(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
954
955
ifneq (,$(JAR_MANIFEST))
956
ifndef NO_DIST_INSTALL
957
958
ifdef XPI_NAME
959
ifdef XPI_ROOT_APPID
960
# For add-on packaging we may specify that an application
961
# sub-dir should be added to the root chrome manifest with
962
# a specific application id.
963
MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)'
964
endif
965
966
# if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
967
# no way langpacks will get packaged right, so error out.
968
ifneq (,$(DIST_SUBDIR))
969
ifndef XPI_ROOT_APPID
970
$(error XPI_ROOT_APPID is not defined - langpacks will break.)
971
endif
972
endif
973
endif
974
975
libs realchrome:: $(FINAL_TARGET)/chrome
976
$(call py_action,jar_maker,\
977
$(QUIET) -d $(FINAL_TARGET) \
978
$(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) \
979
$(JAR_MANIFEST))
980
981
endif
982
983
endif
984
985
# When you move this out of the tools tier, please remove the corresponding
986
# hacks in recursivemake.py that check if Makefile.in sets the variable.
987
ifneq ($(XPI_PKGNAME),)
988
tools realchrome::
989
ifdef STRIP_XPI
990
ifndef MOZ_DEBUG
991
@echo 'Stripping $(XPI_PKGNAME) package directory...'
992
@echo $(FINAL_TARGET)
993
@cd $(FINAL_TARGET) && find . ! -type d \
994
! -name '*.js' \
995
! -name '*.xpt' \
996
! -name '*.gif' \
997
! -name '*.jpg' \
998
! -name '*.png' \
999
! -name '*.xpm' \
1000
! -name '*.txt' \
1001
! -name '*.rdf' \
1002
! -name '*.sh' \
1003
! -name '*.properties' \
1004
! -name '*.dtd' \
1005
! -name '*.html' \
1006
! -name '*.xul' \
1007
! -name '*.css' \
1008
! -name '*.xml' \
1009
! -name '*.jar' \
1010
! -name '*.dat' \
1011
! -name '*.tbl' \
1012
! -name '*.src' \
1013
! -name '*.reg' \
1014
$(PLATFORM_EXCLUDE_LIST) \
1015
-exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
1016
endif
1017
endif
1018
@echo 'Packaging $(XPI_PKGNAME).xpi...'
1019
$(call py_action,zip,-C $(FINAL_TARGET) ../$(XPI_PKGNAME).xpi '*')
1020
endif
1021
1022
# See comment above about moving this out of the tools tier.
1023
ifdef INSTALL_EXTENSION_ID
1024
ifndef XPI_NAME
1025
$(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
1026
endif
1027
1028
tools::
1029
$(RM) -r '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1030
$(NSINSTALL) -D '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1031
$(call copy_dir,$(FINAL_TARGET),$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))
1032
1033
endif
1034
1035
#############################################################################
1036
# MDDEPDIR is the subdirectory where all the dependency files are placed.
1037
# This uses a make rule (instead of a macro) to support parallel
1038
# builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
1039
# processes could simultaneously try to create the same directory.
1040
#
1041
# We use $(CURDIR) in the rule's target to ensure that we don't find
1042
# a dependency directory in the source tree via VPATH (perhaps from
1043
# a previous build in the source tree) and thus neglect to create a
1044
# dependency directory in the object directory, where we really need
1045
# it.
1046
1047
_MDDEPEND_FILES :=
1048
1049
ifneq (,$(filter target-objects target all default,$(MAKECMDGOALS)))
1050
_MDDEPEND_FILES += $(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS))))
1051
endif
1052
1053
ifneq (,$(filter host-objects host all default,$(MAKECMDGOALS)))
1054
_MDDEPEND_FILES += $(addsuffix .pp,$(notdir $(sort $(HOST_OBJS) $(HOST_PROGOBJS))))
1055
endif
1056
1057
MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(_MDDEPEND_FILES) $(EXTRA_MDDEPEND_FILES))))
1058
1059
ifneq (,$(MDDEPEND_FILES))
1060
-include $(MDDEPEND_FILES)
1061
endif
1062
1063
################################################################################
1064
# Install/copy rules
1065
#
1066
# The INSTALL_TARGETS variable contains a list of all install target
1067
# categories. Each category defines a list of files and executables, and an
1068
# install destination,
1069
#
1070
# FOO_FILES := foo bar
1071
# FOO_EXECUTABLES := baz
1072
# FOO_DEST := target_path
1073
# INSTALL_TARGETS += FOO
1074
#
1075
# Additionally, a FOO_TARGET variable may be added to indicate the target for
1076
# which the files and executables are installed. Default is "libs".
1077
#
1078
# Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
1079
# in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
1080
# if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
1081
# file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
1082
1083
# If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
1084
ifneq (,$(filter $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
1085
ifeq (,$(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)))
1086
nsinstall_is_usable = $(if $(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)),yes)
1087
1088
define install_cmd_override
1089
$(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1)
1090
endef
1091
endif
1092
endif
1093
1094
install_target_tier = $(or $($(1)_TARGET),libs)
1095
INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category))))
1096
1097
install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2)))
1098
install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file)))
1099
install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file)))
1100
1101
# Work around a GNU make 3.81 bug where it gives $< the wrong value.
1102
# See details in bug 934864.
1103
define create_dependency
1104
$(1): $(2)
1105
$(1): $(2)
1106
endef
1107
1108
define install_target_template
1109
$(call install_cmd_override,$(2))
1110
$(call create_dependency,$(2),$(1))
1111
endef
1112
1113
$(foreach category,$(INSTALL_TARGETS),\
1114
$(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \
1115
$(foreach tier,$(call install_target_tier,$(category)),\
1116
$(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \
1117
$(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \
1118
) \
1119
$(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \
1120
$(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \
1121
) \
1122
)
1123
1124
$(foreach tier,$(INSTALL_TARGETS_TIERS), \
1125
$(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \
1126
)
1127
1128
install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
1129
1130
$(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))):
1131
$(install_targets_sanity)
1132
$(call install_cmd,$(IFLAGS1) '$<' '$(@D)')
1133
1134
$(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))):
1135
$(install_targets_sanity)
1136
$(call install_cmd,$(IFLAGS2) '$<' '$(@D)')
1137
1138
################################################################################
1139
# Preprocessing rules
1140
#
1141
# The PP_TARGETS variable contains a list of all preprocessing target
1142
# categories. Each category has associated variables listing input files, the
1143
# output directory, extra preprocessor flags, and so on. For example:
1144
#
1145
# FOO := input-file
1146
# FOO_PATH := target-directory
1147
# FOO_FLAGS := -Dsome_flag
1148
# PP_TARGETS += FOO
1149
#
1150
# If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
1151
# following make variables to see what to do:
1152
#
1153
# - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
1154
# We search VPATH for the names given here. If an input file name ends in
1155
# '.in', that suffix is omitted from the output file name.
1156
#
1157
# - <C>_PATH names the directory in which to place the preprocessed output
1158
# files. We create this directory if it does not already exist. Setting
1159
# this variable is optional; if unset, we install the files in $(CURDIR).
1160
#
1161
# - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
1162
# to the usual bunch. Setting this variable is optional.
1163
#
1164
# - <C>_TARGET names the 'make' target that should depend on creating the output
1165
# files. Setting this variable is optional; if unset, we preprocess the
1166
# files for the 'libs' target.
1167
#
1168
# - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
1169
# kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
1170
# $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
1171
# instead of $(DIST)/include/qux.h.
1172
1173
pp_target_tier = $(or $($(1)_TARGET),libs)
1174
PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category))))
1175
1176
pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=)))
1177
pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file)))
1178
1179
$(foreach category,$(PP_TARGETS), \
1180
$(foreach tier,$(call pp_target_tier,$(category)), \
1181
$(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \
1182
) \
1183
$(foreach file,$($(category)), \
1184
$(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \
1185
$(file) $(GLOBAL_DEPS))) \
1186
) \
1187
$(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \
1188
)
1189
1190
$(foreach tier,$(PP_TARGETS_TIERS), \
1191
$(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
1192
)
1193
1194
PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
1195
$(PP_TARGETS_ALL_RESULTS):
1196
$(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS))
1197
$(RM) '$@'
1198
$(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) '$<' -o '$@')
1199
1200
$(filter %.css,$(PP_TARGETS_ALL_RESULTS)): PP_TARGET_FLAGS+=--marker %
1201
1202
# The depfile is based on the filename, and we don't want conflicts. So check
1203
# there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
1204
PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
1205
$(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
1206
$(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
1207
$(error Multiple preprocessing rules are creating a $(file) file) \
1208
) \
1209
)
1210
1211
ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS)))
1212
# If the depfile for a preprocessed file doesn't exist, add a dep to force
1213
# re-preprocessing.
1214
$(foreach file,$(PP_TARGETS_ALL_RESULTS), \
1215
$(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \
1216
, \
1217
$(eval $(file): FORCE) \
1218
) \
1219
)
1220
1221
MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS))))))
1222
1223
ifneq (,$(MDDEPEND_FILES))
1224
-include $(MDDEPEND_FILES)
1225
endif
1226
1227
endif
1228
1229
# Pull in non-recursive targets if this is a partial tree build.
1230
ifndef TOPLEVEL_BUILD
1231
include $(MOZILLA_DIR)/config/makefiles/nonrecursive.mk
1232
endif
1233
1234
################################################################################
1235
# Special gmake rules.
1236
################################################################################
1237
1238
1239
#
1240
# Re-define the list of default suffixes, so gmake won't have to churn through
1241
# hundreds of built-in suffix rules for stuff we don't need.
1242
#
1243
.SUFFIXES:
1244
1245
#
1246
# Fake targets. Always run these rules, even if a file/directory with that
1247
# name already exists.
1248
#
1249
.PHONY: all alltags boot chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) FORCE
1250
1251
# Used as a dependency to force targets to rebuild
1252
FORCE:
1253
1254
# Delete target if error occurs when building target
1255
.DELETE_ON_ERROR:
1256
1257
tags: TAGS
1258
1259
TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1260
-etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1261
$(LOOP_OVER_DIRS)
1262
1263
ifndef INCLUDED_DEBUGMAKE_MK #{
1264
## Only parse when an echo* or show* target is requested
1265
ifneq (,$(call isTargetStem,echo,show))
1266
include $(MOZILLA_DIR)/config/makefiles/debugmake.mk
1267
endif #}
1268
endif #}
1269
1270
documentation:
1271
@cd $(DEPTH)
1272
$(DOXYGEN) $(DEPTH)/config/doxygen.cfg
1273
1274
FREEZE_VARIABLES = \
1275
CSRCS \
1276
CPPSRCS \
1277
EXPORTS \
1278
DIRS \
1279
LIBRARY \
1280
MODULE \
1281
$(NULL)
1282
1283
$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
1284
1285
CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
1286
$(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
1287
1288
libs export::
1289
$(CHECK_FROZEN_VARIABLES)
1290
1291
.DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default)
1292
1293
#############################################################################
1294
# Derived targets and dependencies
1295
1296
include $(MOZILLA_DIR)/config/makefiles/autotargets.mk
1297
ifneq ($(NULL),$(AUTO_DEPS))
1298
default all libs tools export:: $(AUTO_DEPS)
1299
endif