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/.
10 $(error topsrcdir was not set
))
13 # Define an include-at-most-once flag
14 ifdef INCLUDED_RULES_MK
15 $(error Do not
include rules.mk twice
!)
19 ifndef INCLUDED_CONFIG_MK
20 include $(topsrcdir
)/config
/config.mk
23 ifndef INCLUDED_VERSION_MK
24 include $(MOZILLA_DIR
)/config
/version.mk
27 USE_AUTOTARGETS_MK
= 1
28 include $(MOZILLA_DIR
)/config
/makefiles
/makeutils.mk
31 REPORT_BUILD
= $(info $(shell $(PYTHON3
) $(MOZILLA_DIR
)/config
/rebuild_check.py
$@
$^
))
32 REPORT_BUILD_VERBOSE
= $(REPORT_BUILD
)
34 REPORT_BUILD
= $(info $(relativesrcdir
)/$(notdir $@
))
36 ifdef BUILD_VERBOSE_LOG
37 REPORT_BUILD_VERBOSE
= $(REPORT_BUILD
)
39 REPORT_BUILD_VERBOSE
= $(call BUILDSTATUS
,BUILD_VERBOSE
$(relativesrcdir
))
46 ################################################################################
47 # Testing frameworks support
48 ################################################################################
50 testxpcobjdir
= $(DEPTH
)/_tests
/xpcshell
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
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
69 @
$(PYTHON3
) $(MOZILLA_DIR
)/testing
/runcppunittests.py
--xre-path
=$(DIST
)/bin
--symbols-path
=$(DIST
)/crashreporter-symbols
$(CPP_UNIT_TESTS
)
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
86 # If FORCE_STATIC_LIB is set, build a static library.
87 # Otherwise, build a shared library.
93 # Only build actual library if it is requested.
94 LIBRARY
:= $(REAL_LIBRARY
)
99 ifdef FORCE_SHARED_LIB
103 MKSHLIB
= $(MKCSHLIB
)
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
132 ifneq ($(CC_TYPE
),clang
)
133 LINK_PDBFILE
= $(basename $@
).pdb
139 ifdef SIMPLE_PROGRAMS
140 COMPILE_PDB_FLAG ?
= -Fd
$(basename $(@F
)).pdb
141 COMPILE_CFLAGS
+= $(COMPILE_PDB_FLAG
)
142 COMPILE_CXXFLAGS
+= $(COMPILE_PDB_FLAG
)
146 CODFILE
=$(basename $(@F
)).cod
152 ifeq (arm-Darwin
,$(CPU_ARCH
)-$(OS_TARGET
))
154 MOZ_PROGRAM_LDFLAGS
+= -Wl
,-rpath
-Wl
,@executable_path
/Frameworks
158 ifeq ($(OS_ARCH
),WINNT
)
159 ifeq ($(CC_TYPE
),clang
)
160 MOZ_PROGRAM_LDFLAGS
+= -Wl
,-pdb
,$(dir $@
)/$(LINK_PDBFILE
)
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
)
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
)))))
179 ifdef COMPILE_ENVIRONMENT
181 TARGETS
= $(LIBRARY
) $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
) $(HOST_PROGRAM
) $(HOST_SIMPLE_PROGRAMS
) $(HOST_SHARED_LIBRARY
) $(WASM_LIBRARY
)
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
))))
196 _OBJS
= $(COBJS
) $(SOBJS
) $(CPPOBJS
) $(CMOBJS
) $(CMMOBJS
) $(ASOBJS
) $(CWASMOBJS
) $(CPPWASMOBJS
)
197 OBJS
= $(strip $(_OBJS
))
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
))))
206 _HOST_OBJS
= $(HOST_COBJS
) $(HOST_CPPOBJS
) $(HOST_CMOBJS
) $(HOST_CMMOBJS
)
207 HOST_OBJS
= $(strip $(_HOST_OBJS
))
216 HOST_SHARED_LIBRARY
:=
218 HOST_SIMPLE_PROGRAMS
:=
222 WASM_ARCHIVE
= $(addsuffix .
$(WASM_OBJ_SUFFIX
),$(WASM_LIBRARY
))
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
)
237 $(GARBAGE_DIRS
) /no-such-file
240 GARBAGE
+= $(MOCSRCS
)
243 ifdef SIMPLE_PROGRAMS
244 GARBAGE
+= $(SIMPLE_PROGRAMS
:%=%.
$(OBJ_SUFFIX
))
247 ifdef HOST_SIMPLE_PROGRAMS
248 GARBAGE
+= $(HOST_SIMPLE_PROGRAMS
:%=%.
$(OBJ_SUFFIX
))
252 ifndef NO_BUILDSTATUS_MESSAGES
254 @echo
'BUILDSTATUS $1'
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
)))
272 $(foreach dir,$(DIRS
),$(call SUBMAKE
,$@
,$(dir)))
276 # Now we can differentiate between objects used to build a library, and
277 # objects used to build an executable in the same directory.
284 HOST_PROGOBJS
= $(HOST_OBJS
)
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
305 # MacOS X specific stuff
308 ifeq ($(OS_ARCH
),Darwin
)
310 _LOADER_PATH
:= @executable_path
311 EXTRA_DSO_LDOPTS
+= -dynamiclib
-install_name
$(_LOADER_PATH
)/$(SHARED_LIBRARY
) -compatibility_version
1 -current_version
1 -single_module
316 # GNU doesn't have path length limitation
319 ifeq ($(OS_ARCH
),GNU
)
320 OS_CPPFLAGS
+= -DPATH_MAX
=1024 -DMAXPATHLEN
=1024
326 ifeq ($(OS_ARCH
),WINNT
)
328 DSO_LDOPTS
+= -Wl
,--out-implib
-Wl
,$(IMPORT_LIBRARY
)
340 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
344 endif # WINNT && !GNU_CC
346 ifeq (,$(CROSS_COMPILE
))
347 HOST_OUTOPTION
= $(OUTOPTION
)
349 # Windows-to-Windows cross compiles should always use MSVC-style options for
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
!)
355 HOST_OUTOPTION
= -Fo
# eol
357 HOST_OUTOPTION
= -o
# eol
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
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
)
376 $(foreach file
,$(BUILD_BACKEND_FILES
),$(eval
$(call build_backend_rule
,$(file
))))
378 default
:: $(BUILD_BACKEND_FILES
)
380 export MOZBUILD_BACKEND_CHECKED
=1
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
390 $(foreach tier
,$(TIERS
),$(call SUBMAKE
,$(tier
)))
392 ifdef BUILD_VERBOSE_LOG
400 # Do everything from scratch
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
))
422 target-objects
: $(OBJS
) $(PROGOBJS
)
423 host-objects
: $(HOST_OBJS
) $(HOST_PROGOBJS
)
427 include $(MOZILLA_DIR
)/config
/makefiles
/target_binaries.mk
430 clean clobber realclean clobber_all
::
432 -$(RM
) -r
$(ALL_TRASH_DIRS
)
434 clean clobber realclean clobber_all
distclean::
435 $(foreach dir,$(DIRS
),-$(call SUBMAKE
,$@
,$(dir)))
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
))
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
))
455 # creates OBJS, links with LIBS to create Foo
457 $(PROGRAM
): $(PROGOBJS
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(RESFILE
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(FINAL_TARGET
))
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"; \
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
477 $(STRIP
) $(STRIP_FLAGS
) $@
479 ifdef MOZ_POST_PROGRAM_COMMAND
480 $(MOZ_POST_PROGRAM_COMMAND
) $@
483 $(HOST_PROGRAM
): $(HOST_PROGOBJS
) $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(DEPTH
)/dist/host
/bin
)
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"; \
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
497 ifeq ($(HOST_CPP_PROG_LINK
),1)
498 $(HOST_CXX
) -o
$@
$(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
500 $(HOST_CC
) -o
$@
$(HOST_C_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
501 endif # HOST_CPP_PROG_LINK
504 $(call py_action
,check_binary
,--host
$@
)
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
)
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"; \
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
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
533 $(STRIP
) $(STRIP_FLAGS
) $@
535 ifdef MOZ_POST_PROGRAM_COMMAND
536 $(MOZ_POST_PROGRAM_COMMAND
) $@
539 $(HOST_SIMPLE_PROGRAMS
): host_
%$(HOST_BIN_SUFFIX
): $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
)
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
)
544 ifneq (,$(HOST_CPPSRCS
)$(USE_HOST_CXX
))
545 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$(HOST_CXX_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
547 $(HOST_CC
) $(HOST_OUTOPTION
)$@
$(HOST_C_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
551 $(call py_action
,check_binary
,--host
$@
)
554 $(LIBRARY
): $(OBJS
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
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
)
565 --target
$(LUCETC_TARGET
) \
566 --target-cpu baseline \
567 --bindings
$(topsrcdir
)/third_party
/rust
/lucet-wasi
/bindings.json \
569 --min-reserved-size
4GiB \
570 --max-reserved-size
4GiB \
573 $(WASM_LIBRARY
): $(WASM_LIBRARY
).
$(WASM_OBJ_SUFFIX
)
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.
586 $(IMPORT_LIBRARY
): $(SHARED_LIBRARY
) ;
589 $(HOST_SHARED_LIBRARY
): Makefile
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
)
595 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$($(notdir $@
)_OBJS
) $(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
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
)
605 ifndef INCREMENTAL_LINKER
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"; \
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
626 $(STRIP
) $(STRIP_FLAGS
) $@
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.
635 $(basename $3$(notdir $1)).
$2: $1 $$(call mkdir_deps
,$$(MDDEPDIR
))
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
651 $(REPORT_BUILD_VERBOSE
)
652 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(NSPR_CFLAGS
) $<
655 $(REPORT_BUILD_VERBOSE
)
656 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
657 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(NSPR_CFLAGS
) $<
660 $(REPORT_BUILD_VERBOSE
)
661 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(HOST_CMFLAGS
) $(NSPR_CFLAGS
) $<
664 $(REPORT_BUILD_VERBOSE
)
665 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(HOST_CMMFLAGS
) $(NSPR_CFLAGS
) $<
668 $(REPORT_BUILD_VERBOSE
)
669 $(CC
) $(OUTOPTION
)$@
-c
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $<
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.
684 relativize
= $(if
$(filter /%,$1),$(DEPTH
)$(subst $(space
),,$(foreach d
,$(subst /, ,$(topobjdir
)),/..
))$1,$1)
690 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
693 $(REPORT_BUILD_VERBOSE
)
694 $(call WINEWRAP
,$(AS
)) $(ASOUTOPTION
)$@
$(ASFLAGS
) $($(notdir $<)_FLAGS
) $(AS_DASH_C_FLAG
) $(call relativize
,$<)
700 ifdef MOZ_CRASHREPORTER
701 $$(call py_action
,dumpsymbols
,$$(abspath
$$<) $$(abspath
$$@
) $$(DUMP_SYMBOLS_FLAGS
))
702 ifeq ($(OS_ARCH
),WINNT
)
704 $$(PYTHON3
) $$(topsrcdir
)/build
/win32
/autowinchecksec.py
$$<
710 ifneq (,$(filter $(DIST
)/bin
%,$(FINAL_TARGET
)))
711 DUMP_SYMS_TARGETS
:= $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
)
715 ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS
)))
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
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
733 else ifdef MOZ_CRASHREPORTER
734 $(foreach file
,$(DUMP_SYMS_TARGETS
),$(eval
$(call syms_template
,$(file
),$(notdir $(file
))_syms.track
)))
737 ifneq (,$(RUST_TESTS
)$(RUST_LIBRARY_FILE
)$(HOST_RUST_LIBRARY_FILE
)$(RUST_PROGRAMS
)$(HOST_RUST_PROGRAMS
))
738 include $(MOZILLA_DIR
)/config
/makefiles
/rust.mk
743 $(call WINEWRAP
,$(AS
)) $(ASOUTOPTION
)$@
$(SFLAGS
) $($(notdir $<)_FLAGS
) -c
$(call relativize
,$<)
746 $(REPORT_BUILD_VERBOSE
)
747 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
748 $(CCC
) $(OUTOPTION
)$@
-c
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
751 $(REPORT_BUILD_VERBOSE
)
752 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
753 $(WASM_CXX
) $(OUTOPTION
)$@
-c
$(WASM_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
756 $(REPORT_BUILD_VERBOSE
)
757 $(CCC
) -o
$@
-c
$(COMPILE_CXXFLAGS
) $(COMPILE_CMMFLAGS
) $($(notdir $<)_FLAGS
) $<
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
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
) $$<
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.
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.
822 MATCH_cpp
= \
(cpp\|
cc|
cxx\
)
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:
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
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
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: $@"))
858 @
$(MAKE
) PP_REINVOKE
=1 $@ \
859 $(foreach type
,c
cpp mm
,$(UPPER_
$(type
))SRCS
="$(all_$(type)_sources)")
866 $(RESFILE
): %.res
: $(RCFILE
)
868 @echo Creating Resource file
: $@
870 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
:-I
%=--include-dir
%) $(OUTOPTION
)$@
$<
872 $(call WINEWRAP
,$(RC
)) $(RCFLAGS
) -r
$(DEFINES
) $(INCLUDES
:-I
%=-I
$(call relativize
,%)) $(OUTOPTION
)$@
$(call relativize
,$<)
875 # Cancel GNU make built-in implicit rules
878 ifneq (,$(filter WINNT
,$(OS_ARCH
)))
885 SPACE
:= $(EMPTY
) $(EMPTY
)
887 ###############################################################################
888 # Bunch of things that extend the 'export' rule (in order):
889 ###############################################################################
895 export:: $(FINAL_TARGET
)
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
910 ################################################################################
917 $(FINAL_TARGET
)/chrome
: $(call mkdir_deps
,$(FINAL_TARGET
)/chrome
)
919 ifneq (,$(JAR_MANIFEST
))
920 ifndef NO_DIST_INSTALL
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)'
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.
)
939 misc realchrome
:: $(FINAL_TARGET
)/chrome
940 $(call py_action
,jar_maker
,\
941 $(QUIET
) -d
$(FINAL_TARGET
) \
942 $(MAKE_JARS_FLAGS
) $(DEFINES
) $(ACDEFINES
) \
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
),)
959 @echo
'Stripping $(XPI_PKGNAME) package directory...'
960 @echo
$(FINAL_TARGET
)
961 @cd
$(FINAL_TARGET
) && find .
! -type d \
971 ! -name
'*.properties' \
982 $(PLATFORM_EXCLUDE_LIST
) \
983 -exec
$(STRIP
) $(STRIP_FLAGS
) {} >/dev
/null
2>&1 \
;
986 @echo
'Packaging $(XPI_PKGNAME).xpi...'
987 $(call py_action
,zip
,-C
$(FINAL_TARGET
) ..
/$(XPI_PKGNAME
).xpi
'*')
990 # See comment above about moving this out of the tools tier.
991 ifdef INSTALL_EXTENSION_ID
993 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID
)
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
))
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
1017 ifneq (,$(filter target-objects target
all default
,$(MAKECMDGOALS
)))
1018 _MDDEPEND_FILES
+= $(addsuffix .pp
,$(notdir $(sort $(OBJS
) $(PROGOBJS
))))
1021 ifneq (,$(filter host-objects host
all default
,$(MAKECMDGOALS
)))
1022 _MDDEPEND_FILES
+= $(addsuffix .pp
,$(notdir $(sort $(HOST_OBJS
) $(HOST_PROGOBJS
))))
1025 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(_MDDEPEND_FILES
))))
1026 MDDEPEND_FILES
+= $(EXTRA_MDDEPEND_FILES
)
1028 ifneq (,$(MDDEPEND_FILES
))
1029 -include $(MDDEPEND_FILES
)
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)
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
1077 define install_target_template
1078 $(call install_cmd_override
,$(2))
1079 $(call create_dependency
,$(2),$(1))
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:
1115 # FOO_PATH := target-directory
1116 # FOO_FLAGS := -Dsome_flag
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
))
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
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
)
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
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.
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
1223 # Delete target if error occurs when building target
1228 TAGS
: $(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1229 -etags
$(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
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
1239 FREEZE_VARIABLES
= \
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
)).
)))
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
)