1# This file is included several times to build target-specific 2# modules for the Android emulator. It will be called several times 3# (e.g. once for the arm target, and once for the x86 target). 4# 5 6ifndef EMULATOR_TARGET_ARCH 7$(error EMULATOR_TARGET_ARCH is not defined!) 8endif 9 10EMULATOR_TARGET_CPU := $(EMULATOR_TARGET_ARCH) 11ifeq ($(EMULATOR_TARGET_CPU),x86) 12 EMULATOR_TARGET_CPU := i386 13endif 14 15############################################################################## 16############################################################################## 17### 18### emulator-target-$CPU: target-specific emulation code. 19### 20### Used by both the core and standalone programs. 21### 22 23# Common compiler flags for all target-dependent libraries 24EMULATOR_TARGET_CFLAGS := \ 25 -I$(LOCAL_PATH)/android/config/$(HOST_PREBUILT_TAG) \ 26 -I$(LOCAL_PATH)/android/config/target-$(EMULATOR_TARGET_ARCH) \ 27 -I$(LOCAL_PATH)/target-$(EMULATOR_TARGET_CPU) \ 28 -I$(LOCAL_PATH)/fpu \ 29 -DNEED_CPU_H \ 30 31TCG_TARGET := $(HOST_ARCH) 32ifeq ($(HOST_ARCH),x86) 33 TCG_TARGET := i386 34endif 35ifeq ($(HOST_ARCH),x86_64) 36 TCG_TARGET := i386 37endif 38 39EMULATOR_TARGET_CFLAGS += \ 40 -I$(LOCAL_PATH)/tcg \ 41 -I$(LOCAL_PATH)/tcg/$(TCG_TARGET) \ 42 -DTARGET_ARCH=\"$(EMULATOR_TARGET_ARCH)\" 43 44 45$(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU)) 46 47# The following is to ensure that "config.h" will map to a target-specific 48# configuration file header. 49LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS) 50 51LOCAL_SRC_FILES += \ 52 tcg/tcg.c \ 53 54############################################################################## 55# Emulated hardware devices. 56# 57 58HW_SOURCES := \ 59 bt.c \ 60 bt-hci.c \ 61 bt-hid.c \ 62 bt-l2cap.c \ 63 bt-sdp.c \ 64 cdrom.c \ 65 dma.c \ 66 irq.c \ 67 goldfish_audio.c \ 68 goldfish_device.c \ 69 goldfish_events_device.c \ 70 goldfish_fb.c \ 71 goldfish_battery.c \ 72 goldfish_mmc.c \ 73 goldfish_memlog.c \ 74 goldfish_nand.c \ 75 goldfish_pipe.c \ 76 goldfish_tty.c \ 77 msmouse.c \ 78 pci.c \ 79 qdev.c \ 80 scsi-disk.c \ 81 sysbus.c \ 82 usb-hid.c \ 83 usb-hub.c \ 84 usb-msd.c \ 85 usb-ohci.c \ 86 usb.c \ 87 watchdog.c 88 89$(call gen-hw-config-defs) 90 91ifeq ($(EMULATOR_TARGET_ARCH),arm) 92HW_SOURCES += android_arm.c \ 93 arm_pic.c \ 94 goldfish_interrupt.c \ 95 goldfish_switch.c \ 96 goldfish_timer.c \ 97 goldfish_trace.c \ 98 arm_boot.c \ 99 100# The following sources must be compiled with the final executables 101# because they contain device_init() or machine_init() statements. 102HW_OBJ_SOURCES := hw/smc91c111.c 103HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 104 105LOCAL_SRC_FILES += arm-dis.c 106 107# smc91c111.c requires <zlib.h> 108LOCAL_CFLAGS += $(ZLIB_CFLAGS) 109endif 110 111# required to ensure we properly initialize virtual audio hardware 112LOCAL_CFLAGS += -DHAS_AUDIO 113 114ifeq ($(EMULATOR_TARGET_ARCH),x86) 115HW_SOURCES += \ 116 apic.c \ 117 i8259.c \ 118 mc146818rtc.c \ 119 piix_pci.c \ 120 i8254.c \ 121 pckbd.c \ 122 ioapic.c \ 123 ps2.c \ 124 smbios.c \ 125 fw_cfg.c 126 127# The following sources must be compiled with the final executables 128# because they contain device_init() or machine_init() statements. 129HW_OBJ_SOURCES := \ 130 hw/ne2000.c \ 131 hw/pc.c 132 133HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 134 135endif 136 137LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%) 138 139LOCAL_SRC_FILES += \ 140 cpu-exec.c \ 141 exec.c \ 142 translate-all.c \ 143 trace.c \ 144 varint.c \ 145 softmmu_outside_jit.c \ 146 147############################################################################## 148# CPU-specific emulation. 149# 150LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare 151 152ifeq ($(HOST_ARCH),ppc) 153 LOCAL_CFLAGS += -D__powerpc__ 154endif 155 156ifeq ($(EMULATOR_TARGET_ARCH),arm) 157LOCAL_SRC_FILES += \ 158 target-arm/op_helper.c \ 159 target-arm/iwmmxt_helper.c \ 160 target-arm/neon_helper.c \ 161 target-arm/helper.c \ 162 target-arm/helper-android.c \ 163 target-arm/translate.c \ 164 target-arm/machine.c \ 165 hw/armv7m.c \ 166 hw/armv7m_nvic.c \ 167 arm-semi.c \ 168 169LOCAL_SRC_FILES += fpu/softfloat.c 170endif 171 172ifeq ($(EMULATOR_TARGET_ARCH), x86) 173LOCAL_SRC_FILES += \ 174 target-i386/op_helper.c \ 175 target-i386/helper.c \ 176 target-i386/translate.c \ 177 target-i386/machine.c \ 178 179LOCAL_SRC_FILES += fpu/softfloat-native.c 180endif 181 182# compile KVM only if target is x86 on x86 Linux 183QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH) 184QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false) 185ifeq ($(QEMU_DO_KVM),true) 186 LOCAL_SRC_FILES += \ 187 target-i386/kvm.c \ 188 target-i386/kvm-gs-restore.c \ 189 kvm-all.c \ 190 kvm-android.c 191endif 192 193############################################################################## 194# Memory-access checking support. 195# Memory access checker uses information collected by instrumented code in 196# libc.so in order to keep track of memory blocks allocated from heap. Memory 197# checker then uses this information to make sure that every access to allocated 198# memory is within allocated block. This information also allows detecting 199# memory leaks and attempts to free/realloc invalid pointers. 200# 201LOCAL_CFLAGS += \ 202 -I$(LOCAL_PATH)/memcheck \ 203 -I$(LOCAL_PATH)/elff 204 205MCHK_SOURCES := \ 206 memcheck.c \ 207 memcheck_proc_management.c \ 208 memcheck_malloc_map.c \ 209 memcheck_mmrange_map.c \ 210 memcheck_util.c \ 211 212LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%) 213 214LOCAL_SRC_FILES += \ 215 cpus.c \ 216 arch_init.c 217 218# What a mess, os-posix.c depends on the exact values of options 219# which are target specific. 220ifeq ($(HOST_OS),windows) 221 LOCAL_SRC_FILES += os-win32.c oslib-win32.c 222else 223 LOCAL_SRC_FILES += os-posix.c oslib-posix.c 224endif 225$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c) 226 227$(call end-emulator-library) 228 229############################################################################## 230############################################################################## 231### 232### qemu-android-$CPU: headless emulator core program 233### 234### 235$(call start-emulator-program, qemu-android-$(EMULATOR_TARGET_ARCH)) 236 237LOCAL_CFLAGS += \ 238 $(EMULATOR_COMMON_CFLAGS) \ 239 $(ELFF_CFLAGS) \ 240 $(EMULATOR_LIBQEMU_CFLAGS) \ 241 $(EMULATOR_TARGET_CFLAGS) \ 242 -DCONFIG_STANDALONE_CORE \ 243 244LOCAL_CFLAGS += -Wno-missing-field-initializers 245 246 247LOCAL_STATIC_LIBRARIES := \ 248 emulator-libqemu \ 249 emulator-target-$(EMULATOR_TARGET_CPU) \ 250 emulator-libelff \ 251 emulator-common \ 252 253 254LOCAL_LDLIBS += \ 255 $(EMULATOR_COMMON_LDLIBS) \ 256 $(EMULATOR_LIBQEMU_LDLIBS) \ 257 $(ELFF_LDLIBS) \ 258 259LOCAL_SRC_FILES := \ 260 audio/audio.c \ 261 disas.c \ 262 dma-helpers.c \ 263 gdbstub.c \ 264 keymaps.c \ 265 loader.c \ 266 monitor.c \ 267 qemu-timer.c \ 268 qemu-timer-common.c \ 269 user-events-qemu.c \ 270 vl-android.c \ 271 android/console.c \ 272 android/opengles.c \ 273 android/display-core.c \ 274 android/protocol/attach-ui-proxy.c \ 275 android/protocol/fb-updates-proxy.c \ 276 android/protocol/user-events-impl.c \ 277 android/protocol/ui-commands-proxy.c \ 278 android/protocol/core-commands-impl.c \ 279 android/protocol/core-commands-qemu.c \ 280 281$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c) 282$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h) 283$(call gen-hw-config-defs) 284 285ifeq ($(HOST_OS),darwin) 286 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit 287 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%) 288endif 289 290# Generate a completely static executable if needed. 291# Note that this means no sound and graphics on Linux. 292# 293ifeq ($(CONFIG_STATIC_EXECUTABLE),true) 294 LOCAL_SRC_FILES += dynlink-static.c 295 LOCAL_LDLIBS += -static 296endif 297 298# The following files cannot be in static libraries because they contain 299# constructor functions that are otherwise stripped by the final linker 300LOCAL_SRC_FILES += $(HW_OBJ_SOURCES) 301LOCAL_CFLAGS += $(HW_OBJ_CFLAGS) 302 303LOCAL_SRC_FILES += $(BLOCK_SOURCES) 304LOCAL_CFLAGS += $(BLOCK_CFLAGS) 305 306LOCAL_MODULE_TAGS := debug 307 308$(call end-emulator-program) 309 310############################################################################## 311############################################################################## 312### 313### emulator-$ARCH: Standalone emulator program 314### 315### 316 317$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH)) 318 319LOCAL_STATIC_LIBRARIES := \ 320 emulator-libui \ 321 emulator-libqemu \ 322 emulator-target-$(EMULATOR_TARGET_CPU) \ 323 emulator-libelff \ 324 emulator-common \ 325 326LOCAL_LDLIBS += \ 327 $(EMULATOR_COMMON_LDLIBS) \ 328 $(EMULATOR_LIBQEMU_LDLIBS) \ 329 $(EMULATOR_LIBUI_LDLIBS) \ 330 $(ELFF_LDLIBS) \ 331 332LOCAL_CFLAGS += \ 333 $(EMULATOR_TARGET_CFLAGS) \ 334 $(EMULATOR_COMMON_CFLAGS) \ 335 $(EMULATOR_LIBQEMU_CFLAGS) \ 336 $(EMULATOR_LIBUI_CFLAGS) 337 338LOCAL_SRC_FILES := \ 339 audio/audio.c \ 340 disas.c \ 341 dma-helpers.c \ 342 gdbstub.c \ 343 keymaps.c \ 344 loader.c \ 345 monitor.c \ 346 qemu-timer.c \ 347 qemu-timer-common.c \ 348 user-events-qemu.c \ 349 vl-android.c \ 350 android/cmdline-option.c \ 351 android/console.c \ 352 android/display.c \ 353 android/display-core.c \ 354 android/help.c \ 355 android/main-common.c \ 356 android/main.c \ 357 android/opengles.c \ 358 android/protocol/core-commands-qemu.c \ 359 android/protocol/ui-commands-qemu.c \ 360 android/ 361 362$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c) 363$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h) 364$(call gen-hw-config-defs) 365 366# The following files cannot be in static libraries because they contain 367# constructor functions that are otherwise stripped by the final linker 368LOCAL_SRC_FILES += $(HW_OBJ_SOURCES) 369LOCAL_CFLAGS += $(HW_OBJ_CFLAGS) 370 371LOCAL_SRC_FILES += $(BLOCK_SOURCES) 372LOCAL_CFLAGS += $(BLOCK_CFLAGS) 373 374LOCAL_SRC_FILES += $(SDLMAIN_SOURCES) 375 376# Generate a completely static executable if needed. 377# Note that this means no sound and graphics on Linux. 378# 379ifeq ($(CONFIG_STATIC_EXECUTABLE),true) 380 LOCAL_SRC_FILES += dynlink-static.c 381 LOCAL_LDLIBS += -static 382endif 383 384LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES) 385 386$(call end-emulator-program) 387