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