1# This file is included several times to build target-specific 2# modules for the Android emulator. It will be called several times 3# for arm, x86 and mips 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 45common_LOCAL_CFLAGS = 46common_LOCAL_SRC_FILES = 47 48common_LOCAL_CFLAGS += -I$(GLIB_INCLUDE_DIR) 49 50# The following is to ensure that "config.h" will map to a target-specific 51# configuration file header. 52common_LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS) 53 54common_LOCAL_SRC_FILES += \ 55 tcg/optimize.c \ 56 tcg/tcg.c \ 57 tcg-runtime.c \ 58 util/bitops.c \ 59 util/host-utils.c \ 60 61############################################################################## 62# Emulated hardware devices. 63# 64 65HW_SOURCES := \ 66 core/irq.c \ 67 core/qdev.c \ 68 core/sysbus.c \ 69 core/dma.c \ 70 android/goldfish/audio.c \ 71 android/goldfish/device.c \ 72 android/goldfish/events_device.c \ 73 android/goldfish/fb.c \ 74 android/goldfish/battery.c \ 75 android/goldfish/mmc.c \ 76 android/goldfish/nand.c \ 77 android/goldfish/pipe.c \ 78 android/goldfish/tty.c \ 79 android/goldfish/vmem.c \ 80 pci/pci.c \ 81 watchdog/watchdog.c 82 83 84ifeq ($(EMULATOR_TARGET_ARCH),arm) 85HW_SOURCES += \ 86 android/android_arm.c \ 87 arm/pic.c \ 88 arm/boot.c \ 89 android/goldfish/interrupt.c \ 90 android/goldfish/timer.c 91 92# The following sources must be compiled with the final executables 93# because they contain device_init() or machine_init() statements. 94HW_OBJ_SOURCES := hw/net/smc91c111.c 95HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 96 97common_LOCAL_SRC_FILES += disas/arm.c 98 99# smc91c111.c requires <zlib.h> 100common_LOCAL_CFLAGS += $(ZLIB_CFLAGS) 101endif 102 103# required to ensure we properly initialize virtual audio hardware 104common_LOCAL_CFLAGS += -DHAS_AUDIO 105 106ifeq ($(EMULATOR_TARGET_ARCH),x86) 107HW_SOURCES += \ 108 intc/apic.c \ 109 intc/i8259.c \ 110 timer/mc146818rtc.c \ 111 pci-host/piix.c \ 112 timer/i8254.c \ 113 input/pckbd.c \ 114 intc/ioapic.c \ 115 input/ps2.c \ 116 i386/smbios.c \ 117 nvram/fw_cfg.c 118 119# The following sources must be compiled with the final executables 120# because they contain device_init() or machine_init() statements. 121HW_OBJ_SOURCES := \ 122 hw/net/ne2000.c \ 123 hw/i386/pc.c 124 125HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 126 127endif 128 129ifeq ($(EMULATOR_TARGET_ARCH),mips) 130HW_SOURCES += \ 131 android/android_mips.c \ 132 mips/mips_pic.c \ 133 android/goldfish/interrupt.c \ 134 android/goldfish/timer.c \ 135 mips/cputimer.c \ 136 mips/mips_int.c 137 138# The following sources must be compiled with the final executables 139# because they contain device_init() or machine_init() statements. 140HW_OBJ_SOURCES := hw/net/smc91c111.c 141HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS) 142 143common_LOCAL_SRC_FILES += disas/mips.c 144 145# smc91c111.c requires <zlib.h> 146LOCAL_CFLAGS += $(ZLIB_CFLAGS) 147ifeq ($(ARCH_HAS_BIGENDIAN),true) 148 LOCAL_CFLAGS += -DTARGET_WORDS_BIGENDIAN 149endif 150 151endif 152common_LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%) 153 154common_LOCAL_SRC_FILES += \ 155 backends/msmouse.c \ 156 cpu-exec.c \ 157 cputlb.c \ 158 exec.c \ 159 main-loop.c \ 160 memory-android.c \ 161 monitor-android.c \ 162 translate-all.c \ 163 164############################################################################## 165# CPU-specific emulation. 166# 167common_LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare 168 169ifeq ($(HOST_ARCH),ppc) 170 common_LOCAL_CFLAGS += -D__powerpc__ 171endif 172 173ifeq ($(EMULATOR_TARGET_ARCH),arm) 174common_LOCAL_SRC_FILES += \ 175 target-arm/arm-semi.c \ 176 target-arm/op_helper.c \ 177 target-arm/iwmmxt_helper.c \ 178 target-arm/neon_helper.c \ 179 target-arm/helper.c \ 180 target-arm/translate.c \ 181 target-arm/machine.c \ 182 hw/arm/armv7m.c \ 183 hw/arm/armv7m_nvic.c 184endif # EMULATOR_TARGET_ARCH == arm 185 186ifeq ($(EMULATOR_TARGET_ARCH), x86) 187common_LOCAL_SRC_FILES += \ 188 target-i386/cc_helper.c \ 189 target-i386/excp_helper.c \ 190 target-i386/fpu_helper.c \ 191 target-i386/int_helper.c \ 192 target-i386/mem_helper.c \ 193 target-i386/misc_helper.c \ 194 target-i386/seg_helper.c \ 195 target-i386/smm_helper.c \ 196 target-i386/svm_helper.c \ 197 target-i386/helper.c \ 198 target-i386/translate.c \ 199 target-i386/machine.c \ 200 201ifeq ($(HOST_OS),darwin) 202common_LOCAL_SRC_FILES += \ 203 target-i386/hax-all.c \ 204 target-i386/hax-darwin.c 205endif 206 207ifeq ($(HOST_OS),windows) 208common_LOCAL_SRC_FILES += \ 209 target-i386/hax-all.c \ 210 target-i386/hax-windows.c 211endif 212endif # EMULATOR_TARGET_ARCH == x86 213 214ifeq ($(EMULATOR_TARGET_ARCH), mips) 215common_LOCAL_SRC_FILES += \ 216 target-mips/op_helper.c \ 217 target-mips/helper.c \ 218 target-mips/translate.c \ 219 target-mips/machine.c 220endif # EMULATOR_TARGET_ARCH == mips 221 222common_LOCAL_SRC_FILES += fpu/softfloat.c 223 224# compile KVM only if target is x86 on x86 Linux 225QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH) 226QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false) 227ifeq ($(QEMU_DO_KVM),true) 228 common_LOCAL_SRC_FILES += \ 229 target-i386/kvm.c \ 230 target-i386/kvm-gs-restore.c \ 231 kvm-all.c \ 232 kvm-android.c 233endif 234 235common_LOCAL_SRC_FILES += \ 236 cpus.c \ 237 arch_init.c 238 239# What a mess, os-posix.c depends on the exact values of options 240# which are target specific. 241ifeq ($(HOST_OS),windows) 242 common_LOCAL_SRC_FILES += os-win32.c util/oslib-win32.c 243else 244 common_LOCAL_SRC_FILES += os-posix.c util/oslib-posix.c 245endif 246 247 248## one for 32-bit 249$(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU)) 250LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) 251LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES) 252$(call gen-hw-config-defs) 253$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c) 254$(call end-emulator-library) 255 256$(call start-emulator64-library, emulator64-target-$(EMULATOR_TARGET_CPU)) 257LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) 258LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES) 259$(call gen-hw-config-defs) 260$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c) 261$(call end-emulator-library) 262 263############################################################################## 264############################################################################## 265### 266### emulator-$ARCH: Standalone emulator program 267### 268### 269 270common_LOCAL_LDLIBS = 271common_LOCAL_CFLAGS = 272common_LOCAL_SRC_FILES = 273 274 275common_LOCAL_STATIC_LIBRARIES := \ 276 emulator-libui \ 277 emulator-libqemu \ 278 emulator-target-$(EMULATOR_TARGET_CPU) \ 279 emulator-common \ 280 emulator-zlib 281 282common_LOCAL_LDLIBS += \ 283 $(EMULATOR_COMMON_LDLIBS) \ 284 $(EMULATOR_LIBQEMU_LDLIBS) \ 285 $(EMULATOR_LIBUI_LDLIBS) \ 286 $(ELFF_LDLIBS) 287 288common_LOCAL_CFLAGS += \ 289 $(EMULATOR_TARGET_CFLAGS) \ 290 $(EMULATOR_COMMON_CFLAGS) \ 291 $(EMULATOR_LIBQEMU_CFLAGS) \ 292 $(EMULATOR_LIBUI_CFLAGS) 293 294common_LOCAL_SRC_FILES := \ 295 audio/audio.c \ 296 disas.c \ 297 dma-helpers.c \ 298 gdbstub.c \ 299 qemu-timer.c \ 300 log-rotate-android.c \ 301 vl-android.c \ 302 android/cmdline-option.c \ 303 android/console.c \ 304 android/cpu_accelerator.cpp \ 305 android/display.c \ 306 android/display-core.c \ 307 android/help.c \ 308 android/main-common.c \ 309 android/main-common-ui.c \ 310 android/main.c \ 311 android/opengles.c \ 312 android/user-events-qemu.c \ 313 hw/core/loader.c \ 314 ui/keymaps.c \ 315 util/qemu-timer-common.c \ 316 util/iov.c \ 317 318# The following files cannot be in static libraries because they contain 319# constructor functions that are otherwise stripped by the final linker 320common_LOCAL_SRC_FILES += $(HW_OBJ_SOURCES) 321common_LOCAL_CFLAGS += $(HW_OBJ_CFLAGS) 322 323common_LOCAL_SRC_FILES += $(BLOCK_SOURCES) 324common_LOCAL_CFLAGS += $(BLOCK_CFLAGS) 325 326common_LOCAL_LDLIBS += -lstdc++ 327 328# Generate a completely static executable if needed. 329# Note that this means no sound and graphics on Linux. 330# 331ifneq ($(strip $(CONFIG_STATIC_EXECUTABLE)$(BUILD_HOST_static)),) 332 common_LOCAL_SRC_FILES += android/dynlink-static.c 333 common_LOCAL_LDLIBS += -static 334endif 335 336## one for 32-bit 337$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH)) 338LOCAL_STATIC_LIBRARIES += \ 339 emulator-libui \ 340 emulator-libqemu \ 341 emulator-target-$(EMULATOR_TARGET_CPU) \ 342 emulator-libjpeg \ 343 emulator-common \ 344 emulator-libext4_utils \ 345 emulator-libsparse \ 346 emulator-libselinux \ 347 emulator-zlib \ 348 $(SDL_STATIC_LIBRARIES) 349 350LOCAL_LDLIBS += $(common_LOCAL_LDLIBS) 351LOCAL_LDFLAGS += $(common_LOCAL_LDFLAGS) 352LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) 353LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES) 354$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h) 355$(call gen-hw-config-defs) 356 357ifeq ($(HOST_OS),windows) 358 $(eval $(call insert-windows-icon)) 359 # Special exception for Windows: -lmingw32 must appear before libSDLmain 360 # on the link command-line, because it depends on _WinMain@16 which is 361 # exported by the latter. 362 LOCAL_LDFLAGS += -lmingw32 363endif 364 365$(call end-emulator-program) 366 367 368$(call start-emulator64-program, emulator64-$(EMULATOR_TARGET_ARCH)) 369LOCAL_STATIC_LIBRARIES += \ 370 emulator64-libui \ 371 emulator64-libqemu \ 372 emulator64-target-$(EMULATOR_TARGET_CPU) \ 373 emulator64-libjpeg \ 374 emulator64-common \ 375 emulator64-libext4_utils \ 376 emulator64-libsparse \ 377 emulator64-libselinux \ 378 emulator64-zlib \ 379 $(SDL_STATIC_LIBRARIES_64) 380 381LOCAL_LDLIBS += $(common_LOCAL_LDLIBS) 382LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) 383LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES) 384$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h) 385$(call gen-hw-config-defs) 386 387ifeq ($(HOST_OS),windows) 388 $(eval $(call insert-windows-icon)) 389 # Special exception for Windows: -lmingw32 must appear before libSDLmain 390 # on the link command-line, because it depends on _WinMain@16 which is 391 # exported by the latter. 392 LOCAL_LDFLAGS += -lmingw32 393endif 394 395$(call end-emulator-program) 396