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