blob: 797bb711bc639f350147329905809faf6aa779d3 [file] [log] [blame]
Jun Nakajima334ab472011-02-02 23:49:59 -08001ifneq (,$(filter $(TARGET_ARCH),arm x86))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08002LOCAL_PATH:= $(call my-dir)
3
Jun Nakajima334ab472011-02-02 23:49:59 -08004# determine the target cpu
5ifeq ($(TARGET_ARCH),arm)
6EMULATOR_TARGET_CPU := target-arm
7else
8EMULATOR_TARGET_CPU := target-i386
9endif
10
David 'Digit' Turner34d16512010-05-18 17:02:33 -070011# determine the host tag to use
12QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
13ifneq ($(USE_MINGW),)
14 QEMU_HOST_TAG := windows
15endif
16
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080017# determine the location of platform-specific directories
18#
19CONFIG_DIRS := \
David 'Digit' Turner34d16512010-05-18 17:02:33 -070020 $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
21
22ifeq ($(BUILD_STANDALONE_EMULATOR),true)
23 CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS)
24endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080025
26CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
27
David 'Digit' Turner0a349b82011-03-02 12:49:26 +010028MY_CC := $(HOST_CC)
29MY_CXX := $(HOST_CXX)
30MY_AR := $(HOST_AR)
Kenny Root095cd0f2009-09-19 18:32:44 -050031
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070032MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
33ifeq ($(BUILD_DEBUG_EMULATOR),true)
34 MY_OPTIM := -O0 -g
35endif
36
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080037MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080038
David 'Digit' Turner466f5482009-07-30 15:50:19 +020039# Overwrite configuration for debug builds.
40#
41ifeq ($(BUILD_DEBUG_EMULATOR),true)
42 MY_CFLAGS := $(CONFIG_INCLUDES) -O0 -g \
43 -fno-PIC -falign-functions=0
44endif
45
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070046MY_LDLIBS :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080047
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080048ifeq ($(HOST_OS),freebsd)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070049 MY_CFLAGS += -I /usr/local/include
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080050endif
51
52ifeq ($(HOST_OS),windows)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070053 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080054 MY_CFLAGS += -DWINVER=0x501
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070055 MY_CFLAGS += -D_WIN32
56 ifneq ($(BUILD_HOST_64bit),)
57 # Microsoft 64-bit compiler define both _WIN32 and _WIN64
58 MY_CFLAGS += -D_WIN64
59 # amd64-mingw32msvc- toolchain still name it vfw32. May change it once amd64-mingw32msvc-
60 # is stabilized
61 MY_LDLIBS += -lvfw32
62 else
63 MY_LDLIBS += -lvfw32
64 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080065endif
66
67ifeq ($(HOST_ARCH),ppc)
68 MY_CFLAGS += -D__powerpc__
69endif
70
71ifeq ($(HOST_OS),darwin)
David 'Digit' Turner747f7d12011-01-06 22:24:26 +010072 MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
David Turnerbba461c2009-06-03 10:48:15 -070073
74 # When building on Leopard or above, we need to use the 10.4 SDK
75 # or the generated binary will not run on Tiger.
76 DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
Jeff Hamiltond0d97342010-05-27 11:41:41 -050077 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(DARWIN_VERSION)),)
78 $(error Building the Android emulator requires OS X 10.5 or above)
David Turnerbba461c2009-06-03 10:48:15 -070079 endif
Al Sutton85937732011-12-21 13:14:03 -080080 ifneq ($(filter 10.6 10.6.%,$(DARWIN_VERSION)),)
81 # We are on Snow Leopard
Jeff Hamiltond0d97342010-05-27 11:41:41 -050082 LEOPARD_SDK := /Developer/SDKs/MacOSX10.5.sdk
83 ifeq ($(strip $(wildcard $(LEOPARD_SDK))),)
84 $(info Please install the 10.5 SDK on this machine at $(LEOPARD_SDK))
David Turnerbba461c2009-06-03 10:48:15 -070085 $(error Aborting the build.)
86 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050087 MY_CFLAGS += -isysroot $(LEOPARD_SDK) -mmacosx-version-min=10.5 -DMACOSX_DEPLOYMENT_TARGET=10.5
88 MY_LDLIBS += -isysroot $(LEOPARD_SDK) -Wl,-syslibroot,$(LEOPARD_SDK) -mmacosx-version-min=10.5
David Turnerbba461c2009-06-03 10:48:15 -070089 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080090endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080091
92# BUILD_STANDALONE_EMULATOR is only defined when building with
93# the android-rebuild.sh script. The script will also provide
94# adequate values for HOST_CC
95#
96ifneq ($(BUILD_STANDALONE_EMULATOR),true)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070097 # On Linux, use our custom 32-bit host toolchain (unless BUILD_HOST_64bit=1)
98 # which contains the relevant headers and 32-bit libraries for audio (The host 64-bit
99 # Lucid doesn't provide these anymore, only their 64-bit versions).
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100100 ifeq ($(HOST_OS),linux)
Andrew Hsiehd0f2ab62012-03-23 17:35:11 +0800101 HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100102 # Don't do anything if the toolchain is not there
Andrew Hsiehd0f2ab62012-03-23 17:35:11 +0800103 ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc)))
104 MY_CC := $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc
105 MY_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)/g++
106 MY_AR := $(HOST_SDK_TOOLCHAIN_PREFIX)/ar
107 endif # $(HOST_SDK_TOOLCHAIN_PREFIX)/gcc exists
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100108 endif # HOST_OS == linux
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800109
110 ifneq ($(USE_CCACHE),)
Ying Wang762d5de2012-01-09 11:53:58 -0800111 ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
David 'Digit' Turner4ed818f2011-03-12 13:05:15 +0100112 ccache := $(strip $(wildcard $(ccache)))
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700113 ifneq ($(ccache),$(firstword $(MY_CC)))
114 MY_CC := $(ccache) $(MY_CC)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700115 MY_CXX := $(ccache) $(MY_CXX)
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700116 endif
117 ccache :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800118 endif
Jesse Hall183e9272012-04-26 15:13:27 -0700119
120 QEMU_OPENGLES_INCLUDE := sdk/emulator/opengl/host/include
121 QEMU_OPENGLES_LIBS := $(HOST_OUT)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800122endif
123
124
125ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700126 ifneq ($(BUILD_HOST_64bit),)
127 MY_CFLAGS += -m64
128 MY_LDLIBS += -m64
129 else
130 ifneq ($(HOST_ARCH),x86_64)
131 MY_CFLAGS += -m32
132 MY_LDLIBS += -m32
133 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800134 endif
Andrew Hsieh632a0e12012-04-28 00:48:53 +0800135
136 ifneq ($(BUILD_HOST_static),)
137 MY_LDLIBS += -static
138 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800139endif
140
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200141# Enable warning, except those related to missing field initializers
142# (the QEMU coding style loves using these).
143#
144MY_CFLAGS += -Wall -Wno-missing-field-initializers
145
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100146# Needed to build fpu/softfloat-native.h properly
147MY_CFLAGS += -D_GNU_SOURCE=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800148
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100149# A useful function that can be used to start the declaration of a host
150# module. Avoids repeating the same stuff again and again.
151# Usage:
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800152#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100153# $(call start-emulator-library, <module-name>)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800154#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100155# ... declarations
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800156#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100157# $(call end-emulator-library)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800158#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100159start-emulator-library = \
160 $(eval include $(CLEAR_VARS)) \
161 $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \
162 $(eval LOCAL_CC := $(MY_CC)) \
David 'Digit' Turnerb580d262011-03-02 09:49:06 +0100163 $(eval LOCAL_CXX := $(MY_CXX)) \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100164 $(eval LOCAL_CFLAGS := $(MY_CFLAGS)) \
David 'Digit' Turnerb580d262011-03-02 09:49:06 +0100165 $(eval LOCAL_AR := $(MY_AR)) \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100166 $(eval LOCAL_LDLIBS := $(MY_LDLIBS)) \
167 $(eval LOCAL_MODULE_TAGS := debug) \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200168 $(eval LOCAL_MODULE := $1) \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200169 $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800170
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100171# Used with start-emulator-library
172end-emulator-library = \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200173 $(eval include $(BUILD_HOST_STATIC_LIBRARY))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800174
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100175# A variant of start-emulator-library to start the definition of a host
176# program instead. Use with end-emulator-program
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200177start-emulator-program = \
178 $(call start-emulator-library,$1) \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200179 $(eval LOCAL_MODULE_CLASS := EXECUTABLES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800180
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100181# A varient of end-emulator-library for host programs instead
182end-emulator-program = \
183 $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \
184 $(eval include $(BUILD_HOST_EXECUTABLE))
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800185
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700186
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700187# The common libraries
188#
189QEMU_SYSTEM_LDLIBS := -lm
190ifeq ($(HOST_OS),windows)
191 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
192endif
193
194ifeq ($(HOST_OS),freebsd)
195 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
196endif
197
198ifeq ($(HOST_OS),linux)
199 QEMU_SYSTEM_LDLIBS += -lutil -lrt
200endif
201
202ifeq ($(HOST_OS),windows)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700203 # amd64-mingw32msvc- toolchain still name it ws2_32. May change it once amd64-mingw32msvc-
204 # is stabilized
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700205 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
206else
207 QEMU_SYSTEM_LDLIBS += -lpthread
208endif
209
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700210ifeq ($(HOST_OS),darwin)
Vladimir Chtchetkine955a9972011-10-12 15:40:17 -0700211 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo
Al Suttonc3c9c6f2011-12-21 13:16:22 -0800212 ifneq ($(filter 10.7 10.7.%,$(DARWIN_VERSION)),)
Al Sutton49dd3f32012-01-04 15:19:05 -0800213 # Lion/XCode4 needs to be explicitly told the dynamic library
214 # lookup symbols in the precompiled libSDL are resolved at
215 # runtime
216 QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup
Al Suttonc3c9c6f2011-12-21 13:16:22 -0800217 endif
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700218endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700219
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100220include $(LOCAL_PATH)/Makefile.common
221
Raphael Mollcdbea232012-05-04 15:04:27 -0700222ifeq ($(HOST_OS),windows)
223 # on Windows, link the icon file as well into the executable
224 # unfortunately, our build system doesn't help us much, so we need
225 # to use some weird pathnames to make this work...
226
227 # Locate windres executable
228 WINDRES := windres
229 ifneq ($(USE_MINGW),)
230 # When building the Windows emulator under Linux, use the MinGW one
231 WINDRES := i586-mingw32msvc-windres
232 endif
233
234 # Usage: $(eval $(call insert-windows-icon))
235 define insert-windows-icon
236 LOCAL_PREBUILT_OBJ_FILES += images/emulator_icon.o
237 endef
238
239# This seems to be the only way to add an object file that was not generated from
240# a C/C++/Java source file to our build system. and very unfortunately,
241# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
242# us to put the object file in the source directory.
243$(LOCAL_PATH)/images/emulator_icon.o: $(LOCAL_PATH)/images/android_icon.rc
244 $(WINDRES) $< -I $(LOCAL_PATH)/images -o $@
245endif
246
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100247# We want to build all variants of the emulator binaries. This makes
248# it easier to catch target-specific regressions during emulator development.
249EMULATOR_TARGET_ARCH := arm
250include $(LOCAL_PATH)/Makefile.target
251
252EMULATOR_TARGET_ARCH := x86
253include $(LOCAL_PATH)/Makefile.target
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700254
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800255##############################################################################
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100256##############################################################################
257###
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +0100258### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR
259###
260###
261$(call start-emulator-program, emulator)
262
263LOCAL_SRC_FILES := android/main-emulator.c
264LOCAL_STATIC_LIBRARIES := emulator-common
265
Raphael Mollcdbea232012-05-04 15:04:27 -0700266ifeq ($(HOST_OS),windows)
267$(eval $(call insert-windows-icon))
268endif
269
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +0100270$(call end-emulator-program)
271
272##############################################################################
273##############################################################################
274###
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100275### emulator-ui: UI FRONT-END PROGRAM
276###
277###
278$(call start-emulator-program, emulator-ui)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800279
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100280LOCAL_STATIC_LIBRARIES := \
281 emulator-common \
282 emulator-libui \
283 emulator-common \
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800284
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100285LOCAL_CFLAGS += -DCONFIG_STANDALONE_UI=1
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800286
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100287LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS) $(EMULATOR_LIBUI_CFLAGS)
288LOCAL_LDLIBS += $(EMULATOR_COMMON_LDLIBS) $(EMULATOR_LIBUI_LDLIBS)
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800289
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100290LOCAL_SRC_FILES := \
291 android/cmdline-option.c \
292 android/config.c \
293 android/help.c \
294 android/looper-generic.c \
295 android/snapshot.c \
296 android/main-common.c \
297 android/main.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200298 android/opengles.c \
David 'Digit' Turnerf816a752011-06-23 18:40:11 +0200299 android/utils/setenv.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100300 vl-android-ui.c \
301 android/protocol/core-connection.c \
302 android/protocol/attach-ui-impl.c \
303 android/protocol/fb-updates-impl.c \
304 android/protocol/ui-commands-impl.c \
305 android/protocol/core-commands-proxy.c \
306 android/protocol/user-events-proxy.c \
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800307
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200308$(call gen-hw-config-defs,android/main-common.c)
309
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800310LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
311
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800312LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
313
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100314$(call end-emulator-program)
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800315
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100316## VOILA!!
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200317
Jun Nakajima334ab472011-02-02 23:49:59 -0800318endif # TARGET_ARCH == arm || TARGET_ARCH == x86