2009-12-08 Steve Block <steveblock@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
37 # Read JS_ENGINE environment variable
38 JAVASCRIPT_ENGINE = $(JS_ENGINE)
39
40 ifneq ($(JAVASCRIPT_ENGINE),jsc)
41   ifneq ($(JAVASCRIPT_ENGINE),v8)
42     # No JS engine is specified, pickup the one we want as default.
43     ifeq ($(USE_ALT_JS_ENGINE),true)
44       JAVASCRIPT_ENGINE = v8
45     else
46       JAVASCRIPT_ENGINE = jsc
47     endif
48   endif
49 endif
50
51 BASE_PATH := $(call my-dir)
52 include $(CLEAR_VARS)
53
54 # Define our module and find the intermediates directory
55 LOCAL_MODULE := libwebcore
56 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
57 base_intermediates := $(call local-intermediates-dir)
58
59 # Using := here prevents recursive expansion
60 WEBKIT_SRC_FILES :=
61
62 # We have to use bison 2.3
63 include $(BASE_PATH)/bison_check.mk
64
65 ifeq ($(JAVASCRIPT_ENGINE),v8)
66 d := V8Binding
67 LOCAL_PATH := $(BASE_PATH)/$d
68 WEBCORE_PATH := $(BASE_PATH)/WebCore
69 intermediates := $(base_intermediates)/WebCore
70 JAVASCRIPTCORE_PATH := $(BASE_PATH)/JavaScriptCore
71 include $(LOCAL_PATH)/V8Binding.derived.mk
72 WEBKIT_SRC_FILES += $(addprefix $d/, $(LOCAL_SRC_FILES))
73 WEBKIT_SRC_FILES += $(addprefix WebCore/, $(WEBCORE_SRC_FILES))
74
75 # Include WTF source file.
76 d := JavaScriptCore
77 LOCAL_PATH := $(BASE_PATH)/$d
78 intermediates := $(base_intermediates)/$d
79 include $(LOCAL_PATH)/Android.v8.wtf.mk
80 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
81 endif  # JAVASCRIPT_ENGINE == v8
82
83 # Include source files for WebCore
84 d := WebCore
85 LOCAL_PATH := $(BASE_PATH)/$d
86 intermediates := $(base_intermediates)/$d
87 include $(LOCAL_PATH)/Android.mk
88 ifeq ($(JAVASCRIPT_ENGINE),jsc)
89 include $(LOCAL_PATH)/Android.jscbindings.mk
90 endif
91 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
92
93 # Include the derived source files for WebCore. Uses the same path as
94 # WebCore
95 include $(LOCAL_PATH)/Android.derived.mk
96 ifeq ($(JAVASCRIPT_ENGINE),jsc)
97 include $(LOCAL_PATH)/Android.derived.jscbindings.mk
98 endif
99 WEBKIT_SRC_FILES += $(addprefix $d/,$(LOCAL_SRC_FILES))
100
101 # Redefine LOCAL_PATH here so the build system is not confused
102 LOCAL_PATH := $(BASE_PATH)
103
104 # Define our compiler flags
105 LOCAL_CFLAGS += -Wno-endif-labels -Wno-import -Wno-format
106 LOCAL_CFLAGS += -fno-strict-aliasing
107 LOCAL_CFLAGS += -include "WebCorePrefix.h"
108 LOCAL_CFLAGS += -fvisibility=hidden
109
110 ifeq ($(TARGET_ARCH),arm)
111 LOCAL_CFLAGS += -Darm
112 endif
113
114 ifeq ($(ENABLE_SVG),true)
115 LOCAL_CFLAGS += -DENABLE_SVG=1
116 endif
117
118 # Temporary disable SVG_ANIMATION.
119 ifeq ($(ENABLE_SVG_ANIMATION),true)
120 LOCAL_CFLAGS += -DENABLE_SVG_ANIMATION=1
121 endif
122
123 ifeq ($(WEBCORE_INSTRUMENTATION),true)
124 LOCAL_CFLAGS += -DANDROID_INSTRUMENT
125 endif
126
127 # LOCAL_LDLIBS is used in simulator builds only and simulator builds are only
128 # valid on Linux
129 LOCAL_LDLIBS += -lpthread -ldl
130
131 # Build our list of include paths. We include WebKit/android/icu first so that
132 # any files that include <unicode/ucnv.h> will include our ucnv.h first. We
133 # also add external/ as an include directory so that we can specify the real
134 # icu header directory as a more exact reference to avoid including our ucnv.h.
135 LOCAL_C_INCLUDES := \
136         $(JNI_H_INCLUDE) \
137         $(LOCAL_PATH)/WebKit/android/icu \
138         external/ \
139         external/icu4c/common \
140         external/icu4c/i18n \
141         external/libxml2/include \
142         external/skia/emoji \
143         external/skia/include/core \
144         external/skia/include/effects \
145         external/skia/include/images \
146         external/skia/include/ports \
147         external/skia/include/utils \
148         external/skia/src/ports \
149         external/sqlite/dist \
150         frameworks/base/core/jni/android/graphics
151 ifeq ($(JAVASCRIPT_ENGINE),v8)
152 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
153         external/v8/include
154 endif
155
156 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
157         $(LOCAL_PATH)/WebCore \
158         $(LOCAL_PATH)/WebCore/accessibility \
159         $(LOCAL_PATH)/WebCore/css \
160         $(LOCAL_PATH)/WebCore/dom \
161         $(LOCAL_PATH)/WebCore/editing \
162         $(LOCAL_PATH)/WebCore/history \
163         $(LOCAL_PATH)/WebCore/html \
164         $(LOCAL_PATH)/WebCore/html/canvas \
165         $(LOCAL_PATH)/WebCore/inspector \
166         $(LOCAL_PATH)/WebCore/loader \
167         $(LOCAL_PATH)/WebCore/loader/appcache \
168         $(LOCAL_PATH)/WebCore/loader/icon \
169         $(LOCAL_PATH)/WebCore/notifications \
170         $(LOCAL_PATH)/WebCore/page \
171         $(LOCAL_PATH)/WebCore/page/android \
172         $(LOCAL_PATH)/WebCore/page/animation \
173         $(LOCAL_PATH)/WebCore/platform \
174         $(LOCAL_PATH)/WebCore/platform/android \
175         $(LOCAL_PATH)/WebCore/platform/animation \
176         $(LOCAL_PATH)/WebCore/platform/graphics \
177         $(LOCAL_PATH)/WebCore/platform/graphics/android \
178         $(LOCAL_PATH)/WebCore/platform/graphics/network \
179         $(LOCAL_PATH)/WebCore/platform/graphics/skia \
180         $(LOCAL_PATH)/WebCore/platform/graphics/transforms \
181         $(LOCAL_PATH)/WebCore/platform/image-decoders \
182         $(LOCAL_PATH)/WebCore/platform/mock \
183         $(LOCAL_PATH)/WebCore/platform/network \
184         $(LOCAL_PATH)/WebCore/platform/network/android \
185         $(LOCAL_PATH)/WebCore/platform/sql \
186         $(LOCAL_PATH)/WebCore/platform/text \
187         $(LOCAL_PATH)/WebCore/plugins \
188         $(LOCAL_PATH)/WebCore/plugins/android \
189         $(LOCAL_PATH)/WebCore/rendering \
190         $(LOCAL_PATH)/WebCore/rendering/style \
191         $(LOCAL_PATH)/WebCore/storage \
192         $(LOCAL_PATH)/WebCore/workers \
193         $(LOCAL_PATH)/WebCore/xml
194 ifeq ($(JAVASCRIPT_ENGINE),jsc)
195 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
196         $(LOCAL_PATH)/WebCore/bindings/js \
197         $(LOCAL_PATH)/WebCore/bridge \
198         $(LOCAL_PATH)/WebCore/bridge/c \
199         $(LOCAL_PATH)/WebCore/bridge/jni
200 endif
201
202 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
203         $(LOCAL_PATH)/WebKit/android \
204         $(LOCAL_PATH)/WebKit/android/WebCoreSupport \
205         $(LOCAL_PATH)/WebKit/android/jni \
206         $(LOCAL_PATH)/WebKit/android/nav \
207         $(LOCAL_PATH)/WebKit/android/plugins \
208         $(LOCAL_PATH)/WebKit/android/stl
209
210 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
211         $(LOCAL_PATH)/JavaScriptCore/wtf \
212         $(LOCAL_PATH)/JavaScriptCore/wtf/unicode \
213         $(LOCAL_PATH)/JavaScriptCore/wtf/unicode/icu
214 ifeq ($(JAVASCRIPT_ENGINE),jsc)
215 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
216         $(LOCAL_PATH)/JavaScriptCore \
217         $(LOCAL_PATH)/JavaScriptCore/API \
218         $(LOCAL_PATH)/JavaScriptCore/assembler \
219         $(LOCAL_PATH)/JavaScriptCore/bytecode \
220         $(LOCAL_PATH)/JavaScriptCore/bytecompiler \
221         $(LOCAL_PATH)/JavaScriptCore/debugger \
222         $(LOCAL_PATH)/JavaScriptCore/parser \
223         $(LOCAL_PATH)/JavaScriptCore/jit \
224         $(LOCAL_PATH)/JavaScriptCore/interpreter \
225         $(LOCAL_PATH)/JavaScriptCore/pcre \
226         $(LOCAL_PATH)/JavaScriptCore/profiler \
227         $(LOCAL_PATH)/JavaScriptCore/runtime \
228         $(LOCAL_PATH)/JavaScriptCore/wrec \
229         $(LOCAL_PATH)/JavaScriptCore/ForwardingHeaders
230 endif
231
232 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
233         $(base_intermediates)/WebCore/ \
234         $(base_intermediates)/WebCore/css \
235         $(base_intermediates)/WebCore/html \
236         $(base_intermediates)/WebCore/platform
237 ifeq ($(JAVASCRIPT_ENGINE),jsc)
238 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
239         $(base_intermediates)/WebCore/bindings/js \
240         $(base_intermediates)/WebCore/dom \
241         $(base_intermediates)/WebCore/html/canvas \
242         $(base_intermediates)/WebCore/inspector \
243         $(base_intermediates)/WebCore/loader/appcache \
244         $(base_intermediates)/WebCore/page \
245         $(base_intermediates)/WebCore/plugins \
246         $(base_intermediates)/WebCore/storage \
247         $(base_intermediates)/WebCore/workers \
248         $(base_intermediates)/WebCore/xml
249 endif
250 ifeq ($(JAVASCRIPT_ENGINE),v8)
251 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
252         $(base_intermediates)/WebCore/bindings \
253         $(base_intermediates)/JavaScriptCore
254 endif
255
256 ifeq ($(JAVASCRIPT_ENGINE),v8)
257 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
258         $(BINDING_C_INCLUDES)
259 endif
260
261 ifeq ($(ENABLE_SVG), true)
262 LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES) \
263         $(LOCAL_PATH)/WebCore/platform/graphics/filters \
264         $(LOCAL_PATH)/WebCore/svg \
265         $(LOCAL_PATH)/WebCore/svg/animation \
266         $(LOCAL_PATH)/WebCore/svg/graphics \
267         $(LOCAL_PATH)/WebCore/svg/graphics/filters \
268         $(base_intermediates)/WebCore/svg
269 endif
270
271 # Build the list of shared libraries
272 LOCAL_SHARED_LIBRARIES := \
273         libandroid_runtime \
274         libnativehelper \
275         libsqlite \
276         libskia \
277         libutils \
278         libui \
279         libcutils \
280         libicuuc \
281         libicudata \
282         libicui18n \
283         libmedia
284
285 ifeq ($(WEBCORE_INSTRUMENTATION),true)
286 LOCAL_SHARED_LIBRARIES += libhardware_legacy
287 endif
288
289 # We have to use the android version of libdl when we are not on the simulator
290 ifneq ($(TARGET_SIMULATOR),true)
291 LOCAL_SHARED_LIBRARIES += libdl
292 endif
293
294 # Build the list of static libraries
295 LOCAL_STATIC_LIBRARIES := libxml2
296 ifeq ($(JAVASCRIPT_ENGINE),v8)
297 LOCAL_STATIC_LIBRARIES += libv8
298 endif
299
300 # Redefine LOCAL_SRC_FILES to be all the WebKit source files
301 LOCAL_SRC_FILES := $(WEBKIT_SRC_FILES)
302
303 # Define this for use in other makefiles.
304 WEBKIT_C_INCLUDES := $(LOCAL_C_INCLUDES)
305 WEBKIT_CFLAGS := $(LOCAL_CFLAGS)
306 WEBKIT_GENERATED_SOURCES := $(LOCAL_GENERATED_SOURCES)
307 WEBKIT_LDLIBS := $(LOCAL_LDLIBS)
308 WEBKIT_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
309 WEBKIT_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES)
310
311 # Build the library all at once
312 include $(BUILD_STATIC_LIBRARY)
313
314 ifeq ($(JAVASCRIPT_ENGINE),jsc)
315 # Now build libjs as a static library.
316 include $(CLEAR_VARS)
317 LOCAL_MODULE := libjs
318 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
319 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
320 LOCAL_STATIC_LIBRARIES := $(WEBKIT_STATIC_LIBRARIES)
321 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
322 # Include source files for JavaScriptCore
323 d := JavaScriptCore
324 LOCAL_PATH := $(BASE_PATH)/$d
325 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
326 # Cannot use base_intermediates as this is a new module
327 intermediates := $(call local-intermediates-dir)
328 include $(LOCAL_PATH)/Android.mk
329 # Redefine LOCAL_SRC_FILES with the correct prefix
330 LOCAL_SRC_FILES := $(addprefix $d/,$(LOCAL_SRC_FILES))
331 # Use the base path to resolve file names
332 LOCAL_PATH := $(BASE_PATH)
333 # Append jsc intermediate include paths to the WebKit include list.
334 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES) \
335         $(intermediates) \
336         $(intermediates)/parser \
337         $(intermediates)/runtime \
338 # Build libjs
339 include $(BUILD_STATIC_LIBRARY)
340 endif  # JAVASCRIPT_ENGINE == jsc
341
342 # Now build the shared library using only the exported jni entry point. This
343 # will strip out any unused code from the entry point.
344 include $(CLEAR_VARS)
345 # if you need to make webcore huge (for debugging), enable this line
346 #LOCAL_PRELINK_MODULE := false
347 LOCAL_MODULE := libwebcore
348 LOCAL_LDLIBS := $(WEBKIT_LDLIBS)
349 LOCAL_SHARED_LIBRARIES := $(WEBKIT_SHARED_LIBRARIES)
350 LOCAL_STATIC_LIBRARIES := libwebcore $(WEBKIT_STATIC_LIBRARIES)
351 ifeq ($(JAVASCRIPT_ENGINE),jsc)
352 LOCAL_STATIC_LIBRARIES += libjs
353 endif
354 LOCAL_LDFLAGS := -fvisibility=hidden
355 LOCAL_CFLAGS := $(WEBKIT_CFLAGS)
356 LOCAL_C_INCLUDES := $(WEBKIT_C_INCLUDES)
357 LOCAL_PATH := $(BASE_PATH)
358 include $(BUILD_SHARED_LIBRARY)