2011-01-17 MORITA Hajime <morrita@google.com>
[WebKit-https.git] / Android.mk
1 ##
2 ## Copyright 2009, The Android Open Source Project
3 ##
4 ## Redistribution and use in source and binary forms, with or without
5 ## modification, are permitted provided that the following conditions
6 ## are met:
7 ##  * Redistributions of source code must retain the above copyright
8 ##    notice, this list of conditions and the following disclaimer.
9 ##  * Redistributions in binary form must reproduce the above copyright
10 ##    notice, this list of conditions and the following disclaimer in the
11 ##    documentation and/or other materials provided with the distribution.
12 ##
13 ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 ## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 ## PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 ## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 ## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 ## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 ## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 ##
25
26 LOCAL_PATH := $(call my-dir)
27
28 # Two ways to control which JS engine is used:
29 # 1. use JS_ENGINE environment variable, value can be either 'jsc' or 'v8'
30 #    This is the preferred way.
31 # 2. if JS_ENGINE is not set, or is not 'jsc' or 'v8', this makefile picks
32 #    up a default engine to build.
33 #    To help setup buildbot, a new environment variable, USE_ALT_JS_ENGINE,
34 #    can be set to true, so that two builds can be different but without
35 #    specifying which JS engine to use.
36 # To enable JIT in Android's JSC, please set ENABLE_JSC_JIT environment
37 # variable to true.
38
39 # Read JS_ENGINE environment variable
40 JAVASCRIPT_ENGINE = $(JS_ENGINE)
41
42 ifneq ($(JAVASCRIPT_ENGINE),jsc)
43   ifneq ($(JAVASCRIPT_ENGINE),v8)
44     # No JS engine is specified, pickup the one we want as default.
45     ifeq ($(USE_ALT_JS_ENGINE),true)
46       JAVASCRIPT_ENGINE = v8
47     else
48       JAVASCRIPT_ENGINE = jsc
49     endif
50   endif
51 endif
52
53 BASE_PATH := $(call my-dir)
54 include $(CLEAR_VARS)
55
56 # Define our module and find the intermediates directory
57 LOCAL_MODULE := libwebcore
58 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
59 base_intermediates := $(call local-intermediates-dir)
60
61 # Using := here prevents recursive expansion
62 WEBKIT_SRC_FILES :=
63
64 # We have to use bison 2.3
65 include $(BASE_PATH)/bison_check.mk
66
67 # Build our list of include paths. We include Source/WebKit/android/icu first so that
68 # any files that include <unicode/ucnv.h> will include our ucnv.h first. We
69 # also add external/ as an include directory so that we can specify the real
70 # icu header directory as a more exact reference to avoid including our ucnv.h.
71 #
72 # Note that JavasCriptCore/ must be included after WebCore/, so that we pick up
73 # the right config.h.
74 LOCAL_C_INCLUDES := \
75         $(JNI_H_INCLUDE) \
76         $(LOCAL_PATH)/Source/WebKit/android/icu \
77         external/ \
78         external/icu4c/common \
79         external/icu4c/i18n \
80         external/libxml2/include \
81         external/skia/emoji \
82         external/skia/include/core \
83         external/skia/include/effects \
84         external/skia/include/images \
85         external/skia/include/ports \
86         external/skia/include/utils \
87         external/skia/src/ports \
88         external/sqlite/dist \
89         frameworks/base/core/jni/android/graphics
90
91 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
92         $(LOCAL_PATH)/Source/WebCore \
93         $(LOCAL_PATH)/Source/WebCore/accessibility \
94         $(LOCAL_PATH)/Source/WebCore/bindings/generic \
95         $(LOCAL_PATH)/Source/WebCore/css \
96         $(LOCAL_PATH)/Source/WebCore/dom \
97         $(LOCAL_PATH)/Source/WebCore/editing \
98         $(LOCAL_PATH)/Source/WebCore/history \
99         $(LOCAL_PATH)/Source/WebCore/history/android \
100         $(LOCAL_PATH)/Source/WebCore/html \
101         $(LOCAL_PATH)/Source/WebCore/html/canvas \
102         $(LOCAL_PATH)/Source/WebCore/inspector \
103         $(LOCAL_PATH)/Source/WebCore/loader \
104         $(LOCAL_PATH)/Source/WebCore/loader/appcache \
105         $(LOCAL_PATH)/Source/WebCore/loader/icon \
106         $(LOCAL_PATH)/Source/WebCore/notifications \
107         $(LOCAL_PATH)/Source/WebCore/page \
108         $(LOCAL_PATH)/Source/WebCore/page/android \
109         $(LOCAL_PATH)/Source/WebCore/page/animation \
110         $(LOCAL_PATH)/Source/WebCore/platform \
111         $(LOCAL_PATH)/Source/WebCore/platform/android \
112         $(LOCAL_PATH)/Source/WebCore/platform/animation \
113         $(LOCAL_PATH)/Source/WebCore/platform/graphics \
114         $(LOCAL_PATH)/Source/WebCore/platform/graphics/android \
115         $(LOCAL_PATH)/Source/WebCore/platform/graphics/network \
116         $(LOCAL_PATH)/Source/WebCore/platform/graphics/skia \
117         $(LOCAL_PATH)/Source/WebCore/platform/graphics/transforms \
118         $(LOCAL_PATH)/Source/WebCore/platform/image-decoders \
119         $(LOCAL_PATH)/Source/WebCore/platform/mock \
120         $(LOCAL_PATH)/Source/WebCore/platform/network \
121         $(LOCAL_PATH)/Source/WebCore/platform/network/android \
122         $(LOCAL_PATH)/Source/WebCore/platform/sql \
123         $(LOCAL_PATH)/Source/WebCore/platform/text \
124         $(LOCAL_PATH)/Source/WebCore/plugins \
125         $(LOCAL_PATH)/Source/WebCore/plugins/android \
126         $(LOCAL_PATH)/Source/WebCore/rendering \
127         $(LOCAL_PATH)/Source/WebCore/rendering/style \
128         $(LOCAL_PATH)/Source/WebCore/storage \
129         $(LOCAL_PATH)/Source/WebCore/workers \
130         $(LOCAL_PATH)/Source/WebCore/xml
131
132 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
133         $(LOCAL_PATH)/Source/WebKit/android \
134         $(LOCAL_PATH)/Source/WebKit/android/WebCoreSupport \
135         $(LOCAL_PATH)/Source/WebKit/android/jni \
136         $(LOCAL_PATH)/Source/WebKit/android/nav \
137         $(LOCAL_PATH)/Source/WebKit/android/plugins \
138         $(LOCAL_PATH)/Source/WebKit/android/stl
139
140 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
141         $(LOCAL_PATH)/Source/JavaScriptCore \
142         $(LOCAL_PATH)/Source/JavaScriptCore/wtf \
143         $(LOCAL_PATH)/Source/JavaScriptCore/wtf/unicode \
144         $(LOCAL_PATH)/Source/JavaScriptCore/wtf/unicode/icu
145
146 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
147         $(base_intermediates)/Source/WebCore/ \
148         $(base_intermediates)/Source/WebCore/css \
149         $(base_intermediates)/Source/WebCore/html \
150         $(base_intermediates)/Source/WebCore/platform
151
152 ifeq ($(ENABLE_SVG), true)
153 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
154         $(LOCAL_PATH)/Source/WebCore/platform/graphics/filters \
155         $(LOCAL_PATH)/Source/WebCore/svg \
156         $(LOCAL_PATH)/Source/WebCore/svg/animation \
157         $(LOCAL_PATH)/Source/WebCore/svg/graphics \
158         $(LOCAL_PATH)/Source/WebCore/svg/graphics/filters \
159         $(base_intermediates)/Source/WebCore/svg
160 endif
161
162 ifeq ($(JAVASCRIPT_ENGINE),v8)
163 # Include WTF source file.
164 d := Source/JavaScriptCore
165 LOCAL_PATH := $(BASE_PATH)/$d
166 intermediates := $(base_intermediates)/$d
167 include $(LOCAL_PATH)/Android.v8.wtf.mk
168 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
169 endif  # JAVASCRIPT_ENGINE == v8
170
171 # Include source files for WebCore
172 d := WebCore
173 LOCAL_PATH := $(BASE_PATH)/$d
174 JAVASCRIPTCORE_PATH := $(BASE_PATH)/Source/JavaScriptCore
175 intermediates := $(base_intermediates)/$d
176 include $(LOCAL_PATH)/Android.mk
177 ifeq ($(JAVASCRIPT_ENGINE),jsc)
178 include $(LOCAL_PATH)/Android.jscbindings.mk
179 endif
180 ifeq ($(JAVASCRIPT_ENGINE),v8)
181 include $(LOCAL_PATH)/Android.v8bindings.mk
182 endif
183 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
184 LOCAL_C_INCLUDES += $(BINDING_C_INCLUDES)
185
186 # Include the derived source files for WebCore. Uses the same path as
187 # WebCore
188 include $(LOCAL_PATH)/Android.derived.mk
189 ifeq ($(JAVASCRIPT_ENGINE),jsc)
190 include $(LOCAL_PATH)/Android.derived.jscbindings.mk
191 endif
192 ifeq ($(JAVASCRIPT_ENGINE),v8)
193 include $(LOCAL_PATH)/Android.derived.v8bindings.mk
194 endif
195
196 # Redefine LOCAL_PATH here so the build system is not confused
197 LOCAL_PATH := $(BASE_PATH)
198
199 # Define our compiler flags
200 LOCAL_CFLAGS += -Wno-endif-labels -Wno-import -Wno-format
201 LOCAL_CFLAGS += -fno-strict-aliasing
202 LOCAL_CFLAGS += -include "WebCorePrefix.h"
203 LOCAL_CFLAGS += -fvisibility=hidden
204
205 # Enable JSC JIT if JSC is used and ENABLE_JSC_JIT environment
206 # variable is set to true
207 ifeq ($(JAVASCRIPT_ENGINE),jsc)
208 ifeq ($(ENABLE_JSC_JIT),true)
209 LOCAL_CFLAGS += -DENABLE_ANDROID_JSC_JIT=1
210 endif
211 endif
212
213 ifeq ($(TARGET_ARCH),arm)
214 LOCAL_CFLAGS += -Darm
215 endif
216
217 ifeq ($(ENABLE_SVG),true)
218 LOCAL_CFLAGS += -DENABLE_SVG=1
219 endif
220
221 # Temporary disable SVG_ANIMATION.
222 ifeq ($(ENABLE_SVG_ANIMATION),true)
223 LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1
224 endif
225
226 ifeq ($(WEBCORE_INSTRUMENTATION),true)
227 LOCAL_CFLAGS += -DANDROID_INSTRUMENT
228 endif
229
230 # LOCAL_LDLIBS is used in simulator builds only and simulator builds are only
231 # valid on Linux
232 LOCAL_LDLIBS += -lpthread -ldl
233
234 # Build the list of shared libraries
235 LOCAL_SHARED_LIBRARIES := \
236         libandroid_runtime \
237         libnativehelper \
238         libsqlite \
239         libskia \
240         libutils \
241         libui \
242         libcutils \
243         libicuuc \
244         libicudata \
245         libicui18n \
246         libmedia
247
248 ifeq ($(WEBCORE_INSTRUMENTATION),true)
249 LOCAL_SHARED_LIBRARIES += libhardware_legacy
250 endif
251
252 # We have to use the android version of libdl when we are not on the simulator
253 ifneq ($(TARGET_SIMULATOR),true)
254 LOCAL_SHARED_LIBRARIES += libdl
255 endif
256
257 # Build the list of static libraries
258 LOCAL_STATIC_LIBRARIES := libxml2
259 ifeq ($(JAVASCRIPT_ENGINE),v8)
260 LOCAL_STATIC_LIBRARIES += libv8
261 endif
262
263 # Redefine LOCAL_SRC_FILES to be all the WebKit source files
264 LOCAL_SRC_FILES := $(WEBKIT_SRC_FILES)
265
266 # Define this for use in other makefiles.
267 WEBKIT_C_INCLUDES := $(LOCAL_C_INCLUDES)
268 WEBKIT_CFLAGS := $(LOCAL_CFLAGS)
269 WEBKIT_GENERATED_SOURCES := $(LOCAL_GENERATED_SOURCES)
270 WEBKIT_LDLIBS := $(LOCAL_LDLIBS)
271 WEBKIT_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
272 WEBKIT_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES)
273
274 # Build the library all at once
275 include $(BUILD_STATIC_LIBRARY)
276
277 ifeq ($(JAVASCRIPT_ENGINE),jsc)
278 # Now build libjs as a static library.
279 include $(CLEAR_VARS)
280 LOCAL_MODULE := libjs
281 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
282 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
283 LOCAL_STATIC_LIBRARIES := $(WEBKIT_STATIC_LIBRARIES)
284 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
285 # Include source files for JavaScriptCore
286 d := Source/JavaScriptCore
287 LOCAL_PATH := $(BASE_PATH)/$d
288 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
289 # Cannot use base_intermediates as this is a new module
290 intermediates := $(call local-intermediates-dir)
291 include $(LOCAL_PATH)/Android.mk
292 # Redefine LOCAL_SRC_FILES with the correct prefix
293 LOCAL_SRC_FILES := $(addprefix $d/,$(LOCAL_SRC_FILES))
294 # Use the base path to resolve file names
295 LOCAL_PATH := $(BASE_PATH)
296 # Append jsc intermediate include paths to the WebKit include list.
297 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES) \
298         $(intermediates) \
299         $(intermediates)/parser \
300         $(intermediates)/runtime \
301 # Build libjs
302 include $(BUILD_STATIC_LIBRARY)
303 endif  # JAVASCRIPT_ENGINE == jsc
304
305 # Now build the shared library using only the exported jni entry point. This
306 # will strip out any unused code from the entry point.
307 include $(CLEAR_VARS)
308 # if you need to make webcore huge (for debugging), enable this line
309 #LOCAL_PRELINK_MODULE := false
310 LOCAL_MODULE := libwebcore
311 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
312 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
313 LOCAL_STATIC_LIBRARIES := libwebcore $(WEBKIT_STATIC_LIBRARIES)
314 ifeq ($(JAVASCRIPT_ENGINE),jsc)
315 LOCAL_STATIC_LIBRARIES += libjs
316 endif
317 LOCAL_LDFLAGS := -fvisibility=hidden
318 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
319 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES)
320 LOCAL_PATH := $(BASE_PATH)
321 include $(BUILD_SHARED_LIBRARY)