1 # Copyright 2005, Google Inc.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
6 # 1. Redistributions of source code must retain the above copyright notice,
7 # this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright notice,
9 # this list of conditions and the following disclaimer in the documentation
10 # and/or other materials provided with the distribution.
11 # 3. Neither the name of Google Inc. nor the names of its contributors may be
12 # used to endorse or promote products derived from this software without
13 # specific prior written permission.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 # Store value of unmodified command line parameters.
32 CMD_LINE_BROWSER
= $BROWSER
36 ifeq ($(shell uname
),Linux
)
39 ifeq ($(shell uname
),Darwin
)
49 # Set default build mode
54 # Set default OS architecture
55 # OSX builds will override this value (see rules.mk).
56 # For other platforms we set just one value.
63 # $(shell ...) statements need to be different on Windows (%% vs %).
64 ifdef IS_WIN32_OR_WINCE
70 MAKEFLAGS
= --no-print-directory
72 CPPFLAGS
= -I..
-I
$(OUTDIR
)/$(OS
)-$(ARCH
)
74 LIBPNG_CFLAGS
= -DPNG_USER_CONFIG
-DGEARS_PNG_WRITE_SUPPORT
-Ithird_party
/zlib
75 CFLAGS
+= $(LIBPNG_CFLAGS
)
76 CPPFLAGS
+= $(LIBPNG_CFLAGS
)
78 ifdef IS_WIN32_OR_WINCE
79 # Breakpad assumes it is in the include path
80 CPPFLAGS
+= -Ithird_party
/breakpad
/src
83 # We include several different base paths of GECKO_SDK because different sets
84 # of files include SDK/internal files differently.
85 FF_CPPFLAGS
= -DBROWSER_FF
=1 -I
$(GECKO_SDK
) -I
$(GECKO_SDK
)/gecko_sdk
/include -Ithird_party
/gecko_1.8
-DMOZILLA_STRICT_API
86 IE_CPPFLAGS
= -DBROWSER_IE
=1
87 IEMOBILE_CPPFLAGS
= -DBROWSER_IE
=1
88 NPAPI_CPPFLAGS
= -DBROWSER_NPAPI
=1 -I
$(GECKO_SDK
) -I
$(GECKO_SDK
)/gecko_sdk
/include
90 # When adding or removing SQLITE_OMIT_* options, also update and
91 # re-run ../third_party/sqlite_google/google_generate_preprocessed.sh.
92 SQLITE_CFLAGS
+= -DSQLITE_CORE
-DSQLITE_ENABLE_FTS1
-DSQLITE_ENABLE_FTS2 \
93 -DTHREADSAFE
=1 -DSQLITE_DEFAULT_FILE_PERMISSIONS
=0600 \
94 -DSQLITE_OMIT_ATTACH
=1 \
95 -DSQLITE_OMIT_LOAD_EXTENSION
=1 \
96 -DSQLITE_OMIT_VACUUM
=1 \
97 -DSQLITE_TRANSACTION_DEFAULT_IMMEDIATE
=1 \
98 -Ithird_party
/sqlite_google
/src
-Ithird_party
/sqlite_google
/preprocessed
100 LIBGD_CFLAGS
+= -Ithird_party
/libjpeg
-Ithird_party
/libpng
-DHAVE_CONFIG_H
102 # libGD assumes it is in the include path
103 CPPFLAGS
+= -Ithird_party
/libgd
105 ######################################################################
107 ######################################################################
112 MKDEP
= gcc
-M
-MF
$(@D
)/$*.pp
-MT
$@
$(CPPFLAGS
) $(FF_CPPFLAGS
) $<
115 LIBGD_CFLAGS
+= -Wno-unused-variable
-Wno-unused-function
-Wno-unused-label
116 SQLITE_CFLAGS
+= -Wno-uninitialized
-DHAVE_USLEEP
=1
118 THIRD_PARTY_CFLAGS
= -Wno-main
120 COMPILE_FLAGS_dbg
= -g
-O0
121 COMPILE_FLAGS_opt
= -O2
122 COMPILE_FLAGS
= -c
-o
$@
-fPIC
-fmessage-length
=0 -Wall
-Werror
$(COMPILE_FLAGS_
$(MODE
))
123 # NS_LITERAL_STRING does not work properly without this compiler option
124 COMPILE_FLAGS
+= -fshort-wchar
126 CFLAGS
= $(COMPILE_FLAGS
)
127 CXXFLAGS
= $(COMPILE_FLAGS
) -fno-exceptions
-fno-rtti
-Wno-non-virtual-dtor
-Wno-ctor-dtor-privacy
-funsigned-char
132 SHLIBFLAGS
= -o
$@
-shared
-fPIC
-Bsymbolic
-Wl
,--version-script
-Wl
,tools
/xpcom-ld-script
134 # These aren't used on Linux because ld doesn't support "@args_file".
135 #TRANSLATE_LINKER_FILE_LIST = cat -
136 #EXT_LINKER_CMD_FLAG = -Xlinker @
138 GECKO_SDK
= third_party
/gecko_1.8
/linux
140 FF_LIBS
= -L
$(GECKO_SDK
)/gecko_sdk
/bin
-L
$(GECKO_SDK
)/gecko_sdk
/lib
-lxpcom
-lxpcomglue_s
-lnspr4
143 ######################################################################
145 ######################################################################
147 CC
= gcc
-arch
$(ARCH
)
148 CXX
= g
++ -arch
$(ARCH
)
150 MKDEP
= gcc
-M
-MF
$(@D
)/$*.pp
-MT
$@
$(CPPFLAGS
) $(FF_CPPFLAGS
) $<
152 CPPFLAGS
+= -DLINUX
-DOS_MACOSX
153 LIBGD_CFLAGS
+= -Wno-unused-variable
-Wno-unused-function
-Wno-unused-label
154 SQLITE_CFLAGS
+= -Wno-uninitialized
-Wno-pointer-sign
-isysroot
$(OSX_SDK_ROOT
)
155 SQLITE_CFLAGS
+= -DHAVE_USLEEP
=1
157 THIRD_PARTY_CFLAGS
= -Wno-main
159 COMPILE_FLAGS_dbg
= -g
-O0
160 COMPILE_FLAGS_opt
= -O2
161 COMPILE_FLAGS
= -c
-o
$@
-fPIC
-fmessage-length
=0 -Wall
-Werror
$(COMPILE_FLAGS_
$(MODE
)) -isysroot
$(OSX_SDK_ROOT
)
162 # NS_LITERAL_STRING does not work properly without this compiler option
163 COMPILE_FLAGS
+= -fshort-wchar
165 CFLAGS
= $(COMPILE_FLAGS
)
166 CXXFLAGS
= $(COMPILE_FLAGS
) -fno-exceptions
-fno-rtti
-Wno-non-virtual-dtor
-Wno-ctor-dtor-privacy
-funsigned-char
170 MKSHLIB
= g
++ -framework CoreServices
-framework Carbon
-arch
$(ARCH
) -isysroot
$(OSX_SDK_ROOT
)
171 SHLIBFLAGS
= -o
$@
-bundle
-Wl
,-dead_strip
-Wl
,-exported_symbols_list
-Wl
,tools
/xpcom-ld-script.darwin
173 # ld on OSX requires filenames to be separated by a newline, rather than spaces
174 # used on most platforms. So TRANSLATE_LINKER_FILE_LIST changes ' ' to '\n'.
175 TRANSLATE_LINKER_FILE_LIST
= tr
" " "\n"
176 EXT_LINKER_CMD_FLAG
= -Xlinker
-filelist
-Xlinker
178 GECKO_SDK
= third_party
/gecko_1.8
/osx
179 OSX_SDK_ROOT
= /Developer
/SDKs
/MacOSX10.4u.sdk
181 FF_LIBS
= -L
$(GECKO_SDK
)/gecko_sdk
/bin
-L
$(GECKO_SDK
)/gecko_sdk
/lib
-lxpcom
-lmozjs
-lnspr4
-lplds4
-lplc4
-lxpcom_core
184 ######################################################################
185 # OS == win32 OR wince
186 ######################################################################
187 ifdef IS_WIN32_OR_WINCE
191 MKDEP
= python tools
/mkdepend.py
$< $@
> $(@D
)/$*.pp
193 # Most Windows headers use the cross-platform NDEBUG and DEBUG #defines
194 # (handled later). But a few Windows files look at _DEBUG instead.
195 CPPFLAGS_dbg
= /D_DEBUG
=1
197 CPPFLAGS
+= /nologo
/DSTRICT
/D_UNICODE
/DUNICODE
/D_USRDLL
/DWIN32
/D_WINDLL \
198 /D_CRT_SECURE_NO_DEPRECATE
201 # We require APPVER=5.0 for things like HWND_MESSAGE.
202 # When APPVER=5.0, win32.mak in the Platform SDK sets:
203 # C defines: WINVER=0x0500
204 # _WIN32_WINNT=0x0500
206 # _RICHEDIT_VER=0x0010
207 # RC defines: WINVER=0x0500
208 # MIDL flags: /target NT50
209 # Note: _WIN32_WINDOWS was replaced by _WIN32_WINNT for post-Win95 builds.
210 # Note: XP_WIN is only used by Firefox headers
211 CPPFLAGS
+= /D_WINDOWS \
213 /D_WIN32_WINNT
=0x0500 \
215 /D_RICHEDIT_VER
=0x0010 \
217 /DBREAKPAD_AVOID_STREAMS \
221 # For Windows Mobile we need:
222 # C defines: _WIN32_WCE=0x0501
224 CPPFLAGS
+= /D_WIN32_WCE
=0x501 \
225 /DWINVER
=_WIN32_WCE \
228 /DWIN32_PLATFORM_PSPC \
231 /DPOCKETPC2003_UI_MODEL \
232 /D_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA \
236 # disable some warnings when building SQLite on Windows, so we can enable /WX
237 # warning C4244: conversion from 'type1' to 'type2', possible loss of data
238 SQLITE_CFLAGS
+= /wd4018
/wd4244
240 SQLITE_CFLAGS
+= /wd4146
243 LIBGD_CFLAGS
+= /DBGDWIN32
/wd4244
/wd4996
/wd4005
/wd4142
/wd4018
/wd4133
/wd4102
245 COMPILE_FLAGS_dbg
= /MTd
/Zi
246 COMPILE_FLAGS_opt
= /MT
/Zi
/Ox
247 COMPILE_FLAGS
= /c
/Fo
"$@" /Fd
"$(@D)/$*.pdb" /W3
/WX
/GR-
$(COMPILE_FLAGS_
$(MODE
))
248 # In VC8, the way to disable exceptions is to remove all /EH* flags, and to
249 # define _HAS_EXCEPTIONS=0 (for C++ headers) and _ATL_NO_EXCEPTIONS (for ATL).
250 COMPILE_FLAGS
+= /D_HAS_EXCEPTIONS
=0 /D_ATL_NO_EXCEPTIONS
252 CFLAGS
= $(COMPILE_FLAGS
)
253 CXXFLAGS
= $(COMPILE_FLAGS
) /TP
/J
255 # disable some warnings when building third party code on Windows, so we can enable /WX
256 # warning C4018: signed/unsigned mismatch in comparison
257 # warning C4003: not enough actual parameters for macro
258 THIRD_PARTY_CPPFLAGS
= /wd4018
/wd4003
261 ifeq ($(BROWSER
),NPAPI
)
268 # /RELEASE adds a checksum to the PE header to aid symbol loading.
269 # /DEBUG causes PDB files to be produced.
270 # We want both these flags in all build modes, despite their names.
272 SHLIBFLAGS_opt
= /INCREMENTAL
:NO
/OPT
:REF
/OPT
:ICF
273 SHLIBFLAGS_NOPDB
= /NOLOGO
/OUT
:$@
/DLL
/DEBUG
/RELEASE
275 SHLIBFLAGS_NOPDB
+= /SUBSYSTEM
:WINDOWS \
276 $(SHLIBFLAGS_
$(MODE
))
278 SHLIBFLAGS_NOPDB
+= /SUBSYSTEM
:WINDOWSCE
,5.01 \
279 /NODEFAULTLIB
:secchk.lib \
281 $(SHLIBFLAGS_
$(MODE
))
283 # We need SHLIBFLAGS_NOPDB for generating other targets than gears.dll
284 # (e.g. setup.dll for Windows Mobile)
285 SHLIBFLAGS
= $(SHLIBFLAGS_NOPDB
) /PDB
:"$(@D)/$(MODULE).pdb"
288 FF_SHLIBFLAGS_dbg
= /NODEFAULTLIB
:MSVCRT
289 FF_SHLIBFLAGS_opt
= /NODEFAULTLIB
:MSVCRT
290 FF_SHLIBFLAGS
= $(FF_SHLIBFLAGS_
$(MODE
))
294 IE_SHLIBFLAGS
= $(IE_SHLIBFLAGS_
$(MODE
)) /DEF
:tools
/mscom.def
296 NPAPI_SHLIBFLAGS_dbg
= /NODEFAULTLIB
:MSVCRT
297 NPAPI_SHLIBFLAGS_opt
= /NODEFAULTLIB
:MSVCRT
298 NPAPI_SHLIBFLAGS
= $(NPAPI_SHLIBFLAGS_
$(MODE
)) /DEF
:base
/npapi
/npgears.def
300 IEMOBILE_SHLIBFLAGS_dbg
=
301 IEMOBILE_SHLIBFLAGS_opt
=
302 IEMOBILE_SHLIBFLAGS
= $(IE_SHLIBFLAGS_
$(MODE
)) /DEF
:tools
/mscom.def
305 TRANSLATE_LINKER_FILE_LIST
= cat
-
306 EXT_LINKER_CMD_FLAG
= @
308 GECKO_SDK
= third_party
/gecko_1.8
/win32
310 FF_LIBS
= $(GECKO_SDK
)/gecko_sdk
/lib
/xpcom.lib
$(GECKO_SDK
)/gecko_sdk
/lib
/xpcomglue_s.lib
$(GECKO_SDK
)/gecko_sdk
/lib
/nspr4.lib
$(GECKO_SDK
)/gecko_sdk
/lib
/js3250.lib ole32.lib shell32.lib shlwapi.lib advapi32.lib wininet.lib
311 IE_LIBS
= kernel32.lib user32.lib gdi32.lib uuid.lib sensapi.lib shlwapi.lib shell32.lib advapi32.lib wininet.lib
312 IEMOBILE_LIBS
= wininet.lib ceshell.lib coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib atlosapis.lib piedocvw.lib cellcore.lib htmlview.lib imaging.lib toolhelp.lib aygshell.lib
313 NPAPI_LIBS
= sensapi.lib ole32.lib shell32.lib advapi32.lib wininet.lib
315 # Other tools specific to win32/wince builds.
317 MIDLFLAGS
= $(CPPFLAGS
) -env win32
-Oicf
-tlb
"$(@D)/$*.tlb" -h
"$(@D)/$*.h" -iid
"$(IE_OUTDIR)/$*_i.c" -proxy
"$(IE_OUTDIR)/$*_p.c" -dlldata
"$(IE_OUTDIR)/$*_d.c"
320 RCFLAGS_dbg
= /DDEBUG
=1
321 RCFLAGS_opt
= /DNDEBUG
=1
322 RCFLAGS
= $(RCFLAGS_
$(MODE
)) /d
"_UNICODE" /d
"UNICODE" /i
$(OUTDIR
)/$(OS
)-$(ARCH
) /l
0x409 /fo
"$(@D)/$*.res"
324 RCFLAGS
+= /d
"WINCE" /d
"_WIN32" /d
"_WIN32_WCE" /d
"UNDER_CE" /n
/i ..
/
327 GGUIDGEN
= tools
/gguidgen.exe
330 ######################################################################
331 # set the following for all OS values
332 ######################################################################
334 CPPFLAGS
+= $(INCLUDES
)
335 M4FLAGS
+= --prefix-builtins
338 CPPFLAGS
+= -DDEBUG
=1
341 CPPFLAGS
+= -DNDEBUG
=1
342 M4FLAGS
+= -DNDEBUG
=1
345 ifeq ($(OFFICIAL_BUILD
),1)
346 CPPFLAGS
+= -DOFFICIAL_BUILD
=1
347 M4FLAGS
+= -DOFFICIAL_BUILD
=1
350 # Additional values needed for M4 preprocessing
352 M4FLAGS
+= -DPRODUCT_VERSION
=$(VERSION
)
353 M4FLAGS
+= -DPRODUCT_VERSION_MAJOR
=$(MAJOR
)
354 M4FLAGS
+= -DPRODUCT_VERSION_MINOR
=$(MINOR
)
355 M4FLAGS
+= -DPRODUCT_VERSION_BUILD
=$(BUILD
)
356 M4FLAGS
+= -DPRODUCT_VERSION_PATCH
=$(PATCH
)
358 M4FLAGS
+= -DPRODUCT_OS
=$(OS
)
360 # These three macros are suggested by the GNU make documentation for creating
361 # a comma-separated list.
364 SPACE
:= $(EMPTY
) $(EMPTY
)
365 M4FLAGS
+= -DI18N_LANGUAGES
="($(subst $(SPACE),$(COMMA),$(strip $(I18N_LANGS))))"
367 # The friendly name can include spaces.
368 # The short name should be lowercase_with_underscores.
369 # "UQ" means "un-quoted".
370 # IMPORTANT: these values affect most visible names, but there are exceptions.
371 # If you change a name below, also search the code for "[naming]"
372 FRIENDLY_NAME
=Google Gears
374 M4FLAGS
+= -DPRODUCT_FRIENDLY_NAME_UQ
="$(FRIENDLY_NAME)"
375 M4FLAGS
+= -DPRODUCT_SHORT_NAME_UQ
="$(SHORT_NAME)"