blob: e2dccb7bb8a88a6c34ee8dc8fe0e88b8040f4d80 [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
48# this is needed to build the emulator on 64-bit Linux systems
49ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
50 MY_CFLAGS += -Wa,--32
51endif
52
53ifeq ($(HOST_OS),freebsd)
54 MY_CFLAGS += -Wa,--32 -I /usr/local/include
55endif
56
57ifeq ($(HOST_OS),windows)
David 'Digit' Turnerceda5f12011-06-23 17:26:42 +020058 MY_CFLAGS += -D_WIN32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080059 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
60 MY_CFLAGS += -DWINVER=0x501
Vladimir Chtchetkinecf1c2c72011-09-04 09:51:40 -070061 MY_LDLIBS += -lvfw32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080062endif
63
64ifeq ($(HOST_ARCH),ppc)
65 MY_CFLAGS += -D__powerpc__
66endif
67
68ifeq ($(HOST_OS),darwin)
David 'Digit' Turner747f7d12011-01-06 22:24:26 +010069 MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
David Turnerbba461c2009-06-03 10:48:15 -070070
71 # When building on Leopard or above, we need to use the 10.4 SDK
72 # or the generated binary will not run on Tiger.
73 DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
Jeff Hamiltond0d97342010-05-27 11:41:41 -050074 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(DARWIN_VERSION)),)
75 $(error Building the Android emulator requires OS X 10.5 or above)
David Turnerbba461c2009-06-03 10:48:15 -070076 endif
Al Sutton85937732011-12-21 13:14:03 -080077 ifneq ($(filter 10.6 10.6.%,$(DARWIN_VERSION)),)
78 # We are on Snow Leopard
Jeff Hamiltond0d97342010-05-27 11:41:41 -050079 LEOPARD_SDK := /Developer/SDKs/MacOSX10.5.sdk
80 ifeq ($(strip $(wildcard $(LEOPARD_SDK))),)
81 $(info Please install the 10.5 SDK on this machine at $(LEOPARD_SDK))
David Turnerbba461c2009-06-03 10:48:15 -070082 $(error Aborting the build.)
83 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050084 MY_CFLAGS += -isysroot $(LEOPARD_SDK) -mmacosx-version-min=10.5 -DMACOSX_DEPLOYMENT_TARGET=10.5
85 MY_LDLIBS += -isysroot $(LEOPARD_SDK) -Wl,-syslibroot,$(LEOPARD_SDK) -mmacosx-version-min=10.5
David Turnerbba461c2009-06-03 10:48:15 -070086 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080087endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080088
89# BUILD_STANDALONE_EMULATOR is only defined when building with
90# the android-rebuild.sh script. The script will also provide
91# adequate values for HOST_CC
92#
93ifneq ($(BUILD_STANDALONE_EMULATOR),true)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010094 # On Linux, use our custom 32-bit host toolchain, which contains the
95 # relevant headers and 32-bit libraries for audio (The host 64-bit Lucid
96 # doesn't provide these anymore, only their 64-bit versions).
97 ifeq ($(HOST_OS),linux)
Jean-Baptiste Queru6e8d9292012-01-09 15:07:03 -080098 ifneq ($(wildcard prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3/bin/i686-linux),)
99 HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3/bin/i686-linux
100 else
101 HOST_SDK_TOOLCHAIN_PREFIX := prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/bin/i686-linux
102 endif
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100103 # Don't do anything if the toolchain is not there
104 ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc)))
David 'Digit' Turnerb580d262011-03-02 09:49:06 +0100105 MY_CC := $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc
106 MY_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)-g++
107 MY_AR := $(HOST_SDK_TOOLCHAIN_PREFIX)-ar
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100108 endif # $(HOST_SDK_TOOLCHAIN_PREFIX)-gcc exists
109 endif # HOST_OS == linux
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800110
111 ifneq ($(USE_CCACHE),)
Ying Wang762d5de2012-01-09 11:53:58 -0800112 ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
David 'Digit' Turner4ed818f2011-03-12 13:05:15 +0100113 ccache := $(strip $(wildcard $(ccache)))
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700114 ifneq ($(ccache),$(firstword $(MY_CC)))
115 MY_CC := $(ccache) $(MY_CC)
116 endif
117 ccache :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800118 endif
119endif
120
121
122ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
123 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700124 MY_CFLAGS += -m32
125 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800126 endif
127endif
128
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200129# Enable warning, except those related to missing field initializers
130# (the QEMU coding style loves using these).
131#
132MY_CFLAGS += -Wall -Wno-missing-field-initializers
133
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100134# Needed to build fpu/softfloat-native.h properly
135MY_CFLAGS += -D_GNU_SOURCE=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800136
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100137# A useful function that can be used to start the declaration of a host
138# module. Avoids repeating the same stuff again and again.
139# Usage:
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800140#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100141# $(call start-emulator-library, <module-name>)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800142#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100143# ... declarations
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800144#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100145# $(call end-emulator-library)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800146#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100147start-emulator-library = \
148 $(eval include $(CLEAR_VARS)) \
149 $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \
150 $(eval LOCAL_CC := $(MY_CC)) \
David 'Digit' Turnerb580d262011-03-02 09:49:06 +0100151 $(eval LOCAL_CXX := $(MY_CXX)) \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100152 $(eval LOCAL_CFLAGS := $(MY_CFLAGS)) \
David 'Digit' Turnerb580d262011-03-02 09:49:06 +0100153 $(eval LOCAL_AR := $(MY_AR)) \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100154 $(eval LOCAL_LDLIBS := $(MY_LDLIBS)) \
155 $(eval LOCAL_MODULE_TAGS := debug) \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200156 $(eval LOCAL_MODULE := $1) \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200157 $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800158
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100159# Used with start-emulator-library
160end-emulator-library = \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200161 $(eval include $(BUILD_HOST_STATIC_LIBRARY))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800162
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100163# A variant of start-emulator-library to start the definition of a host
164# program instead. Use with end-emulator-program
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200165start-emulator-program = \
166 $(call start-emulator-library,$1) \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200167 $(eval LOCAL_MODULE_CLASS := EXECUTABLES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800168
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100169# A varient of end-emulator-library for host programs instead
170end-emulator-program = \
171 $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \
172 $(eval include $(BUILD_HOST_EXECUTABLE))
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800173
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700174
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700175# The common libraries
176#
177QEMU_SYSTEM_LDLIBS := -lm
178ifeq ($(HOST_OS),windows)
179 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
180endif
181
182ifeq ($(HOST_OS),freebsd)
183 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
184endif
185
186ifeq ($(HOST_OS),linux)
187 QEMU_SYSTEM_LDLIBS += -lutil -lrt
188endif
189
190ifeq ($(HOST_OS),windows)
191 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
192else
193 QEMU_SYSTEM_LDLIBS += -lpthread
194endif
195
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700196ifeq ($(HOST_OS),darwin)
Vladimir Chtchetkine955a9972011-10-12 15:40:17 -0700197 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo
Al Suttonc3c9c6f2011-12-21 13:16:22 -0800198 ifneq ($(filter 10.7 10.7.%,$(DARWIN_VERSION)),)
Al Sutton49dd3f32012-01-04 15:19:05 -0800199 # Lion/XCode4 needs to be explicitly told the dynamic library
200 # lookup symbols in the precompiled libSDL are resolved at
201 # runtime
202 QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup
Al Suttonc3c9c6f2011-12-21 13:16:22 -0800203 endif
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700204endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700205
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100206include $(LOCAL_PATH)/Makefile.common
207
208# We want to build all variants of the emulator binaries. This makes
209# it easier to catch target-specific regressions during emulator development.
210EMULATOR_TARGET_ARCH := arm
211include $(LOCAL_PATH)/Makefile.target
212
213EMULATOR_TARGET_ARCH := x86
214include $(LOCAL_PATH)/Makefile.target
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700215
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800216##############################################################################
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100217##############################################################################
218###
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +0100219### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR
220###
221###
222$(call start-emulator-program, emulator)
223
224LOCAL_SRC_FILES := android/main-emulator.c
225LOCAL_STATIC_LIBRARIES := emulator-common
226
227$(call end-emulator-program)
228
229##############################################################################
230##############################################################################
231###
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100232### emulator-ui: UI FRONT-END PROGRAM
233###
234###
235$(call start-emulator-program, emulator-ui)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800236
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100237LOCAL_STATIC_LIBRARIES := \
238 emulator-common \
239 emulator-libui \
240 emulator-common \
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800241
242
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100243LOCAL_CFLAGS += -DCONFIG_STANDALONE_UI=1
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800244
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100245LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS) $(EMULATOR_LIBUI_CFLAGS)
246LOCAL_LDLIBS += $(EMULATOR_COMMON_LDLIBS) $(EMULATOR_LIBUI_LDLIBS)
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800247
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100248LOCAL_SRC_FILES := \
249 android/cmdline-option.c \
250 android/config.c \
251 android/help.c \
252 android/looper-generic.c \
253 android/snapshot.c \
254 android/main-common.c \
255 android/main.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200256 android/opengles.c \
David 'Digit' Turnerf816a752011-06-23 18:40:11 +0200257 android/utils/setenv.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100258 vl-android-ui.c \
259 android/protocol/core-connection.c \
260 android/protocol/attach-ui-impl.c \
261 android/protocol/fb-updates-impl.c \
262 android/protocol/ui-commands-impl.c \
263 android/protocol/core-commands-proxy.c \
264 android/protocol/user-events-proxy.c \
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800265
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200266$(call gen-hw-config-defs,android/main-common.c)
267
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800268LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
269
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800270LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
271
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100272$(call end-emulator-program)
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800273
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100274## VOILA!!
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200275
Jun Nakajima334ab472011-02-02 23:49:59 -0800276endif # TARGET_ARCH == arm || TARGET_ARCH == x86