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
)
733 # The AS_DASH_C_FLAG is needed cause not all assemblers (Solaris) accept
736 $(REPORT_BUILD_VERBOSE
)
737 $(AS
) $(ASOUTOPTION
)$@
$(ASFLAGS
) $($(notdir $<)_FLAGS
) $(AS_DASH_C_FLAG
) $(_VPATH_SRCS
)
743 ifdef MOZ_CRASHREPORTER
744 $$(call py_action
,dumpsymbols
,$$(abspath
$$<) $$(abspath
$$@
) $$(DUMP_SYMBOLS_FLAGS
))
748 ifndef MOZ_PROFILE_GENERATE
749 ifneq (,$(filter $(DIST
)/bin
%,$(FINAL_TARGET
)))
750 DUMP_SYMS_TARGETS
:= $(SHARED_LIBRARY
) $(PROGRAM
) $(SIMPLE_PROGRAMS
)
755 ifeq (,$(filter 1,$(MOZ_AUTOMATION_BUILD_SYMBOLS
)))
761 MAIN_PDB_FILES
= $(addsuffix .pdb
,$(basename $(DUMP_SYMS_TARGETS
)))
762 MAIN_PDB_DEST ?
= $(FINAL_TARGET
)
763 MAIN_PDB_TARGET
= syms
764 INSTALL_TARGETS
+= MAIN_PDB
767 CPP_UNIT_TESTS_PDB_FILES
= $(addsuffix .pdb
,$(basename $(CPP_UNIT_TESTS
)))
768 CPP_UNIT_TESTS_PDB_DEST
= $(DIST
)/cppunittests
769 CPP_UNIT_TESTS_PDB_TARGET
= syms
770 INSTALL_TARGETS
+= CPP_UNIT_TESTS_PDB
773 else ifdef MOZ_CRASHREPORTER
774 $(foreach file
,$(DUMP_SYMS_TARGETS
),$(eval
$(call syms_template
,$(file
),$(notdir $(file
))_syms.track
)))
777 ifneq (,$(RUST_TESTS
)$(RUST_LIBRARY_FILE
)$(HOST_RUST_LIBRARY_FILE
)$(RUST_PROGRAMS
)$(HOST_RUST_PROGRAMS
))
778 include $(MOZILLA_DIR
)/config
/makefiles
/rust.mk
783 $(AS
) $(ASOUTOPTION
)$@
$(SFLAGS
) $($(notdir $<)_FLAGS
) -c
$<
786 $(REPORT_BUILD_VERBOSE
)
787 $(call BUILDSTATUS
,OBJECT_FILE
$@
)
788 $(CCC
) $(OUTOPTION
)$@
-c
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
791 $(REPORT_BUILD_VERBOSE
)
792 $(CCC
) -o
$@
-c
$(COMPILE_CXXFLAGS
) $(COMPILE_CMMFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
795 $(REPORT_BUILD_VERBOSE
)
796 $(CC
) -o
$@
-c
$(COMPILE_CFLAGS
) $(COMPILE_CMFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
798 $(filter %.s
,$(CPPSRCS
:%.
cpp=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
799 $(REPORT_BUILD_VERBOSE
)
800 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
802 $(filter %.s
,$(CPPSRCS
:%.
cc=%.s
)): %.s
: %.
cc $(call mkdir_deps
,$(MDDEPDIR
))
803 $(REPORT_BUILD_VERBOSE
)
804 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
806 $(filter %.s
,$(CPPSRCS
:%.
cxx=%.s
)): %.s
: %.
cpp $(call mkdir_deps
,$(MDDEPDIR
))
807 $(REPORT_BUILD_VERBOSE
)
808 $(CCC
) -S
$(COMPILE_CXXFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
810 $(filter %.s
,$(CSRCS
:%.c
=%.s
)): %.s
: %.c
$(call mkdir_deps
,$(MDDEPDIR
))
811 $(REPORT_BUILD_VERBOSE
)
812 $(CC
) -S
$(COMPILE_CFLAGS
) $($(notdir $<)_FLAGS
) $(_VPATH_SRCS
)
814 ifneq (,$(filter %.i
,$(MAKECMDGOALS
)))
815 # Call as $(call _group_srcs,extension,$(SRCS)) - this will create a list
816 # of the full sources, as well as the $(notdir) version. So:
817 # foo.cpp sub/bar.cpp
819 # foo.cpp sub/bar.cpp bar.cpp
821 # This way we can match both 'make sub/bar.i' and 'make bar.i'
822 _group_srcs
= $(sort $(patsubst %.
$1,%.i
,$(filter %.
$1,$2 $(notdir $2))))
824 define PREPROCESS_RULES
825 _PREPROCESSED_
$1_FILES := $$(call _group_srcs
,$1,$$($2))
826 # Make preprocessed files PHONY so they are always executed, since they are
827 # manual targets and we don't necessarily write to $@.
828 .PHONY
: $$(_PREPROCESSED_
$1_FILES)
830 # Hack up VPATH so we can reach the sources. Eg: 'make Parser.i' may need to
831 # reach $(srcdir)/frontend/Parser.i
832 vpath
%.
$1 $$(addprefix $$(srcdir)/,$$(sort $$(dir $$($2))))
833 vpath
%.
$1 $$(addprefix $$(CURDIR
)/,$$(sort $$(dir $$($2))))
835 $$(_PREPROCESSED_
$1_FILES): _DEPEND_CFLAGS
=
836 $$(_PREPROCESSED_
$1_FILES): %.i
: %.
$1
837 $$(REPORT_BUILD_VERBOSE
)
838 $$(addprefix $$(MKDIR
) -p
,$$(filter-out .
,$$(@D
)))
839 $$($3) -C
$$(PREPROCESS_OPTION
)$$@
$(foreach var
,$4,$$($(var
))) $$($$(notdir $$<)_FLAGS
) $$(_VPATH_SRCS
)
843 $(eval
$(call PREPROCESS_RULES
,cpp,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
844 $(eval
$(call PREPROCESS_RULES
,cc,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
845 $(eval
$(call PREPROCESS_RULES
,cxx,CPPSRCS
,CCC
,COMPILE_CXXFLAGS
))
846 $(eval
$(call PREPROCESS_RULES
,c
,CSRCS
,CC
,COMPILE_CFLAGS
))
847 $(eval
$(call PREPROCESS_RULES
,mm
,CMMSRCS
,CCC
,COMPILE_CXXFLAGS COMPILE_CMMFLAGS
))
849 # Default to pre-processing the actual unified file. This can be overridden
850 # at the command-line to pre-process only the individual source file.
853 # PP_REINVOKE gets set on the sub-make to prevent us from going in an
854 # infinite loop if the filename doesn't exist in the unified source files.
857 MATCH_cpp
= \
(cpp\|
cc|
cxx\
)
862 # When building with PP_UNIFIED=0, we also have to look in the Unified files to
863 # find a matching pathname.
864 _get_all_sources
= $1 $(if
$(filter Unified
%,$1),$(shell sed
-n
's/\#include "\(.*\)"$$/\1/p' $(filter Unified
%,$1)))
865 all_cpp_sources
:= $(call _get_all_sources
,$(CPPSRCS
))
866 all_mm_sources
:= $(call _get_all_sources
,$(CMMSRCS
))
867 all_c_sources
:= $(call _get_all_sources
,$(CSRCS
))
868 all_sources
:= $(all_cpp_sources
) $(all_cmm_sources
) $(all_c_sources
)
870 # The catch-all %.i rule runs when we pass in a .i filename that doesn't match
871 # one of the *SRCS variables. The two code paths depend on whether or not
872 # we are requesting a unified file (PP_UNIFIED=1, the default) or not:
875 # - Look for it in any of the Unified files, and re-exec make with
876 # Unified_foo0.i as the target. This gets us the full unified preprocessed
880 # - If the .i filename is in *SRCS, or in a Unified filename, then we re-exec
881 # make with that filename as the target. The *SRCS variables are modified
882 # to have the Unified sources appended to them so that the static pattern
885 ifeq ($(PP_UNIFIED
),1)
886 @
$(MAKE
) PP_REINVOKE
=1 \
887 $(or
$(addsuffix .i
, \
888 $(foreach type
,c
cpp mm
, \
889 $(if
$(filter Unified
%,$($(UPPER_
$(type
))SRCS
)), \
890 $(shell grep
-l
'#include "\(.*/\)\?$(basename $@).$(or $(MATCH_$(type)),$(type))"' Unified
*.
$(type
) | sed
's/\.$(type)$$//') \
891 ))),$(error
"File not found for preprocessing: $@"))
893 @
$(MAKE
) PP_REINVOKE
=1 $@ \
894 $(foreach type
,c
cpp mm
,$(UPPER_
$(type
))SRCS
="$(all_$(type)_sources)")
901 $(RESFILE
): %.res
: %.rc
903 @echo Creating Resource file
: $@
905 $(RC
) $(RCFLAGS
) $(filter-out -U
%,$(DEFINES
)) $(INCLUDES
:-I
%=--include-dir
%) $(OUTOPTION
)$@
$(_VPATH_SRCS
)
907 $(RC
) $(RCFLAGS
) -r
$(DEFINES
) $(INCLUDES
) $(OUTOPTION
)$@
$(_VPATH_SRCS
)
910 # Cancel GNU make built-in implicit rules
913 ifneq (,$(filter WINNT
,$(OS_ARCH
)))
920 SPACE
:= $(EMPTY
) $(EMPTY
)
922 ###############################################################################
923 # Bunch of things that extend the 'export' rule (in order):
924 ###############################################################################
930 export:: $(FINAL_TARGET
)
933 ################################################################################
934 # The default location for prefs is the gre prefs directory.
935 # PREF_DIR is used for L10N_PREF_JS_EXPORTS in various locales/ directories.
936 PREF_DIR
= defaults
/pref
938 # If DIST_SUBDIR is defined it indicates that app and gre dirs are
939 # different and that we are building app related resources. Hence,
940 # PREF_DIR should point to the app prefs location.
941 ifneq (,$(DIST_SUBDIR
)$(XPI_NAME
))
942 PREF_DIR
= defaults
/preferences
945 ################################################################################
952 $(FINAL_TARGET
)/chrome
: $(call mkdir_deps
,$(FINAL_TARGET
)/chrome
)
954 ifneq (,$(JAR_MANIFEST
))
955 ifndef NO_DIST_INSTALL
959 # For add-on packaging we may specify that an application
960 # sub-dir should be added to the root chrome manifest with
961 # a specific application id.
962 MAKE_JARS_FLAGS
+= --root-manifest-entry-appid
='$(XPI_ROOT_APPID)'
965 # if DIST_SUBDIR is defined but XPI_ROOT_APPID is not there's
966 # no way langpacks will get packaged right, so error out.
967 ifneq (,$(DIST_SUBDIR
))
968 ifndef XPI_ROOT_APPID
969 $(error XPI_ROOT_APPID is not defined
- langpacks will break.
)
974 libs realchrome
:: $(FINAL_TARGET
)/chrome
975 $(call py_action
,jar_maker
,\
976 $(QUIET
) -d
$(FINAL_TARGET
) \
977 $(MAKE_JARS_FLAGS
) $(DEFINES
) $(ACDEFINES
) \
984 # When you move this out of the tools tier, please remove the corresponding
985 # hacks in recursivemake.py that check if Makefile.in sets the variable.
986 ifneq ($(XPI_PKGNAME
),)
990 @echo
'Stripping $(XPI_PKGNAME) package directory...'
991 @echo
$(FINAL_TARGET
)
992 @cd
$(FINAL_TARGET
) && find .
! -type d \
1002 ! -name
'*.properties' \
1013 $(PLATFORM_EXCLUDE_LIST
) \
1014 -exec
$(STRIP
) $(STRIP_FLAGS
) {} >/dev
/null
2>&1 \
;
1017 @echo
'Packaging $(XPI_PKGNAME).xpi...'
1018 $(call py_action
,zip
,-C
$(FINAL_TARGET
) ..
/$(XPI_PKGNAME
).xpi
'*')
1021 # See comment above about moving this out of the tools tier.
1022 ifdef INSTALL_EXTENSION_ID
1024 $(error XPI_NAME must be set for INSTALL_EXTENSION_ID
)
1028 $(RM
) -r
'$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1029 $(NSINSTALL
) -D
'$(DIST)/bin/distribution$(DIST_SUBDIR:%=/%)/extensions/$(INSTALL_EXTENSION_ID)'
1030 $(call copy_dir
,$(FINAL_TARGET
),$(DIST
)/bin
/distribution
$(DIST_SUBDIR
:%=/%)/extensions
/$(INSTALL_EXTENSION_ID
))
1034 #############################################################################
1035 # MDDEPDIR is the subdirectory where all the dependency files are placed.
1036 # This uses a make rule (instead of a macro) to support parallel
1037 # builds (-jN). If this were done in the LOOP_OVER_DIRS macro, two
1038 # processes could simultaneously try to create the same directory.
1040 # We use $(CURDIR) in the rule's target to ensure that we don't find
1041 # a dependency directory in the source tree via VPATH (perhaps from
1042 # a previous build in the source tree) and thus neglect to create a
1043 # dependency directory in the object directory, where we really need
1046 ifneq (,$(filter-out all chrome default
export realchrome
clean clobber clobber_all
distclean realclean,$(MAKECMDGOALS
)))
1047 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(addsuffix .pp
,$(notdir $(sort $(OBJS
) $(PROGOBJS
) $(HOST_OBJS
) $(HOST_PROGOBJS
)))))))
1049 ifneq (,$(MDDEPEND_FILES
))
1050 -include $(MDDEPEND_FILES
)
1055 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(EXTRA_MDDEPEND_FILES
))))
1057 ifneq (,$(MDDEPEND_FILES
))
1058 -include $(MDDEPEND_FILES
)
1061 ################################################################################
1062 # Install/copy rules
1064 # The INSTALL_TARGETS variable contains a list of all install target
1065 # categories. Each category defines a list of files and executables, and an
1066 # install destination,
1068 # FOO_FILES := foo bar
1069 # FOO_EXECUTABLES := baz
1070 # FOO_DEST := target_path
1071 # INSTALL_TARGETS += FOO
1073 # Additionally, a FOO_TARGET variable may be added to indicate the target for
1074 # which the files and executables are installed. Default is "libs".
1076 # Finally, a FOO_KEEP_PATH variable may be set to 1 to indicate the paths given
1077 # in FOO_FILES/FOO_EXECUTABLES are to be kept at the destination. That is,
1078 # if FOO_FILES is bar/baz/qux.h, and FOO_DEST is $(DIST)/include, the installed
1079 # file would be $(DIST)/include/bar/baz/qux.h instead of $(DIST)/include/qux.h
1081 # If we're using binary nsinstall and it's not built yet, fallback to python nsinstall.
1082 ifneq (,$(filter $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
),$(install_cmd
)))
1083 ifeq (,$(wildcard $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
)))
1084 nsinstall_is_usable
= $(if
$(wildcard $(DEPTH
)/config
/nsinstall
$(HOST_BIN_SUFFIX
)),yes
)
1086 define install_cmd_override
1087 $(1): install_cmd
= $$(if
$$(nsinstall_is_usable
),$$(INSTALL
),$$(NSINSTALL_PY
) -t
) $$(1)
1092 install_target_tier
= $(or
$($(1)_TARGET
),libs
)
1093 INSTALL_TARGETS_TIERS
:= $(sort $(foreach category
,$(INSTALL_TARGETS
),$(call install_target_tier
,$(category
))))
1095 install_target_result
= $($(1)_DEST
:%/=%)/$(if
$($(1)_KEEP_PATH
),$(2),$(notdir $(2)))
1096 install_target_files
= $(foreach file
,$($(1)_FILES
),$(call install_target_result
,$(category
),$(file
)))
1097 install_target_executables
= $(foreach file
,$($(1)_EXECUTABLES
),$(call install_target_result
,$(category
),$(file
)))
1099 # Work around a GNU make 3.81 bug where it gives $< the wrong value.
1100 # See details in bug 934864.
1101 define create_dependency
1106 define install_target_template
1107 $(call install_cmd_override
,$(2))
1108 $(call create_dependency
,$(2),$(1))
1111 $(foreach category
,$(INSTALL_TARGETS
),\
1112 $(if
$($(category
)_DEST
),,$(error Missing
$(category
)_DEST
)) \
1113 $(foreach tier
,$(call install_target_tier
,$(category
)),\
1114 $(eval INSTALL_TARGETS_FILES_
$(tier
) += $(call install_target_files
,$(category
))) \
1115 $(eval INSTALL_TARGETS_EXECUTABLES_
$(tier
) += $(call install_target_executables
,$(category
))) \
1117 $(foreach file
,$($(category
)_FILES
) $($(category
)_EXECUTABLES
), \
1118 $(eval
$(call install_target_template
,$(file
),$(call install_target_result
,$(category
),$(file
)))) \
1122 $(foreach tier
,$(INSTALL_TARGETS_TIERS
), \
1123 $(eval
$(tier
):: $(INSTALL_TARGETS_FILES_
$(tier
)) $(INSTALL_TARGETS_EXECUTABLES_
$(tier
))) \
1126 install_targets_sanity
= $(if
$(filter-out $(notdir $@
),$(notdir $(<))),$(error Looks like
$@ has an unexpected dependency on
$< which breaks INSTALL_TARGETS
))
1128 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_FILES_
$(tier
)))):
1129 $(install_targets_sanity
)
1130 $(call install_cmd
,$(IFLAGS1
) '$<' '$(@D)')
1132 $(sort $(foreach tier
,$(INSTALL_TARGETS_TIERS
),$(INSTALL_TARGETS_EXECUTABLES_
$(tier
)))):
1133 $(install_targets_sanity
)
1134 $(call install_cmd
,$(IFLAGS2
) '$<' '$(@D)')
1136 ################################################################################
1137 # Preprocessing rules
1139 # The PP_TARGETS variable contains a list of all preprocessing target
1140 # categories. Each category has associated variables listing input files, the
1141 # output directory, extra preprocessor flags, and so on. For example:
1144 # FOO_PATH := target-directory
1145 # FOO_FLAGS := -Dsome_flag
1148 # If PP_TARGETS lists a category name <C> (like FOO, above), then we consult the
1149 # following make variables to see what to do:
1151 # - <C> lists input files to be preprocessed with mozbuild.action.preprocessor.
1152 # We search VPATH for the names given here. If an input file name ends in
1153 # '.in', that suffix is omitted from the output file name.
1155 # - <C>_PATH names the directory in which to place the preprocessed output
1156 # files. We create this directory if it does not already exist. Setting
1157 # this variable is optional; if unset, we install the files in $(CURDIR).
1159 # - <C>_FLAGS lists flags to pass to mozbuild.action.preprocessor, in addition
1160 # to the usual bunch. Setting this variable is optional.
1162 # - <C>_TARGET names the 'make' target that should depend on creating the output
1163 # files. Setting this variable is optional; if unset, we preprocess the
1164 # files for the 'libs' target.
1166 # - <C>_KEEP_PATH may be set to 1 to indicate the paths given in <C> are to be
1167 # kept under <C>_PATH. That is, if <C> is bar/baz/qux.h.in and <C>_PATH is
1168 # $(DIST)/include, the preprocessed file would be $(DIST)/include/bar/baz/qux.h
1169 # instead of $(DIST)/include/qux.h.
1171 pp_target_tier
= $(or
$($(1)_TARGET
),libs
)
1172 PP_TARGETS_TIERS
:= $(sort $(foreach category
,$(PP_TARGETS
),$(call pp_target_tier
,$(category
))))
1174 pp_target_result
= $(or
$($(1)_PATH
:%/=%),$(CURDIR
))/$(if
$($(1)_KEEP_PATH
),$(2:.in
=),$(notdir $(2:.in
=)))
1175 pp_target_results
= $(foreach file
,$($(1)),$(call pp_target_result
,$(category
),$(file
)))
1177 $(foreach category
,$(PP_TARGETS
), \
1178 $(foreach tier
,$(call pp_target_tier
,$(category
)), \
1179 $(eval PP_TARGETS_RESULTS_
$(tier
) += $(call pp_target_results
,$(category
))) \
1181 $(foreach file
,$($(category
)), \
1182 $(eval
$(call create_dependency
,$(call pp_target_result
,$(category
),$(file
)), \
1183 $(file
) $(GLOBAL_DEPS
))) \
1185 $(eval
$(call pp_target_results
,$(category
)): PP_TARGET_FLAGS
=$($(category
)_FLAGS
)) \
1188 $(foreach tier
,$(PP_TARGETS_TIERS
), \
1189 $(eval
$(tier
):: $(PP_TARGETS_RESULTS_
$(tier
))) \
1192 PP_TARGETS_ALL_RESULTS
:= $(sort $(foreach tier
,$(PP_TARGETS_TIERS
),$(PP_TARGETS_RESULTS_
$(tier
))))
1193 $(PP_TARGETS_ALL_RESULTS
):
1194 $(if
$(filter-out $(notdir $@
),$(notdir $(<:.in
=))),$(error Looks like
$@ has an unexpected dependency on
$< which breaks PP_TARGETS
))
1196 $(call py_action
,preprocessor
,--depend
$(MDDEPDIR
)/$(@F
).pp
$(PP_TARGET_FLAGS
) $(DEFINES
) $(ACDEFINES
) '$<' -o
'$@')
1198 $(filter %.css
,$(PP_TARGETS_ALL_RESULTS
)): PP_TARGET_FLAGS
+=--marker
%
1200 # The depfile is based on the filename, and we don't want conflicts. So check
1201 # there's only one occurrence of any given filename in PP_TARGETS_ALL_RESULTS.
1202 PP_TARGETS_ALL_RESULT_NAMES
:= $(notdir $(PP_TARGETS_ALL_RESULTS
))
1203 $(foreach file
,$(sort $(PP_TARGETS_ALL_RESULT_NAMES
)), \
1204 $(if
$(filter-out 1,$(words $(filter $(file
),$(PP_TARGETS_ALL_RESULT_NAMES
)))), \
1205 $(error Multiple preprocessing rules are creating a
$(file
) file
) \
1209 ifneq (,$(filter $(PP_TARGETS_TIERS
) $(PP_TARGETS_ALL_RESULTS
),$(MAKECMDGOALS
)))
1210 # If the depfile for a preprocessed file doesn't exist, add a dep to force
1212 $(foreach file
,$(PP_TARGETS_ALL_RESULTS
), \
1213 $(if
$(wildcard $(MDDEPDIR
)/$(notdir $(file
)).pp
), \
1215 $(eval
$(file
): FORCE
) \
1219 MDDEPEND_FILES
:= $(strip $(wildcard $(addprefix $(MDDEPDIR
)/,$(addsuffix .pp
,$(notdir $(PP_TARGETS_ALL_RESULTS
))))))
1221 ifneq (,$(MDDEPEND_FILES
))
1222 -include $(MDDEPEND_FILES
)
1227 # Pull in non-recursive targets if this is a partial tree build.
1228 ifndef TOPLEVEL_BUILD
1229 include $(MOZILLA_DIR
)/config
/makefiles
/nonrecursive.mk
1232 ################################################################################
1233 # Special gmake rules.
1234 ################################################################################
1238 # Re-define the list of default suffixes, so gmake won't have to churn through
1239 # hundreds of built-in suffix rules for stuff we don't need.
1244 # Fake targets. Always run these rules, even if a file/directory with that
1245 # name already exists.
1247 .PHONY
: all alltags boot chrome realchrome
clean clobber clobber_all
export install libs makefiles
realclean run_apprunner tools
$(DIRS
) FORCE
1249 # Used as a dependency to force targets to rebuild
1252 # Delete target if error occurs when building target
1257 TAGS
: $(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1258 -etags
$(CSRCS
) $(CPPSRCS
) $(wildcard *.h
)
1261 ifndef INCLUDED_DEBUGMAKE_MK
#{
1262 ## Only parse when an echo* or show* target is requested
1263 ifneq (,$(call isTargetStem
,echo
,show
))
1264 include $(MOZILLA_DIR
)/config
/makefiles
/debugmake.mk
1270 $(DOXYGEN
) $(DEPTH
)/config
/doxygen.cfg
1272 FREEZE_VARIABLES
= \
1281 $(foreach var
,$(FREEZE_VARIABLES
),$(eval
$(var
)_FROZEN
:= '$($(var))'))
1283 CHECK_FROZEN_VARIABLES
= $(foreach var
,$(FREEZE_VARIABLES
), \
1284 $(if
$(subst $($(var
)_FROZEN
),,'$($(var))'),$(error Makefile variable
'$(var)' changed value after including rules.mk. Was
$($(var
)_FROZEN
), now
$($(var
)).
)))
1287 $(CHECK_FROZEN_VARIABLES
)
1289 .DEFAULT_GOAL
:= $(or
$(OVERRIDE_DEFAULT_GOAL
),default
)
1291 #############################################################################
1292 # Derived targets and dependencies
1294 include $(MOZILLA_DIR
)/config
/makefiles
/autotargets.mk
1295 ifneq ($(NULL
),$(AUTO_DEPS
))
1296 default
all libs tools
export:: $(AUTO_DEPS
)