2010-02-23 Arno Renevier <arno@renevier.net>
[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 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)/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)/WebCore \
93         $(LOCAL_PATH)/WebCore/accessibility \
94         $(LOCAL_PATH)/WebCore/css \
95         $(LOCAL_PATH)/WebCore/dom \
96         $(LOCAL_PATH)/WebCore/editing \
97         $(LOCAL_PATH)/WebCore/history \
98         $(LOCAL_PATH)/WebCore/history/android \
99         $(LOCAL_PATH)/WebCore/html \
100         $(LOCAL_PATH)/WebCore/html/canvas \
101         $(LOCAL_PATH)/WebCore/inspector \
102         $(LOCAL_PATH)/WebCore/loader \
103         $(LOCAL_PATH)/WebCore/loader/appcache \
104         $(LOCAL_PATH)/WebCore/loader/icon \
105         $(LOCAL_PATH)/WebCore/notifications \
106         $(LOCAL_PATH)/WebCore/page \
107         $(LOCAL_PATH)/WebCore/page/android \
108         $(LOCAL_PATH)/WebCore/page/animation \
109         $(LOCAL_PATH)/WebCore/platform \
110         $(LOCAL_PATH)/WebCore/platform/android \
111         $(LOCAL_PATH)/WebCore/platform/animation \
112         $(LOCAL_PATH)/WebCore/platform/graphics \
113         $(LOCAL_PATH)/WebCore/platform/graphics/android \
114         $(LOCAL_PATH)/WebCore/platform/graphics/network \
115         $(LOCAL_PATH)/WebCore/platform/graphics/skia \
116         $(LOCAL_PATH)/WebCore/platform/graphics/transforms \
117         $(LOCAL_PATH)/WebCore/platform/image-decoders \
118         $(LOCAL_PATH)/WebCore/platform/mock \
119         $(LOCAL_PATH)/WebCore/platform/network \
120         $(LOCAL_PATH)/WebCore/platform/network/android \
121         $(LOCAL_PATH)/WebCore/platform/sql \
122         $(LOCAL_PATH)/WebCore/platform/text \
123         $(LOCAL_PATH)/WebCore/plugins \
124         $(LOCAL_PATH)/WebCore/plugins/android \
125         $(LOCAL_PATH)/WebCore/rendering \
126         $(LOCAL_PATH)/WebCore/rendering/style \
127         $(LOCAL_PATH)/WebCore/storage \
128         $(LOCAL_PATH)/WebCore/workers \
129         $(LOCAL_PATH)/WebCore/xml
130
131 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
132         $(LOCAL_PATH)/WebKit/android \
133         $(LOCAL_PATH)/WebKit/android/WebCoreSupport \
134         $(LOCAL_PATH)/WebKit/android/jni \
135         $(LOCAL_PATH)/WebKit/android/nav \
136         $(LOCAL_PATH)/WebKit/android/plugins \
137         $(LOCAL_PATH)/WebKit/android/stl
138
139 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
140         $(LOCAL_PATH)/JavaScriptCore \
141         $(LOCAL_PATH)/JavaScriptCore/wtf \
142         $(LOCAL_PATH)/JavaScriptCore/wtf/unicode \
143         $(LOCAL_PATH)/JavaScriptCore/wtf/unicode/icu
144
145 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
146         $(base_intermediates)/WebCore/ \
147         $(base_intermediates)/WebCore/css \
148         $(base_intermediates)/WebCore/html \
149         $(base_intermediates)/WebCore/platform
150
151 ifeq ($(ENABLE_SVG), true)
152 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
153         $(LOCAL_PATH)/WebCore/platform/graphics/filters \
154         $(LOCAL_PATH)/WebCore/svg \
155         $(LOCAL_PATH)/WebCore/svg/animation \
156         $(LOCAL_PATH)/WebCore/svg/graphics \
157         $(LOCAL_PATH)/WebCore/svg/graphics/filters \
158         $(base_intermediates)/WebCore/svg
159 endif
160
161 ifeq ($(JAVASCRIPT_ENGINE),v8)
162 # Include WTF source file.
163 d := JavaScriptCore
164 LOCAL_PATH := $(BASE_PATH)/$d
165 intermediates := $(base_intermediates)/$d
166 include $(LOCAL_PATH)/Android.v8.wtf.mk
167 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
168 endif  # JAVASCRIPT_ENGINE == v8
169
170 # Include source files for WebCore
171 d := WebCore
172 LOCAL_PATH := $(BASE_PATH)/$d
173 JAVASCRIPTCORE_PATH := $(BASE_PATH)/JavaScriptCore
174 intermediates := $(base_intermediates)/$d
175 include $(LOCAL_PATH)/Android.mk
176 ifeq ($(JAVASCRIPT_ENGINE),jsc)
177 include $(LOCAL_PATH)/Android.jscbindings.mk
178 endif
179 ifeq ($(JAVASCRIPT_ENGINE),v8)
180 include $(LOCAL_PATH)/Android.v8bindings.mk
181 endif
182 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
183 LOCAL_C_INCLUDES += $(BINDING_C_INCLUDES)
184
185 # Include the derived source files for WebCore. Uses the same path as
186 # WebCore
187 include $(LOCAL_PATH)/Android.derived.mk
188 ifeq ($(JAVASCRIPT_ENGINE),jsc)
189 include $(LOCAL_PATH)/Android.derived.jscbindings.mk
190 endif
191 ifeq ($(JAVASCRIPT_ENGINE),v8)
192 include $(LOCAL_PATH)/Android.derived.v8bindings.mk
193 endif
194
195 # Redefine LOCAL_PATH here so the build system is not confused
196 LOCAL_PATH := $(BASE_PATH)
197
198 # Define our compiler flags
199 LOCAL_CFLAGS += -Wno-endif-labels -Wno-import -Wno-format
200 LOCAL_CFLAGS += -fno-strict-aliasing
201 LOCAL_CFLAGS += -include "WebCorePrefix.h"
202 LOCAL_CFLAGS += -fvisibility=hidden
203
204 # Enable JSC JIT if JSC is used and ENABLE_JSC_JIT environment
205 # variable is set to true
206 ifeq ($(JAVASCRIPT_ENGINE),jsc)
207 ifeq ($(ENABLE_JSC_JIT),true)
208 LOCAL_CFLAGS += -DENABLE_ANDROID_JSC_JIT=1
209 endif
210 endif
211
212 ifeq ($(TARGET_ARCH),arm)
213 LOCAL_CFLAGS += -Darm
214 endif
215
216 ifeq ($(ENABLE_SVG),true)
217 LOCAL_CFLAGS += -DENABLE_SVG=1
218 endif
219
220 # Temporary disable SVG_ANIMATION.
221 ifeq ($(ENABLE_SVG_ANIMATION),true)
222 LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1
223 endif
224
225 ifeq ($(WEBCORE_INSTRUMENTATION),true)
226 LOCAL_CFLAGS += -DANDROID_INSTRUMENT
227 endif
228
229 # LOCAL_LDLIBS is used in simulator builds only and simulator builds are only
230 # valid on Linux
231 LOCAL_LDLIBS += -lpthread -ldl
232
233 # Build the list of shared libraries
234 LOCAL_SHARED_LIBRARIES := \
235         libandroid_runtime \
236         libnativehelper \
237         libsqlite \
238         libskia \
239         libutils \
240         libui \
241         libcutils \
242         libicuuc \
243         libicudata \
244         libicui18n \
245         libmedia
246
247 ifeq ($(WEBCORE_INSTRUMENTATION),true)
248 LOCAL_SHARED_LIBRARIES += libhardware_legacy
249 endif
250
251 # We have to use the android version of libdl when we are not on the simulator
252 ifneq ($(TARGET_SIMULATOR),true)
253 LOCAL_SHARED_LIBRARIES += libdl
254 endif
255
256 # Build the list of static libraries
257 LOCAL_STATIC_LIBRARIES := libxml2
258 ifeq ($(JAVASCRIPT_ENGINE),v8)
259 LOCAL_STATIC_LIBRARIES += libv8
260 endif
261
262 # Redefine LOCAL_SRC_FILES to be all the WebKit source files
263 LOCAL_SRC_FILES := $(WEBKIT_SRC_FILES)
264
265 # Define this for use in other makefiles.
266 WEBKIT_C_INCLUDES := $(LOCAL_C_INCLUDES)
267 WEBKIT_CFLAGS := $(LOCAL_CFLAGS)
268 WEBKIT_GENERATED_SOURCES := $(LOCAL_GENERATED_SOURCES)
269 WEBKIT_LDLIBS := $(LOCAL_LDLIBS)
270 WEBKIT_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
271 WEBKIT_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES)
272
273 # Build the library all at once
274 include $(BUILD_STATIC_LIBRARY)
275
276 ifeq ($(JAVASCRIPT_ENGINE),jsc)
277 # Now build libjs as a static library.
278 include $(CLEAR_VARS)
279 LOCAL_MODULE := libjs
280 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
281 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
282 LOCAL_STATIC_LIBRARIES := $(WEBKIT_STATIC_LIBRARIES)
283 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
284 # Include source files for JavaScriptCore
285 d := JavaScriptCore
286 LOCAL_PATH := $(BASE_PATH)/$d
287 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
288 # Cannot use base_intermediates as this is a new module
289 intermediates := $(call local-intermediates-dir)
290 include $(LOCAL_PATH)/Android.mk
291 # Redefine LOCAL_SRC_FILES with the correct prefix
292 LOCAL_SRC_FILES := $(addprefix $d/,$(LOCAL_SRC_FILES))
293 # Use the base path to resolve file names
294 LOCAL_PATH := $(BASE_PATH)
295 # Append jsc intermediate include paths to the WebKit include list.
296 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES) \
297         $(intermediates) \
298         $(intermediates)/parser \
299         $(intermediates)/runtime \
300 # Build libjs
301 include $(BUILD_STATIC_LIBRARY)
302 endif  # JAVASCRIPT_ENGINE == jsc
303
304 # Now build the shared library using only the exported jni entry point. This
305 # will strip out any unused code from the entry point.
306 include $(CLEAR_VARS)
307 # if you need to make webcore huge (for debugging), enable this line
308 #LOCAL_PRELINK_MODULE := false
309 LOCAL_MODULE := libwebcore
310 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
311 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
312 LOCAL_STATIC_LIBRARIES := libwebcore $(WEBKIT_STATIC_LIBRARIES)
313 ifeq ($(JAVASCRIPT_ENGINE),jsc)
314 LOCAL_STATIC_LIBRARIES += libjs
315 endif
316 LOCAL_LDFLAGS := -fvisibility=hidden
317 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
318 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES)
319 LOCAL_PATH := $(BASE_PATH)
320 include $(BUILD_SHARED_LIBRARY)