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 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 # Do everything from scratch
202 everything
: clean build
204 ####################################
205 # Profile-Guided Optimization
206 # To use this, you should set the following variables in your mozconfig
207 # mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
209 # The profile script should exercise the functionality to be included
210 # in the profile feedback.
212 # This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
213 # is usable in multi-pass builds, where you might not have a runnable
214 # application until all the build passes and postflight scripts have run.
216 PGO_OBJDIR
= $(MOZ_OBJDIR
)
218 PGO_OBJDIR
:= $(TOPSRCDIR
)
222 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk realbuild MOZ_PROFILE_GENERATE
=1 MOZ_PGO_INSTRUMENTED
=1
223 $(MAKE
) -C
$(PGO_OBJDIR
) stage-package MOZ_PGO_INSTRUMENTED
=1
224 MOZ_PGO_INSTRUMENTED
=1 OBJDIR
=${PGO_OBJDIR} JARLOG_DIR
=${PGO_OBJDIR}/jarlog
/en-US
$(PROFILE_GEN_SCRIPT
)
225 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk maybe_clobber_profiledbuild
226 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk realbuild MOZ_PROFILE_USE
=1
228 #####################################################
229 # Build date unification
231 ifdef MOZ_UNIFY_BDATE
232 ifndef MOZ_BUILD_DATE
233 ifdef MOZ_BUILD_PROJECTS
234 MOZ_BUILD_DATE
= $(shell $(PYTHON
) $(TOPSRCDIR
)/toolkit
/xre
/make-platformini.py
--print-buildid
)
235 export MOZ_BUILD_DATE
240 #####################################################
241 # Preflight, before building any project
243 realbuild alldep preflight_all
::
244 ifeq (,$(MOZ_CURRENT_PROJECT
)$(if
$(MOZ_PREFLIGHT_ALL
),,1))
245 # Don't run preflight_all for individual projects in multi-project builds
246 # (when MOZ_CURRENT_PROJECT is set.)
247 ifndef MOZ_BUILD_PROJECTS
248 # Building a single project, OBJDIR is usable.
250 for mkfile in
$(MOZ_PREFLIGHT_ALL
); do \
251 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile preflight_all TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
254 # OBJDIR refers to the project-specific OBJDIR, which is not available at
255 # this point when building multiple projects. Only MOZ_OBJDIR is available.
257 for mkfile in
$(MOZ_PREFLIGHT_ALL
); do \
258 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile preflight_all TOPSRCDIR
=$(TOPSRCDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
) MOZ_BUILD_PROJECTS
="$(MOZ_BUILD_PROJECTS)"; \
263 # If we're building multiple projects, but haven't specified which project,
266 ifeq (,$(MOZ_CURRENT_PROJECT
)$(if
$(MOZ_BUILD_PROJECTS
),,1))
267 configure depend realbuild preflight postflight
$(OBJDIR_TARGETS
)::
269 for app in
$(MOZ_BUILD_PROJECTS
); do \
270 $(MAKE
) -f
$(TOPSRCDIR
)/client.mk
$@ MOZ_CURRENT_PROJECT
=$$app; \
275 # MOZ_CURRENT_PROJECT: either doing a single-project build, or building an
276 # individual project in a multi-project build.
278 ####################################
281 MAKEFILE
= $(wildcard $(OBJDIR
)/Makefile
)
282 CONFIG_STATUS
= $(wildcard $(OBJDIR
)/config.status
)
283 CONFIG_CACHE
= $(wildcard $(OBJDIR
)/config.cache
)
285 EXTRA_CONFIG_DEPS
:= \
286 $(TOPSRCDIR
)/aclocal.m4 \
287 $(wildcard $(TOPSRCDIR
)/build
/autoconf
/*.m4
) \
288 $(TOPSRCDIR
)/js
/src
/aclocal.m4 \
291 $(CONFIGURES
): %: %.in
$(EXTRA_CONFIG_DEPS
)
292 @
$(PYTHON
) $(TOPSRCDIR
)/js
/src
/config
/check-sync-dirs.py
$(TOPSRCDIR
)/js
/src
/build
$(TOPSRCDIR
)/build
293 @echo Generating
$@ using autoconf
294 cd
$(@D
); $(AUTOCONF
)
296 CONFIG_STATUS_DEPS
:= \
299 $(TOPSRCDIR
)/allmakefiles.sh \
300 $(TOPSRCDIR
)/nsprpub
/configure \
301 $(TOPSRCDIR
)/config
/milestone.txt \
302 $(TOPSRCDIR
)/js
/src
/config
/milestone.txt \
303 $(TOPSRCDIR
)/browser
/config
/version.txt \
304 $(TOPSRCDIR
)/*/confvars.sh \
308 CONFIGURE_ENV_ARGS
+= \
312 # configure uses the program name to determine @srcdir@. Calling it without
313 # $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
314 # path of $(TOPSRCDIR).
315 ifeq ($(TOPSRCDIR
),$(OBJDIR
))
316 CONFIGURE
= .
/configure
318 CONFIGURE
= $(TOPSRCDIR
)/configure
321 configure-files
: $(CONFIGURES
)
325 $(call mkdir_deps
,$(OBJDIR
)) \
326 $(if
$(MOZ_BUILD_PROJECTS
),$(call mkdir_deps
,$(MOZ_OBJDIR
))) \
329 configure
:: $(configure-preqs
)
331 @echo
$(CONFIGURE
) $(CONFIGURE_ARGS
)
332 @cd
$(OBJDIR
) && $(BUILD_PROJECT_ARG
) $(CONFIGURE_ENV_ARGS
) $(CONFIGURE
) $(CONFIGURE_ARGS
) \
333 ||
( echo
"*** Fix above errors and then restart with\
334 \"$(MAKE) -f client.mk build\"" && exit
1 )
335 @touch
$(OBJDIR
)/Makefile
338 $(OBJDIR
)/Makefile
: $(OBJDIR
)/config.status
340 $(OBJDIR
)/config.status
: $(CONFIG_STATUS_DEPS
)
342 $(OBJDIR
)/Makefile
: $(CONFIG_STATUS_DEPS
)
344 @
$(MAKE
) -f
$(TOPSRCDIR
)/client.mk configure
346 ifneq (,$(CONFIG_STATUS
))
347 $(OBJDIR
)/config
/autoconf.mk
: $(TOPSRCDIR
)/config
/autoconf.mk.in
349 CONFIG_FILES
=config
/autoconf.mk .
/config.status
353 ####################################
356 depend
:: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status
357 $(MOZ_MAKE
) export && $(MOZ_MAKE
) depend
359 ####################################
362 realbuild alldep preflight
::
365 for mkfile in
$(MOZ_PREFLIGHT
); do \
366 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile preflight TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
370 ####################################
373 realbuild
:: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status check-sync-dirs-config
376 ####################################
379 # Pass these target onto the real build system
380 $(OBJDIR_TARGETS
):: $(OBJDIR
)/Makefile
$(OBJDIR
)/config.status
383 ####################################
386 realbuild alldep postflight
::
389 for mkfile in
$(MOZ_POSTFLIGHT
); do \
390 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile postflight TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
394 endif # MOZ_CURRENT_PROJECT
396 ####################################
397 # Postflight, after building all projects
399 realbuild alldep postflight_all
::
400 ifeq (,$(MOZ_CURRENT_PROJECT
)$(if
$(MOZ_POSTFLIGHT_ALL
),,1))
401 # Don't run postflight_all for individual projects in multi-project builds
402 # (when MOZ_CURRENT_PROJECT is set.)
403 ifndef MOZ_BUILD_PROJECTS
404 # Building a single project, OBJDIR is usable.
406 for mkfile in
$(MOZ_POSTFLIGHT_ALL
); do \
407 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile postflight_all TOPSRCDIR
=$(TOPSRCDIR
) OBJDIR
=$(OBJDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
); \
410 # OBJDIR refers to the project-specific OBJDIR, which is not available at
411 # this point when building multiple projects. Only MOZ_OBJDIR is available.
413 for mkfile in
$(MOZ_POSTFLIGHT_ALL
); do \
414 $(MAKE
) -f
$(TOPSRCDIR
)/$$mkfile postflight_all TOPSRCDIR
=$(TOPSRCDIR
) MOZ_OBJDIR
=$(MOZ_OBJDIR
) MOZ_BUILD_PROJECTS
="$(MOZ_BUILD_PROJECTS)"; \
421 if
[ -f Makefile
]; then \
422 $(MAKE
) distclean ; \
424 echo
"Removing object files from srcdir..."; \
425 rm -fr
`find . -type d \( -name .deps -print -o -name CVS \
426 -o -exec test ! -d {}/CVS \; \) -prune \
427 -o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
428 build
/autoconf
/clean-config.sh
; \
431 ## Sanity check $X and js/src/$X are in sync
432 .PHONY
: check-sync-dirs
433 check-sync-dirs
: check-sync-dirs-build check-sync-dirs-config
435 @
$(PYTHON
) $(TOPSRCDIR
)/js
/src
/config
/check-sync-dirs.py
$(TOPSRCDIR
)/js
/src
/$* $(TOPSRCDIR
)/$*
440 # This makefile doesn't support parallel execution. It does pass
441 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
445 .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
)