Bug 1646700 [wpt PR 24235] - Update picture-in-picture idlharness test, a=testonly
[gecko.git] / config / rules.mk
blob37af2ec84c47c0768b441fe166ef89e5af7bd3f1
1 # -*- makefile -*-
2 # vim:set ts=8 sw=8 sts=8 noet:
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/.
9 ifndef topsrcdir
10 $(error topsrcdir was not set))
11 endif
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
19 ifndef INCLUDED_CONFIG_MK
20 include $(topsrcdir)/config/config.mk
21 endif
23 ifndef INCLUDED_VERSION_MK
24 include $(MOZILLA_DIR)/config/version.mk
25 endif
27 USE_AUTOTARGETS_MK = 1
28 include $(MOZILLA_DIR)/config/makefiles/makeutils.mk
30 ifdef REBUILD_CHECK
31 REPORT_BUILD = $(info $(shell $(PYTHON3) $(MOZILLA_DIR)/config/rebuild_check.py $@ $^))
32 REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
33 else
34 REPORT_BUILD = $(info $(relativesrcdir)/$(notdir $@))
36 ifdef BUILD_VERBOSE_LOG
37 REPORT_BUILD_VERBOSE = $(REPORT_BUILD)
38 else
39 REPORT_BUILD_VERBOSE = $(call BUILDSTATUS,BUILD_VERBOSE $(relativesrcdir))
40 endif
42 endif
44 EXEC = exec
46 ################################################################################
47 # Testing frameworks support
48 ################################################################################
50 testxpcobjdir = $(DEPTH)/_tests/xpcshell
52 ifdef ENABLE_TESTS
53 ifdef CPP_UNIT_TESTS
54 ifdef COMPILE_ENVIRONMENT
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)
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
68 run-cppunittests::
69 @$(PYTHON3) $(MOZILLA_DIR)/testing/runcppunittests.py --xre-path=$(DIST)/bin --symbols-path=$(DIST)/crashreporter-symbols $(CPP_UNIT_TESTS)
71 cppunittests-remote:
72 $(PYTHON3) -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); \
78 endif # COMPILE_ENVIRONMENT
79 endif # CPP_UNIT_TESTS
80 endif # ENABLE_TESTS
84 # Library rules
86 # If FORCE_STATIC_LIB is set, build a static library.
87 # Otherwise, build a shared library.
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
99 ifdef FORCE_SHARED_LIB
100 ifdef MKSHLIB
102 ifdef LIB_IS_C_ONLY
103 MKSHLIB = $(MKCSHLIB)
104 endif
106 EMBED_MANIFEST_AT=2
108 endif # MKSHLIB
109 endif # FORCE_SHARED_LIB
111 ifeq ($(OS_ARCH),WINNT)
114 # This next line captures both the default (non-MOZ_COPY_PDBS)
115 # case as well as the MOZ_COPY_PDBS-for-mingwclang case.
117 # For the default case, placing the pdb in the build
118 # directory is needed.
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.)
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.
129 LINK_PDBFILE ?= $(basename $(@F)).pdb
131 ifdef MOZ_COPY_PDBS
132 ifneq ($(CC_TYPE),clang)
133 LINK_PDBFILE = $(basename $@).pdb
134 endif
135 endif
137 ifndef GNU_CC
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
145 ifdef MOZ_DEBUG
146 CODFILE=$(basename $(@F)).cod
147 endif
149 endif # !GNU_CC
150 endif # WINNT
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
158 ifeq ($(OS_ARCH),WINNT)
159 ifeq ($(CC_TYPE),clang)
160 MOZ_PROGRAM_LDFLAGS += -Wl,-pdb,$(dir $@)/$(LINK_PDBFILE)
161 endif
162 endif
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
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
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
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
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
222 WASM_ARCHIVE = $(addsuffix .$(WASM_OBJ_SUFFIX),$(WASM_LIBRARY))
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) \
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
239 ifdef QTDIR
240 GARBAGE += $(MOCSRCS)
241 endif
243 ifdef SIMPLE_PROGRAMS
244 GARBAGE += $(SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
245 endif
247 ifdef HOST_SIMPLE_PROGRAMS
248 GARBAGE += $(HOST_SIMPLE_PROGRAMS:%=%.$(OBJ_SUFFIX))
249 endif
251 ifdef MACH
252 ifndef NO_BUILDSTATUS_MESSAGES
253 define BUILDSTATUS
254 @echo 'BUILDSTATUS $1'
256 endef
257 endif
258 endif
260 define SUBMAKE # $(call SUBMAKE,target,directory,static)
261 +@$(MAKE) $(if $(2),-C $(2)) $(1)
263 endef # The extra line is important here! don't delete it
265 define TIER_DIR_SUBMAKE
266 $(call SUBMAKE,$(4),$(3),$(5))
268 endef # Ths empty line is important.
270 ifneq (,$(strip $(DIRS)))
271 LOOP_OVER_DIRS = \
272 $(foreach dir,$(DIRS),$(call SUBMAKE,$@,$(dir)))
273 endif
276 # Now we can differentiate between objects used to build a library, and
277 # objects used to build an executable in the same directory.
279 ifndef PROGOBJS
280 PROGOBJS = $(OBJS)
281 endif
283 ifndef HOST_PROGOBJS
284 HOST_PROGOBJS = $(HOST_OBJS)
285 endif
287 GARBAGE_DIRS += $(wildcard $(CURDIR)/$(MDDEPDIR))
290 # Tags: emacs (etags), vi (ctags)
291 # TAG_PROGRAM := ctags -L -
293 TAG_PROGRAM = xargs etags -a
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)
300 ifneq ($(HOST_CPPSRCS)$(HOST_CMMSRCS),)
301 HOST_CPP_PROG_LINK = 1
302 endif
305 # MacOS X specific stuff
308 ifeq ($(OS_ARCH),Darwin)
309 ifdef SHARED_LIBRARY
310 _LOADER_PATH := @executable_path
311 EXTRA_DSO_LDOPTS += -dynamiclib -install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) -compatibility_version 1 -current_version 1 -single_module
312 endif
313 endif
316 # GNU doesn't have path length limitation
319 ifeq ($(OS_ARCH),GNU)
320 OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
321 endif
324 # MINGW32
326 ifeq ($(OS_ARCH),WINNT)
327 ifdef GNU_CC
328 DSO_LDOPTS += -Wl,--out-implib -Wl,$(IMPORT_LIBRARY)
329 endif
330 endif
332 ifeq ($(USE_TVFS),1)
333 IFLAGS1 = -rb
334 IFLAGS2 = -rb
335 else
336 IFLAGS1 = -m 644
337 IFLAGS2 = -m 755
338 endif
340 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
341 OUTOPTION = -Fo# eol
342 else
343 OUTOPTION = -o # eol
344 endif # WINNT && !GNU_CC
346 ifeq (,$(CROSS_COMPILE))
347 HOST_OUTOPTION = $(OUTOPTION)
348 else
349 # Windows-to-Windows cross compiles should always use MSVC-style options for
350 # host compiles.
351 ifeq (WINNT_WINNT,$(HOST_OS_ARCH)_$(OS_ARCH))
352 ifneq (,$(filter-out clang-cl,$(HOST_CC_TYPE)))
353 $(error MSVC-style compilers should be used for host compilations!)
354 endif
355 HOST_OUTOPTION = -Fo# eol
356 else
357 HOST_OUTOPTION = -o # eol
358 endif
359 endif
360 ################################################################################
362 # Ensure the build config is up to date. This is done automatically when builds
363 # are performed through |mach build|. The check here is to catch people not
364 # using mach. If we ever enforce builds through mach, this code can be removed.
365 ifndef MOZBUILD_BACKEND_CHECKED
366 ifndef MACH
367 ifndef TOPLEVEL_BUILD
368 BUILD_BACKEND_FILES := $(addprefix $(DEPTH)/backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
369 $(DEPTH)/backend.%Backend:
370 $(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
372 define build_backend_rule
373 $(1): $$(shell cat $(1).in)
375 endef
376 $(foreach file,$(BUILD_BACKEND_FILES),$(eval $(call build_backend_rule,$(file))))
378 default:: $(BUILD_BACKEND_FILES)
380 export MOZBUILD_BACKEND_CHECKED=1
381 endif
382 endif
383 endif
385 # The root makefile doesn't want to do a plain export/libs, because
386 # of the tiers and because of libxul. Suppress the default rules in favor
387 # of something else. Makefiles which use this var *must* provide a sensible
388 # default rule before including rules.mk
389 default all::
390 $(foreach tier,$(TIERS),$(call SUBMAKE,$(tier)))
392 ifdef BUILD_VERBOSE_LOG
393 ECHO := echo
394 QUIET :=
395 else
396 ECHO := true
397 QUIET := -q
398 endif
400 # Do everything from scratch
401 everything::
402 $(MAKE) clean
403 $(MAKE) all
405 # Dependencies which, if modified, should cause everything to rebuild
406 GLOBAL_DEPS += Makefile $(addprefix $(DEPTH)/config/,$(INCLUDED_AUTOCONF_MK)) $(MOZILLA_DIR)/config/config.mk
408 ##############################################
409 ifdef COMPILE_ENVIRONMENT
410 compile:: host target
412 host:: $(HOST_OBJS) $(HOST_PROGRAM) $(HOST_SIMPLE_PROGRAMS) $(HOST_RUST_PROGRAMS) $(HOST_RUST_LIBRARY_FILE) $(HOST_SHARED_LIBRARY)
414 target:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS),$(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS) $(RUST_LIBRARY_FILE) $(RUST_PROGRAMS) $(WASM_LIBRARY))
416 ifndef LIBRARY
417 ifdef OBJS
418 target:: $(OBJS)
419 endif
420 endif
422 target-objects: $(OBJS) $(PROGOBJS)
423 host-objects: $(HOST_OBJS) $(HOST_PROGOBJS)
425 syms::
427 include $(MOZILLA_DIR)/config/makefiles/target_binaries.mk
428 endif
430 clean clobber realclean clobber_all::
431 -$(RM) $(ALL_TRASH)
432 -$(RM) -r $(ALL_TRASH_DIRS)
434 clean clobber realclean clobber_all distclean::
435 $(foreach dir,$(DIRS),-$(call SUBMAKE,$@,$(dir)))
437 distclean::
438 -$(RM) -r $(ALL_TRASH_DIRS)
439 -$(RM) $(ALL_TRASH) \
440 Makefile .HSancillary \
441 $(wildcard *.$(OBJ_SUFFIX)) $(wildcard *.ho) $(wildcard host_*.o*) \
442 $(wildcard *.$(LIB_SUFFIX)) $(wildcard *$(DLL_SUFFIX)) \
443 $(wildcard *.$(IMPORT_LIB_SUFFIX))
445 alltags:
446 $(RM) TAGS
447 find $(topsrcdir) -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' -o -name '*.idl' \) -print | $(TAG_PROGRAM)
449 define EXPAND_CC_OR_CXX
450 $(if $(PROG_IS_C_ONLY_$(1)),$(CC),$(CCC))
451 endef
454 # PROGRAM = Foo
455 # creates OBJS, links with LIBS to create Foo
457 $(PROGRAM): $(PROGOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(RESFILE) $(GLOBAL_DEPS) $(call mkdir_deps,$(FINAL_TARGET))
458 $(REPORT_BUILD)
459 @$(RM) $@.manifest
460 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
461 $(LINKER) -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_OBJS) $(RESFILE) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
462 ifdef MSMANIFEST_TOOL
463 @if test -f $@.manifest; then \
464 echo "Manifest in objdir is not supported"; \
465 exit 1; \
466 elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
467 echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
468 $(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
470 endif # MSVC with manifest tool
471 else # !WINNT || GNU_CC
472 $(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)
473 $(call py_action,check_binary,--target $@)
474 endif # WINNT && !GNU_CC
476 ifdef ENABLE_STRIP
477 $(STRIP) $(STRIP_FLAGS) $@
478 endif
479 ifdef MOZ_POST_PROGRAM_COMMAND
480 $(MOZ_POST_PROGRAM_COMMAND) $@
481 endif
483 $(HOST_PROGRAM): $(HOST_PROGOBJS) $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS) $(call mkdir_deps,$(DEPTH)/dist/host/bin)
484 $(REPORT_BUILD)
485 ifeq (_WINNT,$(GNU_CC)_$(HOST_OS_ARCH))
486 $(HOST_LINKER) -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
487 ifdef MSMANIFEST_TOOL
488 @if test -f $@.manifest; then \
489 echo "Manifest in objdir is not supported"; \
490 exit 1; \
491 elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
492 echo 'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
493 $(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
495 endif # MSVC with manifest tool
496 else
497 ifeq ($(HOST_CPP_PROG_LINK),1)
498 $(HOST_CXX) -o $@ $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
499 else
500 $(HOST_CC) -o $@ $(HOST_C_LDFLAGS) $(HOST_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
501 endif # HOST_CPP_PROG_LINK
502 endif
503 ifndef CROSS_COMPILE
504 $(call py_action,check_binary,--host $@)
505 endif
508 # This is an attempt to support generation of multiple binaries
509 # in one directory, it assumes everything to compile Foo is in
510 # Foo.o (from either Foo.c or Foo.cpp).
512 # SIMPLE_PROGRAMS = Foo Bar
513 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
515 $(SIMPLE_PROGRAMS): %$(BIN_SUFFIX): %.$(OBJ_SUFFIX) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
516 $(REPORT_BUILD)
517 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
518 $(LINKER) -out:$@ -pdb:$(LINK_PDBFILE) $($@_OBJS) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
519 ifdef MSMANIFEST_TOOL
520 @if test -f $@.manifest; then \
521 echo "Manifest in objdir is not supported"; \
522 exit 1; \
523 elif test -f '$(srcdir)/$(notdir $@).manifest'; then \
524 $(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE:$@\;1; \
526 endif # MSVC with manifest tool
527 else
528 $(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)
529 $(call py_action,check_binary,--target $@)
530 endif # WINNT && !GNU_CC
532 ifdef ENABLE_STRIP
533 $(STRIP) $(STRIP_FLAGS) $@
534 endif
535 ifdef MOZ_POST_PROGRAM_COMMAND
536 $(MOZ_POST_PROGRAM_COMMAND) $@
537 endif
539 $(HOST_SIMPLE_PROGRAMS): host_%$(HOST_BIN_SUFFIX): $(HOST_LIBS) $(HOST_EXTRA_DEPS) $(GLOBAL_DEPS)
540 $(REPORT_BUILD)
541 ifeq (WINNT_,$(HOST_OS_ARCH)_$(GNU_CC))
542 $(HOST_LINKER) -OUT:$@ -PDB:$(HOST_PDBFILE) $($(notdir $@)_OBJS) $(WIN32_EXE_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
543 else
544 ifneq (,$(HOST_CPPSRCS)$(USE_HOST_CXX))
545 $(HOST_CXX) $(HOST_OUTOPTION)$@ $(HOST_CXX_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
546 else
547 $(HOST_CC) $(HOST_OUTOPTION)$@ $(HOST_C_LDFLAGS) $($(notdir $@)_OBJS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
548 endif
549 endif
550 ifndef CROSS_COMPILE
551 $(call py_action,check_binary,--host $@)
552 endif
554 $(LIBRARY): $(OBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
555 $(REPORT_BUILD)
556 $(RM) $(REAL_LIBRARY)
557 $(AR) $(AR_FLAGS) $($@_OBJS)
559 $(WASM_ARCHIVE): $(CWASMOBJS) $(CPPWASMOBJS) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
560 $(REPORT_BUILD_VERBOSE)
561 $(RM) $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX)
562 $(WASM_CXX) $(OUTOPTION)$@ -Wl,--export-all $(WASM_LDFLAGS) $(CWASMOBJS) $(CPPWASMOBJS)
564 lucet_options := \
565 --target $(LUCETC_TARGET) \
566 --target-cpu baseline \
567 --bindings $(topsrcdir)/third_party/rust/lucet-wasi/bindings.json \
568 --guard-size 4GiB \
569 --min-reserved-size 4GiB \
570 --max-reserved-size 4GiB \
571 --opt-level 2
573 $(WASM_LIBRARY): $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX)
574 $(REPORT_BUILD)
575 $(RM) $(WASM_LIBRARY)
576 env LD="$(CC)" LDFLAGS="$(LUCETC_LDFLAGS)" $(LUCETC) $(lucet_options) $(WASM_LIBRARY).$(WASM_OBJ_SUFFIX) -o $(WASM_LIBRARY)
578 ifeq ($(OS_ARCH),WINNT)
579 # Import libraries are created by the rules creating shared libraries.
580 # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
581 # but make will happily consider the import library before it is refreshed
582 # when rebuilding the corresponding shared library. Defining an empty recipe
583 # for import libraries forces make to wait for the shared library recipe to
584 # have run before considering other targets that depend on the import library.
585 # See bug 795204.
586 $(IMPORT_LIBRARY): $(SHARED_LIBRARY) ;
587 endif
589 $(HOST_SHARED_LIBRARY): Makefile
590 $(REPORT_BUILD)
591 $(RM) $@
592 ifneq (,$(filter clang-cl,$(HOST_CC_TYPE)))
593 $(HOST_LINKER) -DLL -OUT:$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LINKER_LIBPATHS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
594 else
595 $(HOST_CXX) $(HOST_OUTOPTION)$@ $($(notdir $@)_OBJS) $(HOST_CXX_LDFLAGS) $(HOST_LDFLAGS) $(HOST_LIBS) $(HOST_EXTRA_LIBS)
596 endif
598 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
599 # so instead of deleting .o files after repacking them into a dylib, we make
600 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
601 # so no need to conditionalize on OS version or debugging format.
603 $(SHARED_LIBRARY): $(OBJS) $(RESFILE) $(STATIC_LIBS) $(EXTRA_DEPS) $(GLOBAL_DEPS)
604 $(REPORT_BUILD)
605 ifndef INCREMENTAL_LINKER
606 $(RM) $@
607 endif
608 $(MKSHLIB) $($@_OBJS) $(RESFILE) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS)
609 $(call py_action,check_binary,--target $@)
611 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
612 ifdef MSMANIFEST_TOOL
613 ifdef EMBED_MANIFEST_AT
614 @if test -f $@.manifest; then \
615 echo "Manifest in objdir is not supported"; \
616 exit 1; \
617 elif test -f '$(srcdir)/$@.manifest'; then \
618 echo 'Embedding manifest from $(srcdir_rel)/$@.manifest'; \
619 $(call WINEWRAP,$(MT)) -NOLOGO -MANIFEST '$(srcdir_rel)/$@.manifest' -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
621 endif # EMBED_MANIFEST_AT
622 endif # MSVC with manifest tool
623 endif # WINNT && !GCC
624 chmod +x $@
625 ifdef ENABLE_STRIP
626 $(STRIP) $(STRIP_FLAGS) $@
627 endif
629 # The object file is in the current directory, and the source file can be any
630 # relative path. This macro adds the dependency obj: src for each source file.
631 # This dependency must be first for the $< flag to work correctly, and the
632 # rules that have commands for these targets must not list any other
633 # prerequisites, or they will override the $< variable.
634 define src_objdep
635 $(basename $3$(notdir $1)).$2: $1 $$(call mkdir_deps,$$(MDDEPDIR))
636 endef
637 $(foreach f,$(CSRCS) $(SSRCS) $(CPPSRCS) $(CMSRCS) $(CMMSRCS) $(ASFILES),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX))))
638 $(foreach f,$(HOST_CSRCS) $(HOST_CPPSRCS) $(HOST_CMSRCS) $(HOST_CMMSRCS),$(eval $(call src_objdep,$(f),$(OBJ_SUFFIX),host_)))
639 $(foreach f,$(WASM_CSRCS) $(WASM_CPPSRCS),$(eval $(call src_objdep,$(f),wasm)))
641 # The Rust compiler only outputs library objects, and so we need different
642 # mangling to generate dependency rules for it.
643 mk_global_crate_libname = $(basename lib$(notdir $1)).$(LIB_SUFFIX)
644 crate_src_libdep = $(call mk_global_crate_libname,$1): $1 $$(call mkdir_deps,$$(MDDEPDIR))
645 $(foreach f,$(RS_STATICLIB_CRATE_SRC),$(eval $(call crate_src_libdep,$(f))))
647 $(OBJS) $(HOST_OBJS) $(PROGOBJS) $(HOST_PROGOBJS): $(GLOBAL_DEPS)
649 # Rules for building native targets must come first because of the host_ prefix
650 $(HOST_COBJS):
651 $(REPORT_BUILD_VERBOSE)
652 $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(NSPR_CFLAGS) $<
654 $(HOST_CPPOBJS):
655 $(REPORT_BUILD_VERBOSE)
656 $(call BUILDSTATUS,OBJECT_FILE $@)
657 $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(NSPR_CFLAGS) $<
659 $(HOST_CMOBJS):
660 $(REPORT_BUILD_VERBOSE)
661 $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CFLAGS) $(HOST_CMFLAGS) $(NSPR_CFLAGS) $<
663 $(HOST_CMMOBJS):
664 $(REPORT_BUILD_VERBOSE)
665 $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CPPFLAGS) $(HOST_CXXFLAGS) $(HOST_CMMFLAGS) $(NSPR_CFLAGS) $<
667 $(COBJS):
668 $(REPORT_BUILD_VERBOSE)
669 $(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $<
671 $(CWASMOBJS):
672 $(REPORT_BUILD_VERBOSE)
673 $(WASM_CC) $(OUTOPTION)$@ -c $(WASM_CFLAGS) $($(notdir $<)_FLAGS) $<
675 WINEWRAP = $(if $(and $(filter %.exe,$1),$(WINE)),$(WINE) $1,$1)
677 # Windows program run via Wine don't like Unix absolute paths (they look
678 # like command line arguments). So when needed, create relative paths
679 # from absolute paths. We start with $(DEPTH), which gets us to topobjdir,
680 # then add "/.." for each component of topobjdir, which gets us to /.
681 # then we can add the absolute path after that and we have a relative path,
682 # albeit longer than it could be.
683 ifdef WINE
684 relativize = $(if $(filter /%,$1),$(DEPTH)$(subst $(space),,$(foreach d,$(subst /, ,$(topobjdir)),/..))$1,$1)
685 else
686 relativize = $1
687 endif
689 ifdef ASFILES
690 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
691 # a '-c' flag.
692 $(ASOBJS):
693 $(REPORT_BUILD_VERBOSE)
694 $(call WINEWRAP,$(AS)) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(call relativize,$<)
695 endif
697 define syms_template
698 syms:: $(2)
699 $(2): $(1)
700 ifdef MOZ_CRASHREPORTER
701 $$(call py_action,dumpsymbols,$$(abspath $$<) $$(abspath $$@) $$(DUMP_SYMBOLS_FLAGS))
702 ifeq ($(OS_ARCH),WINNT)
703 ifdef WINCHECKSEC
704 $$(PYTHON3) $$(topsrcdir)/build/win32/autowinchecksec.py $$<
705 endif # WINCHECKSEC
706 endif # WINNT
707 endif
708 endef
710 ifneq (,$(filter $(DIST)/bin%,$(FINAL_TARGET)))
711 DUMP_SYMS_TARGETS := $(SHARED_LIBRARY) $(PROGRAM) $(SIMPLE_PROGRAMS)
712 endif
714 ifdef MOZ_AUTOMATION
715 ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS)))
716 DUMP_SYMS_TARGETS :=
717 endif
718 endif
720 ifdef MOZ_COPY_PDBS
721 MAIN_PDB_FILES = $(addsuffix .pdb,$(basename $(DUMP_SYMS_TARGETS)))
722 MAIN_PDB_DEST ?= $(FINAL_TARGET)
723 MAIN_PDB_TARGET = syms
724 INSTALL_TARGETS += MAIN_PDB
726 ifdef CPP_UNIT_TESTS
727 CPP_UNIT_TESTS_PDB_FILES = $(addsuffix .pdb,$(basename $(CPP_UNIT_TESTS)))
728 CPP_UNIT_TESTS_PDB_DEST = $(DIST)/cppunittests
729 CPP_UNIT_TESTS_PDB_TARGET = syms
730 INSTALL_TARGETS += CPP_UNIT_TESTS_PDB
731 endif
733 else ifdef MOZ_CRASHREPORTER
734 $(foreach file,$(DUMP_SYMS_TARGETS),$(eval $(call syms_template,$(file),$(notdir $(file))_syms.track)))
735 endif
737 ifneq (,$(RUST_TESTS)$(RUST_LIBRARY_FILE)$(HOST_RUST_LIBRARY_FILE)$(RUST_PROGRAMS)$(HOST_RUST_PROGRAMS))
738 include $(MOZILLA_DIR)/config/makefiles/rust.mk
739 endif
741 $(SOBJS):
742 $(REPORT_BUILD)
743 $(call WINEWRAP,$(AS)) $(ASOUTOPTION)$@ $(SFLAGS) $($(notdir $<)_FLAGS) -c $(call relativize,$<)
745 $(CPPOBJS):
746 $(REPORT_BUILD_VERBOSE)
747 $(call BUILDSTATUS,OBJECT_FILE $@)
748 $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
750 $(CPPWASMOBJS):
751 $(REPORT_BUILD_VERBOSE)
752 $(call BUILDSTATUS,OBJECT_FILE $@)
753 $(WASM_CXX) $(OUTOPTION)$@ -c $(WASM_CXXFLAGS) $($(notdir $<)_FLAGS) $<
755 $(CMMOBJS):
756 $(REPORT_BUILD_VERBOSE)
757 $(CCC) -o $@ -c $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $($(notdir $<)_FLAGS) $<
759 $(CMOBJS):
760 $(REPORT_BUILD_VERBOSE)
761 $(CC) -o $@ -c $(COMPILE_CFLAGS) $(COMPILE_CMFLAGS) $($(notdir $<)_FLAGS) $<
763 $(filter %.s,$(CPPSRCS:%.cpp=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
764 $(REPORT_BUILD_VERBOSE)
765 $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
767 $(filter %.s,$(CPPSRCS:%.cc=%.s)): %.s: %.cc $(call mkdir_deps,$(MDDEPDIR))
768 $(REPORT_BUILD_VERBOSE)
769 $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
771 $(filter %.s,$(CPPSRCS:%.cxx=%.s)): %.s: %.cpp $(call mkdir_deps,$(MDDEPDIR))
772 $(REPORT_BUILD_VERBOSE)
773 $(CCC) -S $(COMPILE_CXXFLAGS) $($(notdir $<)_FLAGS) $<
775 $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR))
776 $(REPORT_BUILD_VERBOSE)
777 $(CC) -S $(COMPILE_CFLAGS) $($(notdir $<)_FLAGS) $<
779 ifneq (,$(filter %.i,$(MAKECMDGOALS)))
780 # Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
781 # of the full sources, as well as the $(notdir) version. So:
782 # foo.cpp sub/bar.cpp
783 # becomes:
784 # foo.cpp sub/bar.cpp bar.cpp
786 # This way we can match both 'make sub/bar.i' and 'make bar.i'
787 _group_srcs = $(sort $(patsubst %.$1,%.i,$(filter %.$1,$2 $(notdir $2))))
789 define PREPROCESS_RULES
790 _PREPROCESSED_$1_FILES := $$(call _group_srcs,$1,$$($2))
791 # Make preprocessed files PHONY so they are always executed, since they are
792 # manual targets and we don't necessarily write to $@.
793 .PHONY: $$(_PREPROCESSED_$1_FILES)
795 # Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
796 # reach $(srcdir)/frontend/Parser.i
797 vpath %.$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
798 vpath %.$1 $$(addprefix $$(CURDIR)/,$$(sort $$(dir $$($2))))
800 $$(_PREPROCESSED_$1_FILES): _DEPEND_CFLAGS=
801 $$(_PREPROCESSED_$1_FILES): %.i: %.$1
802 $$(REPORT_BUILD_VERBOSE)
803 $$(addprefix $$(MKDIR) -p ,$$(filter-out .,$$(@D)))
804 $$($3) -C $$(PREPROCESS_OPTION)$$@ $(foreach var,$4,$$($(var))) $$($$(notdir $$<)_FLAGS) $$<
806 endef
808 $(eval $(call PREPROCESS_RULES,cpp,CPPSRCS,CCC,COMPILE_CXXFLAGS))
809 $(eval $(call PREPROCESS_RULES,cc,CPPSRCS,CCC,COMPILE_CXXFLAGS))
810 $(eval $(call PREPROCESS_RULES,cxx,CPPSRCS,CCC,COMPILE_CXXFLAGS))
811 $(eval $(call PREPROCESS_RULES,c,CSRCS,CC,COMPILE_CFLAGS))
812 $(eval $(call PREPROCESS_RULES,mm,CMMSRCS,CCC,COMPILE_CXXFLAGS COMPILE_CMMFLAGS))
814 # Default to pre-processing the actual unified file. This can be overridden
815 # at the command-line to pre-process only the individual source file.
816 PP_UNIFIED ?= 1
818 # PP_REINVOKE gets set on the sub-make to prevent us from going in an
819 # infinite loop if the filename doesn't exist in the unified source files.
820 ifndef PP_REINVOKE
822 MATCH_cpp = \(cpp\|cc|cxx\)
823 UPPER_c = C
824 UPPER_cpp = CPP
825 UPPER_mm = CMM
827 # When building with PP_UNIFIED=0, we also have to look in the Unified files to
828 # find a matching pathname.
829 _get_all_sources = $1 $(if $(filter Unified%,$1),$(shell sed -n 's/\#include "\(.*\)"$$/\1/p' $(filter Unified%,$1)))
830 all_cpp_sources := $(call _get_all_sources,$(CPPSRCS))
831 all_mm_sources := $(call _get_all_sources,$(CMMSRCS))
832 all_c_sources := $(call _get_all_sources,$(CSRCS))
833 all_sources := $(all_cpp_sources) $(all_cmm_sources) $(all_c_sources)
835 # The catch-all %.i rule runs when we pass in a .i filename that doesn't match
836 # one of the *SRCS variables. The two code paths depend on whether or not
837 # we are requesting a unified file (PP_UNIFIED=1, the default) or not:
839 # PP_UNIFIED=1:
840 # - Look for it in any of the Unified files, and re-exec make with
841 # Unified_foo0.i as the target. This gets us the full unified preprocessed
842 # file.
844 # PP_UNIFIED=0:
845 # - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
846 # make with that filename as the target. The *SRCS variables are modified
847 # to have the Unified sources appended to them so that the static pattern
848 # rules will match.
849 %.i: FORCE
850 ifeq ($(PP_UNIFIED),1)
851 @$(MAKE) PP_REINVOKE=1 \
852 $(or $(addsuffix .i, \
853 $(foreach type,c cpp mm, \
854 $(if $(filter Unified%,$($(UPPER_$(type))SRCS)), \
855 $(shell grep -l '#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified*.$(type) | sed 's/\.$(type)$$//') \
856 ))),$(error "File not found for preprocessing: $@"))
857 else
858 @$(MAKE) PP_REINVOKE=1 $@ \
859 $(foreach type,c cpp mm,$(UPPER_$(type))SRCS="$(all_$(type)_sources)")
860 endif
862 endif
864 endif
866 $(RESFILE): %.res: $(RCFILE)
867 $(REPORT_BUILD)
868 @echo Creating Resource file: $@
869 ifdef GNU_CC
870 $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) $(OUTOPTION)$@ $<
871 else
872 $(call WINEWRAP,$(RC)) $(RCFLAGS) -r $(DEFINES) $(INCLUDES:-I%=-I$(call relativize,%)) $(OUTOPTION)$@ $(call relativize,$<)
873 endif
875 # Cancel GNU make built-in implicit rules
876 MAKEFLAGS += -r
878 ifneq (,$(filter WINNT,$(OS_ARCH)))
879 SEP := ;
880 else
881 SEP := :
882 endif
884 EMPTY :=
885 SPACE := $(EMPTY) $(EMPTY)
887 ###############################################################################
888 # Bunch of things that extend the 'export' rule (in order):
889 ###############################################################################
891 ifneq ($(XPI_NAME),)
892 $(FINAL_TARGET):
893 $(NSINSTALL) -D $@
895 export:: $(FINAL_TARGET)
896 endif
898 ################################################################################
899 # The default location for prefs is the gre prefs directory.
900 # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
901 PREF_DIR = defaults/pref
903 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
904 # different and that we are building app related resources. Hence,
905 # PREF_DIR should point to the app prefs location.
906 ifneq (,$(DIST_SUBDIR)$(XPI_NAME))
907 PREF_DIR = defaults/preferences
908 endif
910 ################################################################################
911 # CHROME PACKAGING
913 chrome::
914 $(MAKE) realchrome
915 $(LOOP_OVER_DIRS)
917 $(FINAL_TARGET)/chrome: $(call mkdir_deps,$(FINAL_TARGET)/chrome)
919 ifneq (,$(JAR_MANIFEST))
920 ifndef NO_DIST_INSTALL
922 ifdef XPI_NAME
923 ifdef XPI_ROOT_APPID
924 # For add-on packaging we may specify that an application
925 # sub-dir should be added to the root chrome manifest with
926 # a specific application id.
927 MAKE_JARS_FLAGS += --root-manifest-entry-appid='$(XPI_ROOT_APPID)'
928 endif
930 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
931 # no way langpacks will get packaged right, so error out.
932 ifneq (,$(DIST_SUBDIR))
933 ifndef XPI_ROOT_APPID
934 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
935 endif
936 endif
937 endif
939 misc realchrome:: $(FINAL_TARGET)/chrome
940 $(call py_action,jar_maker,\
941 $(QUIET) -d $(FINAL_TARGET) \
942 $(MAKE_JARS_FLAGS) $(DEFINES) $(ACDEFINES) \
943 $(JAR_MANIFEST))
945 ifdef AB_CD
946 .PHONY: l10n
947 l10n: misc ;
948 endif
949 endif
951 endif
953 # When you move this out of the tools tier, please remove the corresponding
954 # hacks in recursivemake.py that check if Makefile.in sets the variable.
955 ifneq ($(XPI_PKGNAME),)
956 tools realchrome::
957 ifdef STRIP_XPI
958 ifndef MOZ_DEBUG
959 @echo 'Stripping $(XPI_PKGNAME) package directory...'
960 @echo $(FINAL_TARGET)
961 @cd $(FINAL_TARGET) && find . ! -type d \
962 ! -name '*.js' \
963 ! -name '*.xpt' \
964 ! -name '*.gif' \
965 ! -name '*.jpg' \
966 ! -name '*.png' \
967 ! -name '*.xpm' \
968 ! -name '*.txt' \
969 ! -name '*.rdf' \
970 ! -name '*.sh' \
971 ! -name '*.properties' \
972 ! -name '*.dtd' \
973 ! -name '*.html' \
974 ! -name '*.xul' \
975 ! -name '*.css' \
976 ! -name '*.xml' \
977 ! -name '*.jar' \
978 ! -name '*.dat' \
979 ! -name '*.tbl' \
980 ! -name '*.src' \
981 ! -name '*.reg' \
982 $(PLATFORM_EXCLUDE_LIST) \
983 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
984 endif
985 endif
986 @echo 'Packaging $(XPI_PKGNAME).xpi...'
987 $(call py_action,zip,-C $(FINAL_TARGET) ../$(XPI_PKGNAME).xpi '*')
988 endif
990 # See comment above about moving this out of the tools tier.
991 ifdef INSTALL_EXTENSION_ID
992 ifndef XPI_NAME
993 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID)
994 endif
996 tools::
997 $(RM) -r '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
998 $(NSINSTALL) -D '$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
999 $(call copy_dir,$(FINAL_TARGET),$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID))
1001 endif
1003 #############################################################################
1004 # MDDEPDIR is the subdirectory where all the dependency files are placed.
1005 # This uses a make rule (instead of a macro) to support parallel
1006 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
1007 # processes could simultaneously try to create the same directory.
1009 # We use $(CURDIR) in the rule's target to ensure that we don't find
1010 # a dependency directory in the source tree via VPATH (perhaps from
1011 # a previous build in the source tree) and thus neglect to create a
1012 # dependency directory in the object directory, where we really need
1013 # it.
1015 _MDDEPEND_FILES :=
1017 ifneq (,$(filter target-objects target all default,$(MAKECMDGOALS)))
1018 _MDDEPEND_FILES += $(addsuffix .pp,$(notdir $(sort $(OBJS) $(PROGOBJS))))
1019 endif
1021 ifneq (,$(filter host-objects host all default,$(MAKECMDGOALS)))
1022 _MDDEPEND_FILES += $(addsuffix .pp,$(notdir $(sort $(HOST_OBJS) $(HOST_PROGOBJS))))
1023 endif
1025 MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(_MDDEPEND_FILES))))
1026 MDDEPEND_FILES += $(EXTRA_MDDEPEND_FILES)
1028 ifneq (,$(MDDEPEND_FILES))
1029 -include $(MDDEPEND_FILES)
1030 endif
1032 ################################################################################
1033 # Install/copy rules
1035 # The INSTALL_TARGETS variable contains a list of all install target
1036 # categories. Each category defines a list of files and executables, and an
1037 # install destination,
1039 # FOO_FILES := foo bar
1040 # FOO_EXECUTABLES := baz
1041 # FOO_DEST := target_path
1042 # INSTALL_TARGETS += FOO
1044 # Additionally, a FOO_TARGET variable may be added to indicate the target for
1045 # which the files and executables are installed. Default is "libs".
1047 # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
1048 # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
1049 # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
1050 # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
1052 # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
1053 ifneq (,$(filter $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX),$(install_cmd)))
1054 ifeq (,$(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)))
1055 nsinstall_is_usable = $(if $(wildcard $(DEPTH)/config/nsinstall$(HOST_BIN_SUFFIX)),yes)
1057 define install_cmd_override
1058 $(1): install_cmd = $$(if $$(nsinstall_is_usable),$$(INSTALL),$$(NSINSTALL_PY) -t) $$(1)
1059 endef
1060 endif
1061 endif
1063 install_target_tier = $(or $($(1)_TARGET),libs)
1064 INSTALL_TARGETS_TIERS := $(sort $(foreach category,$(INSTALL_TARGETS),$(call install_target_tier,$(category))))
1066 install_target_result = $($(1)_DEST:%/=%)/$(if $($(1)_KEEP_PATH),$(2),$(notdir $(2)))
1067 install_target_files = $(foreach file,$($(1)_FILES),$(call install_target_result,$(category),$(file)))
1068 install_target_executables = $(foreach file,$($(1)_EXECUTABLES),$(call install_target_result,$(category),$(file)))
1070 # Work around a GNU make 3.81 bug where it gives $< the wrong value.
1071 # See details in bug 934864.
1072 define create_dependency
1073 $(1): $(2)
1074 $(1): $(2)
1075 endef
1077 define install_target_template
1078 $(call install_cmd_override,$(2))
1079 $(call create_dependency,$(2),$(1))
1080 endef
1082 $(foreach category,$(INSTALL_TARGETS),\
1083 $(if $($(category)_DEST),,$(error Missing $(category)_DEST)) \
1084 $(foreach tier,$(call install_target_tier,$(category)),\
1085 $(eval INSTALL_TARGETS_FILES_$(tier) += $(call install_target_files,$(category))) \
1086 $(eval INSTALL_TARGETS_EXECUTABLES_$(tier) += $(call install_target_executables,$(category))) \
1088 $(foreach file,$($(category)_FILES) $($(category)_EXECUTABLES), \
1089 $(eval $(call install_target_template,$(file),$(call install_target_result,$(category),$(file)))) \
1093 $(foreach tier,$(INSTALL_TARGETS_TIERS), \
1094 $(eval $(tier):: $(INSTALL_TARGETS_FILES_$(tier)) $(INSTALL_TARGETS_EXECUTABLES_$(tier))) \
1097 install_targets_sanity = $(if $(filter-out $(notdir $@),$(notdir $(<))),$(error Looks like $@ has an unexpected dependency on $< which breaks INSTALL_TARGETS))
1099 $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_FILES_$(tier)))):
1100 $(install_targets_sanity)
1101 $(call install_cmd,$(IFLAGS1) '$<' '$(@D)')
1103 $(sort $(foreach tier,$(INSTALL_TARGETS_TIERS),$(INSTALL_TARGETS_EXECUTABLES_$(tier)))):
1104 $(install_targets_sanity)
1105 $(call install_cmd,$(IFLAGS2) '$<' '$(@D)')
1107 ################################################################################
1108 # Preprocessing rules
1110 # The PP_TARGETS variable contains a list of all preprocessing target
1111 # categories. Each category has associated variables listing input files, the
1112 # output directory, extra preprocessor flags, and so on. For example:
1114 # FOO := input-file
1115 # FOO_PATH := target-directory
1116 # FOO_FLAGS := -Dsome_flag
1117 # PP_TARGETS += FOO
1119 # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
1120 # following make variables to see what to do:
1122 # - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
1123 # We search VPATH for the names given here. If an input file name ends in
1124 # '.in', that suffix is omitted from the output file name.
1126 # - <C>_PATH names the directory in which to place the preprocessed output
1127 # files. We create this directory if it does not already exist. Setting
1128 # this variable is optional; if unset, we install the files in $(CURDIR).
1130 # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
1131 # to the usual bunch. Setting this variable is optional.
1133 # - <C>_TARGET names the 'make' target that should depend on creating the output
1134 # files. Setting this variable is optional; if unset, we preprocess the
1135 # files for the 'libs' target.
1137 # - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
1138 # kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
1139 # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
1140 # instead of $(DIST)/include/qux.h.
1142 pp_target_tier = $(or $($(1)_TARGET),libs)
1143 PP_TARGETS_TIERS := $(sort $(foreach category,$(PP_TARGETS),$(call pp_target_tier,$(category))))
1145 pp_target_result = $(or $($(1)_PATH:%/=%),$(CURDIR))/$(if $($(1)_KEEP_PATH),$(2:.in=),$(notdir $(2:.in=)))
1146 pp_target_results = $(foreach file,$($(1)),$(call pp_target_result,$(category),$(file)))
1148 $(foreach category,$(PP_TARGETS), \
1149 $(foreach tier,$(call pp_target_tier,$(category)), \
1150 $(eval PP_TARGETS_RESULTS_$(tier) += $(call pp_target_results,$(category))) \
1152 $(foreach file,$($(category)), \
1153 $(eval $(call create_dependency,$(call pp_target_result,$(category),$(file)), \
1154 $(file) $(GLOBAL_DEPS))) \
1156 $(eval $(call pp_target_results,$(category)): PP_TARGET_FLAGS=$($(category)_FLAGS)) \
1159 $(foreach tier,$(PP_TARGETS_TIERS), \
1160 $(eval $(tier):: $(PP_TARGETS_RESULTS_$(tier))) \
1163 PP_TARGETS_ALL_RESULTS := $(sort $(foreach tier,$(PP_TARGETS_TIERS),$(PP_TARGETS_RESULTS_$(tier))))
1164 $(PP_TARGETS_ALL_RESULTS):
1165 $(if $(filter-out $(notdir $@),$(notdir $(<:.in=))),$(error Looks like $@ has an unexpected dependency on $< which breaks PP_TARGETS))
1166 $(RM) '$@'
1167 $(call py_action,preprocessor,--depend $(MDDEPDIR)/$(@F).pp $(PP_TARGET_FLAGS) $(DEFINES) $(ACDEFINES) '$<' -o '$@')
1169 $(filter %.css,$(PP_TARGETS_ALL_RESULTS)): PP_TARGET_FLAGS+=--marker %
1171 # The depfile is based on the filename, and we don't want conflicts. So check
1172 # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
1173 PP_TARGETS_ALL_RESULT_NAMES := $(notdir $(PP_TARGETS_ALL_RESULTS))
1174 $(foreach file,$(sort $(PP_TARGETS_ALL_RESULT_NAMES)), \
1175 $(if $(filter-out 1,$(words $(filter $(file),$(PP_TARGETS_ALL_RESULT_NAMES)))), \
1176 $(error Multiple preprocessing rules are creating a $(file) file) \
1180 ifneq (,$(filter $(PP_TARGETS_TIERS) $(PP_TARGETS_ALL_RESULTS),$(MAKECMDGOALS)))
1181 # If the depfile for a preprocessed file doesn't exist, add a dep to force
1182 # re-preprocessing.
1183 $(foreach file,$(PP_TARGETS_ALL_RESULTS), \
1184 $(if $(wildcard $(MDDEPDIR)/$(notdir $(file)).pp), \
1186 $(eval $(file): FORCE) \
1190 MDDEPEND_FILES := $(strip $(wildcard $(addprefix $(MDDEPDIR)/,$(addsuffix .pp,$(notdir $(PP_TARGETS_ALL_RESULTS))))))
1192 ifneq (,$(MDDEPEND_FILES))
1193 -include $(MDDEPEND_FILES)
1194 endif
1196 endif
1198 # Pull in non-recursive targets if this is a partial tree build.
1199 ifndef TOPLEVEL_BUILD
1200 include $(MOZILLA_DIR)/config/makefiles/nonrecursive.mk
1201 endif
1203 ################################################################################
1204 # Special gmake rules.
1205 ################################################################################
1209 # Re-define the list of default suffixes, so gmake won't have to churn through
1210 # hundreds of built-in suffix rules for stuff we don't need.
1212 .SUFFIXES:
1215 # Fake targets. Always run these rules, even if a file/directory with that
1216 # name already exists.
1218 .PHONY: all alltags boot chrome realchrome clean clobber clobber_all export install libs makefiles realclean run_apprunner tools $(DIRS) FORCE
1220 # Used as a dependency to force targets to rebuild
1221 FORCE:
1223 # Delete target if error occurs when building target
1224 .DELETE_ON_ERROR:
1226 tags: TAGS
1228 TAGS: $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1229 -etags $(CSRCS) $(CPPSRCS) $(wildcard *.h)
1230 $(LOOP_OVER_DIRS)
1232 ifndef INCLUDED_DEBUGMAKE_MK #{
1233 ## Only parse when an echo* or show* target is requested
1234 ifneq (,$(call isTargetStem,echo,show))
1235 include $(MOZILLA_DIR)/config/makefiles/debugmake.mk
1236 endif #}
1237 endif #}
1239 FREEZE_VARIABLES = \
1240 CSRCS \
1241 CPPSRCS \
1242 EXPORTS \
1243 DIRS \
1244 LIBRARY \
1245 WASM_LIBRARY \
1246 MODULE \
1247 $(NULL)
1249 $(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))
1251 CHECK_FROZEN_VARIABLES = $(foreach var,$(FREEZE_VARIABLES), \
1252 $(if $(subst $($(var)_FROZEN),,'$($(var))'),$(error Makefile variable '$(var)' changed value after including rules.mk. Was $($(var)_FROZEN), now $($(var)).)))
1254 libs export::
1255 $(CHECK_FROZEN_VARIABLES)
1257 .DEFAULT_GOAL := $(or $(OVERRIDE_DEFAULT_GOAL),default)
1259 #############################################################################
1260 # Derived targets and dependencies
1262 include $(MOZILLA_DIR)/config/makefiles/autotargets.mk
1263 ifneq ($(NULL),$(AUTO_DEPS))
1264 default all libs tools export:: $(AUTO_DEPS)
1265 endif