Fixed cursor handling
[mozilla-central.git] / client.mk
blob69ec076620df5ab215b0336cae78595b5f22271c
1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
12 # License.
14 # The Original Code is mozilla.org code.
16 # The Initial Developer of the Original Code is
17 # Netscape Communications Corporation.
18 # Portions created by the Initial Developer are Copyright (C) 1998
19 # the Initial Developer. All Rights Reserved.
21 # Contributor(s):
22 # Stephen Lamm
23 # Benjamin Smedberg <bsmedberg@covad.net>
24 # Chase Phillips <chase@mozilla.org>
25 # Mark Mentovai <mark@moxienet.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 # Build a mozilla application.
43 # To build a tree,
44 # 1. hg clone ssh://hg.mozilla.org/mozilla-central mozilla
45 # 2. cd mozilla
46 # 3. python client.py checkout
47 # 4. create your .mozconfig file with
48 # mk_add_options MOZ_CO_PROJECT=
49 # suite,browser
50 # 5. gmake -f client.mk
52 # Other targets (gmake -f client.mk [targets...]),
53 # build
54 # clean (realclean is now the same as clean)
55 # distclean
57 # See http://developer.mozilla.org/en/docs/Build_Documentation for
58 # more information.
60 # Options:
61 # MOZ_BUILD_PROJECTS - Build multiple projects in subdirectories
62 # of MOZ_OBJDIR
63 # MOZ_OBJDIR - Destination object directory
64 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
65 # MOZ_PREFLIGHT_ALL } - Makefiles to run before any project in
66 # MOZ_PREFLIGHT } MOZ_BUILD_PROJECTS, before each project, after
67 # MOZ_POSTFLIGHT } each project, and after all projects; these
68 # MOZ_POSTFLIGHT_ALL } variables contain space-separated lists
69 # MOZ_UNIFY_BDATE - Set to use the same bdate for each project in
70 # MOZ_BUILD_PROJECTS
72 #######################################################################
73 # Defines
75 CVS = cvs
76 comma := ,
78 CWD := $(shell pwd)
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 $(error Must run from the client.mk directory, or specify TOPSRCDIR)
90 endif
91 TOPSRCDIR = $(CWD)
92 endif
94 AUTOCONF := autoconf-2.13
95 MKDIR := mkdir
96 SH := /bin/sh
97 ifndef MAKE
98 MAKE := gmake
99 endif
100 PERL ?= perl
101 PYTHON ?= python
103 RUN_AUTOCONF_LOCALLY = 1
105 ####################################
106 # Sanity checks
108 ifneq (,$(filter MINGW%,$(shell uname -s)))
109 # check for CRLF line endings
110 ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
111 $(error This source tree appears to have Windows-style line endings. To \
112 convert it to Unix-style line endings, run \
113 "python mozilla/build/win32/mozilla-dos2unix.py")
114 endif
115 endif
117 ####################################
118 # Load mozconfig Options
120 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
122 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
123 MOZCONFIG_FINDER := build/autoconf/mozconfig-find
124 MOZCONFIG_MODULES := build/unix/uniq.pl
128 run_for_side_effects := \
129 $(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
131 include $(TOPSRCDIR)/.mozconfig.mk
133 ifdef MOZ_BUILD_PROJECTS
135 ifndef MOZ_OBJDIR
136 $(error When MOZ_BUILD_PROJECTS is set, you must set MOZ_OBJDIR)
137 endif
138 ifdef MOZ_CURRENT_PROJECT
139 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
140 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
141 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
142 else
143 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
144 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
145 endif
147 else # MOZ_BUILD_PROJECTS
149 ifdef MOZ_OBJDIR
150 OBJDIR = $(MOZ_OBJDIR)
151 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
152 else
153 OBJDIR := $(TOPSRCDIR)
154 MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
155 endif
157 endif # MOZ_BUILD_PROJECTS
159 CONFIGURES := $(TOPSRCDIR)/configure
160 CONFIGURES += $(TOPSRCDIR)/nsprpub/configure
162 #######################################################################
163 # Rules
166 # The default rule is build
167 build::
169 # Print out any options loaded from mozconfig.
170 all build 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 # Do everything from scratch
184 everything: clean build
186 ####################################
187 # Profile-Guided Optimization
188 # To use this, you should set the following variables in your mozconfig
189 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
191 # The profile script should exercise the functionality to be included
192 # in the profile feedback.
194 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
195 # is usable in multi-pass builds, where you might not have a runnable
196 # application until all the build passes and postflight scripts have run.
197 ifdef MOZ_OBJDIR
198 PGO_OBJDIR = $(MOZ_OBJDIR)
199 else
200 PGO_OBJDIR := $(TOPSRCDIR)
201 endif
203 profiledbuild::
204 $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1
205 OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
206 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
207 $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1
209 #####################################################
210 # Build date unification
212 ifdef MOZ_UNIFY_BDATE
213 ifndef MOZ_BUILD_DATE
214 ifdef MOZ_BUILD_PROJECTS
215 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
216 export MOZ_BUILD_DATE
217 endif
218 endif
219 endif
221 #####################################################
222 # Preflight, before building any project
224 build alldep preflight_all::
225 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
226 # Don't run preflight_all for individual projects in multi-project builds
227 # (when MOZ_CURRENT_PROJECT is set.)
228 ifndef MOZ_BUILD_PROJECTS
229 # Building a single project, OBJDIR is usable.
230 set -e; \
231 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
232 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
233 done
234 else
235 # OBJDIR refers to the project-specific OBJDIR, which is not available at
236 # this point when building multiple projects. Only MOZ_OBJDIR is available.
237 set -e; \
238 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
239 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
240 done
241 endif
242 endif
244 # If we're building multiple projects, but haven't specified which project,
245 # loop through them.
247 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
248 configure depend build install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild::
249 set -e; \
250 for app in $(MOZ_BUILD_PROJECTS); do \
251 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
252 done
254 else
256 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
257 # individual project in a multi-project build.
259 ####################################
260 # Configure
262 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
263 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
265 ifdef RUN_AUTOCONF_LOCALLY
266 EXTRA_CONFIG_DEPS := \
267 $(TOPSRCDIR)/aclocal.m4 \
268 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
269 $(NULL)
271 $(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
272 @echo Generating $@ using autoconf
273 cd $(TOPSRCDIR); $(AUTOCONF)
275 $(TOPSRCDIR)/nsprpub/configure: $(TOPSRCDIR)/nsprpub/configure.in $(EXTRA_CONFIG_DEPS)
276 @echo Generating $@ using autoconf
277 cd $(TOPSRCDIR)/nsprpub; $(AUTOCONF)
278 endif
280 CONFIG_STATUS_DEPS := \
281 $(TOPSRCDIR)/configure \
282 $(TOPSRCDIR)/.mozconfig.mk \
283 $(wildcard $(TOPSRCDIR)/nsprpub/configure) \
284 $(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
285 $(wildcard $(TOPSRCDIR)/config/milestone.txt) \
286 $(wildcard $(TOPSRCDIR)/config/chrome-versions.sh) \
287 $(wildcard $(addsuffix confvars.sh,$(wildcard $(TOPSRCDIR)/*/))) \
288 $(NULL)
290 # configure uses the program name to determine @srcdir@. Calling it without
291 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
292 # path of $(TOPSRCDIR).
293 ifeq ($(TOPSRCDIR),$(OBJDIR))
294 CONFIGURE = ./configure
295 else
296 CONFIGURE = $(TOPSRCDIR)/configure
297 endif
299 ifdef MOZ_TOOLS
300 CONFIGURE = $(TOPSRCDIR)/configure
301 endif
303 configure:: $(CONFIGURES)
304 ifdef MOZ_BUILD_PROJECTS
305 @if test ! -d $(MOZ_OBJDIR); then $(MKDIR) $(MOZ_OBJDIR); else true; fi
306 endif
307 @if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
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 $(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
316 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
318 ifneq (,$(CONFIG_STATUS))
319 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
320 cd $(OBJDIR); \
321 CONFIG_FILES=config/autoconf.mk ./config.status
322 endif
325 ####################################
326 # Depend
328 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
329 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
331 ####################################
332 # Preflight
334 build alldep preflight::
335 ifdef MOZ_PREFLIGHT
336 set -e; \
337 for mkfile in $(MOZ_PREFLIGHT); do \
338 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
339 done
340 endif
342 ####################################
343 # Build it
345 build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
346 $(MOZ_MAKE)
348 ####################################
349 # Other targets
351 # Pass these target onto the real build system
352 install export libs clean realclean distclean alldep maybe_clobber_profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
353 $(MOZ_MAKE) $@
355 ####################################
356 # Postflight
358 build alldep postflight::
359 ifdef MOZ_POSTFLIGHT
360 set -e; \
361 for mkfile in $(MOZ_POSTFLIGHT); do \
362 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
363 done
364 endif
366 endif # MOZ_CURRENT_PROJECT
368 ####################################
369 # Postflight, after building all projects
371 build alldep postflight_all::
372 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
373 # Don't run postflight_all for individual projects in multi-project builds
374 # (when MOZ_CURRENT_PROJECT is set.)
375 ifndef MOZ_BUILD_PROJECTS
376 # Building a single project, OBJDIR is usable.
377 set -e; \
378 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
379 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
380 done
381 else
382 # OBJDIR refers to the project-specific OBJDIR, which is not available at
383 # this point when building multiple projects. Only MOZ_OBJDIR is available.
384 set -e; \
385 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
386 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
387 done
388 endif
389 endif
391 cleansrcdir:
392 @cd $(TOPSRCDIR); \
393 if [ -f Makefile ]; then \
394 $(MAKE) distclean ; \
395 else \
396 echo "Removing object files from srcdir..."; \
397 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
398 -o -exec test ! -d {}/CVS \; \) -prune \
399 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
400 build/autoconf/clean-config.sh; \
403 echo-variable-%:
404 @echo $($*)
406 .PHONY: checkout real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all