[Author: aa]
[google-gears.git] / gears / tools / config.mk
blob0888d489370fe01dd72aaa28a71e5347c72fb389
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.
27 ifdef MODE
28 CMD_LINE_MODE = $MODE
29 endif
31 ifdef BROWSER
32 CMD_LINE_BROWSER = $BROWSER
33 endif
35 # Discover the OS
36 ifeq ($(shell uname),Linux)
37 OS = linux
38 else
39 ifeq ($(shell uname),Darwin)
40 OS = osx
41 else
42 IS_WIN32_OR_WINCE = 1
43 ifneq ($(OS),wince)
44 OS = win32
45 endif
46 endif
47 endif
49 # Set default build mode
50 # dbg = debug build
51 # opt = release build
52 MODE = dbg
54 # Set default OS architecture
55 # OSX builds will override this value (see rules.mk).
56 # For other platforms we set just one value.
57 ifeq ($(OS),wince)
58 ARCH = arm
59 else
60 ARCH = i386
61 endif
63 # $(shell ...) statements need to be different on Windows (%% vs %).
64 ifdef IS_WIN32_OR_WINCE
65 PCT=%%
66 else
67 PCT=%
68 endif
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
81 endif
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 ######################################################################
106 # OS == linux
107 ######################################################################
108 ifeq ($(OS),linux)
109 CC = gcc
110 CXX = g++
111 OBJ_SUFFIX = .o
112 MKDEP = gcc -M -MF $(@D)/$*.pp -MT $@ $(CPPFLAGS) $(FF_CPPFLAGS) $<
114 CPPFLAGS += -DLINUX
115 LIBGD_CFLAGS += -Wno-unused-variable -Wno-unused-function -Wno-unused-label
116 SQLITE_CFLAGS += -Wno-uninitialized -DHAVE_USLEEP=1
117 # for libjpeg:
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
129 DLL_PREFIX = lib
130 DLL_SUFFIX = .so
131 MKSHLIB = g++
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
141 endif
143 ######################################################################
144 # OS == osx
145 ######################################################################
146 ifeq ($(OS),osx)
147 CC = gcc -arch $(ARCH)
148 CXX = g++ -arch $(ARCH)
149 OBJ_SUFFIX = .o
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
156 # for libjpeg:
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
168 DLL_PREFIX = lib
169 DLL_SUFFIX = .dylib
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
182 endif
184 ######################################################################
185 # OS == win32 OR wince
186 ######################################################################
187 ifdef IS_WIN32_OR_WINCE
188 CC = cl
189 CXX = cl
190 OBJ_SUFFIX = .obj
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
196 CPPFLAGS_opt =
197 CPPFLAGS += /nologo /DSTRICT /D_UNICODE /DUNICODE /D_USRDLL /DWIN32 /D_WINDLL \
198 /D_CRT_SECURE_NO_DEPRECATE
200 ifeq ($(OS),win32)
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
205 # _WIN32_IE=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 \
212 /DWINVER=0x0500 \
213 /D_WIN32_WINNT=0x0500 \
214 /D_WIN32_IE=0x0500 \
215 /D_RICHEDIT_VER=0x0010 \
216 /D_MERGE_PROXYSTUB \
217 /DBREAKPAD_AVOID_STREAMS \
218 /DXP_WIN \
219 $(CPPFLAGS_$(MODE))
220 else
221 # For Windows Mobile we need:
222 # C defines: _WIN32_WCE=0x0501
223 # _UNDER_CE=0x0501
224 CPPFLAGS += /D_WIN32_WCE=0x501 \
225 /DWINVER=_WIN32_WCE \
226 /DUNDER_CE=0x501 \
227 /DWINCE \
228 /DWIN32_PLATFORM_PSPC \
229 /DARM \
230 /D_ARM_ \
231 /DPOCKETPC2003_UI_MODEL \
232 /D_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA \
233 $(CPPFLAGS_$(MODE))
234 endif
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
239 ifeq ($(OS),wince)
240 SQLITE_CFLAGS += /wd4146
241 endif
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)
262 DLL_PREFIX = np
263 else
264 DLL_PREFIX =
265 endif
266 DLL_SUFFIX = .dll
267 MKSHLIB = link
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.
271 SHLIBFLAGS_dbg =
272 SHLIBFLAGS_opt = /INCREMENTAL:NO /OPT:REF /OPT:ICF
273 SHLIBFLAGS_NOPDB = /NOLOGO /OUT:$@ /DLL /DEBUG /RELEASE
274 ifeq ($(OS),win32)
275 SHLIBFLAGS_NOPDB += /SUBSYSTEM:WINDOWS \
276 $(SHLIBFLAGS_$(MODE))
277 else
278 SHLIBFLAGS_NOPDB += /SUBSYSTEM:WINDOWSCE,5.01 \
279 /NODEFAULTLIB:secchk.lib \
280 /MACHINE:THUMB \
281 $(SHLIBFLAGS_$(MODE))
282 endif
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"
287 ifeq ($(OS),win32)
288 FF_SHLIBFLAGS_dbg = /NODEFAULTLIB:MSVCRT
289 FF_SHLIBFLAGS_opt = /NODEFAULTLIB:MSVCRT
290 FF_SHLIBFLAGS = $(FF_SHLIBFLAGS_$(MODE))
292 IE_SHLIBFLAGS_dbg =
293 IE_SHLIBFLAGS_opt =
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
299 else
300 IEMOBILE_SHLIBFLAGS_dbg =
301 IEMOBILE_SHLIBFLAGS_opt =
302 IEMOBILE_SHLIBFLAGS = $(IE_SHLIBFLAGS_$(MODE)) /DEF:tools/mscom.def
303 endif
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.
316 MIDL = midl
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"
319 RC = rc
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"
323 ifeq ($(OS),wince)
324 RCFLAGS += /d "WINCE" /d "_WIN32" /d "_WIN32_WCE" /d "UNDER_CE" /n /i ../
325 endif
327 GGUIDGEN = tools/gguidgen.exe
328 endif
330 ######################################################################
331 # set the following for all OS values
332 ######################################################################
334 CPPFLAGS += $(INCLUDES)
335 M4FLAGS += --prefix-builtins
337 ifeq ($(MODE),dbg)
338 CPPFLAGS += -DDEBUG=1
339 M4FLAGS += -DDEBUG=1
340 else
341 CPPFLAGS += -DNDEBUG=1
342 M4FLAGS += -DNDEBUG=1
343 endif
345 ifeq ($(OFFICIAL_BUILD),1)
346 CPPFLAGS += -DOFFICIAL_BUILD=1
347 M4FLAGS += -DOFFICIAL_BUILD=1
348 endif
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.
362 COMMA := ,
363 EMPTY :=
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
373 SHORT_NAME=gears
374 M4FLAGS += -DPRODUCT_FRIENDLY_NAME_UQ="$(FRIENDLY_NAME)"
375 M4FLAGS += -DPRODUCT_SHORT_NAME_UQ="$(SHORT_NAME)"