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