1ifneq (,$(filter $(TARGET_ARCH),arm x86)) 2LOCAL_PATH:= $(call my-dir) 3 4# determine the target cpu 5ifeq ($(TARGET_ARCH),arm) 6EMULATOR_TARGET_CPU := target-arm 7else 8EMULATOR_TARGET_CPU := target-i386 9endif 10 11# determine the host tag to use 12QEMU_HOST_TAG := $(HOST_PREBUILT_TAG) 13ifneq ($(USE_MINGW),) 14 QEMU_HOST_TAG := windows 15endif 16 17# determine the location of platform-specific directories 18# 19CONFIG_DIRS := \ 20 $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG) 21 22ifeq ($(BUILD_STANDALONE_EMULATOR),true) 23 CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS) 24endif 25 26CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%) 27 28MY_CC := $(HOST_CC) 29MY_CXX := $(HOST_CXX) 30MY_AR := $(HOST_AR) 31 32MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer 33ifeq ($(BUILD_DEBUG_EMULATOR),true) 34 MY_OPTIM := -O0 -g 35endif 36 37MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM) 38 39# 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 46MY_LDLIBS := 47 48ifeq ($(HOST_OS),freebsd) 49 MY_CFLAGS += -I /usr/local/include 50endif 51 52ifeq ($(HOST_OS),windows) 53 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0) 54 MY_CFLAGS += -DWINVER=0x501 55 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 65endif 66 67ifeq ($(HOST_ARCH),ppc) 68 MY_CFLAGS += -D__powerpc__ 69endif 70 71ifeq ($(HOST_OS),darwin) 72 MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1 73 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)) 77 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) 79 endif 80 ifneq ($(filter 10.6 10.6.%,$(DARWIN_VERSION)),) 81 # We are on Snow Leopard 82 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)) 85 $(error Aborting the build.) 86 endif 87 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 89 endif 90endif 91 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) 97 # 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). 100 ifeq ($(HOST_OS),linux) 101 HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk 102 # Don't do anything if the toolchain is not there 103 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 108 endif # HOST_OS == linux 109 110 ifneq ($(USE_CCACHE),) 111 ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache 112 ccache := $(strip $(wildcard $(ccache))) 113 ifneq ($(ccache),$(firstword $(MY_CC))) 114 MY_CC := $(ccache) $(MY_CC) 115 MY_CXX := $(ccache) $(MY_CXX) 116 endif 117 ccache := 118 endif 119endif 120 121 122ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true) 123 ifneq ($(BUILD_HOST_64bit),) 124 MY_CFLAGS += -m64 125 MY_LDLIBS += -m64 126 else 127 ifneq ($(HOST_ARCH),x86_64) 128 MY_CFLAGS += -m32 129 MY_LDLIBS += -m32 130 endif 131 endif 132endif 133 134# Enable warning, except those related to missing field initializers 135# (the QEMU coding style loves using these). 136# 137MY_CFLAGS += -Wall -Wno-missing-field-initializers 138 139# Needed to build fpu/softfloat-native.h properly 140MY_CFLAGS += -D_GNU_SOURCE=1 141 142# A useful function that can be used to start the declaration of a host 143# module. Avoids repeating the same stuff again and again. 144# Usage: 145# 146# $(call start-emulator-library, <module-name>) 147# 148# ... declarations 149# 150# $(call end-emulator-library) 151# 152start-emulator-library = \ 153 $(eval include $(CLEAR_VARS)) \ 154 $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \ 155 $(eval LOCAL_CC := $(MY_CC)) \ 156 $(eval LOCAL_CXX := $(MY_CXX)) \ 157 $(eval LOCAL_CFLAGS := $(MY_CFLAGS)) \ 158 $(eval LOCAL_AR := $(MY_AR)) \ 159 $(eval LOCAL_LDLIBS := $(MY_LDLIBS)) \ 160 $(eval LOCAL_MODULE_TAGS := debug) \ 161 $(eval LOCAL_MODULE := $1) \ 162 $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES) 163 164# Used with start-emulator-library 165end-emulator-library = \ 166 $(eval include $(BUILD_HOST_STATIC_LIBRARY)) 167 168# A variant of start-emulator-library to start the definition of a host 169# program instead. Use with end-emulator-program 170start-emulator-program = \ 171 $(call start-emulator-library,$1) \ 172 $(eval LOCAL_MODULE_CLASS := EXECUTABLES) 173 174# A varient of end-emulator-library for host programs instead 175end-emulator-program = \ 176 $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \ 177 $(eval include $(BUILD_HOST_EXECUTABLE)) 178 179 180# The common libraries 181# 182QEMU_SYSTEM_LDLIBS := -lm 183ifeq ($(HOST_OS),windows) 184 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole 185endif 186 187ifeq ($(HOST_OS),freebsd) 188 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil 189endif 190 191ifeq ($(HOST_OS),linux) 192 QEMU_SYSTEM_LDLIBS += -lutil -lrt 193endif 194 195ifeq ($(HOST_OS),windows) 196 # amd64-mingw32msvc- toolchain still name it ws2_32. May change it once amd64-mingw32msvc- 197 # is stabilized 198 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi 199else 200 QEMU_SYSTEM_LDLIBS += -lpthread 201endif 202 203ifeq ($(HOST_OS),darwin) 204 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo 205 ifneq ($(filter 10.7 10.7.%,$(DARWIN_VERSION)),) 206 # Lion/XCode4 needs to be explicitly told the dynamic library 207 # lookup symbols in the precompiled libSDL are resolved at 208 # runtime 209 QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup 210 endif 211endif 212 213include $(LOCAL_PATH)/Makefile.common 214 215# We want to build all variants of the emulator binaries. This makes 216# it easier to catch target-specific regressions during emulator development. 217EMULATOR_TARGET_ARCH := arm 218include $(LOCAL_PATH)/Makefile.target 219 220EMULATOR_TARGET_ARCH := x86 221include $(LOCAL_PATH)/Makefile.target 222 223############################################################################## 224############################################################################## 225### 226### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR 227### 228### 229$(call start-emulator-program, emulator) 230 231LOCAL_SRC_FILES := android/main-emulator.c 232LOCAL_STATIC_LIBRARIES := emulator-common 233 234$(call end-emulator-program) 235 236############################################################################## 237############################################################################## 238### 239### emulator-ui: UI FRONT-END PROGRAM 240### 241### 242$(call start-emulator-program, emulator-ui) 243 244LOCAL_STATIC_LIBRARIES := \ 245 emulator-common \ 246 emulator-libui \ 247 emulator-common \ 248 249 250LOCAL_CFLAGS += -DCONFIG_STANDALONE_UI=1 251 252LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS) $(EMULATOR_LIBUI_CFLAGS) 253LOCAL_LDLIBS += $(EMULATOR_COMMON_LDLIBS) $(EMULATOR_LIBUI_LDLIBS) 254 255LOCAL_SRC_FILES := \ 256 android/cmdline-option.c \ 257 android/config.c \ 258 android/help.c \ 259 android/looper-generic.c \ 260 android/snapshot.c \ 261 android/main-common.c \ 262 android/main.c \ 263 android/opengles.c \ 264 android/utils/setenv.c \ 265 vl-android-ui.c \ 266 android/protocol/core-connection.c \ 267 android/protocol/attach-ui-impl.c \ 268 android/protocol/fb-updates-impl.c \ 269 android/protocol/ui-commands-impl.c \ 270 android/protocol/core-commands-proxy.c \ 271 android/protocol/user-events-proxy.c \ 272 273$(call gen-hw-config-defs,android/main-common.c) 274 275LOCAL_SRC_FILES += $(SDLMAIN_SOURCES) 276 277LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES) 278 279$(call end-emulator-program) 280 281## VOILA!! 282 283endif # TARGET_ARCH == arm || TARGET_ARCH == x86 284