bug 886995 - wait for the popup to be populated in browser_CTP_drag_drop.js r=bsmedberg
[gecko.git] / client.mk
blob95a0e25137829b9c1026558092a3f43c36f6a65a
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 # Windows checks.
86 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
88 # Require pymake (as opposed to GNU make).
89 ifndef .PYMAKE
90 $(error Pymake is required to build on Windows. Run |./mach build| to \
91 automatically use pymake. Or, invoke pymake directly via \
92 |python build/pymake/make.py|.)
93 endif
95 # check for CRLF line endings
96 ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
97 $(error This source tree appears to have Windows-style line endings. To \
98 convert it to Unix-style line endings, run \
99 "python mozilla/build/win32/mozilla-dos2unix.py")
100 endif
101 endif
103 ####################################
104 # Load mozconfig Options
106 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
108 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
110 define CR
113 endef
115 # As $(shell) doesn't preserve newlines, use sed to replace them with an
116 # unlikely sequence (||), which is then replaced back to newlines by make
117 # before evaluation.
118 $(eval $(subst ||,$(CR),$(shell _PYMAKE=$(.PYMAKE) $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) 2> $(TOPSRCDIR)/.mozconfig.out | sed 's/$$/||/')))
120 ifdef AUTOCLOBBER
121 export AUTOCLOBBER=1
122 endif
124 # Automatically add -jN to make flags if not defined. N defaults to number of cores.
125 ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
126 cores=$(shell $(PYTHON) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
127 MOZ_MAKE_FLAGS += -j$(cores)
128 endif
131 ifndef MOZ_OBJDIR
132 MOZ_OBJDIR = obj-$(CONFIG_GUESS)
133 else
134 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
135 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
136 ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
137 $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
138 endif
139 endif
140 endif
142 ifdef MOZ_BUILD_PROJECTS
144 ifdef MOZ_CURRENT_PROJECT
145 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
146 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
147 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
148 else
149 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
150 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
151 endif
153 else # MOZ_BUILD_PROJECTS
155 OBJDIR = $(MOZ_OBJDIR)
156 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
158 endif # MOZ_BUILD_PROJECTS
160 # 'configure' scripts generated by autoconf.
161 CONFIGURES := $(TOPSRCDIR)/configure
162 CONFIGURES += $(TOPSRCDIR)/js/src/configure
164 # Make targets that are going to be passed to the real build system
165 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
167 #######################################################################
168 # Rules
170 # The default rule is build
171 build::
172 $(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
174 # Define mkdir
175 include $(TOPSRCDIR)/config/makefiles/makeutils.mk
176 include $(TOPSRCDIR)/config/makefiles/autotargets.mk
178 # Print out any options loaded from mozconfig.
179 all realbuild clean depend distclean export libs install realclean::
180 @if test -f .mozconfig.out; then \
181 cat .mozconfig.out; \
182 rm -f .mozconfig.out; \
183 else true; \
186 # Windows equivalents
187 build_all: build
188 build_all_dep: alldep
189 build_all_depend: alldep
190 clobber clobber_all: clean
192 # helper target for mobile
193 build_and_deploy: build fast-package install
195 # Do everything from scratch
196 everything: clean build
198 ####################################
199 # Profile-Guided Optimization
200 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
201 # is usable in multi-pass builds, where you might not have a runnable
202 # application until all the build passes and postflight scripts have run.
203 ifdef MOZ_OBJDIR
204 PGO_OBJDIR = $(MOZ_OBJDIR)
205 else
206 PGO_OBJDIR := $(TOPSRCDIR)
207 endif
209 profiledbuild::
210 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
211 $(MAKE) -C $(PGO_OBJDIR) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
212 rm -f ${PGO_OBJDIR}/jarlog/en-US.log
213 MOZ_PGO_INSTRUMENTED=1 JARLOG_FILE=jarlog/en-US.log EXTRA_TEST_ARGS=10 $(MAKE) -C $(PGO_OBJDIR) pgo-profile-run
214 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
215 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1
217 #####################################################
218 # Build date unification
220 ifdef MOZ_UNIFY_BDATE
221 ifndef MOZ_BUILD_DATE
222 ifdef MOZ_BUILD_PROJECTS
223 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
224 export MOZ_BUILD_DATE
225 endif
226 endif
227 endif
229 #####################################################
230 # Preflight, before building any project
232 realbuild alldep preflight_all::
233 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
234 # Don't run preflight_all for individual projects in multi-project builds
235 # (when MOZ_CURRENT_PROJECT is set.)
236 ifndef MOZ_BUILD_PROJECTS
237 # Building a single project, OBJDIR is usable.
238 set -e; \
239 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
240 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
241 done
242 else
243 # OBJDIR refers to the project-specific OBJDIR, which is not available at
244 # this point when building multiple projects. Only MOZ_OBJDIR is available.
245 set -e; \
246 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
247 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
248 done
249 endif
250 endif
252 # If we're building multiple projects, but haven't specified which project,
253 # loop through them.
255 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
256 configure depend realbuild preflight postflight $(OBJDIR_TARGETS)::
257 set -e; \
258 for app in $(MOZ_BUILD_PROJECTS); do \
259 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
260 done
262 else
264 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
265 # individual project in a multi-project build.
267 ####################################
268 # Configure
270 MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
271 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
272 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
274 EXTRA_CONFIG_DEPS := \
275 $(TOPSRCDIR)/aclocal.m4 \
276 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
277 $(TOPSRCDIR)/js/src/aclocal.m4 \
278 $(NULL)
280 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
281 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/build $(TOPSRCDIR)/build
282 @echo Generating $@ using autoconf
283 cd $(@D); $(AUTOCONF)
285 CONFIG_STATUS_DEPS := \
286 $(wildcard $(TOPSRCDIR)/*/confvars.sh) \
287 $(CONFIGURES) \
288 $(TOPSRCDIR)/CLOBBER \
289 $(TOPSRCDIR)/nsprpub/configure \
290 $(TOPSRCDIR)/config/milestone.txt \
291 $(TOPSRCDIR)/js/src/config/milestone.txt \
292 $(TOPSRCDIR)/browser/config/version.txt \
293 $(TOPSRCDIR)/build/virtualenv/packages.txt \
294 $(TOPSRCDIR)/build/virtualenv/populate_virtualenv.py \
295 $(TOPSRCDIR)/testing/mozbase/packages.txt \
296 $(NULL)
298 CONFIGURE_ENV_ARGS += \
299 MAKE="$(MAKE)" \
300 $(NULL)
302 # configure uses the program name to determine @srcdir@. Calling it without
303 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
304 # path of $(TOPSRCDIR).
305 ifeq ($(TOPSRCDIR),$(OBJDIR))
306 CONFIGURE = ./configure
307 else
308 CONFIGURE = $(TOPSRCDIR)/configure
309 endif
311 check-clobber:
312 $(PYTHON) $(TOPSRCDIR)/config/pythonpath.py -I $(TOPSRCDIR)/testing/mozbase/mozfile \
313 $(TOPSRCDIR)/python/mozbuild/mozbuild/controller/clobber.py $(TOPSRCDIR) $(OBJDIR)
315 configure-files: $(CONFIGURES)
317 configure-preqs = \
318 check-clobber \
319 configure-files \
320 $(call mkdir_deps,$(OBJDIR)) \
321 $(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
322 save-mozconfig \
323 $(NULL)
325 save-mozconfig: $(FOUND_MOZCONFIG)
326 -cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
328 configure:: $(configure-preqs)
329 @echo cd $(OBJDIR);
330 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
331 @cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
332 || ( echo "*** Fix above errors and then restart with\
333 \"$(MAKE) -f client.mk build\"" && exit 1 )
334 @touch $(OBJDIR)/Makefile
336 ifneq (,$(MAKEFILE))
337 $(OBJDIR)/Makefile: $(OBJDIR)/config.status
339 $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
340 else
341 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
342 endif
343 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
345 ifneq (,$(CONFIG_STATUS))
346 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
347 $(PYTHON) $(OBJDIR)/config.status -n --file=$(OBJDIR)/config/autoconf.mk
348 endif
351 ####################################
352 # Depend
354 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
355 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
357 ####################################
358 # Preflight
360 realbuild alldep preflight::
361 ifdef MOZ_PREFLIGHT
362 set -e; \
363 for mkfile in $(MOZ_PREFLIGHT); do \
364 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
365 done
366 endif
368 ####################################
369 # Build it
371 realbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status check-sync-dirs-config
372 $(MOZ_MAKE)
374 ####################################
375 # Other targets
377 # Pass these target onto the real build system
378 $(OBJDIR_TARGETS):: $(OBJDIR)/Makefile $(OBJDIR)/config.status
379 $(MOZ_MAKE) $@
381 ####################################
382 # Postflight
384 realbuild alldep postflight::
385 ifdef MOZ_POSTFLIGHT
386 set -e; \
387 for mkfile in $(MOZ_POSTFLIGHT); do \
388 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
389 done
390 endif
392 endif # MOZ_CURRENT_PROJECT
394 ####################################
395 # Postflight, after building all projects
397 realbuild alldep postflight_all::
398 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
399 # Don't run postflight_all for individual projects in multi-project builds
400 # (when MOZ_CURRENT_PROJECT is set.)
401 ifndef MOZ_BUILD_PROJECTS
402 # Building a single project, OBJDIR is usable.
403 set -e; \
404 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
405 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
406 done
407 else
408 # OBJDIR refers to the project-specific OBJDIR, which is not available at
409 # this point when building multiple projects. Only MOZ_OBJDIR is available.
410 set -e; \
411 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
412 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
413 done
414 endif
415 endif
417 cleansrcdir:
418 @cd $(TOPSRCDIR); \
419 if [ -f Makefile ]; then \
420 $(MAKE) distclean ; \
421 else \
422 echo "Removing object files from srcdir..."; \
423 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
424 -o -exec test ! -d {}/CVS \; \) -prune \
425 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
426 build/autoconf/clean-config.sh; \
429 # Because SpiderMonkey can be distributed and built independently
430 # of the Mozilla source tree, it contains its own copies of many of
431 # the files used by the top-level Mozilla build process, from the
432 # 'config' and 'build' subtrees.
434 # To make it simpler to keep the copies in sync, we follow the policy
435 # that the SpiderMonkey copies must always be exact copies of those in
436 # the containing Mozilla tree. If you've made a change in one, it
437 # belongs in the other as well. If the change isn't right for both
438 # places, then that's something to bring up with the other developers.
440 # Some files are reasonable to diverge; for example,
441 # js/src/config/autoconf.mk.in doesn't need most of the stuff in
442 # config/autoconf.mk.in.
443 .PHONY: check-sync-dirs
444 check-sync-dirs: check-sync-dirs-build check-sync-dirs-config
445 check-sync-dirs-%:
446 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/$* $(TOPSRCDIR)/$*
448 echo-variable-%:
449 @echo $($*)
451 # This makefile doesn't support parallel execution. It does pass
452 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
453 # in parallel.
454 .NOTPARALLEL:
456 .PHONY: checkout \
457 real_checkout \
458 depend \
459 realbuild \
460 build \
461 profiledbuild \
462 cleansrcdir \
463 pull_all \
464 build_all \
465 check-clobber \
466 clobber \
467 clobber_all \
468 pull_and_build_all \
469 everything \
470 configure \
471 preflight_all \
472 preflight \
473 postflight \
474 postflight_all \
475 $(OBJDIR_TARGETS)