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 6 ifndef EMULATOR_TARGET_ARCH 7 $(error EMULATOR_TARGET_ARCH is not defined!) 8 endif 9 10 EMULATOR_TARGET_CPU := $(EMULATOR_TARGET_ARCH) 11 ifeq ($(EMULATOR_TARGET_CPU),x86) 12 EMULATOR_TARGET_CPU := i386 13 endif 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 24 EMULATOR_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 31 TCG_TARGET := $(HOST_ARCH) 32 ifeq ($(HOST_ARCH),x86) 33 TCG_TARGET := i386 34 endif 35 ifeq ($(HOST_ARCH),x86_64) 36 TCG_TARGET := i386 37 endif 38 39 EMULATOR_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. 49 LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS) 50 51 LOCAL_SRC_FILES += \ 52 tcg/tcg.c \ 53 54 ############################################################################## 55 # Emulated hardware devices. 56 # 57 58 HW_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 91 ifeq ($(EMULATOR_TARGET_ARCH),arm) 92 HW_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. 102 HW_OBJ_SOURCES := hw/smc91c111.c 103 HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 104 105 LOCAL_SRC_FILES += arm-dis.c 106 107 # smc91c111.c requires <zlib.h> 108 LOCAL_CFLAGS += $(ZLIB_CFLAGS) 109 endif 110 111 # required to ensure we properly initialize virtual audio hardware 112 LOCAL_CFLAGS += -DHAS_AUDIO 113 114 ifeq ($(EMULATOR_TARGET_ARCH),x86) 115 HW_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. 129 HW_OBJ_SOURCES := \ 130 hw/ne2000.c \ 131 hw/pc.c 132 133 HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 134 135 endif 136 137 LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%) 138 139 LOCAL_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 # 150 LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare 151 152 ifeq ($(HOST_ARCH),ppc) 153 LOCAL_CFLAGS += -D__powerpc__ 154 endif 155 156 ifeq ($(EMULATOR_TARGET_ARCH),arm) 157 LOCAL_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 169 LOCAL_SRC_FILES += fpu/softfloat.c 170 endif 171 172 ifeq ($(EMULATOR_TARGET_ARCH), x86) 173 LOCAL_SRC_FILES += \ 174 target-i386/op_helper.c \ 175 target-i386/helper.c \ 176 target-i386/translate.c \ 177 target-i386/machine.c \ 178 179 LOCAL_SRC_FILES += fpu/softfloat-native.c 180 endif 181 182 # compile KVM only if target is x86 on x86 Linux 183 QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH) 184 QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false) 185 ifeq ($(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 191 endif 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 # 201 LOCAL_CFLAGS += \ 202 -I$(LOCAL_PATH)/memcheck \ 203 -I$(LOCAL_PATH)/elff 204 205 MCHK_SOURCES := \ 206 memcheck.c \ 207 memcheck_proc_management.c \ 208 memcheck_malloc_map.c \ 209 memcheck_mmrange_map.c \ 210 memcheck_util.c \ 211 212 LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%) 213 214 LOCAL_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. 220 ifeq ($(HOST_OS),windows) 221 LOCAL_SRC_FILES += os-win32.c oslib-win32.c 222 else 223 LOCAL_SRC_FILES += os-posix.c oslib-posix.c 224 endif 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 237 LOCAL_CFLAGS += \ 238 $(EMULATOR_COMMON_CFLAGS) \ 239 $(ELFF_CFLAGS) \ 240 $(EMULATOR_LIBQEMU_CFLAGS) \ 241 $(EMULATOR_TARGET_CFLAGS) \ 242 -DCONFIG_STANDALONE_CORE \ 243 244 LOCAL_CFLAGS += -Wno-missing-field-initializers 245 246 247 LOCAL_STATIC_LIBRARIES := \ 248 emulator-libqemu \ 249 emulator-target-$(EMULATOR_TARGET_CPU) \ 250 emulator-libelff \ 251 emulator-common \ 252 253 254 LOCAL_LDLIBS += \ 255 $(EMULATOR_COMMON_LDLIBS) \ 256 $(EMULATOR_LIBQEMU_LDLIBS) \ 257 $(ELFF_LDLIBS) \ 258 259 LOCAL_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 285 ifeq ($(HOST_OS),darwin) 286 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit 287 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%) 288 endif 289 290 # Generate a completely static executable if needed. 291 # Note that this means no sound and graphics on Linux. 292 # 293 ifeq ($(CONFIG_STATIC_EXECUTABLE),true) 294 LOCAL_SRC_FILES += dynlink-static.c 295 LOCAL_LDLIBS += -static 296 endif 297 298 # The following files cannot be in static libraries because they contain 299 # constructor functions that are otherwise stripped by the final linker 300 LOCAL_SRC_FILES += $(HW_OBJ_SOURCES) 301 LOCAL_CFLAGS += $(HW_OBJ_CFLAGS) 302 303 LOCAL_SRC_FILES += $(BLOCK_SOURCES) 304 LOCAL_CFLAGS += $(BLOCK_CFLAGS) 305 306 LOCAL_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 319 LOCAL_STATIC_LIBRARIES := \ 320 emulator-libui \ 321 emulator-libqemu \ 322 emulator-target-$(EMULATOR_TARGET_CPU) \ 323 emulator-libelff \ 324 emulator-common \ 325 326 LOCAL_LDLIBS += \ 327 $(EMULATOR_COMMON_LDLIBS) \ 328 $(EMULATOR_LIBQEMU_LDLIBS) \ 329 $(EMULATOR_LIBUI_LDLIBS) \ 330 $(ELFF_LDLIBS) \ 331 332 LOCAL_CFLAGS += \ 333 $(EMULATOR_TARGET_CFLAGS) \ 334 $(EMULATOR_COMMON_CFLAGS) \ 335 $(EMULATOR_LIBQEMU_CFLAGS) \ 336 $(EMULATOR_LIBUI_CFLAGS) 337 338 LOCAL_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 368 LOCAL_SRC_FILES += $(HW_OBJ_SOURCES) 369 LOCAL_CFLAGS += $(HW_OBJ_CFLAGS) 370 371 LOCAL_SRC_FILES += $(BLOCK_SOURCES) 372 LOCAL_CFLAGS += $(BLOCK_CFLAGS) 373 374 LOCAL_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 # 379 ifeq ($(CONFIG_STATIC_EXECUTABLE),true) 380 LOCAL_SRC_FILES += dynlink-static.c 381 LOCAL_LDLIBS += -static 382 endif 383 384 LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES) 385 386 $(call end-emulator-program) 387