Bug 752461 - Hide click-to-play overlays when choosing "never activate plugins.....
[gecko.git] / client.mk
blob085941bc3fe02157501e076b811413107db6a205
1 # -*- makefile -*-
2 # vim:set ts=8 sw=8 sts=8 noet:
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
23 # Contributor(s):
24 # Stephen Lamm
25 # Benjamin Smedberg <bsmedberg@covad.net>
26 # Chase Phillips <chase@mozilla.org>
27 # Mark Mentovai <mark@moxienet.com>
28 # Joey Armstrong <joey@mozilla.com>
30 # Alternatively, the contents of this file may be used under the terms of
31 # either the GNU General Public License Version 2 or later (the "GPL"), or
32 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33 # in which case the provisions of the GPL or the LGPL are applicable instead
34 # of those above. If you wish to allow use of your version of this file only
35 # under the terms of either the GPL or the LGPL, and not to allow others to
36 # use your version of this file under the terms of the MPL, indicate your
37 # decision by deleting the provisions above and replace them with the notice
38 # and other provisions required by the GPL or the LGPL. If you do not delete
39 # the provisions above, a recipient may use your version of this file under
40 # the terms of any one of the MPL, the GPL or the LGPL.
42 # ***** END LICENSE BLOCK *****
44 # Build a mozilla application.
46 # To build a tree,
47 # 1. hg clone ssh://hg.mozilla.org/mozilla-central mozilla
48 # 2. cd mozilla
49 # 3. create your .mozconfig file with
50 # ac_add_options --enable-application=browser
51 # 4. gmake -f client.mk
53 # Other targets (gmake -f client.mk [targets...]),
54 # build
55 # clean (realclean is now the same as clean)
56 # distclean
58 # See http://developer.mozilla.org/en/docs/Build_Documentation for
59 # more information.
61 # Options:
62 # MOZ_BUILD_PROJECTS - Build multiple projects in subdirectories
63 # of MOZ_OBJDIR
64 # MOZ_OBJDIR - Destination object directory
65 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
66 # MOZ_PREFLIGHT_ALL } - Makefiles to run before any project in
67 # MOZ_PREFLIGHT } MOZ_BUILD_PROJECTS, before each project, after
68 # MOZ_POSTFLIGHT } each project, and after all projects; these
69 # MOZ_POSTFLIGHT_ALL } variables contain space-separated lists
70 # MOZ_UNIFY_BDATE - Set to use the same bdate for each project in
71 # MOZ_BUILD_PROJECTS
73 #######################################################################
74 # Defines
76 comma := ,
78 CWD := $(CURDIR)
79 ifneq (1,$(words $(CWD)))
80 $(error The mozilla directory cannot be located in a path with spaces.)
81 endif
83 ifeq "$(CWD)" "/"
84 CWD := /.
85 endif
87 ifndef TOPSRCDIR
88 ifeq (,$(wildcard client.mk))
89 TOPSRCDIR := $(patsubst %/,%,$(dir $(MAKEFILE_LIST)))
90 MOZ_OBJDIR = .
91 else
92 TOPSRCDIR := $(CWD)
93 endif
94 endif
96 # try to find autoconf 2.13 - discard errors from 'which'
97 # MacOS X 10.4 sends "no autoconf*" errors to stdout, discard those via grep
98 AUTOCONF ?= $(shell which autoconf-2.13 autoconf2.13 autoconf213 2>/dev/null | grep -v '^no autoconf' | head -1)
100 ifeq (,$(strip $(AUTOCONF)))
101 AUTOCONF=$(error Could not find autoconf 2.13)
102 endif
104 SH := /bin/sh
105 PERL ?= perl
106 PYTHON ?= python
108 CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
109 ifdef CONFIG_GUESS_SCRIPT
110 CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
111 endif
114 ####################################
115 # Sanity checks
117 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
118 # check for CRLF line endings
119 ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
120 $(error This source tree appears to have Windows-style line endings. To \
121 convert it to Unix-style line endings, run \
122 "python mozilla/build/win32/mozilla-dos2unix.py")
123 endif
124 endif
126 ####################################
127 # Load mozconfig Options
129 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
131 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
132 MOZCONFIG_FINDER := build/autoconf/mozconfig-find
133 MOZCONFIG_MODULES := build/unix/uniq.pl
135 run_for_side_effects := \
136 $(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
138 include $(TOPSRCDIR)/.mozconfig.mk
140 ifndef MOZ_OBJDIR
141 MOZ_OBJDIR = obj-$(CONFIG_GUESS)
142 else
143 # On Windows Pymake builds check MOZ_OBJDIR doesn't start with "/"
144 ifneq (,$(findstring mingw,$(CONFIG_GUESS)))
145 ifeq (1_a,$(.PYMAKE)_$(firstword a$(subst /, ,$(MOZ_OBJDIR))))
146 $(error For Windows Pymake builds, MOZ_OBJDIR must be a Windows [and not MSYS] style path.)
147 endif
148 endif
149 endif
151 ifdef MOZ_BUILD_PROJECTS
153 ifdef MOZ_CURRENT_PROJECT
154 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
155 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
156 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
157 else
158 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
159 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
160 endif
162 else # MOZ_BUILD_PROJECTS
164 OBJDIR = $(MOZ_OBJDIR)
165 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
167 endif # MOZ_BUILD_PROJECTS
169 # 'configure' scripts generated by autoconf.
170 CONFIGURES := $(TOPSRCDIR)/configure
171 CONFIGURES += $(TOPSRCDIR)/js/src/configure
173 # Make targets that are going to be passed to the real build system
174 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
176 #######################################################################
177 # Rules
179 # The default rule is build
180 build::
181 $(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild)
183 # Define mkdir
184 include $(TOPSRCDIR)/config/makefiles/makeutils.mk
185 include $(TOPSRCDIR)/config/makefiles/autotargets.mk
187 # Print out any options loaded from mozconfig.
188 all realbuild clean depend distclean export libs install realclean::
189 @if test -f .mozconfig.out; then \
190 cat .mozconfig.out; \
191 rm -f .mozconfig.out; \
192 else true; \
195 # Windows equivalents
196 build_all: build
197 build_all_dep: alldep
198 build_all_depend: alldep
199 clobber clobber_all: clean
201 # helper target for mobile
202 build_and_deploy: build fast-package install
204 # Do everything from scratch
205 everything: clean build
207 ####################################
208 # Profile-Guided Optimization
209 # To use this, you should set the following variables in your mozconfig
210 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
212 # The profile script should exercise the functionality to be included
213 # in the profile feedback.
215 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
216 # is usable in multi-pass builds, where you might not have a runnable
217 # application until all the build passes and postflight scripts have run.
218 ifdef MOZ_OBJDIR
219 PGO_OBJDIR = $(MOZ_OBJDIR)
220 else
221 PGO_OBJDIR := $(TOPSRCDIR)
222 endif
224 profiledbuild::
225 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
226 $(MAKE) -C $(PGO_OBJDIR) stage-package MOZ_PGO_INSTRUMENTED=1
227 MOZ_PGO_INSTRUMENTED=1 OBJDIR=${PGO_OBJDIR} JARLOG_DIR=${PGO_OBJDIR}/jarlog/en-US $(PROFILE_GEN_SCRIPT)
228 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
229 $(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1
231 #####################################################
232 # Build date unification
234 ifdef MOZ_UNIFY_BDATE
235 ifndef MOZ_BUILD_DATE
236 ifdef MOZ_BUILD_PROJECTS
237 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
238 export MOZ_BUILD_DATE
239 endif
240 endif
241 endif
243 #####################################################
244 # Preflight, before building any project
246 realbuild alldep preflight_all::
247 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
248 # Don't run preflight_all for individual projects in multi-project builds
249 # (when MOZ_CURRENT_PROJECT is set.)
250 ifndef MOZ_BUILD_PROJECTS
251 # Building a single project, OBJDIR is usable.
252 set -e; \
253 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
254 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
255 done
256 else
257 # OBJDIR refers to the project-specific OBJDIR, which is not available at
258 # this point when building multiple projects. Only MOZ_OBJDIR is available.
259 set -e; \
260 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
261 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
262 done
263 endif
264 endif
266 # If we're building multiple projects, but haven't specified which project,
267 # loop through them.
269 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
270 configure depend realbuild preflight postflight $(OBJDIR_TARGETS)::
271 set -e; \
272 for app in $(MOZ_BUILD_PROJECTS); do \
273 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
274 done
276 else
278 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
279 # individual project in a multi-project build.
281 ####################################
282 # Configure
284 MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
285 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
286 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
288 EXTRA_CONFIG_DEPS := \
289 $(TOPSRCDIR)/aclocal.m4 \
290 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
291 $(TOPSRCDIR)/js/src/aclocal.m4 \
292 $(NULL)
294 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
295 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/build $(TOPSRCDIR)/build
296 @echo Generating $@ using autoconf
297 cd $(@D); $(AUTOCONF)
299 CONFIG_STATUS_DEPS := \
300 $(wildcard \
301 $(CONFIGURES) \
302 $(TOPSRCDIR)/allmakefiles.sh \
303 $(TOPSRCDIR)/nsprpub/configure \
304 $(TOPSRCDIR)/config/milestone.txt \
305 $(TOPSRCDIR)/js/src/config/milestone.txt \
306 $(TOPSRCDIR)/browser/config/version.txt \
307 $(TOPSRCDIR)/*/confvars.sh \
309 $(NULL)
311 CONFIGURE_ENV_ARGS += \
312 MAKE="$(MAKE)" \
313 $(NULL)
315 # configure uses the program name to determine @srcdir@. Calling it without
316 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
317 # path of $(TOPSRCDIR).
318 ifeq ($(TOPSRCDIR),$(OBJDIR))
319 CONFIGURE = ./configure
320 else
321 CONFIGURE = $(TOPSRCDIR)/configure
322 endif
324 configure-files: $(CONFIGURES)
326 configure-preqs = \
327 configure-files \
328 $(call mkdir_deps,$(OBJDIR)) \
329 $(if $(MOZ_BUILD_PROJECTS),$(call mkdir_deps,$(MOZ_OBJDIR))) \
330 save-mozconfig \
331 $(NULL)
333 save-mozconfig:
334 -cp $(FOUND_MOZCONFIG) $(OBJDIR)/.mozconfig
336 configure:: $(configure-preqs)
337 @echo cd $(OBJDIR);
338 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
339 @cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
340 || ( echo "*** Fix above errors and then restart with\
341 \"$(MAKE) -f client.mk build\"" && exit 1 )
342 @touch $(OBJDIR)/Makefile
344 ifneq (,$(MAKEFILE))
345 $(OBJDIR)/Makefile: $(OBJDIR)/config.status
347 $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
348 else
349 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
350 endif
351 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
353 ifneq (,$(CONFIG_STATUS))
354 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
355 cd $(OBJDIR); \
356 CONFIG_FILES=config/autoconf.mk ./config.status
357 endif
360 ####################################
361 # Depend
363 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
364 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
366 ####################################
367 # Preflight
369 realbuild alldep preflight::
370 ifdef MOZ_PREFLIGHT
371 set -e; \
372 for mkfile in $(MOZ_PREFLIGHT); do \
373 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
374 done
375 endif
377 ####################################
378 # Build it
380 realbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status check-sync-dirs-config
381 $(MOZ_MAKE)
383 ####################################
384 # Other targets
386 # Pass these target onto the real build system
387 $(OBJDIR_TARGETS):: $(OBJDIR)/Makefile $(OBJDIR)/config.status
388 $(MOZ_MAKE) $@
390 ####################################
391 # Postflight
393 realbuild alldep postflight::
394 ifdef MOZ_POSTFLIGHT
395 set -e; \
396 for mkfile in $(MOZ_POSTFLIGHT); do \
397 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
398 done
399 endif
401 endif # MOZ_CURRENT_PROJECT
403 ####################################
404 # Postflight, after building all projects
406 realbuild alldep postflight_all::
407 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
408 # Don't run postflight_all for individual projects in multi-project builds
409 # (when MOZ_CURRENT_PROJECT is set.)
410 ifndef MOZ_BUILD_PROJECTS
411 # Building a single project, OBJDIR is usable.
412 set -e; \
413 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
414 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
415 done
416 else
417 # OBJDIR refers to the project-specific OBJDIR, which is not available at
418 # this point when building multiple projects. Only MOZ_OBJDIR is available.
419 set -e; \
420 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
421 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
422 done
423 endif
424 endif
426 cleansrcdir:
427 @cd $(TOPSRCDIR); \
428 if [ -f Makefile ]; then \
429 $(MAKE) distclean ; \
430 else \
431 echo "Removing object files from srcdir..."; \
432 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
433 -o -exec test ! -d {}/CVS \; \) -prune \
434 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
435 build/autoconf/clean-config.sh; \
438 ## Sanity check $X and js/src/$X are in sync
439 .PHONY: check-sync-dirs
440 check-sync-dirs: check-sync-dirs-build check-sync-dirs-config
441 check-sync-dirs-%:
442 @$(PYTHON) $(TOPSRCDIR)/js/src/config/check-sync-dirs.py $(TOPSRCDIR)/js/src/$* $(TOPSRCDIR)/$*
444 echo-variable-%:
445 @echo $($*)
447 # This makefile doesn't support parallel execution. It does pass
448 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
449 # in parallel.
450 .NOTPARALLEL:
452 .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)