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 $(PYTHON
) $(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 @
$(PYTHON
) $(MOZILLA_DIR
)/testing
/runcppunittests.py
--xre-path
=$(DIST
)/bin
--symbols-path
=$(DIST
)/crashreporter-symbols
$(CPP_UNIT_TESTS
)
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
); \
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
) $(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
)
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
)
311 _LOADER_PATH
:= @rpath
313 _LOADER_PATH
:= @executable_path
315 EXTRA_DSO_LDOPTS
+= -dynamiclib
-install_name
$(_LOADER_PATH
)/$(SHARED_LIBRARY
) -compatibility_version
1 -current_version
1 -single_module
320 # GNU doesn't have path length limitation
323 ifeq ($(OS_ARCH
),GNU
)
324 OS_CPPFLAGS
+= -DPATH_MAX
=1024 -DMAXPATHLEN
=1024
330 ifeq ($(OS_ARCH
),WINNT
)
332 DSO_LDOPTS
+= -Wl
,--out-implib
-Wl
,$(IMPORT_LIBRARY
)
344 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
348 endif # WINNT && !GNU_CC
350 ifeq (,$(CROSS_COMPILE
))
351 HOST_OUTOPTION
= $(OUTOPTION
)
353 # Windows-to-Windows cross compiles should always use MSVC-style options for
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
!)
359 HOST_OUTOPTION
= -Fo
# eol
361 HOST_OUTOPTION
= -o
# eol
364 ################################################################################
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
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
)
376 define build_backend_rule
377 $(1): $$(shell cat
$(1).in
)
380 $(foreach file
,$(BUILD_BACKEND_FILES
),$(eval
$(call build_backend_rule
,$(file
))))
382 default
:: $(BUILD_BACKEND_FILES
)
384 export MOZBUILD_BACKEND_CHECKED
=1
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
394 $(foreach tier
,$(TIERS
),$(call SUBMAKE
,$(tier
)))
396 ifdef BUILD_VERBOSE_LOG
404 # Do everything from scratch
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
412 ##############################################
413 ifdef COMPILE_ENVIRONMENT
414 compile
:: host target
416 host
:: $(HOST_OBJS
) $(HOST_PROGRAM
) $(HOST_SIMPLE_PROGRAMS
) $(HOST_RUST_PROGRAMS
) $(HOST_RUST_LIBRARY_FILE
) $(HOST_SHARED_LIBRARY
)
418 target
:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS
),$(LIBRARY
) $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
) $(RUST_LIBRARY_FILE
) $(RUST_PROGRAMS
) $(WASM_LIBRARY
))
426 target-objects
: $(OBJS
) $(PROGOBJS
)
427 host-objects
: $(HOST_OBJS
) $(HOST_PROGOBJS
)
431 include $(MOZILLA_DIR
)/config
/makefiles
/target_binaries.mk
434 clean clobber realclean clobber_all
::
436 -$(RM
) -r
$(ALL_TRASH_DIRS
)
438 clean clobber realclean clobber_all
distclean::
439 $(foreach dir,$(DIRS
),-$(call SUBMAKE
,$@
,$(dir)))
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
))
451 find
$(topsrcdir
) -name
dist -prune
-o \
( -name
'*.[hc]' -o
-name
'*.cp' -o
-name
'*.cpp' -o
-name
'*.idl' \
) -print |
$(TAG_PROGRAM
)
453 define EXPAND_CC_OR_CXX
454 $(if
$(PROG_IS_C_ONLY_
$(1)),$(CC
),$(CCC
))
459 # creates OBJS, links with LIBS to create Foo
461 $(PROGRAM
): $(PROGOBJS
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(RESFILE
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(FINAL_TARGET
))
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; \
472 echo
'Embedding manifest from $@.manifest'; \
473 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
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; \
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
486 $(STRIP
) $(STRIP_FLAGS
) $@
488 ifdef MOZ_POST_PROGRAM_COMMAND
489 $(MOZ_POST_PROGRAM_COMMAND
) $@
492 $(HOST_PROGRAM
): $(HOST_PROGOBJS
) $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(DEPTH
)/dist/host
/bin
)
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; \
502 echo
'Embedding manifest from $@.manifest'; \
503 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
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; \
509 endif # MSVC with manifest tool
511 ifeq ($(HOST_CPP_PROG_LINK
),1)
512 $(HOST_CXX
) -o
$@
$(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
514 $(HOST_CC
) -o
$@
$(HOST_C_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
515 endif # HOST_CPP_PROG_LINK
518 $(call py_action
,check_binary
,--host
$@
)
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).
526 # SIMPLE_PROGRAMS = Foo Bar
527 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
529 $(SIMPLE_PROGRAMS
): %$(BIN_SUFFIX
): %.
$(OBJ_SUFFIX
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
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; \
537 elif
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
538 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE
:$@\
;1; \
540 endif # MSVC with manifest tool
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
547 $(STRIP
) $(STRIP_FLAGS
) $@
549 ifdef MOZ_POST_PROGRAM_COMMAND
550 $(MOZ_POST_PROGRAM_COMMAND
) $@
553 $(HOST_SIMPLE_PROGRAMS
): host_
%$(HOST_BIN_SUFFIX
): $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
)
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
)
558 ifneq (,$(HOST_CPPSRCS
)$(USE_HOST_CXX
))
559 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$(HOST_CXX_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
561 $(HOST_CC
) $(HOST_OUTOPTION
)$@
$(HOST_C_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
565 $(call py_action
,check_binary
,--host
$@
)
568 $(LIBRARY
): $(OBJS
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
570 $(RM
) $(REAL_LIBRARY
)
571 $(AR
) $(AR_FLAGS
) $($@_OBJS
)
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
)
579 --bindings
$(topsrcdir
)/third_party
/rust
/lucet-wasi
/bindings.json \
581 --min-reserved-size
4GiB \
582 --max-reserved-size
4GiB \
585 $(WASM_LIBRARY
): $(WASM_LIBRARY
).
$(WASM_OBJ_SUFFIX
)
587 $(RM
) $(WASM_LIBRARY
)
588 $(LUCETC
) $(lucet_options
) $(WASM_LIBRARY
).
$(WASM_OBJ_SUFFIX
) -o
$(WASM_LIBRARY
)
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.
598 $(IMPORT_LIBRARY
): $(SHARED_LIBRARY
) ;
601 $(HOST_SHARED_LIBRARY
): Makefile
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
)
607 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$($(notdir $@
)_OBJS
) $(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
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.
615 $(SHARED_LIBRARY
): $(OBJS
) $(RESFILE
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
617 ifndef INCREMENTAL_LINKER
620 $(MKSHLIB
) $($@_OBJS
) $(RESFILE
) $(LDFLAGS
) $(STATIC_LIBS
) $(SHARED_LIBS
) $(EXTRA_DSO_LDOPTS
) $(MOZ_GLUE_LDFLAGS
) $(OS_LIBS
)
621 $(call py_action
,check_binary
,--target
$@
)
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
); \
631 echo
'Embedding manifest from $@.manifest'; \
632 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;$(EMBED_MANIFEST_AT
); \
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
); \
638 endif # EMBED_MANIFEST_AT
639 endif # MSVC with manifest tool
640 endif # WINNT && !GCC
643 $(STRIP
) $(STRIP_FLAGS
) $@
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.
652 $(basename $3$(notdir $1)).
$2: $1 $$(call mkdir_deps
,$$(MDDEPDIR
))
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
)))
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
))))
664 $(OBJS
) $(HOST_OBJS
) $(PROGOBJS
) $(HOST_PROGOBJS
): $(GLOBAL_DEPS
)
666 # Rules for building native targets must come first because of the host_ prefix
668 $(REPORT_BUILD_VERBOSE
)
669 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(NSPR_CFLAGS
) $<
672 $(REPORT_BUILD_VERBOSE
)
673 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
674 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(NSPR_CFLAGS
) $<
677 $(REPORT_BUILD_VERBOSE
)
678 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(HOST_CMFLAGS
) $(NSPR_CFLAGS
) $<
681 $(REPORT_BUILD_VERBOSE
)
682 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(HOST_CMMFLAGS
) $(NSPR_CFLAGS
) $<
685 $(REPORT_BUILD_VERBOSE
)
686 $(CC
) $(OUTOPTION
)$@
-c
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $<
689 $(REPORT_BUILD_VERBOSE
)
690 $(WASM_CC
) $(OUTOPTION
)$@
-c
$(WASM_CFLAGS
) $($(notdir $<)_FLAGS
) $<
693 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
696 $(REPORT_BUILD_VERBOSE
)
697 $(AS
) $(ASOUTOPTION
)$@
$(ASFLAGS
) $($(notdir $<)_FLAGS
) $(AS_DASH_C_FLAG
) $<
703 ifdef MOZ_CRASHREPORTER
704 $$(call py_action
,dumpsymbols
,$$(abspath
$$<) $$(abspath
$$@
) $$(DUMP_SYMBOLS_FLAGS
))
708 ifneq (,$(filter $(DIST
)/bin
%,$(FINAL_TARGET
)))
709 DUMP_SYMS_TARGETS
:= $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
)
713 ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS
)))
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
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
731 else ifdef MOZ_CRASHREPORTER
732 $(foreach file
,$(DUMP_SYMS_TARGETS
),$(eval
$(call syms_template
,$(file
),$(notdir $(file
))_syms.track
)))
735 ifneq (,$(RUST_TESTS
)$(RUST_LIBRARY_FILE
)$(HOST_RUST_LIBRARY_FILE
)$(RUST_PROGRAMS
)$(HOST_RUST_PROGRAMS
))
736 include $(MOZILLA_DIR
)/config
/makefiles
/rust.mk
741 $(AS
) $(ASOUTOPTION
)$@
$(SFLAGS
) $($(notdir $<)_FLAGS
) -c
$<
744 $(REPORT_BUILD_VERBOSE
)
745 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
746 $(CCC
) $(OUTOPTION
)$@
-c
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
749 $(REPORT_BUILD_VERBOSE
)
750 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
751 $(WASM_CXX
) $(OUTOPTION
)$@
-c
$(WASM_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
754 $(REPORT_BUILD_VERBOSE
)
755 $(CCC
) -o
$@
-c
$(COMPILE_CXXFLAGS
) $(COMPILE_CMMFLAGS
) $($(notdir $<)_FLAGS
) $<
758 $(REPORT_BUILD_VERBOSE
)
759 $(CC
) -o
$@
-c
$(COMPILE_CFLAGS
) $(COMPILE_CMFLAGS
) $($(notdir $<)_FLAGS
) $<
761 $(filter %.s
,$(CPPSRCS
:%.
cpp=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
762 $(REPORT_BUILD_VERBOSE
)
763 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
765 $(filter %.s
,$(CPPSRCS
:%.
cc=%.s
)): %.s
: %.
cc $(call mkdir_deps
,$(MDDEPDIR
))
766 $(REPORT_BUILD_VERBOSE
)
767 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
769 $(filter %.s
,$(CPPSRCS
:%.
cxx=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
770 $(REPORT_BUILD_VERBOSE
)
771 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $<
773 $(filter %.s
,$(CSRCS
:%.c
=%.s
)): %.s
: %.c
$(call mkdir_deps
,$(MDDEPDIR
))
774 $(REPORT_BUILD_VERBOSE
)
775 $(CC
) -S
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $<
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
782 # foo.cpp sub/bar.cpp bar.cpp
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))))
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)
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))))
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
) $$<
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
))
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.
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.
820 MATCH_cpp
= \
(cpp\|
cc|
cxx\
)
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
)
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:
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
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
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: $@"))
856 @
$(MAKE
) PP_REINVOKE
=1 $@ \
857 $(foreach type
,c
cpp mm
,$(UPPER_
$(type
))SRCS
="$(all_$(type)_sources)")
864 $(RESFILE
): %.res
: $(RCFILE
)
866 @echo Creating Resource file
: $@
868 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
:-I
%=--include-dir
%) $(OUTOPTION
)$@
$<
870 $(RC
) $(RCFLAGS
) -r
$(DEFINES
) $(INCLUDES
) $(OUTOPTION
)$@
$<
873 # Cancel GNU make built-in implicit rules
876 ifneq (,$(filter WINNT
,$(OS_ARCH
)))
883 SPACE
:= $(EMPTY
) $(EMPTY
)
885 ###############################################################################
886 # Bunch of things that extend the 'export' rule (in order):
887 ###############################################################################
893 export:: $(FINAL_TARGET
)
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
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
908 ################################################################################
915 $(FINAL_TARGET
)/chrome
: $(call mkdir_deps
,$(FINAL_TARGET
)/chrome
)
917 ifneq (,$(JAR_MANIFEST
))
918 ifndef NO_DIST_INSTALL
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)'
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.
)
937 libs realchrome
:: $(FINAL_TARGET
)/chrome
938 $(call py_action
,jar_maker
,\
939 $(QUIET
) -d
$(FINAL_TARGET
) \
940 $(MAKE_JARS_FLAGS
) $(DEFINES
) $(ACDEFINES
) \
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
),)
953 @echo
'Stripping $(XPI_PKGNAME) package directory...'
954 @echo
$(FINAL_TARGET
)
955 @cd
$(FINAL_TARGET
) && find .
! -type d \
965 ! -name
'*.properties' \
976 $(PLATFORM_EXCLUDE_LIST
) \
977 -exec
$(STRIP
) $(STRIP_FLAGS
) {} >/dev
/null
2>&1 \
;
980 @echo
'Packaging $(XPI_PKGNAME).xpi...'
981 $(call py_action
,zip
,-C
$(FINAL_TARGET
) ..
/$(XPI_PKGNAME
).xpi
'*')
984 # See comment above about moving this out of the tools tier.
985 ifdef INSTALL_EXTENSION_ID
987 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID
)
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
))
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.
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
1011 ifneq (,$(filter target-objects target
all default
,$(MAKECMDGOALS
)))
1012 _MDDEPEND_FILES
+= $(addsuffix .pp
,$(notdir $(sort $(OBJS
) $(PROGOBJS
))))
1015 ifneq (,$(filter host-objects host
all default
,$(MAKECMDGOALS
)))
1016 _MDDEPEND_FILES
+= $(addsuffix .pp
,$(notdir $(sort $(HOST_OBJS
) $(HOST_PROGOBJS
))))
1019 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(_MDDEPEND_FILES
))))
1020 MDDEPEND_FILES
+= $(EXTRA_MDDEPEND_FILES
)
1022 ifneq (,$(MDDEPEND_FILES
))
1023 -include $(MDDEPEND_FILES
)
1026 ################################################################################
1027 # Install/copy rules
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,
1033 # FOO_FILES := foo bar
1034 # FOO_EXECUTABLES := baz
1035 # FOO_DEST := target_path
1036 # INSTALL_TARGETS += FOO
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".
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
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
)
1051 define install_cmd_override
1052 $(1): install_cmd
= $$(if
$$(nsinstall_is_usable
),$$(INSTALL
),$$(NSINSTALL_PY
) -t
) $$(1)
1057 install_target_tier
= $(or
$($(1)_TARGET
),libs
)
1058 INSTALL_TARGETS_TIERS
:= $(sort $(foreach category
,$(INSTALL_TARGETS
),$(call install_target_tier
,$(category
))))
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
)))
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
1071 define install_target_template
1072 $(call install_cmd_override
,$(2))
1073 $(call create_dependency
,$(2),$(1))
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
))) \
1082 $(foreach file
,$($(category
)_FILES
) $($(category
)_EXECUTABLES
), \
1083 $(eval
$(call install_target_template
,$(file
),$(call install_target_result
,$(category
),$(file
)))) \
1087 $(foreach tier
,$(INSTALL_TARGETS_TIERS
), \
1088 $(eval
$(tier
):: $(INSTALL_TARGETS_FILES_
$(tier
)) $(INSTALL_TARGETS_EXECUTABLES_
$(tier
))) \
1091 install_targets_sanity
= $(if
$(filter-out $(notdir $@
),$(notdir $(<))),$(error Looks like
$@ has an unexpected dependency on
$< which breaks INSTALL_TARGETS
))
1093 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_FILES_
$(tier
)))):
1094 $(install_targets_sanity
)
1095 $(call install_cmd
,$(IFLAGS1
) '$<' '$(@D)')
1097 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_EXECUTABLES_
$(tier
)))):
1098 $(install_targets_sanity
)
1099 $(call install_cmd
,$(IFLAGS2
) '$<' '$(@D)')
1101 ################################################################################
1102 # Preprocessing rules
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:
1109 # FOO_PATH := target-directory
1110 # FOO_FLAGS := -Dsome_flag
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:
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.
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).
1124 # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
1125 # to the usual bunch. Setting this variable is optional.
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.
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.
1136 pp_target_tier
= $(or
$($(1)_TARGET
),libs
)
1137 PP_TARGETS_TIERS
:= $(sort $(foreach category
,$(PP_TARGETS
),$(call pp_target_tier
,$(category
))))
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
)))
1142 $(foreach category
,$(PP_TARGETS
), \
1143 $(foreach tier
,$(call pp_target_tier
,$(category
)), \
1144 $(eval PP_TARGETS_RESULTS_
$(tier
) += $(call pp_target_results
,$(category
))) \
1146 $(foreach file
,$($(category
)), \
1147 $(eval
$(call create_dependency
,$(call pp_target_result
,$(category
),$(file
)), \
1148 $(file
) $(GLOBAL_DEPS
))) \
1150 $(eval
$(call pp_target_results
,$(category
)): PP_TARGET_FLAGS
=$($(category
)_FLAGS
)) \
1153 $(foreach tier
,$(PP_TARGETS_TIERS
), \
1154 $(eval
$(tier
):: $(PP_TARGETS_RESULTS_
$(tier
))) \
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
))
1161 $(call py_action
,preprocessor
,--depend
$(MDDEPDIR
)/$(@F
).pp
$(PP_TARGET_FLAGS
) $(DEFINES
) $(ACDEFINES
) '$<' -o
'$@')
1163 $(filter %.css
,$(PP_TARGETS_ALL_RESULTS
)): PP_TARGET_FLAGS
+=--marker
%
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
) \
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
1177 $(foreach file
,$(PP_TARGETS_ALL_RESULTS
), \
1178 $(if
$(wildcard $(MDDEPDIR
)/$(notdir $(file
)).pp
), \
1180 $(eval
$(file
): FORCE
) \
1184 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(addsuffix .pp
,$(notdir $(PP_TARGETS_ALL_RESULTS
))))))
1186 ifneq (,$(MDDEPEND_FILES
))
1187 -include $(MDDEPEND_FILES
)
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
1197 ################################################################################
1198 # Special gmake rules.
1199 ################################################################################
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.
1209 # Fake targets. Always run these rules, even if a file/directory with that
1210 # name already exists.
1212 .PHONY
: all alltags boot chrome realchrome
clean clobber clobber_all
export install libs makefiles
realclean run_apprunner tools
$(DIRS
) FORCE
1214 # Used as a dependency to force targets to rebuild
1217 # Delete target if error occurs when building target
1222 TAGS
: $(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1223 -etags
$(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
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
1235 $(DOXYGEN
) $(DEPTH
)/config
/doxygen.cfg
1237 FREEZE_VARIABLES
= \
1247 $(foreach var
,$(FREEZE_VARIABLES
),$(eval
$(var
)_FROZEN
:= '$($(var))'))
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
)).
)))
1253 $(CHECK_FROZEN_VARIABLES
)
1255 .DEFAULT_GOAL
:= $(or
$(OVERRIDE_DEFAULT_GOAL
),default
)
1257 #############################################################################
1258 # Derived targets and dependencies
1260 include $(MOZILLA_DIR
)/config
/makefiles
/autotargets.mk
1261 ifneq ($(NULL
),$(AUTO_DEPS
))
1262 default
all libs tools
export:: $(AUTO_DEPS
)