Bug 853551 - Implement the doppler part of AudioPannerNode. r=ehsan
[gecko.git] / client.mk
blob6e52b8bb348ce8e6b0b86aab15fe88581440c92d
1 # -*- makefile -*-
2 # vim:set ts=8 sw=8 sts=8 noet:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Build a mozilla application.
9 # To build a tree,
10 # 1. hg clone ssh://hg.mozilla.org/mozilla-central mozilla
11 # 2. cd mozilla
12 # 3. create your .mozconfig file with
13 # ac_add_options --enable-application=browser
14 # 4. gmake -f client.mk
16 # Other targets (gmake -f client.mk [targets...]),
17 # build
18 # clean (realclean is now the same as clean)
19 # distclean
21 # See http://developer.mozilla.org/en/docs/Build_Documentation for
22 # more information.
24 # Options:
25 # MOZ_BUILD_PROJECTS - Build multiple projects in subdirectories
26 # of MOZ_OBJDIR
27 # MOZ_OBJDIR - Destination object directory
28 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
29 # MOZ_PREFLIGHT_ALL } - Makefiles to run before any project in
30 # MOZ_PREFLIGHT } MOZ_BUILD_PROJECTS, before each project, after
31 # MOZ_POSTFLIGHT } each project, and after all projects; these
32 # MOZ_POSTFLIGHT_ALL } variables contain space-separated lists
33 # MOZ_UNIFY_BDATE - Set to use the same bdate for each project in
34 # MOZ_BUILD_PROJECTS
36 #######################################################################
37 # Defines
39 comma := ,
41 CWD := $(CURDIR)
42 ifneq (1,$(words $(CWD)))
43 $(error The mozilla directory cannot be located in a path with spaces.)
44 endif
46 ifeq "$(CWD)" "/"
47 CWD := /.
48 endif
50 ifndef TOPSRCDIR
51 ifeq (,$(wildcard client.mk))
52 TOPSRCDIR := $(patsubst %/,%,$(dir $(MAKEFILE_LIST)))
53 MOZ_OBJDIR = .
54 else
55 TOPSRCDIR := $(CWD)
56 endif
57 endif
59 # try to find autoconf 2.13 - discard errors from 'which'
60 # MacOS X 10.4 sends "no autoconf*" errors to stdout, discard those via grep
61 AUTOCONF ?= $(shell which autoconf-2.13 autoconf2.13 autoconf213 2>/dev/null | grep -v '^no autoconf' | head -1)
63 # See if the autoconf package was installed through fink
64 ifeq (,$(strip $(AUTOCONF)))
65 AUTOCONF = $(shell which fink >/dev/null 2>&1 && echo `which fink`/../../lib/autoconf2.13/bin/autoconf)
66 endif
68 ifeq (,$(strip $(AUTOCONF)))
69 AUTOCONF=$(error Could not find autoconf 2.13)
70 endif
72 SH := /bin/sh
73 PERL ?= perl
74 PYTHON ?= python
76 CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
77 ifdef CONFIG_GUESS_SCRIPT
78 CONFIG_GUESS := $(shell $(CONFIG_GUESS_SCRIPT))
79 endif
82 ####################################
83 # Sanity checks
85 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
86 # check for CRLF line endings
87 ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
88 $(error This source tree appears to have Windows-style line endings. To \
89 convert it to Unix-style line endings, run \
90 "python mozilla/build/win32/mozilla-dos2unix.py")
91 endif
92 endif
94 ####################################
95 # Load mozconfig Options
97 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
99 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
101 define CR
104 endef
106 # As $(shell) doesn't preserve newlines, use sed to replace them with an
107 # unlikely sequence (||), which is then replaced back to newlines by make
108 # before evaluation.
109 $(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
111 ifdef NO_AUTOCLOBBER
112 export NO_AUTOCLOBBER=1
113 endif
115 # Automatically add -jN to make flags if not defined. N defaults to number of cores.
116 ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
117 cores=$(shell $(PYTHON) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
118 MOZ_MAKE_FLAGS += -j$(cores)
119 endif
122 ifndef MOZ_OBJDIR
123 MOZ_OBJDIR = obj-$(CONFIG_GUESS)
124 else
125 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
126 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
127 ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
128 $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
129 endif
130 endif
131 endif
133 ifdef MOZ_BUILD_PROJECTS
135 ifdef MOZ_CURRENT_PROJECT
136 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
137 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
138 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
139 else
140 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
141 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
142 endif
144 else # MOZ_BUILD_PROJECTS
146 OBJDIR = $(MOZ_OBJDIR)
147 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
149 endif # MOZ_BUILD_PROJECTS
151 # 'configure' scripts generated by autoconf.
152 CONFIGURES := $(TOPSRCDIR)/configure
153 CONFIGURES += $(TOPSRCDIR)/js/src/configure
155 # Make targets that are going to be passed to the real build system
156 OBJDIR_TARGETS = install export libs clean realclean distclean alldep maybe_clobber_profiledbuild upload sdk installer package fast-package package-compare stage-package source-package l10n-check
158 #######################################################################
159 # Rules
161 # The default rule is build
162 build::
163 $(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
165 # Define mkdir
166 include $(TOPSRCDIR)/config/makefiles/makeutils.mk
167 include $(TOPSRCDIR)/config/makefiles/autotargets.mk
169 # Print out any options loaded from mozconfig.
170 all realbuild clean depend distclean export libs install realclean::
171 @if test -f .mozconfig.out; then \
172 cat .mozconfig.out; \
173 rm -f .mozconfig.out; \
174 else true; \
177 # Windows equivalents
178 build_all: build
179 build_all_dep: alldep
180 build_all_depend: alldep
181 clobber clobber_all: clean
183 # helper target for mobile
184 build_and_deploy: build fast-package install
186 # Do everything from scratch
187 everything: clean build
189 ####################################
190 # Profile-Guided Optimization
191 # To use this, you should set the following variables in your mozconfig
192 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
194 # The profile script should exercise the functionality to be included
195 # in the profile feedback.
197 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
198 # is usable in multi-pass builds, where you might not have a runnable
199 # application until all the build passes and postflight scripts have run.
200 ifdef MOZ_OBJDIR
201 PGO_OBJDIR = $(MOZ_OBJDIR)
202 else
203 PGO_OBJDIR := $(TOPSRCDIR)
204 endif
206 profiledbuild::
207 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
208 $(MAKE) -C $(PGO_OBJDIR) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
209 rm -f ${PGO_OBJDIR}/jarlog/en-US.log
210 MOZ_PGO_INSTRUMENTED=1 OBJDIR=${PGO_OBJDIR} JARLOG_FILE=${PGO_OBJDIR}/jarlog/en-US.log $(PROFILE_GEN_SCRIPT)
211 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
212 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1
214 #####################################################
215 # Build date unification
217 ifdef MOZ_UNIFY_BDATE
218 ifndef MOZ_BUILD_DATE
219 ifdef MOZ_BUILD_PROJECTS
220 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
221 export MOZ_BUILD_DATE
222 endif
223 endif
224 endif
226 #####################################################
227 # Preflight, before building any project
229 realbuild alldep preflight_all::
230 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
231 # Don't run preflight_all for individual projects in multi-project builds
232 # (when MOZ_CURRENT_PROJECT is set.)
233 ifndef MOZ_BUILD_PROJECTS
234 # Building a single project, OBJDIR is usable.
235 set -e; \
236 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
237 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
238 done
239 else
240 # OBJDIR refers to the project-specific OBJDIR, which is not available at
241 # this point when building multiple projects. Only MOZ_OBJDIR is available.
242 set -e; \
243 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
244 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
245 done
246 endif
247 endif
249 # If we're building multiple projects, but haven't specified which project,
250 # loop through them.
252 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
253 configure depend realbuild preflight postflight $(OBJDIR_TARGETS)::
254 set -e; \
255 for app in $(MOZ_BUILD_PROJECTS); do \
256 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
257 done
259 else
261 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
262 # individual project in a multi-project build.
264 ####################################
265 # Configure
267 MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
268 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
269 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
271 EXTRA_CONFIG_DEPS := \
272 $(TOPSRCDIR)/aclocal.m4 \
273 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
274 $(TOPSRCDIR)/js/src/aclocal.m4 \
275 $(NULL)
277 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
278 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/build $(TOPSRCDIR)/build
279 @echo Generating $@ using autoconf
280 cd $(@D); $(AUTOCONF)
282 CONFIG_STATUS_DEPS := \
283 $(wildcard $(TOPSRCDIR)/*/confvars.sh) \
284 $(CONFIGURES) \
285 $(TOPSRCDIR)/CLOBBER \
286 $(TOPSRCDIR)/nsprpub/configure \
287 $(TOPSRCDIR)/config/milestone.txt \
288 $(TOPSRCDIR)/js/src/config/milestone.txt \
289 $(TOPSRCDIR)/browser/config/version.txt \
290 $(TOPSRCDIR)/build/virtualenv/packages.txt \
291 $(TOPSRCDIR)/build/virtualenv/populate_virtualenv.py \
292 $(TOPSRCDIR)/testing/mozbase/packages.txt \
293 $(NULL)
295 CONFIGURE_ENV_ARGS += \
296 MAKE="$(MAKE)" \
297 $(NULL)
299 # configure uses the program name to determine @srcdir@. Calling it without
300 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
301 # path of $(TOPSRCDIR).
302 ifeq ($(TOPSRCDIR),$(OBJDIR))
303 CONFIGURE = ./configure
304 else
305 CONFIGURE = $(TOPSRCDIR)/configure
306 endif
308 check-clobber:
309 $(PYTHON) $(TOPSRCDIR)/config/pythonpath.py -I $(TOPSRCDIR)/testing/mozbase/mozfile \
310 $(TOPSRCDIR)/python/mozbuild/mozbuild/controller/clobber.py $(TOPSRCDIR) $(OBJDIR)
312 configure-files: $(CONFIGURES)
314 configure-preqs = \
315 check-clobber \
316 configure-files \
317 $(call mkdir_deps,$(OBJDIR)) \
318 $(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
319 save-mozconfig \
320 $(NULL)
322 save-mozconfig: $(FOUND_MOZCONFIG)
323 -cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
325 configure:: $(configure-preqs)
326 @echo cd $(OBJDIR);
327 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
328 @cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
329 || ( echo "*** Fix above errors and then restart with\
330 \"$(MAKE) -f client.mk build\"" && exit 1 )
331 @touch $(OBJDIR)/Makefile
333 ifneq (,$(MAKEFILE))
334 $(OBJDIR)/Makefile: $(OBJDIR)/config.status
336 $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
337 else
338 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
339 endif
340 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
342 ifneq (,$(CONFIG_STATUS))
343 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
344 $(PYTHON) $(OBJDIR)/config.status -n --file=$(OBJDIR)/config/autoconf.mk
345 endif
348 ####################################
349 # Depend
351 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
352 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
354 ####################################
355 # Preflight
357 realbuild alldep preflight::
358 ifdef MOZ_PREFLIGHT
359 set -e; \
360 for mkfile in $(MOZ_PREFLIGHT); do \
361 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
362 done
363 endif
365 ####################################
366 # Build it
368 realbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status check-sync-dirs-config
369 $(MOZ_MAKE)
371 ####################################
372 # Other targets
374 # Pass these target onto the real build system
375 $(OBJDIR_TARGETS):: $(OBJDIR)/Makefile $(OBJDIR)/config.status
376 $(MOZ_MAKE) $@
378 ####################################
379 # Postflight
381 realbuild alldep postflight::
382 ifdef MOZ_POSTFLIGHT
383 set -e; \
384 for mkfile in $(MOZ_POSTFLIGHT); do \
385 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
386 done
387 endif
389 endif # MOZ_CURRENT_PROJECT
391 ####################################
392 # Postflight, after building all projects
394 realbuild alldep postflight_all::
395 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
396 # Don't run postflight_all for individual projects in multi-project builds
397 # (when MOZ_CURRENT_PROJECT is set.)
398 ifndef MOZ_BUILD_PROJECTS
399 # Building a single project, OBJDIR is usable.
400 set -e; \
401 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
402 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
403 done
404 else
405 # OBJDIR refers to the project-specific OBJDIR, which is not available at
406 # this point when building multiple projects. Only MOZ_OBJDIR is available.
407 set -e; \
408 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
409 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
410 done
411 endif
412 endif
414 cleansrcdir:
415 @cd $(TOPSRCDIR); \
416 if [ -f Makefile ]; then \
417 $(MAKE) distclean ; \
418 else \
419 echo "Removing object files from srcdir..."; \
420 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
421 -o -exec test ! -d {}/CVS \; \) -prune \
422 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
423 build/autoconf/clean-config.sh; \
426 # Because SpiderMonkey can be distributed and built independently
427 # of the Mozilla source tree, it contains its own copies of many of
428 # the files used by the top-level Mozilla build process, from the
429 # 'config' and 'build' subtrees.
431 # To make it simpler to keep the copies in sync, we follow the policy
432 # that the SpiderMonkey copies must always be exact copies of those in
433 # the containing Mozilla tree. If you've made a change in one, it
434 # belongs in the other as well. If the change isn't right for both
435 # places, then that's something to bring up with the other developers.
437 # Some files are reasonable to diverge; for example,
438 # js/src/config/autoconf.mk.in doesn't need most of the stuff in
439 # config/autoconf.mk.in.
440 .PHONY: check-sync-dirs
441 check-sync-dirs: check-sync-dirs-build check-sync-dirs-config
442 check-sync-dirs-%:
443 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/$* $(TOPSRCDIR)/$*
445 echo-variable-%:
446 @echo $($*)
448 # This makefile doesn't support parallel execution. It does pass
449 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
450 # in parallel.
451 .NOTPARALLEL:
453 .PHONY: checkout \
454 real_checkout \
455 depend \
456 realbuild \
457 build \
458 profiledbuild \
459 cleansrcdir \
460 pull_all \
461 build_all \
462 check-clobber \
463 clobber \
464 clobber_all \
465 pull_and_build_all \
466 everything \
467 configure \
468 preflight_all \
469 preflight \
470 postflight \
471 postflight_all \
472 $(OBJDIR_TARGETS)