Bug 788829 - Call SetSizeConstraints even if a popup is not open. r=enndeakin
[gecko.git] / client.mk
blob040de49db916fb2dd4aa95be4f549e0b5fddcce7
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 ifndef MOZ_OBJDIR
112 MOZ_OBJDIR = obj-$(CONFIG_GUESS)
113 else
114 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
115 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
116 ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
117 $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
118 endif
119 endif
120 endif
122 ifdef MOZ_BUILD_PROJECTS
124 ifdef MOZ_CURRENT_PROJECT
125 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
126 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
127 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
128 else
129 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
130 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
131 endif
133 else # MOZ_BUILD_PROJECTS
135 OBJDIR = $(MOZ_OBJDIR)
136 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
138 endif # MOZ_BUILD_PROJECTS
140 # 'configure' scripts generated by autoconf.
141 CONFIGURES := $(TOPSRCDIR)/configure
142 CONFIGURES += $(TOPSRCDIR)/js/src/configure
144 # Make targets that are going to be passed to the real build system
145 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
147 #######################################################################
148 # Rules
150 # The default rule is build
151 build::
152 $(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
154 # Define mkdir
155 include $(TOPSRCDIR)/config/makefiles/makeutils.mk
156 include $(TOPSRCDIR)/config/makefiles/autotargets.mk
158 # Print out any options loaded from mozconfig.
159 all realbuild clean depend distclean export libs install realclean::
160 @if test -f .mozconfig.out; then \
161 cat .mozconfig.out; \
162 rm -f .mozconfig.out; \
163 else true; \
166 # Windows equivalents
167 build_all: build
168 build_all_dep: alldep
169 build_all_depend: alldep
170 clobber clobber_all: clean
172 # helper target for mobile
173 build_and_deploy: build fast-package install
175 # Do everything from scratch
176 everything: clean build
178 ####################################
179 # Profile-Guided Optimization
180 # To use this, you should set the following variables in your mozconfig
181 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
183 # The profile script should exercise the functionality to be included
184 # in the profile feedback.
186 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
187 # is usable in multi-pass builds, where you might not have a runnable
188 # application until all the build passes and postflight scripts have run.
189 ifdef MOZ_OBJDIR
190 PGO_OBJDIR = $(MOZ_OBJDIR)
191 else
192 PGO_OBJDIR := $(TOPSRCDIR)
193 endif
195 profiledbuild::
196 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
197 $(MAKE) -C $(PGO_OBJDIR) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
198 MOZ_PGO_INSTRUMENTED=1 OBJDIR=${PGO_OBJDIR} JARLOG_DIR=${PGO_OBJDIR}/jarlog/en-US $(PROFILE_GEN_SCRIPT)
199 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
200 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1
202 #####################################################
203 # Build date unification
205 ifdef MOZ_UNIFY_BDATE
206 ifndef MOZ_BUILD_DATE
207 ifdef MOZ_BUILD_PROJECTS
208 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
209 export MOZ_BUILD_DATE
210 endif
211 endif
212 endif
214 #####################################################
215 # Preflight, before building any project
217 realbuild alldep preflight_all::
218 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
219 # Don't run preflight_all for individual projects in multi-project builds
220 # (when MOZ_CURRENT_PROJECT is set.)
221 ifndef MOZ_BUILD_PROJECTS
222 # Building a single project, OBJDIR is usable.
223 set -e; \
224 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
225 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
226 done
227 else
228 # OBJDIR refers to the project-specific OBJDIR, which is not available at
229 # this point when building multiple projects. Only MOZ_OBJDIR is available.
230 set -e; \
231 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
232 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
233 done
234 endif
235 endif
237 # If we're building multiple projects, but haven't specified which project,
238 # loop through them.
240 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
241 configure depend realbuild preflight postflight $(OBJDIR_TARGETS)::
242 set -e; \
243 for app in $(MOZ_BUILD_PROJECTS); do \
244 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
245 done
247 else
249 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
250 # individual project in a multi-project build.
252 ####################################
253 # Configure
255 MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
256 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
257 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
259 EXTRA_CONFIG_DEPS := \
260 $(TOPSRCDIR)/aclocal.m4 \
261 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
262 $(TOPSRCDIR)/js/src/aclocal.m4 \
263 $(NULL)
265 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
266 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/build $(TOPSRCDIR)/build
267 @echo Generating $@ using autoconf
268 cd $(@D); $(AUTOCONF)
270 CONFIG_STATUS_DEPS := \
271 $(wildcard $(TOPSRCDIR)/*/confvars.sh) \
272 $(CONFIGURES) \
273 $(TOPSRCDIR)/allmakefiles.sh \
274 $(TOPSRCDIR)/nsprpub/configure \
275 $(TOPSRCDIR)/config/milestone.txt \
276 $(TOPSRCDIR)/js/src/config/milestone.txt \
277 $(TOPSRCDIR)/browser/config/version.txt \
278 $(TOPSRCDIR)/build/virtualenv/packages.txt \
279 $(TOPSRCDIR)/build/virtualenv/populate_virtualenv.py \
280 $(NULL)
282 CONFIGURE_ENV_ARGS += \
283 MAKE="$(MAKE)" \
284 $(NULL)
286 # configure uses the program name to determine @srcdir@. Calling it without
287 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
288 # path of $(TOPSRCDIR).
289 ifeq ($(TOPSRCDIR),$(OBJDIR))
290 CONFIGURE = ./configure
291 else
292 CONFIGURE = $(TOPSRCDIR)/configure
293 endif
295 configure-files: $(CONFIGURES)
297 configure-preqs = \
298 configure-files \
299 $(call mkdir_deps,$(OBJDIR)) \
300 $(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
301 save-mozconfig \
302 $(NULL)
304 save-mozconfig: $(FOUND_MOZCONFIG)
305 -cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
307 configure:: $(configure-preqs)
308 @echo cd $(OBJDIR);
309 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
310 @cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
311 || ( echo "*** Fix above errors and then restart with\
312 \"$(MAKE) -f client.mk build\"" && exit 1 )
313 @touch $(OBJDIR)/Makefile
315 ifneq (,$(MAKEFILE))
316 $(OBJDIR)/Makefile: $(OBJDIR)/config.status
318 $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
319 else
320 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
321 endif
322 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
324 ifneq (,$(CONFIG_STATUS))
325 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
326 $(PYTHON) $(OBJDIR)/config.status -n --file=$(OBJDIR)/config/autoconf.mk
327 endif
330 ####################################
331 # Depend
333 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
334 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
336 ####################################
337 # Preflight
339 realbuild alldep preflight::
340 ifdef MOZ_PREFLIGHT
341 set -e; \
342 for mkfile in $(MOZ_PREFLIGHT); do \
343 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
344 done
345 endif
347 ####################################
348 # Build it
350 realbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status check-sync-dirs-config
351 $(MOZ_MAKE)
353 ####################################
354 # Other targets
356 # Pass these target onto the real build system
357 $(OBJDIR_TARGETS):: $(OBJDIR)/Makefile $(OBJDIR)/config.status
358 $(MOZ_MAKE) $@
360 ####################################
361 # Postflight
363 realbuild alldep postflight::
364 ifdef MOZ_POSTFLIGHT
365 set -e; \
366 for mkfile in $(MOZ_POSTFLIGHT); do \
367 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
368 done
369 endif
371 endif # MOZ_CURRENT_PROJECT
373 ####################################
374 # Postflight, after building all projects
376 realbuild alldep postflight_all::
377 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
378 # Don't run postflight_all for individual projects in multi-project builds
379 # (when MOZ_CURRENT_PROJECT is set.)
380 ifndef MOZ_BUILD_PROJECTS
381 # Building a single project, OBJDIR is usable.
382 set -e; \
383 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
384 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
385 done
386 else
387 # OBJDIR refers to the project-specific OBJDIR, which is not available at
388 # this point when building multiple projects. Only MOZ_OBJDIR is available.
389 set -e; \
390 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
391 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
392 done
393 endif
394 endif
396 cleansrcdir:
397 @cd $(TOPSRCDIR); \
398 if [ -f Makefile ]; then \
399 $(MAKE) distclean ; \
400 else \
401 echo "Removing object files from srcdir..."; \
402 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
403 -o -exec test ! -d {}/CVS \; \) -prune \
404 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
405 build/autoconf/clean-config.sh; \
408 # Because SpiderMonkey can be distributed and built independently
409 # of the Mozilla source tree, it contains its own copies of many of
410 # the files used by the top-level Mozilla build process, from the
411 # 'config' and 'build' subtrees.
413 # To make it simpler to keep the copies in sync, we follow the policy
414 # that the SpiderMonkey copies must always be exact copies of those in
415 # the containing Mozilla tree. If you've made a change in one, it
416 # belongs in the other as well. If the change isn't right for both
417 # places, then that's something to bring up with the other developers.
419 # Some files are reasonable to diverge; for example,
420 # js/src/config/autoconf.mk.in doesn't need most of the stuff in
421 # config/autoconf.mk.in.
422 .PHONY: check-sync-dirs
423 check-sync-dirs: check-sync-dirs-build check-sync-dirs-config
424 check-sync-dirs-%:
425 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/$* $(TOPSRCDIR)/$*
427 echo-variable-%:
428 @echo $($*)
430 # This makefile doesn't support parallel execution. It does pass
431 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
432 # in parallel.
433 .NOTPARALLEL:
435 .PHONY: checkout real_checkout depend realbuild build profiledbuild cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all $(OBJDIR_TARGETS)