Merge remote-tracking branch 'redux/master' into sh4-pool
[tamarin-stm.git] / platform / android / Makefile
blob98fdb54c9b723ce574c7e2b0921a5b1dc1e4ca32
1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
12 # License.
14 # The Original Code is [Open Source Virtual Machine.].
16 # The Initial Developer of the Original Code is
17 # Adobe System Incorporated.
18 # Portions created by the Initial Developer are Copyright (C) 2010
19 # the Initial Developer. All Rights Reserved.
21 # Contributor(s):
22 # Adobe AS3 Team
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
36 # ***** END LICENSE BLOCK ***** */
38 # Makefile for building AVM shell for Android.
40 #****************************************************************************
41 # The following Android SDK commands must be run before invoking this
42 # makefile content:
43 # the android sdk volume should be mounted to /Volumes/android
44 # cd /Volumes/android/device
45 # . build/envsetup.sh
46 # choosecombo 0 1 2 3
48 # make MAKECMDGOALS=release
49 # make MAKECMDGOALS=debug
51 #****************************************************************************
53 #****************************************************************************
54 # Targets of the build
55 #****************************************************************************
57 FINAL_TARGET := avmshell
59 # make sure this is the first (and so default) target
60 .PHONY: default_target
61 default_target:
63 #****************************************************************************
64 # Variables and includes
65 #****************************************************************************
67 ENABLE_NANOJIT := true
69 ANDROID_MAKEFILE_DIR := .
71 # from make.common
72 ifndef TARGET_ARCH
73 TARGET_ARCH := ARMV5
74 endif
76 ifndef BUILD_CONFIG
77 ifeq (${MAKECMDGOALS},release)
78 BUILD_CONFIG := Release
79 else
80 BUILD_CONFIG := Debug
81 endif
82 endif
84 # some libraries that we link with are not in the official NDK, so we need to tell the compiler line
85 # where to pick those libraries up from. We don't wan't to use this path more generally because we
86 # want to keep a clear understanding of what libraries we are using that are not part of the NDK.
87 # We do this by setting the ANDR_OUT_SYS_LIB_DIR path and then explicitly linking to non-NDK libraries
88 # using this path. This has the effect of making us require that we pick a "product" to link against
89 # even though our targets are, in spirit, supposed to represent more generic configurations.
91 ifeq (${TARGET_ARCH},ARMV7-A)
92 ARCH_CFLAGS := -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH__=7 -DARMV6_ASSEMBLY -DTARGET_NEON -DSDK_ON2_OPT -DSDK_ON2_OPT_ARM11 -DFP_ON2_USE_C_FILTERING_FUNCTIONS
93 PLATFORM_LDFLAGS := $(PLATFORM_LDFLAGS) -Wl,--fix-cortex-a8
94 INCLUDE_ARM_ASM_FILES := 1
95 HAS_OPENGL_ES2_SUPPORT := 0
96 ANDR_OUT_SYS_LIB_DIR := $(ANDROID_BUILD_TOP)/out/target/product/sholes/system/lib
97 YS_ARCH := arm7
98 else
99 ifeq (${TARGET_ARCH},ARMV6)
100 ARCH_CFLAGS := -march=armv6 -mfloat-abi=soft -D__ARM_ARCH__=6 -DARMV5_ASSEMBLY -DARMV6_ASSEMBLY
101 INCLUDE_ARM_ASM_FILES := 1
102 HAS_OPENGL_ES2_SUPPORT := 0
103 ANDR_OUT_SYS_LIB_DIR := $(ANDROID_BUILD_TOP)/out/target/product/generic/system/lib
104 YS_ARCH := arm5
105 else
106 ifeq (${TARGET_ARCH},ARMV5)
107 ARCH_CFLAGS := -march=armv5te -mfloat-abi=soft -mtune=xscale -D__ARM_ARCH__=5 -DARMV5_ASSEMBLY
108 INCLUDE_ARM_ASM_FILES := 0
109 HAS_OPENGL_ES2_SUPPORT := 0
110 ANDR_OUT_SYS_LIB_DIR := $(ANDROID_BUILD_TOP)/out/target/product/generic/system/lib
111 YS_ARCH := arm5
112 else
113 $(warning is not a supported target architecture)
114 endif
115 endif
116 endif
118 BUILD_ROOT := ./build/android
119 BUILD_RESULTS_DIR := ${BUILD_ROOT}/results/${FINAL_TARGET}/${TARGET_ARCH}/${BUILD_CONFIG}
120 BUILD_INT_ROOT := ${BUILD_ROOT}/int
121 BUILD_INT_DIR := ${BUILD_INT_ROOT}/${FINAL_TARGET}/${TARGET_ARCH}/${BUILD_CONFIG}
122 OBJDIR := ${BUILD_INT_DIR}/obj
123 LIBDIR := ${BUILD_INT_DIR}/lib
125 # warnings for both c and c++
126 # disable -Werror 2/1/2010 dschaffe
127 FLASH_C_WARNINGS := -Wall -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wpointer-arith -Wstrict-aliasing=3 -Wstrict-overflow=1 -Wwrite-strings -Wno-missing-field-initializers -Wno-type-limits -Wno-unused-parameter -Wno-clobbered
129 # additional warnings that are only for c++
130 FLASH_CXX_WARNINGS := -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo -Wstrict-null-sentinel -Wno-missing-braces -Wno-multichar -Wno-psabi -Wno-reorder -Wno-switch -Wno-invalid-offsetof
132 # re-#define ZLIB's "compress()" to "zlib_compress()" to avoid libys.a link errors
133 MMGC_DEFINES := -DAVMFEATURE_OVERRIDE_GLOBAL_NEW=0 -DRTMFPUTIL_OVERRIDE_OPERATOR_NEW
134 FLASH_DEFINES := -DANDROID -DNETSCAPE -DDISABLE_DRM -DGENERIC_PLATFORM -DHAVE_SYS_UIO_H -Dlinux -DNEEDS_IN6_H -DUNIX -Dcompress=zlib_compress $(MMGC_DEFINES)
135 ifeq (${HAS_OPENGL_ES2_SUPPORT},1)
136 FLASH_DEFINES := $(FLASH_DEFINES) -DFEATURE_GPU_ACCEL_OPENGLES2 -DFEATURE_GPU_VECTOR -DGL_GLEXT_PROTOTYPES
137 endif
139 # some cflags that are used by all Android builds as defined by Google
140 GOOGLE_COMMON_CFLAGS:= -fmessage-length=0 -fpic -fno-strict-aliasing -mlong-calls -mthumb-interwork -fsigned-char -funwind-tables -fstack-protector
142 # cflags that we use for both c and c++, and for both debug-like and release-like targets
143 FLASH_COMMON_CFLAGS := $(GOOGLE_COMMON_CFLAGS) $(FLASH_C_WARNINGS) $(FLASH_DEFINES) $(ARCH_CFLAGS) -finline-limit=200 -MD -fwrapv
145 # additional cflags that we use only for c++, but for both debug-like and release-like targets
146 FLASH_COMMON_CXXFLAGS := $(FLASH_COMMON_CFLAGS) -fno-exceptions -fno-rtti $(FLASH_CXX_WARNINGS)
148 FLASH_DEBUG_CFLAGS := -DDEBUG -D_DEBUG -DASYNC_DEBUG -O0 -ggdb3
149 FLASH_DEBUG_CXXFLAGS := $(FLASH_DEBUG_CFLAGS)
151 FLASH_RELEASE_CFLAGS := -DNDEBUG -O3 -fomit-frame-pointer -fvisibility=hidden -finline-functions -fgcse-after-reload -frerun-cse-after-loop -frename-registers
152 FLASH_RELEASE_CXXFLAGS := $(FLASH_RELEASE_CFLAGS) -fvisibility-inlines-hidden
154 # Enable RTMPE?
155 ifeq ($(DISABLE_RTMPE),1)
156 FLASH_COMMON_CXXFLAGS := $(FLASH_COMMON_CXXFLAGS) -DDISABLE_RTMPE
157 YS_LIB :=
158 else
159 # link libys.a and silence its linker warnings
160 YS_LIB := $(FLASHRUNTIME_CODE_ROOT)/third_party/yellowstone/libs/GCC-arm/$(YS_ARCH)/libys.a
161 PLATFORM_LDFLAGS := $(PLATFORM_LDFLAGS) -Wl,--no-enum-size-warning
162 endif # DISABLE_RTMPE
165 # ^^^ If any CXXFLAGS need CFLAGS flags, then combine them in the previous CXXFLAGS definitions. ^^^
166 # To simplify this code, CONFIG FLAGS should strictly use CFLAGS or CXXFLAGS, as appropriate.
168 ifeq (${BUILD_CONFIG},Debug)
169 CONFIG_CFLAGS := $(FLASH_COMMON_CFLAGS) $(FLASH_DEBUG_CFLAGS)
170 CONFIG_CXXFLAGS := $(FLASH_COMMON_CXXFLAGS) $(FLASH_DEBUG_CXXFLAGS)
171 else
172 CONFIG_CFLAGS := $(FLASH_COMMON_CFLAGS) $(FLASH_RELEASE_CFLAGS)
173 CONFIG_CXXFLAGS := $(FLASH_COMMON_CXXFLAGS) $(FLASH_RELEASE_CXXFLAGS)
174 endif
176 FLASH_CFLAGS_ARM := $(CONFIG_CFLAGS)
177 FLASH_CXXFLAGS_ARM := $(CONFIG_CXXFLAGS)
178 FLASH_CFLAGS_THUMB := $(FLASH_CFLAGS_ARM) -mthumb
179 FLASH_CXXFLAGS_THUMB := $(FLASH_CXXFLAGS_ARM) -mthumb
181 CC := $(ANDROID_EABI_TOOLCHAIN)/arm-eabi-gcc
182 AS := $(ANDROID_EABI_TOOLCHAIN)/arm-eabi-as
183 AR := $(ANDROID_EABI_TOOLCHAIN)/arm-eabi-ar
184 LD := $(ANDROID_EABI_TOOLCHAIN)/arm-eabi-ld
185 STRIP := $(ANDROID_EABI_TOOLCHAIN)/arm-eabi-strip
187 INC := -I$(ANDROID_BUILD_TOP)/bionic/libc/arch-arm/include \
188 -I$(ANDROID_BUILD_TOP)/bionic/libc/kernel/arch-arm \
189 -I$(ANDROID_BUILD_TOP)/bionic/libc/kernel/common \
190 -I$(ANDROID_BUILD_TOP)/bionic/libm/include \
191 -I$(ANDROID_BUILD_TOP)/bionic/libstdc++/include \
192 -I$(ANDROID_BUILD_TOP)/bionic/libc/include \
193 -I$(ANDROID_BUILD_TOP)/external/webkit/WebKit/android/stl \
194 -I$(ANDROID_BUILD_TOP)/external/openssl/include \
195 -I$(ANDROID_BUILD_TOP)/frameworks/base/opengl/include
197 # Link flags for a headless (command-line) application:
198 LFLAGS_HEADLESS := -nostdlib -Bdynamic \
199 -Wl,-T,$(ANDROID_BUILD_TOP)/build/core/armelf.x \
200 -Wl,-dynamic-linker,/system/bin/linker \
201 -Wl,-z,nocopyreloc \
202 -L$(ANDROID_PRODUCT_OUT)/system/lib \
203 -Wl,-rpath-link=$(ANDROID_PRODUCT_OUT)/system/lib \
204 $(ANDROID_PRODUCT_OUT)/obj/lib/crtbegin_dynamic.o \
205 $(ANDROID_PRODUCT_OUT)/obj/lib/crtend_android.o
207 # Define these to use the ctuils atomics API
208 #LFLAGS_HEADLESS := $(LFLAGS_HEADLESS) -lcutils
209 #INC := $(INC) -I$(ANDROID_BUILD_TOP)/system/core/include
211 ifndef VERBOSE
212 VERBOSE :=
213 endif
215 ifeq (${VERBOSE},)
217 # compile-files-arm function:
218 # ${1} = obj directory name
219 define compile-files-arm
220 @mkdir -p ${OBJDIR}/${1}
221 @echo C++ arm $<
222 @$(CC) $(FLASH_CXXFLAGS_ARM) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
223 endef
225 # compile-files function:
226 # ${1} = obj directory name
227 define compile-files
228 @mkdir -p ${OBJDIR}/${1}
229 @echo C++ thumb $<
230 @$(CC) $(FLASH_CXXFLAGS_THUMB) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
231 endef
233 # compile-c-files-arm function:
234 # ${1} = obj directory name
235 define compile-c-files-arm
236 @mkdir -p ${OBJDIR}/${1}
237 @echo C arm $<
238 @$(CC) $(FLASH_CFLAGS_ARM) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
239 endef
241 # compile-c-files function:
242 # ${1} = obj directory name
243 define compile-c-files
244 @mkdir -p ${OBJDIR}/${1}
245 @echo C thumb $<
246 @$(CC) $(FLASH_CFLAGS_THUMB) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
247 endef
249 # compile-asm-files function:
250 # ${1} = obj directory name
251 define compile-asm-files
252 @mkdir -p ${OBJDIR}/${1}
253 @echo asm $<
254 @$(AS) -o $@ $<
255 endef
257 else
259 define compile-files-arm
260 @echo compiling arm
261 @mkdir -p ${OBJDIR}/${1}
262 $(CC) $(FLASH_CXXFLAGS_ARM) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
263 endef
265 define compile-files
266 @mkdir -p ${OBJDIR}/${1}
267 $(CC) $(FLASH_CXXFLAGS_THUMB) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
268 endef
270 # compile-c-files-arm function:
271 # ${1} = obj directory name
272 # ${2} = *_DEFS defines
273 define compile-c-files-arm
274 @mkdir -p ${OBJDIR}/${1}
275 $(CC) $(FLASH_CFLAGS_ARM) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
276 endef
278 # compile-c-files function:
279 # ${1} = obj directory name
280 # ${2} = *_DEFS defines
281 define compile-c-files
282 @mkdir -p ${OBJDIR}/${1}
283 $(CC) $(FLASH_CFLAGS_THUMB) ${AVMSHELL_DEFS} $(INC) -o $@ -c $<
284 endef
286 # compile-asm-files function:
287 # ${1} = obj directory name
288 define compile-asm-files
289 @mkdir -p ${OBJDIR}/${1}
290 $(AS) -o $@ $<
291 endef
293 endif
295 # make-lib function:
296 # ${1} = *_OBJS files
297 define make-lib
298 @mkdir -p ${LIBDIR}
299 ${AR} -rcs $@ ${1}
300 endef # make-lib
302 # Display the state of some Makefile variables:
303 .PHONY: variables
304 variables:
305 ifeq ($(ENABLE_NANOJIT),true)
306 @echo nanojit ENabled
307 else
308 @echo nanojit DISabled
309 endif
310 ifdef SPEAK_STATUS
311 @echo Speak status ENabled
312 else
313 @echo Speak status DISabled
314 endif
316 # end make.common
318 # Modify variables set by make.common before including other makefiles:
319 INC := -I. -I.. -I../.. -I../../shell -I../../core -I../../eval -I../../MMgc -I../../pcre -I../../extensions -I../../VMPI -I../../vmbase -I../../generated -I../../other-licenses/zlib -I../../other-licenses $(INC)
321 AVMSHELL_DEFS := -DUNIX -Dlinux -DUSE_PTHREAD_MUTEX -DNO_SYS_SIGNAL -DHAVE_STDARG -DNO_CONSOLE_FWRITE -DAVMPLUS_ARM -DAVMPLUS_UNIX -DAVMSHELL_BUILD
323 ifneq ($(ENABLE_NANOJIT),true)
324 AVMSHELL_DEFS := ${AVMSHELL_DEFS} -DAVMPLUS_DISABLE_NJ
325 endif
327 include $(ANDROID_MAKEFILE_DIR)/make.avm
328 include $(ANDROID_MAKEFILE_DIR)/make.mmgc
329 include $(ANDROID_MAKEFILE_DIR)/make.zlib
331 LDFLAGS := -lc -lm -lstdc++ -lssl -lgcc
333 #****************************************************************************
334 # Shell Source files
335 #****************************************************************************
337 SHELL_SRCS := ../../shell/ConsoleOutputStream.cpp \
338 ../../shell/DebugCLI.cpp \
339 ../../shell/DomainClass.cpp \
340 ../../shell/FileClass.cpp \
341 ../../shell/FileInputStream.cpp \
342 ../../shell/PosixFile.cpp \
343 ../../shell/PosixPartialPlatform.cpp \
344 ../../shell/ShellCore.cpp \
345 ../../shell/SystemClass.cpp \
346 ../../shell/avmshell.cpp \
347 ../../shell/avmshellUnix.cpp \
348 ../../shell/swf.cpp \
349 ../../shell/../extensions/DictionaryGlue.cpp \
350 ../../shell/../extensions/JavaGlue.cpp \
351 ../../shell/../extensions/SamplerScript.cpp \
352 ../../shell/../extensions/Selftest.cpp \
353 ../../shell/../extensions/SelftestInit.cpp \
354 ../../shell/../extensions/ST_avmplus_basics.cpp \
355 ../../shell/../extensions/ST_avmplus_peephole.cpp \
356 ../../shell/../extensions/ST_mmgc_basics.cpp \
357 ../../shell/../extensions/ST_mmgc_threads.cpp \
358 ../../shell/../extensions/ST_mmgc_weakref.cpp \
359 ../../shell/../extensions/ST_mmgc_dependent.cpp \
360 ../../shell/../extensions/ST_mmgc_gcheap.cpp \
361 ../../shell/../extensions/ST_mmgc_finalize_uninit.cpp \
362 ../../shell/../extensions/ST_vmpi_threads.cpp \
363 ../../shell/../extensions/ST_mmgc_575631.cpp \
364 android_cpuid.cpp
366 #****************************************************************************
367 # Dependencies
368 #****************************************************************************
370 ALL_SRCS := ${SHELL_SRCS} ${AVMPLUS_SRCS} ${MMGC_SRCS} ${ZLIB_SRC}
371 SHELL_OBJS := $(addprefix ${OBJDIR}/avmshell/, $(notdir $(addsuffix .o, $(basename ${SHELL_SRCS}))))
372 ALL_OBJS := ${SHELL_OBJS} ${AVMPLUS_OBJS} ${MMGC_OBJS} ${ZLIB_OBJS}
374 #****************************************************************************
375 # Output
376 #****************************************************************************
378 ${FINAL_TARGET}: $(ALL_OBJS)
379 @echo "=== linking:" $@ "==="
380 ifeq ($(ENABLE_NANOJIT),true)
381 @echo Note: nanojit ENabled
382 else
383 @echo Note: nanojit DISabled
384 endif
385 ${CC} $(LFLAGS_HEADLESS) $(ALL_OBJS) ${LDFLAGS} -o $@
386 @if [ ${SPEAK_STATUS}XXX != XXX ]; then say "Build succeeded"; fi
387 @echo "=== done:" $@ "==="
389 $(OBJDIR)/avmshell/%.o: ../../shell/%.cpp
390 ${call compile-files-arm,avmshell}
392 $(OBJDIR)/avmshell/%.o: ../../extensions/%.cpp
393 ${call compile-files-arm,avmshell}
395 $(OBJDIR)/avmshell/%.o: %.cpp
396 ${call compile-files-arm,avmshell}
398 default_target:
399 @$(MAKE) -j4 ${FINAL_TARGET}
401 #****************************************************************************
402 # Additional targets
403 #****************************************************************************
405 clean:
406 -rm -f core* ${ALL_OBJS} ${FINAL_TARGET} ${AVMPLUS_LIB} ${MMGC_LIB} ${ZLIB_LIB} log outputdebug.txt
408 install:
409 -adb push ${FINAL_TARGET} /data/app
410 @if [ ${SPEAK_STATUS}XXX != XXX ]; then say "Installation complete"; fi
412 uninstall:
413 -adb shell rm /data/app/${FINAL_TARGET}