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
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.
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.
47 # 1. hg clone ssh://hg.mozilla.org/mozilla-central 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...]),
55 # clean (realclean is now the same as clean)
58 # See http://developer.mozilla.org/en/docs/Build_Documentation for
62 # MOZ_BUILD_PROJECTS - Build multiple projects in subdirectories
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
73 #######################################################################
79 ifneq (1,$(words $(CWD
)))
80 $(error The mozilla directory cannot be located in a path with spaces.
)
88 ifeq (,$(wildcard client.mk
))
89 TOPSRCDIR
:= $(patsubst %/,%,$(dir $(MAKEFILE_LIST
)))
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)
108 CONFIG_GUESS_SCRIPT
:= $(wildcard $(TOPSRCDIR
)/build
/autoconf
/config.guess
)
109 ifdef CONFIG_GUESS_SCRIPT
110 CONFIG_GUESS
= $(shell $(CONFIG_GUESS_SCRIPT
))
114 ####################################
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")
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
141 MOZ_OBJDIR
= obj-
$(CONFIG_GUESS
)
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.
)
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
)
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.
)
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 #######################################################################
179 # The default rule is build
181 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk
$(if
$(MOZ_PGO
),profiledbuild
,realbuild
)
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
; \
195 # Windows equivalents
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.
219 PGO_OBJDIR
= $(MOZ_OBJDIR
)
221 PGO_OBJDIR
:= $(TOPSRCDIR
)
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
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.
253 for mkfile in
$(MOZ_PREFLIGHT_ALL
); do \
254 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile preflight_all TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
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.
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)"; \
266 # If we're building multiple projects, but haven't specified which project,
269 ifeq (,$(MOZ_CURRENT_PROJECT
)$(if
$(MOZ_BUILD_PROJECTS
),,1))
270 configure depend realbuild preflight postflight
$(OBJDIR_TARGETS
)::
272 for app in
$(MOZ_BUILD_PROJECTS
); do \
273 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk
$@ MOZ_CURRENT_PROJECT
=$$app; \
278 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
279 # individual project in a multi-project build.
281 ####################################
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 \
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
:= \
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 \
311 CONFIGURE_ENV_ARGS
+= \
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
321 CONFIGURE
= $(TOPSRCDIR
)/configure
324 configure-files
: $(CONFIGURES
)
328 $(call mkdir_deps
,$(OBJDIR
)) \
329 $(if
$(MOZ_BUILD_PROJECTS
),$(call mkdir_deps
,$(MOZ_OBJDIR
))) \
334 -cp
$(FOUND_MOZCONFIG
) $(OBJDIR
)/.mozconfig
336 configure
:: $(configure-preqs
)
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
345 $(OBJDIR
)/Makefile
: $(OBJDIR
)/config.status
347 $(OBJDIR
)/config.status
: $(CONFIG_STATUS_DEPS
)
349 $(OBJDIR
)/Makefile
: $(CONFIG_STATUS_DEPS
)
351 @
$(MAKE
) -f
$(TOPSRCDIR
)/client.mk configure
353 ifneq (,$(CONFIG_STATUS
))
354 $(OBJDIR
)/config
/autoconf.mk
: $(TOPSRCDIR
)/config
/autoconf.mk.in
356 CONFIG_FILES
=config
/autoconf.mk .
/config.status
360 ####################################
363 depend
:: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status
364 $(MOZ_MAKE
) export && $(MOZ_MAKE
) depend
366 ####################################
369 realbuild alldep preflight
::
372 for mkfile in
$(MOZ_PREFLIGHT
); do \
373 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile preflight TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
377 ####################################
380 realbuild
:: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status check-sync-dirs-config
383 ####################################
386 # Pass these target onto the real build system
387 $(OBJDIR_TARGETS
):: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status
390 ####################################
393 realbuild alldep postflight
::
396 for mkfile in
$(MOZ_POSTFLIGHT
); do \
397 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile postflight TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
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.
413 for mkfile in
$(MOZ_POSTFLIGHT_ALL
); do \
414 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile postflight_all TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
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.
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)"; \
428 if
[ -f Makefile
]; then \
429 $(MAKE
) distclean ; \
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
442 @
$(PYTHON
) $(TOPSRCDIR
)/js
/src
/config
/check-sync-dirs.py
$(TOPSRCDIR
)/js
/src
/$* $(TOPSRCDIR
)/$*
447 # This makefile doesn't support parallel execution. It does pass
448 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
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
)