Merge m-c to b2g-inbound.
[gecko.git] / Makefile.in
blob66fe460eecc90f729f347085acc3e30fe06f00c5
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 ifndef .PYMAKE
7 ifeq (,$(MAKE_VERSION))
8 $(error GNU Make is required)
9 endif
10 ifeq (,$(filter-out 3.78 3.79,$(MAKE_VERSION)))
11 $(error GNU Make 3.80 or higher is required)
12 endif
13 endif
15 export TOPLEVEL_BUILD := 1
17 default::
19 ifdef COMPILE_ENVIRONMENT
20 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
21 endif
24 include $(topsrcdir)/config/config.mk
26 GARBAGE_DIRS += dist _javagen _profile staticlib
27 DIST_GARBAGE = config.cache config.log config.status* config-defs.h \
28 config/autoconf.mk \
29 mozilla-config.h \
30 netwerk/necko-config.h xpcom/xpcom-config.h xpcom/xpcom-private.h \
31 .mozconfig.mk
33 ifndef MOZ_PROFILE_USE
34 # We need to explicitly put backend.RecursiveMakeBackend.built here
35 # otherwise the rule in rules.mk doesn't run early enough.
36 libs export tools:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built
37 ifndef LIBXUL_SDK
38 libs export tools:: js-config-status
39 endif
40 endif
42 CLOBBER: $(topsrcdir)/CLOBBER
43 @echo "STOP! The CLOBBER file has changed."
44 @echo "Please run the build through a sanctioned build wrapper, such as"
45 @echo "'mach build' or client.mk."
46 @exit 1
48 $(topsrcdir)/configure: $(topsrcdir)/configure.in
49 @echo "STOP! configure.in has changed, and your configure is out of date."
50 @echo "Please rerun autoconf and re-configure your build directory."
51 @echo "To ignore this message, touch 'configure' in the source directory,"
52 @echo "but your build might not succeed."
53 @exit 1
55 config.status: $(topsrcdir)/configure
56 @echo "STOP! configure has changed and needs to be run in this build directory."
57 @echo "Please rerun configure."
58 @echo "To ignore this message, touch 'config.status' in the build directory,"
59 @echo "but your build might not succeed."
60 @exit 1
62 ifndef LIBXUL_SDK
63 .PHONY: js-config-status
64 js-config-status:
65 $(call SUBMAKE,backend.RecursiveMakeBackend.built,js/src,1)
66 endif
68 install_manifests := bin idl include public private sdk
69 install_manifest_depends = \
70 CLOBBER \
71 $(topsrcdir)/configure \
72 config.status \
73 backend.RecursiveMakeBackend.built \
74 $(NULL)
76 ifndef LIBXUL_SDK
77 install_manifest_depends += js-config-status
78 endif
80 .PHONY: install-manifests
81 install-manifests: $(addprefix install-dist-,$(install_manifests))
83 .PHONY: $(addprefix install-dist-,$(install_manifests))
84 $(addprefix install-dist-,$(install_manifests)): install-dist-%: $(install_manifest_depends)
85 $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$(DIST)/$* _build_manifests/install/dist_$* $(if $(LIBXUL_SDK),,js/src/_build_manifests/install/dist_$*))
87 .PHONY: install-tests
88 install-manifests: install-tests
89 install-tests: $(install_manifest_depends)
90 $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )_tests _build_manifests/install/tests js/src/_build_manifests/install/tests)
93 # _tests should be purged during cleaning. However, we don't want it purged
94 # during PGO builds because it contains some auto-generated files.
95 ifneq ($(filter-out maybe_clobber_profiledbuild,$(MAKECMDGOALS)),)
96 GARBAGE_DIRS += _tests
97 endif
99 # Windows PGO builds don't perform a clean before the 2nd pass. So, we want
100 # to preserve content for the 2nd pass on Windows. Everywhere else, we always
101 # process the install manifests as part of export.
102 ifdef MOZ_PROFILE_USE
103 ifndef NO_PROFILE_GUIDED_OPTIMIZE
104 ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
105 export:: install-manifests
106 endif
107 endif
108 else # !MOZ_PROFILE_USE (normal build)
109 export:: install-manifests
110 endif
112 # For historical reasons that are unknown, $(DIST)/sdk is always blown away
113 # with no regard for PGO passes. This decision could probably be revisited.
114 export:: install-dist-sdk
116 ifdef ENABLE_TESTS
117 # Additional makefile targets to call automated test suites
118 include $(topsrcdir)/testing/testsuite-targets.mk
119 endif
121 default all::
122 $(call BUILDSTATUS,TIERS export $(if $(MOZ_PSEUDO_DERECURSE),compile )libs tools)
124 include $(topsrcdir)/config/rules.mk
126 distclean::
127 $(RM) $(DIST_GARBAGE)
129 ifeq ($(OS_ARCH),WINNT)
130 # we want to copy PDB files on Windows
131 MAKE_SYM_STORE_ARGS := -c --vcs-info
132 ifdef PDBSTR_PATH
133 MAKE_SYM_STORE_ARGS += -i
134 endif
135 DUMP_SYMS_BIN ?= $(topsrcdir)/toolkit/crashreporter/tools/win32/dump_syms_vc$(_MSC_VER).exe
136 # PDB files don't get moved to dist, so we need to scan the whole objdir
137 MAKE_SYM_STORE_PATH := .
138 endif
139 ifeq ($(OS_ARCH),Darwin)
140 # need to pass arch flags for universal builds
141 ifdef UNIVERSAL_BINARY
142 MAKE_SYM_STORE_ARGS := -c -a "i386 x86_64" --vcs-info
143 MAKE_SYM_STORE_PATH := $(DIST)/universal
144 else
145 MAKE_SYM_STORE_ARGS := -c -a $(OS_TEST) --vcs-info
146 MAKE_SYM_STORE_PATH := $(DIST)/bin
147 endif
148 DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms
149 endif
150 ifeq (,$(filter-out Linux SunOS,$(OS_ARCH)))
151 MAKE_SYM_STORE_ARGS := -c --vcs-info
152 DUMP_SYMS_BIN ?= $(DIST)/host/bin/dump_syms
153 MAKE_SYM_STORE_PATH := $(DIST)/bin
154 endif
156 SYM_STORE_SOURCE_DIRS := $(topsrcdir)
158 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
160 ifdef MOZ_SYMBOLS_EXTRA_BUILDID
161 EXTRA_BUILDID := -$(MOZ_SYMBOLS_EXTRA_BUILDID)
162 endif
164 SYMBOL_INDEX_NAME = \
165 $(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_TARGET)-$(BUILDID)-$(CPU_ARCH)$(EXTRA_BUILDID)-symbols.txt
167 buildsymbols:
168 ifdef MOZ_CRASHREPORTER
169 echo building symbol store
170 $(RM) -r $(DIST)/crashreporter-symbols
171 $(RM) "$(DIST)/$(SYMBOL_ARCHIVE_BASENAME).zip"
172 $(NSINSTALL) -D $(DIST)/crashreporter-symbols
173 OBJCOPY="$(OBJCOPY)" \
174 $(PYTHON) $(topsrcdir)/toolkit/crashreporter/tools/symbolstore.py \
175 $(MAKE_SYM_STORE_ARGS) \
176 $(foreach dir,$(SYM_STORE_SOURCE_DIRS),-s $(dir)) \
177 $(DUMP_SYMS_BIN) \
178 $(DIST)/crashreporter-symbols \
179 $(MAKE_SYM_STORE_PATH) | grep -iv test > \
180 $(DIST)/crashreporter-symbols/$(SYMBOL_INDEX_NAME)
181 echo packing symbols
182 $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
183 cd $(DIST)/crashreporter-symbols && \
184 zip -r9D "../$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip" . -x "*test*" -x "*Test*"
185 cd $(DIST)/crashreporter-symbols && \
186 grep "sym" $(SYMBOL_INDEX_NAME) > $(SYMBOL_INDEX_NAME).tmp && \
187 mv $(SYMBOL_INDEX_NAME).tmp $(SYMBOL_INDEX_NAME)
188 cd $(DIST)/crashreporter-symbols && \
189 zip -r9D "../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip" . -i "*.sym" -i "*.txt" -x "*test*" -x "*Test*"
190 endif # MOZ_CRASHREPORTER
192 uploadsymbols:
193 ifdef MOZ_CRASHREPORTER
194 $(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) "$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip"
195 endif
197 # MOZ_SOURCE_STAMP is defined in package-name.mk with a deferred assignment.
198 # exporting it makes make run its $(shell) command for each invoked submake,
199 # so transform it to an immediate assignment.
200 MOZ_SOURCE_STAMP := $(MOZ_SOURCE_STAMP)
201 export MOZ_SOURCE_STAMP
203 #XXX: this is a hack, since we don't want to clobber for MSVC
204 # PGO support, but we can't do this test in client.mk
205 ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_)
206 # No point in clobbering if PGO has been explicitly disabled.
207 ifndef NO_PROFILE_GUIDED_OPTIMIZE
208 maybe_clobber_profiledbuild: clean
209 else
210 maybe_clobber_profiledbuild:
211 endif
212 else
213 maybe_clobber_profiledbuild:
214 $(RM) $(DIST)/bin/*.pgc
215 find $(DIST)/$(MOZ_APP_NAME) -name "*.pgc" -exec mv {} $(DIST)/bin \;
216 endif
218 .PHONY: maybe_clobber_profiledbuild
220 # Look for R_386_PC32 relocations in shared libs, these
221 # break x86_64 builds and SELinux users.
222 ifeq ($(OS_TARGET)_$(TARGET_XPCOM_ABI),Linux_x86-gcc3)
223 scheck::
224 @relcount=`find $(DIST)/bin -name "*.so" | xargs objdump -R | grep R_386_PC32 | wc -l` && if test $$relcount -gt 0; then echo "FAILED: R_386_PC32 relocations detected in a shared library. Did you use a system header without adding it to config/system-headers?"; exit 1; else echo "PASSED"; fi
225 endif
227 ifndef LIBXUL_SDK
228 js/src/Makefile: subsrcdir := js/src
230 ifdef ENABLE_TESTS
231 # Incorporate static tier directories into tests. This should be incorporated
232 # into moz.build files someday.
233 check::
234 $(call SUBMAKE,$@,js/src)
235 endif
237 ifdef MOZ_PSEUDO_DERECURSE
238 # Interdependencies for parallel export.
239 js/xpconnect/src/export: dom/bindings/export
240 accessible/src/xpcom/export: xpcom/xpidl/export
241 js/src/export: mfbt/export
242 endif
243 endif