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 _VPATH_SRCS
= $(abspath
$<)
48 ################################################################################
49 # Testing frameworks support
50 ################################################################################
52 testxpcobjdir
= $(DEPTH
)/_tests
/xpcshell
56 ifdef COMPILE_ENVIRONMENT
58 # Compile the tests to $(DIST)/bin. Make lots of niceties available by default
59 # through TestHarness.h, by modifying the list of includes and the libs against
61 SIMPLE_PROGRAMS
+= $(CPP_UNIT_TESTS
)
63 ifndef MOZ_PROFILE_GENERATE
64 CPP_UNIT_TESTS_FILES
= $(CPP_UNIT_TESTS
)
65 CPP_UNIT_TESTS_DEST
= $(DIST
)/cppunittests
66 CPP_UNIT_TESTS_TARGET
= target
67 INSTALL_TARGETS
+= CPP_UNIT_TESTS
71 @
$(PYTHON
) $(MOZILLA_DIR
)/testing
/runcppunittests.py
--xre-path
=$(DIST
)/bin
--symbols-path
=$(DIST
)/crashreporter-symbols
$(CPP_UNIT_TESTS
)
74 $(PYTHON
) -u
$(MOZILLA_DIR
)/testing
/remotecppunittests.py \
75 --xre-path
=$(DEPTH
)/dist/bin \
76 --localLib
=$(DEPTH
)/dist/$(MOZ_APP_NAME
) \
77 --deviceIP
=${TEST_DEVICE} \
78 $(CPP_UNIT_TESTS
) $(EXTRA_TEST_ARGS
); \
80 endif # COMPILE_ENVIRONMENT
81 endif # CPP_UNIT_TESTS
88 # If FORCE_STATIC_LIB is set, build a static library.
89 # Otherwise, build a shared library.
95 # Only build actual library if it is requested.
96 LIBRARY
:= $(REAL_LIBRARY
)
101 ifdef FORCE_SHARED_LIB
105 MKSHLIB
= $(MKCSHLIB
)
111 endif # FORCE_SHARED_LIB
113 ifeq ($(OS_ARCH
),WINNT
)
116 # This next line captures both the default (non-MOZ_COPY_PDBS)
117 # case as well as the MOZ_COPY_PDBS-for-mingwclang case.
119 # For the default case, placing the pdb in the build
120 # directory is needed.
122 # For the MOZ_COPY_PDBS, non-mingwclang case - we need to
123 # build the pdb next to the executable (handled in the if
124 # statement immediately below.)
126 # For the MOZ_COPY_PDBS, mingwclang case - we also need to
127 # build the pdb next to the executable, but this macro doesn't
128 # work for jsapi-tests which is a little special, so we specify
129 # the output directory below with MOZ_PROGRAM_LDFLAGS.
131 LINK_PDBFILE ?
= $(basename $(@F
)).pdb
134 ifneq ($(CC_TYPE
),clang
)
135 LINK_PDBFILE
= $(basename $@
).pdb
141 ifdef SIMPLE_PROGRAMS
142 COMPILE_PDB_FLAG ?
= -Fd
$(basename $(@F
)).pdb
143 COMPILE_CFLAGS
+= $(COMPILE_PDB_FLAG
)
144 COMPILE_CXXFLAGS
+= $(COMPILE_PDB_FLAG
)
148 CODFILE
=$(basename $(@F
)).cod
154 ifeq (arm-Darwin
,$(CPU_ARCH
)-$(OS_TARGET
))
156 MOZ_PROGRAM_LDFLAGS
+= -Wl
,-rpath
-Wl
,@executable_path
/Frameworks
160 ifeq ($(OS_ARCH
),WINNT
)
161 ifeq ($(CC_TYPE
),clang
)
162 MOZ_PROGRAM_LDFLAGS
+= -Wl
,-pdb
,$(dir $@
)/$(LINK_PDBFILE
)
166 ifeq ($(HOST_OS_ARCH
),WINNT
)
167 HOST_PDBFILE
=$(basename $(@F
)).pdb
168 HOST_PDB_FLAG ?
= -Fd
$(HOST_PDBFILE
)
169 HOST_C_LDFLAGS
+= $(HOST_PDB_FLAG
)
170 HOST_CXX_LDFLAGS
+= $(HOST_PDB_FLAG
)
173 # Don't build SIMPLE_PROGRAMS during the MOZ_PROFILE_GENERATE pass, and do not
174 # attempt to install them
175 ifdef MOZ_PROFILE_GENERATE
176 $(foreach category
,$(INSTALL_TARGETS
),\
177 $(eval
$(category
)_FILES
:= $(foreach file
,$($(category
)_FILES
),$(if
$(filter $(SIMPLE_PROGRAMS
),$(notdir $(file
))),,$(file
)))))
181 ifdef COMPILE_ENVIRONMENT
183 TARGETS
= $(LIBRARY
) $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
) $(HOST_PROGRAM
) $(HOST_SIMPLE_PROGRAMS
) $(HOST_SHARED_LIBRARY
)
186 COBJS
= $(notdir $(CSRCS
:.c
=.
$(OBJ_SUFFIX
)))
187 SOBJS
= $(notdir $(SSRCS
:.S
=.
$(OBJ_SUFFIX
)))
188 # CPPSRCS can have different extensions (eg: .cpp, .cc)
189 CPPOBJS
= $(notdir $(addsuffix .
$(OBJ_SUFFIX
),$(basename $(CPPSRCS
))))
190 CMOBJS
= $(notdir $(CMSRCS
:.m
=.
$(OBJ_SUFFIX
)))
191 CMMOBJS
= $(notdir $(CMMSRCS
:.mm
=.
$(OBJ_SUFFIX
)))
192 # ASFILES can have different extensions (.s, .asm)
193 ASOBJS
= $(notdir $(addsuffix .
$(OBJ_SUFFIX
),$(basename $(ASFILES
))))
194 RS_STATICLIB_CRATE_OBJ
= $(addprefix lib
,$(notdir $(RS_STATICLIB_CRATE_SRC
:.rs
=.
$(LIB_SUFFIX
))))
196 _OBJS
= $(COBJS
) $(SOBJS
) $(CPPOBJS
) $(CMOBJS
) $(CMMOBJS
) $(ASOBJS
)
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 $(GARBAGE
) $(TARGETS
) $(OBJS
) $(PROGOBJS
) LOGS TAGS a.out \
223 $(filter-out $(ASFILES
),$(OBJS
:.
$(OBJ_SUFFIX
)=.s
)) $(OBJS
:.
$(OBJ_SUFFIX
)=.ii
) \
224 $(OBJS
:.
$(OBJ_SUFFIX
)=.i
) $(OBJS
:.
$(OBJ_SUFFIX
)=.i_o
) \
225 $(HOST_PROGOBJS
) $(HOST_OBJS
) $(IMPORT_LIBRARY
) \
226 so_locations _gen _stubs
$(wildcard *.res
) $(wildcard *.RES
) \
227 $(wildcard *.pdb
) $(CODFILE
) $(IMPORT_LIBRARY
) \
228 $(SHARED_LIBRARY
:$(DLL_SUFFIX
)=.exp
) $(wildcard *.ilk
) \
229 $(PROGRAM
:$(BIN_SUFFIX
)=.exp
) $(SIMPLE_PROGRAMS
:$(BIN_SUFFIX
)=.exp
) \
230 $(PROGRAM
:$(BIN_SUFFIX
)=.lib
) $(SIMPLE_PROGRAMS
:$(BIN_SUFFIX
)=.lib
) \
231 $(SIMPLE_PROGRAMS
:$(BIN_SUFFIX
)=.
$(OBJ_SUFFIX
)) \
232 $(wildcard gts_tmp_
*) $(LIBRARY
:%.a
=.
%.timestamp
)
234 $(GARBAGE_DIRS
) /no-such-file
237 GARBAGE
+= $(MOCSRCS
)
240 ifdef SIMPLE_PROGRAMS
241 GARBAGE
+= $(SIMPLE_PROGRAMS
:%=%.
$(OBJ_SUFFIX
))
244 ifdef HOST_SIMPLE_PROGRAMS
245 GARBAGE
+= $(HOST_SIMPLE_PROGRAMS
:%=%.
$(_OBJ_SUFFIX
))
249 ifndef NO_BUILDSTATUS_MESSAGES
251 @echo
'BUILDSTATUS $1'
257 define SUBMAKE
# $(call SUBMAKE,target,directory,static)
258 +@
$(MAKE
) $(if
$(2),-C
$(2)) $(1)
260 endef # The extra line is important here! don't delete it
262 define TIER_DIR_SUBMAKE
263 $(call SUBMAKE
,$(4),$(3),$(5))
265 endef # Ths empty line is important.
267 ifneq (,$(strip $(DIRS
)))
269 $(foreach dir,$(DIRS
),$(call SUBMAKE
,$@
,$(dir)))
273 # Now we can differentiate between objects used to build a library, and
274 # objects used to build an executable in the same directory.
281 HOST_PROGOBJS
= $(HOST_OBJS
)
284 GARBAGE_DIRS
+= $(wildcard $(CURDIR
)/$(MDDEPDIR
))
287 # Tags: emacs (etags), vi (ctags)
288 # TAG_PROGRAM := ctags -L -
290 TAG_PROGRAM
= xargs etags
-a
293 # Turn on C++ linking if we have any .cpp or .mm files
294 # (moved this from config.mk so that config.mk can be included
295 # before the CPPSRCS are defined)
297 ifneq ($(HOST_CPPSRCS
)$(HOST_CMMSRCS
),)
298 HOST_CPP_PROG_LINK
= 1
302 # MacOS X specific stuff
305 ifeq ($(OS_ARCH
),Darwin
)
308 _LOADER_PATH
:= @rpath
310 _LOADER_PATH
:= @executable_path
312 EXTRA_DSO_LDOPTS
+= -dynamiclib
-install_name
$(_LOADER_PATH
)/$(SHARED_LIBRARY
) -compatibility_version
1 -current_version
1 -single_module
317 # GNU doesn't have path length limitation
320 ifeq ($(OS_ARCH
),GNU
)
321 OS_CPPFLAGS
+= -DPATH_MAX
=1024 -DMAXPATHLEN
=1024
327 ifeq ($(OS_ARCH
),WINNT
)
329 DSO_LDOPTS
+= -Wl
,--out-implib
-Wl
,$(IMPORT_LIBRARY
)
341 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
345 endif # WINNT && !GNU_CC
347 ifeq (,$(CROSS_COMPILE
))
348 HOST_OUTOPTION
= $(OUTOPTION
)
350 # Windows-to-Windows cross compiles should always use MSVC-style options for
352 ifeq (WINNT_WINNT
,$(HOST_OS_ARCH
)_
$(OS_ARCH
))
353 ifneq (,$(filter-out clang-cl
,$(HOST_CC_TYPE
)))
354 $(error MSVC-style compilers should be used for host compilations
!)
356 HOST_OUTOPTION
= -Fo
# eol
358 HOST_OUTOPTION
= -o
# eol
361 ################################################################################
363 # Ensure the build config is up to date. This is done automatically when builds
364 # are performed through |mach build|. The check here is to catch people not
365 # using mach. If we ever enforce builds through mach, this code can be removed.
366 ifndef MOZBUILD_BACKEND_CHECKED
368 ifndef TOPLEVEL_BUILD
369 BUILD_BACKEND_FILES
:= $(addprefix $(DEPTH
)/backend.
,$(addsuffix Backend
,$(BUILD_BACKENDS
)))
370 $(DEPTH
)/backend.
%Backend
:
371 $(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config
)
373 define build_backend_rule
374 $(1): $$(shell cat
$(1).in
)
377 $(foreach file
,$(BUILD_BACKEND_FILES
),$(eval
$(call build_backend_rule
,$(file
))))
379 default
:: $(BUILD_BACKEND_FILES
)
381 export MOZBUILD_BACKEND_CHECKED
=1
386 # The root makefile doesn't want to do a plain export/libs, because
387 # of the tiers and because of libxul. Suppress the default rules in favor
388 # of something else. Makefiles which use this var *must* provide a sensible
389 # default rule before including rules.mk
391 $(foreach tier
,$(TIERS
),$(call SUBMAKE
,$(tier
)))
393 ifdef BUILD_VERBOSE_LOG
401 # Do everything from scratch
406 # Dependencies which, if modified, should cause everything to rebuild
407 GLOBAL_DEPS
+= Makefile
$(addprefix $(DEPTH
)/config
/,$(INCLUDED_AUTOCONF_MK
)) $(MOZILLA_DIR
)/config
/config.mk
409 ##############################################
410 ifdef COMPILE_ENVIRONMENT
411 OBJ_TARGETS
= $(OBJS
) $(PROGOBJS
) $(HOST_OBJS
) $(HOST_PROGOBJS
)
413 compile
:: host target
415 host
:: $(HOST_OBJS
) $(HOST_PROGRAM
) $(HOST_SIMPLE_PROGRAMS
) $(HOST_RUST_PROGRAMS
) $(HOST_RUST_LIBRARY_FILE
) $(HOST_SHARED_LIBRARY
)
417 target
:: $(filter-out $(MOZBUILD_NON_DEFAULT_TARGETS
),$(LIBRARY
) $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
) $(RUST_LIBRARY_FILE
) $(RUST_PROGRAMS
))
427 include $(MOZILLA_DIR
)/config
/makefiles
/target_binaries.mk
430 ##############################################
431 ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE
))
433 ifeq ($(OS_ARCH
)_
$(GNU_CC
), WINNT_
)
434 # When building with PGO, we have to make sure to re-link
435 # in the MOZ_PROFILE_USE phase if we linked in the
436 # MOZ_PROFILE_GENERATE phase. We'll touch this pgo.relink
437 # file in the link rule in the GENERATE phase to indicate
438 # that we need a relink.
440 $(SHARED_LIBRARY
): pgo.relink
443 $(PROGRAM
): pgo.relink
446 # In the second pass, we need to merge the pgc files into the pgd file.
447 # The compiler would do this for us automatically if they were in the right
448 # place, but they're in dist/bin.
449 ifneq (,$(SHARED_LIBRARY
)$(PROGRAM
))
452 $(PYTHON
) $(MOZILLA_DIR
)/build
/win32
/pgomerge.py \
453 $(PROGRAM
:$(BIN_SUFFIX
)=) $(DIST
)/bin
456 $(PYTHON
) $(MOZILLA_DIR
)/build
/win32
/pgomerge.py \
457 $(patsubst $(DLL_PREFIX
)%$(DLL_SUFFIX
),%,$(SHARED_LIBRARY
)) $(DIST
)/bin
459 endif # SHARED_LIBRARY || PROGRAM
461 endif # MOZ_PROFILE_USE
462 ifdef MOZ_PROFILE_GENERATE
463 # Clean up profiling data during PROFILE_GENERATE phase
465 ifeq ($(OS_ARCH
)_
$(GNU_CC
), WINNT_
)
466 $(foreach pgd
,$(wildcard *.pgd
),pgomgr
-clear
$(pgd
);)
474 ifneq (,$(MOZ_PROFILE_GENERATE
)$(MOZ_PROFILE_USE
))
475 ifneq (,$(filter target
,$(MAKECMDGOALS
)))
477 # Force rebuilding libraries and programs in both passes because each
478 # pass uses different object files.
479 $(PROGRAM
) $(SHARED_LIBRARY
) $(LIBRARY
): FORCE
484 endif # NO_PROFILE_GUIDED_OPTIMIZE
486 ##############################################
488 clean clobber realclean clobber_all
::
490 -$(RM
) -r
$(ALL_TRASH_DIRS
)
492 clean clobber realclean clobber_all
distclean::
493 $(foreach dir,$(DIRS
),-$(call SUBMAKE
,$@
,$(dir)))
496 -$(RM
) -r
$(ALL_TRASH_DIRS
)
497 -$(RM
) $(ALL_TRASH
) \
498 Makefile .HSancillary \
499 $(wildcard *.
$(OBJ_SUFFIX
)) $(wildcard *.ho
) $(wildcard host_
*.o
*) \
500 $(wildcard *.
$(LIB_SUFFIX
)) $(wildcard *$(DLL_SUFFIX
)) \
501 $(wildcard *.
$(IMPORT_LIB_SUFFIX
))
505 find
$(topsrcdir
) -name
dist -prune
-o \
( -name
'*.[hc]' -o
-name
'*.cp' -o
-name
'*.cpp' -o
-name
'*.idl' \
) -print |
$(TAG_PROGRAM
)
507 define EXPAND_CC_OR_CXX
508 $(if
$(PROG_IS_C_ONLY_
$(1)),$(CC
),$(CCC
))
513 # creates OBJS, links with LIBS to create Foo
515 $(PROGRAM
): $(PROGOBJS
) $(STATIC_LIBS
) $(RUST_STATIC_LIB
) $(EXTRA_DEPS
) $(RESFILE
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(FINAL_TARGET
))
518 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
519 $(LINKER
) -NOLOGO
-OUT
:$@
-PDB
:$(LINK_PDBFILE
) -IMPLIB
:$(basename $(@F
)).lib
$(WIN32_EXE_LDFLAGS
) $(LDFLAGS
) $(MOZ_PROGRAM_LDFLAGS
) $($(notdir $@
)_
$(OBJS_VAR_SUFFIX
)) $(RESFILE
) $(STATIC_LIBS
) $(RUST_STATIC_LIB
) $(SHARED_LIBS
) $(OS_LIBS
)
520 ifdef MSMANIFEST_TOOL
521 @if
test -f
$@.manifest
; then \
522 if
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
523 echo
'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest and $@.manifest'; \
524 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' $@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
526 echo
'Embedding manifest from $@.manifest'; \
527 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
529 elif
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
530 echo
'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
531 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE
:$@\
;1; \
533 endif # MSVC with manifest tool
534 ifdef MOZ_PROFILE_GENERATE
535 # touch it a few seconds into the future to work around FAT's
536 # 2-second granularity
537 touch
-t
`date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
539 else # !WINNT || GNU_CC
540 $(call EXPAND_CC_OR_CXX
,$@
) -o
$@
$(COMPUTED_CXX_LDFLAGS
) $(PGO_CFLAGS
) $($(notdir $@
)_
$(OBJS_VAR_SUFFIX
)) $(RESFILE
) $(WIN32_EXE_LDFLAGS
) $(LDFLAGS
) $(STATIC_LIBS
) $(RUST_STATIC_LIB
) $(MOZ_PROGRAM_LDFLAGS
) $(SHARED_LIBS
) $(OS_LIBS
)
541 $(call py_action
,check_binary
,--target
$@
)
542 endif # WINNT && !GNU_CC
545 $(STRIP
) $(STRIP_FLAGS
) $@
547 ifdef MOZ_POST_PROGRAM_COMMAND
548 $(MOZ_POST_PROGRAM_COMMAND
) $@
551 $(HOST_PROGRAM
): $(HOST_PROGOBJS
) $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
) $(call mkdir_deps
,$(DEPTH
)/dist/host
/bin
)
553 ifeq (_WINNT
,$(GNU_CC
)_
$(HOST_OS_ARCH
))
554 $(HOST_LINKER
) -NOLOGO
-OUT
:$@
-PDB
:$(HOST_PDBFILE
) $($(notdir $@
)_OBJS
) $(WIN32_EXE_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LINKER_LIBPATHS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
555 ifdef MSMANIFEST_TOOL
556 @if
test -f
$@.manifest
; then \
557 if
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
558 echo
'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest and $@.manifest'; \
559 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' $@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
561 echo
'Embedding manifest from $@.manifest'; \
562 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
564 elif
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
565 echo
'Embedding manifest from $(srcdir_rel)/$(notdir $@).manifest'; \
566 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE
:$@\
;1; \
568 endif # MSVC with manifest tool
570 ifeq ($(HOST_CPP_PROG_LINK
),1)
571 $(HOST_CXX
) -o
$@
$(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
573 $(HOST_CC
) -o
$@
$(HOST_C_LDFLAGS
) $(HOST_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
574 endif # HOST_CPP_PROG_LINK
577 $(call py_action
,check_binary
,--host
$@
)
581 # This is an attempt to support generation of multiple binaries
582 # in one directory, it assumes everything to compile Foo is in
583 # Foo.o (from either Foo.c or Foo.cpp).
585 # SIMPLE_PROGRAMS = Foo Bar
586 # creates Foo.o Bar.o, links with LIBS to create Foo, Bar.
588 $(SIMPLE_PROGRAMS
): %$(BIN_SUFFIX
): %.
$(OBJ_SUFFIX
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
590 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
591 $(LINKER
) -nologo
-out
:$@
-pdb
:$(LINK_PDBFILE
) $($@_
$(OBJS_VAR_SUFFIX
)) $(WIN32_EXE_LDFLAGS
) $(LDFLAGS
) $(MOZ_PROGRAM_LDFLAGS
) $(STATIC_LIBS
) $(SHARED_LIBS
) $(OS_LIBS
)
592 ifdef MSMANIFEST_TOOL
593 @if
test -f
$@.manifest
; then \
594 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;1; \
596 elif
test -f
'$(srcdir)/$(notdir $@).manifest'; then \
597 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$(notdir $@).manifest' -OUTPUTRESOURCE
:$@\
;1; \
599 endif # MSVC with manifest tool
601 $(call EXPAND_CC_OR_CXX
,$@
) $(COMPUTED_CXX_LDFLAGS
) $(PGO_CFLAGS
) -o
$@
$($@_
$(OBJS_VAR_SUFFIX
)) $(WIN32_EXE_LDFLAGS
) $(LDFLAGS
) $(STATIC_LIBS
) $(MOZ_PROGRAM_LDFLAGS
) $(SHARED_LIBS
) $(OS_LIBS
)
602 $(call py_action
,check_binary
,--target
$@
)
603 endif # WINNT && !GNU_CC
606 $(STRIP
) $(STRIP_FLAGS
) $@
608 ifdef MOZ_POST_PROGRAM_COMMAND
609 $(MOZ_POST_PROGRAM_COMMAND
) $@
612 $(HOST_SIMPLE_PROGRAMS
): host_
%$(HOST_BIN_SUFFIX
): $(HOST_LIBS
) $(HOST_EXTRA_DEPS
) $(GLOBAL_DEPS
)
614 ifeq (WINNT_
,$(HOST_OS_ARCH
)_
$(GNU_CC
))
615 $(HOST_LINKER
) -NOLOGO
-OUT
:$@
-PDB
:$(HOST_PDBFILE
) $($(notdir $@
)_OBJS
) $(WIN32_EXE_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LINKER_LIBPATHS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
617 ifneq (,$(HOST_CPPSRCS
)$(USE_HOST_CXX
))
618 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$(HOST_CXX_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
620 $(HOST_CC
) $(HOST_OUTOPTION
)$@
$(HOST_C_LDFLAGS
) $($(notdir $@
)_OBJS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
624 $(call py_action
,check_binary
,--host
$@
)
627 $(LIBRARY
): $(OBJS
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
629 $(RM
) $(REAL_LIBRARY
)
630 $(AR
) $(AR_FLAGS
) $($@_
$(OBJS_VAR_SUFFIX
))
632 ifeq ($(OS_ARCH
),WINNT
)
633 # Import libraries are created by the rules creating shared libraries.
634 # The rules to copy them to $(DIST)/lib depend on $(IMPORT_LIBRARY),
635 # but make will happily consider the import library before it is refreshed
636 # when rebuilding the corresponding shared library. Defining an empty recipe
637 # for import libraries forces make to wait for the shared library recipe to
638 # have run before considering other targets that depend on the import library.
640 $(IMPORT_LIBRARY
): $(SHARED_LIBRARY
) ;
643 $(HOST_SHARED_LIBRARY
): Makefile
646 ifneq (,$(filter clang-cl
,$(HOST_CC_TYPE
)))
647 $(HOST_LINKER
) -NOLOGO
-DLL
-OUT
:$@
$($(notdir $@
)_OBJS
) $(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LINKER_LIBPATHS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
649 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
$($(notdir $@
)_OBJS
) $(HOST_CXX_LDFLAGS
) $(HOST_LDFLAGS
) $(HOST_LIBS
) $(HOST_EXTRA_LIBS
)
652 # On Darwin (Mac OS X), dwarf2 debugging uses debug info left in .o files,
653 # so instead of deleting .o files after repacking them into a dylib, we make
654 # symlinks back to the originals. The symlinks are a no-op for stabs debugging,
655 # so no need to conditionalize on OS version or debugging format.
657 $(SHARED_LIBRARY
): $(OBJS
) $(RESFILE
) $(RUST_STATIC_LIB
) $(STATIC_LIBS
) $(EXTRA_DEPS
) $(GLOBAL_DEPS
)
659 ifndef INCREMENTAL_LINKER
662 $(MKSHLIB
) $($@_
$(OBJS_VAR_SUFFIX
)) $(RESFILE
) $(LDFLAGS
) $(STATIC_LIBS
) $(RUST_STATIC_LIB
) $(SHARED_LIBS
) $(EXTRA_DSO_LDOPTS
) $(MOZ_GLUE_LDFLAGS
) $(OS_LIBS
)
663 $(call py_action
,check_binary
,--target
$@
)
665 ifeq (_WINNT
,$(GNU_CC
)_
$(OS_ARCH
))
666 ifdef MSMANIFEST_TOOL
667 ifdef EMBED_MANIFEST_AT
668 @if
test -f
$@.manifest
; then \
669 if
test -f
'$(srcdir)/$@.manifest'; then \
670 echo
'Embedding manifest from $(srcdir_rel)/$@.manifest and $@.manifest'; \
671 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$@.manifest' $@.manifest
-OUTPUTRESOURCE
:$@\
;$(EMBED_MANIFEST_AT
); \
673 echo
'Embedding manifest from $@.manifest'; \
674 $(MT
) -NOLOGO
-MANIFEST
$@.manifest
-OUTPUTRESOURCE
:$@\
;$(EMBED_MANIFEST_AT
); \
676 elif
test -f
'$(srcdir)/$@.manifest'; then \
677 echo
'Embedding manifest from $(srcdir_rel)/$@.manifest'; \
678 $(MT
) -NOLOGO
-MANIFEST
'$(srcdir_rel)/$@.manifest' -OUTPUTRESOURCE
:$@\
;$(EMBED_MANIFEST_AT
); \
680 endif # EMBED_MANIFEST_AT
681 endif # MSVC with manifest tool
682 ifdef MOZ_PROFILE_GENERATE
683 touch
-t
`date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink
685 endif # WINNT && !GCC
688 $(STRIP
) $(STRIP_FLAGS
) $@
691 # The object file is in the current directory, and the source file can be any
692 # relative path. This macro adds the dependency obj: src for each source file.
693 # This dependency must be first for the $< flag to work correctly, and the
694 # rules that have commands for these targets must not list any other
695 # prerequisites, or they will override the $< variable.
697 $(basename $3$(notdir $1)).
$2: $1 $$(call mkdir_deps
,$$(MDDEPDIR
))
699 $(foreach f
,$(CSRCS
) $(SSRCS
) $(CPPSRCS
) $(CMSRCS
) $(CMMSRCS
) $(ASFILES
),$(eval
$(call src_objdep
,$(f
),$(OBJ_SUFFIX
))))
700 $(foreach f
,$(HOST_CSRCS
) $(HOST_CPPSRCS
) $(HOST_CMSRCS
) $(HOST_CMMSRCS
),$(eval
$(call src_objdep
,$(f
),$(_OBJ_SUFFIX
),host_
)))
702 # The Rust compiler only outputs library objects, and so we need different
703 # mangling to generate dependency rules for it.
704 mk_global_crate_libname
= $(basename lib
$(notdir $1)).
$(LIB_SUFFIX
)
705 crate_src_libdep
= $(call mk_global_crate_libname
,$1): $1 $$(call mkdir_deps
,$$(MDDEPDIR
))
706 $(foreach f
,$(RS_STATICLIB_CRATE_SRC
),$(eval
$(call crate_src_libdep
,$(f
))))
708 $(OBJS
) $(HOST_OBJS
) $(PROGOBJS
) $(HOST_PROGOBJS
): $(GLOBAL_DEPS
)
710 # Rules for building native targets must come first because of the host_ prefix
712 $(REPORT_BUILD_VERBOSE
)
713 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(NSPR_CFLAGS
) $(_VPATH_SRCS
)
716 $(REPORT_BUILD_VERBOSE
)
717 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
718 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(NSPR_CFLAGS
) $(_VPATH_SRCS
)
721 $(REPORT_BUILD_VERBOSE
)
722 $(HOST_CC
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CFLAGS
) $(HOST_CMFLAGS
) $(NSPR_CFLAGS
) $(_VPATH_SRCS
)
725 $(REPORT_BUILD_VERBOSE
)
726 $(HOST_CXX
) $(HOST_OUTOPTION
)$@
-c
$(HOST_CPPFLAGS
) $(HOST_CXXFLAGS
) $(HOST_CMMFLAGS
) $(NSPR_CFLAGS
) $(_VPATH_SRCS
)
729 $(REPORT_BUILD_VERBOSE
)
730 $(CC
) $(OUTOPTION
)$@
-c
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
732 # DEFINES and ACDEFINES are needed here to enable conditional compilation of Q_OBJECTs:
733 # 'moc' only knows about #defines it gets on the command line (-D...), not in
734 # included headers like mozilla-config.h
735 $(filter moc_
%.
cpp,$(CPPSRCS
)): moc_
%.
cpp: %.h
736 $(REPORT_BUILD_VERBOSE
)
737 $(MOC
) $(DEFINES
) $(ACDEFINES
) $< $(OUTOPTION
)$@
739 $(filter moc_
%.
cc,$(CPPSRCS
)): moc_
%.
cc: %.
cc
740 $(REPORT_BUILD_VERBOSE
)
741 $(MOC
) $(DEFINES
) $(ACDEFINES
) $(_VPATH_SRCS
:.
cc=.h
) $(OUTOPTION
)$@
743 $(filter qrc_
%.
cpp,$(CPPSRCS
)): qrc_
%.
cpp: %.qrc
744 $(REPORT_BUILD_VERBOSE
)
745 $(RCC
) -name
$* $< $(OUTOPTION
)$@
748 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
751 $(REPORT_BUILD_VERBOSE
)
752 $(AS
) $(ASOUTOPTION
)$@
$(ASFLAGS
) $($(notdir $<)_FLAGS
) $(AS_DASH_C_FLAG
) $(_VPATH_SRCS
)
758 ifdef MOZ_CRASHREPORTER
759 $$(call py_action
,dumpsymbols
,$$(abspath
$$<) $$(abspath
$$@
) $$(DUMP_SYMBOLS_FLAGS
))
763 ifndef MOZ_PROFILE_GENERATE
764 ifneq (,$(filter $(DIST
)/bin
%,$(FINAL_TARGET
)))
765 DUMP_SYMS_TARGETS
:= $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
)
770 ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS
)))
776 MAIN_PDB_FILES
= $(addsuffix .pdb
,$(basename $(DUMP_SYMS_TARGETS
)))
777 MAIN_PDB_DEST ?
= $(FINAL_TARGET
)
778 MAIN_PDB_TARGET
= syms
779 INSTALL_TARGETS
+= MAIN_PDB
782 CPP_UNIT_TESTS_PDB_FILES
= $(addsuffix .pdb
,$(basename $(CPP_UNIT_TESTS
)))
783 CPP_UNIT_TESTS_PDB_DEST
= $(DIST
)/cppunittests
784 CPP_UNIT_TESTS_PDB_TARGET
= syms
785 INSTALL_TARGETS
+= CPP_UNIT_TESTS_PDB
788 else ifdef MOZ_CRASHREPORTER
789 $(foreach file
,$(DUMP_SYMS_TARGETS
),$(eval
$(call syms_template
,$(file
),$(notdir $(file
))_syms.track
)))
792 ifneq (,$(RUST_TESTS
)$(RUST_LIBRARY_FILE
)$(HOST_RUST_LIBRARY_FILE
)$(RUST_PROGRAMS
)$(HOST_RUST_PROGRAMS
))
793 include $(MOZILLA_DIR
)/config
/makefiles
/rust.mk
798 $(AS
) $(ASOUTOPTION
)$@
$(SFLAGS
) $($(notdir $<)_FLAGS
) -c
$<
801 $(REPORT_BUILD_VERBOSE
)
802 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
803 $(CCC
) $(OUTOPTION
)$@
-c
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
806 $(REPORT_BUILD_VERBOSE
)
807 $(CCC
) -o
$@
-c
$(COMPILE_CXXFLAGS
) $(COMPILE_CMMFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
810 $(REPORT_BUILD_VERBOSE
)
811 $(CC
) -o
$@
-c
$(COMPILE_CFLAGS
) $(COMPILE_CMFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
813 $(filter %.s
,$(CPPSRCS
:%.
cpp=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
814 $(REPORT_BUILD_VERBOSE
)
815 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
817 $(filter %.s
,$(CPPSRCS
:%.
cc=%.s
)): %.s
: %.
cc $(call mkdir_deps
,$(MDDEPDIR
))
818 $(REPORT_BUILD_VERBOSE
)
819 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
821 $(filter %.s
,$(CPPSRCS
:%.
cxx=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
822 $(REPORT_BUILD_VERBOSE
)
823 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
825 $(filter %.s
,$(CSRCS
:%.c
=%.s
)): %.s
: %.c
$(call mkdir_deps
,$(MDDEPDIR
))
826 $(REPORT_BUILD_VERBOSE
)
827 $(CC
) -S
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
829 ifneq (,$(filter %.i
,$(MAKECMDGOALS
)))
830 # Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
831 # of the full sources, as well as the $(notdir) version. So:
832 # foo.cpp sub/bar.cpp
834 # foo.cpp sub/bar.cpp bar.cpp
836 # This way we can match both 'make sub/bar.i' and 'make bar.i'
837 _group_srcs
= $(sort $(patsubst %.
$1,%.i
,$(filter %.
$1,$2 $(notdir $2))))
839 define PREPROCESS_RULES
840 _PREPROCESSED_
$1_FILES := $$(call _group_srcs
,$1,$$($2))
841 # Make preprocessed files PHONY so they are always executed, since they are
842 # manual targets and we don't necessarily write to $@.
843 .PHONY
: $$(_PREPROCESSED_
$1_FILES)
845 # Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
846 # reach $(srcdir)/frontend/Parser.i
847 vpath
%.
$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
848 vpath
%.
$1 $$(addprefix $$(CURDIR
)/,$$(sort $$(dir $$($2))))
850 $$(_PREPROCESSED_
$1_FILES): _DEPEND_CFLAGS
=
851 $$(_PREPROCESSED_
$1_FILES): %.i
: %.
$1
852 $$(REPORT_BUILD_VERBOSE
)
853 $$(addprefix $$(MKDIR
) -p
,$$(filter-out .
,$$(@D
)))
854 $$($3) -C
$$(PREPROCESS_OPTION
)$$@
$(foreach var
,$4,$$($(var
))) $$($$(notdir $$<)_FLAGS
) $$(_VPATH_SRCS
)
858 $(eval
$(call PREPROCESS_RULES
,cpp,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
859 $(eval
$(call PREPROCESS_RULES
,cc,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
860 $(eval
$(call PREPROCESS_RULES
,cxx,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
861 $(eval
$(call PREPROCESS_RULES
,c
,CSRCS
,CC
,COMPILE_CFLAGS
))
862 $(eval
$(call PREPROCESS_RULES
,mm
,CMMSRCS
,CCC
,COMPILE_CXXFLAGS COMPILE_CMMFLAGS
))
864 # Default to pre-processing the actual unified file. This can be overridden
865 # at the command-line to pre-process only the individual source file.
868 # PP_REINVOKE gets set on the sub-make to prevent us from going in an
869 # infinite loop if the filename doesn't exist in the unified source files.
872 MATCH_cpp
= \
(cpp\|
cc|
cxx\
)
877 # When building with PP_UNIFIED=0, we also have to look in the Unified files to
878 # find a matching pathname.
879 _get_all_sources
= $1 $(if
$(filter Unified
%,$1),$(shell sed
-n
's/\#include "\(.*\)"$$/\1/p' $(filter Unified
%,$1)))
880 all_cpp_sources
:= $(call _get_all_sources
,$(CPPSRCS
))
881 all_mm_sources
:= $(call _get_all_sources
,$(CMMSRCS
))
882 all_c_sources
:= $(call _get_all_sources
,$(CSRCS
))
883 all_sources
:= $(all_cpp_sources
) $(all_cmm_sources
) $(all_c_sources
)
885 # The catch-all %.i rule runs when we pass in a .i filename that doesn't match
886 # one of the *SRCS variables. The two code paths depend on whether or not
887 # we are requesting a unified file (PP_UNIFIED=1, the default) or not:
890 # - Look for it in any of the Unified files, and re-exec make with
891 # Unified_foo0.i as the target. This gets us the full unified preprocessed
895 # - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
896 # make with that filename as the target. The *SRCS variables are modified
897 # to have the Unified sources appended to them so that the static pattern
900 ifeq ($(PP_UNIFIED
),1)
901 @
$(MAKE
) PP_REINVOKE
=1 \
902 $(or
$(addsuffix .i
, \
903 $(foreach type
,c
cpp mm
, \
904 $(if
$(filter Unified
%,$($(UPPER_
$(type
))SRCS
)), \
905 $(shell grep
-l
'#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified
*.
$(type
) | sed
's/\.$(type)$$//') \
906 ))),$(error
"File not found for preprocessing: $@"))
908 @
$(MAKE
) PP_REINVOKE
=1 $@ \
909 $(foreach type
,c
cpp mm
,$(UPPER_
$(type
))SRCS
="$(all_$(type)_sources)")
916 $(RESFILE
): %.res
: %.rc
918 @echo Creating Resource file
: $@
920 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
:-I
%=--include-dir
%) $(OUTOPTION
)$@
$(_VPATH_SRCS
)
922 $(RC
) $(RCFLAGS
) -r
$(DEFINES
) $(INCLUDES
) $(OUTOPTION
)$@
$(_VPATH_SRCS
)
925 # Cancel GNU make built-in implicit rules
928 ifneq (,$(filter WINNT
,$(OS_ARCH
)))
935 SPACE
:= $(EMPTY
) $(EMPTY
)
937 ###############################################################################
938 # Bunch of things that extend the 'export' rule (in order):
939 ###############################################################################
945 export:: $(FINAL_TARGET
)
948 ################################################################################
949 # The default location for prefs is the gre prefs directory.
950 # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
951 PREF_DIR
= defaults
/pref
953 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
954 # different and that we are building app related resources. Hence,
955 # PREF_DIR should point to the app prefs location.
956 ifneq (,$(DIST_SUBDIR
)$(XPI_NAME
))
957 PREF_DIR
= defaults
/preferences
960 ################################################################################
967 $(FINAL_TARGET
)/chrome
: $(call mkdir_deps
,$(FINAL_TARGET
)/chrome
)
969 ifneq (,$(JAR_MANIFEST
))
970 ifndef NO_DIST_INSTALL
974 # For add-on packaging we may specify that an application
975 # sub-dir should be added to the root chrome manifest with
976 # a specific application id.
977 MAKE_JARS_FLAGS
+= --root-manifest-entry-appid
='$(XPI_ROOT_APPID)'
980 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
981 # no way langpacks will get packaged right, so error out.
982 ifneq (,$(DIST_SUBDIR
))
983 ifndef XPI_ROOT_APPID
984 $(error XPI_ROOT_APPID is not defined
- langpacks will break.
)
989 libs realchrome
:: $(FINAL_TARGET
)/chrome
990 $(call py_action
,jar_maker
,\
991 $(QUIET
) -d
$(FINAL_TARGET
) \
992 $(MAKE_JARS_FLAGS
) $(DEFINES
) $(ACDEFINES
) \
999 # When you move this out of the tools tier, please remove the corresponding
1000 # hacks in recursivemake.py that check if Makefile.in sets the variable.
1001 ifneq ($(XPI_PKGNAME
),)
1005 @echo
'Stripping $(XPI_PKGNAME) package directory...'
1006 @echo
$(FINAL_TARGET
)
1007 @cd
$(FINAL_TARGET
) && find .
! -type d \
1017 ! -name
'*.properties' \
1028 $(PLATFORM_EXCLUDE_LIST
) \
1029 -exec
$(STRIP
) $(STRIP_FLAGS
) {} >/dev
/null
2>&1 \
;
1032 @echo
'Packaging $(XPI_PKGNAME).xpi...'
1033 $(call py_action
,zip
,-C
$(FINAL_TARGET
) ..
/$(XPI_PKGNAME
).xpi
'*')
1036 # See comment above about moving this out of the tools tier.
1037 ifdef INSTALL_EXTENSION_ID
1039 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID
)
1043 $(RM
) -r
'$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1044 $(NSINSTALL
) -D
'$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1045 $(call copy_dir
,$(FINAL_TARGET
),$(DIST
)/bin
/distribution
$(DIST_SUBDIR
:%=/%)/extensions
/$(INSTALL_EXTENSION_ID
))
1049 #############################################################################
1050 # MDDEPDIR is the subdirectory where all the dependency files are placed.
1051 # This uses a make rule (instead of a macro) to support parallel
1052 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
1053 # processes could simultaneously try to create the same directory.
1055 # We use $(CURDIR) in the rule's target to ensure that we don't find
1056 # a dependency directory in the source tree via VPATH (perhaps from
1057 # a previous build in the source tree) and thus neglect to create a
1058 # dependency directory in the object directory, where we really need
1061 ifneq (,$(filter-out all chrome default
export realchrome
clean clobber clobber_all
distclean realclean,$(MAKECMDGOALS
)))
1062 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(addsuffix .pp
,$(notdir $(sort $(OBJS
) $(PROGOBJS
) $(HOST_OBJS
) $(HOST_PROGOBJS
)))))))
1064 ifneq (,$(MDDEPEND_FILES
))
1065 -include $(MDDEPEND_FILES
)
1070 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(EXTRA_MDDEPEND_FILES
))))
1072 ifneq (,$(MDDEPEND_FILES
))
1073 -include $(MDDEPEND_FILES
)
1076 ################################################################################
1077 # Install/copy rules
1079 # The INSTALL_TARGETS variable contains a list of all install target
1080 # categories. Each category defines a list of files and executables, and an
1081 # install destination,
1083 # FOO_FILES := foo bar
1084 # FOO_EXECUTABLES := baz
1085 # FOO_DEST := target_path
1086 # INSTALL_TARGETS += FOO
1088 # Additionally, a FOO_TARGET variable may be added to indicate the target for
1089 # which the files and executables are installed. Default is "libs".
1091 # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
1092 # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
1093 # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
1094 # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
1096 # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
1097 ifneq (,$(filter $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
),$(install_cmd
)))
1098 ifeq (,$(wildcard $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
)))
1099 nsinstall_is_usable
= $(if
$(wildcard $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
)),yes
)
1101 define install_cmd_override
1102 $(1): install_cmd
= $$(if
$$(nsinstall_is_usable
),$$(INSTALL
),$$(NSINSTALL_PY
) -t
) $$(1)
1107 install_target_tier
= $(or
$($(1)_TARGET
),libs
)
1108 INSTALL_TARGETS_TIERS
:= $(sort $(foreach category
,$(INSTALL_TARGETS
),$(call install_target_tier
,$(category
))))
1110 install_target_result
= $($(1)_DEST
:%/=%)/$(if
$($(1)_KEEP_PATH
),$(2),$(notdir $(2)))
1111 install_target_files
= $(foreach file
,$($(1)_FILES
),$(call install_target_result
,$(category
),$(file
)))
1112 install_target_executables
= $(foreach file
,$($(1)_EXECUTABLES
),$(call install_target_result
,$(category
),$(file
)))
1114 # Work around a GNU make 3.81 bug where it gives $< the wrong value.
1115 # See details in bug 934864.
1116 define create_dependency
1121 define install_target_template
1122 $(call install_cmd_override
,$(2))
1123 $(call create_dependency
,$(2),$(1))
1126 $(foreach category
,$(INSTALL_TARGETS
),\
1127 $(if
$($(category
)_DEST
),,$(error Missing
$(category
)_DEST
)) \
1128 $(foreach tier
,$(call install_target_tier
,$(category
)),\
1129 $(eval INSTALL_TARGETS_FILES_
$(tier
) += $(call install_target_files
,$(category
))) \
1130 $(eval INSTALL_TARGETS_EXECUTABLES_
$(tier
) += $(call install_target_executables
,$(category
))) \
1132 $(foreach file
,$($(category
)_FILES
) $($(category
)_EXECUTABLES
), \
1133 $(eval
$(call install_target_template
,$(file
),$(call install_target_result
,$(category
),$(file
)))) \
1137 $(foreach tier
,$(INSTALL_TARGETS_TIERS
), \
1138 $(eval
$(tier
):: $(INSTALL_TARGETS_FILES_
$(tier
)) $(INSTALL_TARGETS_EXECUTABLES_
$(tier
))) \
1141 install_targets_sanity
= $(if
$(filter-out $(notdir $@
),$(notdir $(<))),$(error Looks like
$@ has an unexpected dependency on
$< which breaks INSTALL_TARGETS
))
1143 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_FILES_
$(tier
)))):
1144 $(install_targets_sanity
)
1145 $(call install_cmd
,$(IFLAGS1
) '$<' '$(@D)')
1147 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_EXECUTABLES_
$(tier
)))):
1148 $(install_targets_sanity
)
1149 $(call install_cmd
,$(IFLAGS2
) '$<' '$(@D)')
1151 ################################################################################
1152 # Preprocessing rules
1154 # The PP_TARGETS variable contains a list of all preprocessing target
1155 # categories. Each category has associated variables listing input files, the
1156 # output directory, extra preprocessor flags, and so on. For example:
1159 # FOO_PATH := target-directory
1160 # FOO_FLAGS := -Dsome_flag
1163 # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
1164 # following make variables to see what to do:
1166 # - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
1167 # We search VPATH for the names given here. If an input file name ends in
1168 # '.in', that suffix is omitted from the output file name.
1170 # - <C>_PATH names the directory in which to place the preprocessed output
1171 # files. We create this directory if it does not already exist. Setting
1172 # this variable is optional; if unset, we install the files in $(CURDIR).
1174 # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
1175 # to the usual bunch. Setting this variable is optional.
1177 # - <C>_TARGET names the 'make' target that should depend on creating the output
1178 # files. Setting this variable is optional; if unset, we preprocess the
1179 # files for the 'libs' target.
1181 # - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
1182 # kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
1183 # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
1184 # instead of $(DIST)/include/qux.h.
1186 pp_target_tier
= $(or
$($(1)_TARGET
),libs
)
1187 PP_TARGETS_TIERS
:= $(sort $(foreach category
,$(PP_TARGETS
),$(call pp_target_tier
,$(category
))))
1189 pp_target_result
= $(or
$($(1)_PATH
:%/=%),$(CURDIR
))/$(if
$($(1)_KEEP_PATH
),$(2:.in
=),$(notdir $(2:.in
=)))
1190 pp_target_results
= $(foreach file
,$($(1)),$(call pp_target_result
,$(category
),$(file
)))
1192 $(foreach category
,$(PP_TARGETS
), \
1193 $(foreach tier
,$(call pp_target_tier
,$(category
)), \
1194 $(eval PP_TARGETS_RESULTS_
$(tier
) += $(call pp_target_results
,$(category
))) \
1196 $(foreach file
,$($(category
)), \
1197 $(eval
$(call create_dependency
,$(call pp_target_result
,$(category
),$(file
)), \
1198 $(file
) $(GLOBAL_DEPS
))) \
1200 $(eval
$(call pp_target_results
,$(category
)): PP_TARGET_FLAGS
=$($(category
)_FLAGS
)) \
1203 $(foreach tier
,$(PP_TARGETS_TIERS
), \
1204 $(eval
$(tier
):: $(PP_TARGETS_RESULTS_
$(tier
))) \
1207 PP_TARGETS_ALL_RESULTS
:= $(sort $(foreach tier
,$(PP_TARGETS_TIERS
),$(PP_TARGETS_RESULTS_
$(tier
))))
1208 $(PP_TARGETS_ALL_RESULTS
):
1209 $(if
$(filter-out $(notdir $@
),$(notdir $(<:.in
=))),$(error Looks like
$@ has an unexpected dependency on
$< which breaks PP_TARGETS
))
1211 $(call py_action
,preprocessor
,--depend
$(MDDEPDIR
)/$(@F
).pp
$(PP_TARGET_FLAGS
) $(DEFINES
) $(ACDEFINES
) '$<' -o
'$@')
1213 $(filter %.css
,$(PP_TARGETS_ALL_RESULTS
)): PP_TARGET_FLAGS
+=--marker
%
1215 # The depfile is based on the filename, and we don't want conflicts. So check
1216 # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
1217 PP_TARGETS_ALL_RESULT_NAMES
:= $(notdir $(PP_TARGETS_ALL_RESULTS
))
1218 $(foreach file
,$(sort $(PP_TARGETS_ALL_RESULT_NAMES
)), \
1219 $(if
$(filter-out 1,$(words $(filter $(file
),$(PP_TARGETS_ALL_RESULT_NAMES
)))), \
1220 $(error Multiple preprocessing rules are creating a
$(file
) file
) \
1224 ifneq (,$(filter $(PP_TARGETS_TIERS
) $(PP_TARGETS_ALL_RESULTS
),$(MAKECMDGOALS
)))
1225 # If the depfile for a preprocessed file doesn't exist, add a dep to force
1227 $(foreach file
,$(PP_TARGETS_ALL_RESULTS
), \
1228 $(if
$(wildcard $(MDDEPDIR
)/$(notdir $(file
)).pp
), \
1230 $(eval
$(file
): FORCE
) \
1234 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(addsuffix .pp
,$(notdir $(PP_TARGETS_ALL_RESULTS
))))))
1236 ifneq (,$(MDDEPEND_FILES
))
1237 -include $(MDDEPEND_FILES
)
1242 # Pull in non-recursive targets if this is a partial tree build.
1243 ifndef TOPLEVEL_BUILD
1244 include $(MOZILLA_DIR
)/config
/makefiles
/nonrecursive.mk
1247 ################################################################################
1248 # Special gmake rules.
1249 ################################################################################
1253 # Re-define the list of default suffixes, so gmake won't have to churn through
1254 # hundreds of built-in suffix rules for stuff we don't need.
1259 # Fake targets. Always run these rules, even if a file/directory with that
1260 # name already exists.
1262 .PHONY
: all alltags boot chrome realchrome
clean clobber clobber_all
export install libs makefiles
realclean run_apprunner tools
$(DIRS
) FORCE
1264 # Used as a dependency to force targets to rebuild
1267 # Delete target if error occurs when building target
1272 TAGS
: $(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1273 -etags
$(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1276 ifndef INCLUDED_DEBUGMAKE_MK
#{
1277 ## Only parse when an echo* or show* target is requested
1278 ifneq (,$(call isTargetStem
,echo
,show
))
1279 include $(MOZILLA_DIR
)/config
/makefiles
/debugmake.mk
1285 $(DOXYGEN
) $(DEPTH
)/config
/doxygen.cfg
1287 FREEZE_VARIABLES
= \
1296 $(foreach var
,$(FREEZE_VARIABLES
),$(eval
$(var
)_FROZEN
:= '$($(var))'))
1298 CHECK_FROZEN_VARIABLES
= $(foreach var
,$(FREEZE_VARIABLES
), \
1299 $(if
$(subst $($(var
)_FROZEN
),,'$($(var))'),$(error Makefile variable
'$(var)' changed value after including rules.mk. Was
$($(var
)_FROZEN
), now
$($(var
)).
)))
1302 $(CHECK_FROZEN_VARIABLES
)
1304 .DEFAULT_GOAL
:= $(or
$(OVERRIDE_DEFAULT_GOAL
),default
)
1306 #############################################################################
1307 # Derived targets and dependencies
1309 include $(MOZILLA_DIR
)/config
/makefiles
/autotargets.mk
1310 ifneq ($(NULL
),$(AUTO_DEPS
))
1311 default
all libs tools
export:: $(AUTO_DEPS
)