Bug 452390 Tracemonkey will crash if the compiler doesn't have FASTCALL r=danderson
[wine-gecko.git] / client.mk
blob65fa99fa5c868e808866116c7bf235eab4b293d8
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. create your .mozconfig file with
47 # ac_add_options --enable-application=browser
48 # 4. gmake -f client.mk
50 # Other targets (gmake -f client.mk [targets...]),
51 # build
52 # clean (realclean is now the same as clean)
53 # distclean
55 # See http://developer.mozilla.org/en/docs/Build_Documentation for
56 # more information.
58 # Options:
59 # MOZ_BUILD_PROJECTS - Build multiple projects in subdirectories
60 # of MOZ_OBJDIR
61 # MOZ_OBJDIR - Destination object directory
62 # MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
63 # MOZ_PREFLIGHT_ALL } - Makefiles to run before any project in
64 # MOZ_PREFLIGHT } MOZ_BUILD_PROJECTS, before each project, after
65 # MOZ_POSTFLIGHT } each project, and after all projects; these
66 # MOZ_POSTFLIGHT_ALL } variables contain space-separated lists
67 # MOZ_UNIFY_BDATE - Set to use the same bdate for each project in
68 # MOZ_BUILD_PROJECTS
70 #######################################################################
71 # Defines
73 CVS = cvs
74 comma := ,
76 CWD := $(shell pwd)
77 ifneq (1,$(words $(CWD)))
78 $(error The mozilla directory cannot be located in a path with spaces.)
79 endif
81 ifeq "$(CWD)" "/"
82 CWD := /.
83 endif
85 ifndef TOPSRCDIR
86 ifeq (,$(wildcard client.mk))
87 $(error Must run from the client.mk directory, or specify TOPSRCDIR)
88 endif
89 TOPSRCDIR = $(CWD)
90 endif
92 # try to find autoconf 2.13 - discard errors from 'which'
93 # MacOS X 10.4 sends "no autoconf*" errors to stdout, discard those via grep
94 AUTOCONF ?= $(shell which autoconf-2.13 autoconf2.13 autoconf213 2>/dev/null | grep -v '^no autoconf' | head -1)
96 ifeq (,$(strip $(AUTOCONF)))
97 AUTOCONF=$(error Couldn't find autoconf 2.13)
98 endif
100 MKDIR := mkdir
101 SH := /bin/sh
102 ifndef MAKE
103 MAKE := gmake
104 endif
105 PERL ?= perl
106 PYTHON ?= python
108 RUN_AUTOCONF_LOCALLY = 1
109 CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
110 ifdef CONFIG_GUESS_SCRIPT
111 CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
112 endif
115 ####################################
116 # Sanity checks
118 ifneq (,$(filter MINGW%,$(shell uname -s)))
119 # check for CRLF line endings
120 ifneq (0,$(shell $(PERL) -e 'binmode(STDIN); while (<STDIN>) { if (/\r/) { print "1"; exit } } print "0"' < $(TOPSRCDIR)/client.mk))
121 $(error This source tree appears to have Windows-style line endings. To \
122 convert it to Unix-style line endings, run \
123 "python mozilla/build/win32/mozilla-dos2unix.py")
124 endif
125 endif
127 ####################################
128 # Load mozconfig Options
130 # See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.
132 MOZCONFIG_LOADER := build/autoconf/mozconfig2client-mk
133 MOZCONFIG_FINDER := build/autoconf/mozconfig-find
134 MOZCONFIG_MODULES := build/unix/uniq.pl
138 run_for_side_effects := \
139 $(shell $(TOPSRCDIR)/$(MOZCONFIG_LOADER) $(TOPSRCDIR) $(TOPSRCDIR)/.mozconfig.mk > $(TOPSRCDIR)/.mozconfig.out)
141 include $(TOPSRCDIR)/.mozconfig.mk
143 ifdef MOZ_BUILD_PROJECTS
145 ifndef MOZ_OBJDIR
146 $(error When MOZ_BUILD_PROJECTS is set, you must set MOZ_OBJDIR)
147 endif
148 ifdef MOZ_CURRENT_PROJECT
149 OBJDIR = $(MOZ_OBJDIR)/$(MOZ_CURRENT_PROJECT)
150 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
151 BUILD_PROJECT_ARG = MOZ_BUILD_APP=$(MOZ_CURRENT_PROJECT)
152 else
153 OBJDIR = $(error Cannot find the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
154 MOZ_MAKE = $(error Cannot build in the OBJDIR when MOZ_CURRENT_PROJECT is not set.)
155 endif
157 else # MOZ_BUILD_PROJECTS
159 ifdef MOZ_OBJDIR
160 OBJDIR = $(MOZ_OBJDIR)
161 MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
162 else
163 OBJDIR := $(TOPSRCDIR)
164 MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
165 endif
167 endif # MOZ_BUILD_PROJECTS
169 # 'configure' scripts generated by autoconf.
170 CONFIGURES := $(TOPSRCDIR)/configure
171 CONFIGURES += $(TOPSRCDIR)/nsprpub/configure
172 CONFIGURES += $(TOPSRCDIR)/js/src/configure
174 #######################################################################
175 # Rules
178 # The default rule is build
179 build::
181 # Print out any options loaded from mozconfig.
182 all build clean depend distclean export libs install realclean::
183 @if test -f .mozconfig.out; then \
184 cat .mozconfig.out; \
185 rm -f .mozconfig.out; \
186 else true; \
189 # Windows equivalents
190 build_all: build
191 build_all_dep: alldep
192 build_all_depend: alldep
193 clobber clobber_all: clean
195 # Do everything from scratch
196 everything: clean build
198 ####################################
199 # Profile-Guided Optimization
200 # To use this, you should set the following variables in your mozconfig
201 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
203 # The profile script should exercise the functionality to be included
204 # in the profile feedback.
206 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
207 # is usable in multi-pass builds, where you might not have a runnable
208 # application until all the build passes and postflight scripts have run.
209 ifdef MOZ_OBJDIR
210 PGO_OBJDIR = $(MOZ_OBJDIR)
211 else
212 PGO_OBJDIR := $(TOPSRCDIR)
213 endif
215 profiledbuild::
216 $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1
217 OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
218 $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
219 $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1
221 #####################################################
222 # Build date unification
224 ifdef MOZ_UNIFY_BDATE
225 ifndef MOZ_BUILD_DATE
226 ifdef MOZ_BUILD_PROJECTS
227 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/toolkit/xre/make-platformini.py --print-buildid)
228 export MOZ_BUILD_DATE
229 endif
230 endif
231 endif
233 #####################################################
234 # Preflight, before building any project
236 build alldep preflight_all::
237 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_PREFLIGHT_ALL),,1))
238 # Don't run preflight_all for individual projects in multi-project builds
239 # (when MOZ_CURRENT_PROJECT is set.)
240 ifndef MOZ_BUILD_PROJECTS
241 # Building a single project, OBJDIR is usable.
242 set -e; \
243 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
244 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
245 done
246 else
247 # OBJDIR refers to the project-specific OBJDIR, which is not available at
248 # this point when building multiple projects. Only MOZ_OBJDIR is available.
249 set -e; \
250 for mkfile in $(MOZ_PREFLIGHT_ALL); do \
251 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
252 done
253 endif
254 endif
256 # If we're building multiple projects, but haven't specified which project,
257 # loop through them.
259 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_BUILD_PROJECTS),,1))
260 configure depend build install export libs clean realclean distclean alldep preflight postflight maybe_clobber_profiledbuild::
261 set -e; \
262 for app in $(MOZ_BUILD_PROJECTS); do \
263 $(MAKE) -f $(TOPSRCDIR)/client.mk $@ MOZ_CURRENT_PROJECT=$$app; \
264 done
266 else
268 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
269 # individual project in a multi-project build.
271 ####################################
272 # Configure
274 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
275 CONFIG_CACHE = $(wildcard $(OBJDIR)/config.cache)
277 ifdef RUN_AUTOCONF_LOCALLY
278 EXTRA_CONFIG_DEPS := \
279 $(TOPSRCDIR)/aclocal.m4 \
280 $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
281 $(TOPSRCDIR)/js/src/aclocal.m4 \
282 $(NULL)
284 $(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
285 @echo Generating $@ using autoconf
286 cd $(@D); $(AUTOCONF)
287 endif
289 CONFIG_STATUS_DEPS := \
290 $(wildcard $(CONFIGURES)) \
291 $(TOPSRCDIR)/allmakefiles.sh \
292 $(TOPSRCDIR)/.mozconfig.mk \
293 $(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
294 $(wildcard $(TOPSRCDIR)/config/milestone.txt) \
295 $(wildcard $(TOPSRCDIR)/config/chrome-versions.sh) \
296 $(wildcard $(addsuffix confvars.sh,$(wildcard $(TOPSRCDIR)/*/))) \
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 ifdef MOZ_TOOLS
309 CONFIGURE = $(TOPSRCDIR)/configure
310 endif
312 configure-files: $(CONFIGURES)
314 configure:: configure-files
315 ifdef MOZ_BUILD_PROJECTS
316 @if test ! -d $(MOZ_OBJDIR); then $(MKDIR) $(MOZ_OBJDIR); else true; fi
317 endif
318 @if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
319 @echo cd $(OBJDIR);
320 @echo $(CONFIGURE) $(CONFIGURE_ARGS)
321 @cd $(OBJDIR) && $(BUILD_PROJECT_ARG) $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
322 || ( echo "*** Fix above errors and then restart with\
323 \"$(MAKE) -f client.mk build\"" && exit 1 )
324 @touch $(OBJDIR)/Makefile
326 $(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
327 @$(MAKE) -f $(TOPSRCDIR)/client.mk configure
329 ifneq (,$(CONFIG_STATUS))
330 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
331 cd $(OBJDIR); \
332 CONFIG_FILES=config/autoconf.mk ./config.status
333 endif
336 ####################################
337 # Depend
339 depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
340 $(MOZ_MAKE) export && $(MOZ_MAKE) depend
342 ####################################
343 # Preflight
345 build alldep preflight::
346 ifdef MOZ_PREFLIGHT
347 set -e; \
348 for mkfile in $(MOZ_PREFLIGHT); do \
349 $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
350 done
351 endif
353 ####################################
354 # Build it
356 build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
357 $(MOZ_MAKE)
359 ####################################
360 # Other targets
362 # Pass these target onto the real build system
363 install export libs clean realclean distclean alldep maybe_clobber_profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
364 $(MOZ_MAKE) $@
366 ####################################
367 # Postflight
369 build alldep postflight::
370 ifdef MOZ_POSTFLIGHT
371 set -e; \
372 for mkfile in $(MOZ_POSTFLIGHT); do \
373 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
374 done
375 endif
377 endif # MOZ_CURRENT_PROJECT
379 ####################################
380 # Postflight, after building all projects
382 build alldep postflight_all::
383 ifeq (,$(MOZ_CURRENT_PROJECT)$(if $(MOZ_POSTFLIGHT_ALL),,1))
384 # Don't run postflight_all for individual projects in multi-project builds
385 # (when MOZ_CURRENT_PROJECT is set.)
386 ifndef MOZ_BUILD_PROJECTS
387 # Building a single project, OBJDIR is usable.
388 set -e; \
389 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
390 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
391 done
392 else
393 # OBJDIR refers to the project-specific OBJDIR, which is not available at
394 # this point when building multiple projects. Only MOZ_OBJDIR is available.
395 set -e; \
396 for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
397 $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) MOZ_OBJDIR=$(MOZ_OBJDIR) MOZ_BUILD_PROJECTS="$(MOZ_BUILD_PROJECTS)"; \
398 done
399 endif
400 endif
402 cleansrcdir:
403 @cd $(TOPSRCDIR); \
404 if [ -f Makefile ]; then \
405 $(MAKE) distclean ; \
406 else \
407 echo "Removing object files from srcdir..."; \
408 rm -fr `find . -type d \( -name .deps -print -o -name CVS \
409 -o -exec test ! -d {}/CVS \; \) -prune \
410 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
411 build/autoconf/clean-config.sh; \
414 echo-variable-%:
415 @echo $($*)
417 .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