Home | History | Annotate | Download | only in qemu
      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 
      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 common_LOCAL_CFLAGS =
     46 common_LOCAL_SRC_FILES =
     47 
     48 common_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.
     52 common_LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS)
     53 
     54 common_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 
     65 HW_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 
     84 ifeq ($(EMULATOR_TARGET_ARCH),arm)
     85 HW_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.
     94 HW_OBJ_SOURCES := hw/net/smc91c111.c
     95 HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)
     96 
     97 common_LOCAL_SRC_FILES += disas/arm.c
     98 
     99 # smc91c111.c requires <zlib.h>
    100 common_LOCAL_CFLAGS += $(ZLIB_CFLAGS)
    101 endif
    102 
    103 # required to ensure we properly initialize virtual audio hardware
    104 common_LOCAL_CFLAGS += -DHAS_AUDIO
    105 
    106 ifeq ($(EMULATOR_TARGET_ARCH),x86)
    107 HW_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.
    121 HW_OBJ_SOURCES := \
    122     hw/net/ne2000.c \
    123     hw/i386/pc.c
    124 
    125 HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)
    126 
    127 endif
    128 
    129 ifeq ($(EMULATOR_TARGET_ARCH),mips)
    130 HW_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.
    140 HW_OBJ_SOURCES := hw/net/smc91c111.c
    141 HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)
    142 
    143 common_LOCAL_SRC_FILES += disas/mips.c
    144 
    145 # smc91c111.c requires <zlib.h>
    146 LOCAL_CFLAGS += $(ZLIB_CFLAGS)
    147 ifeq ($(ARCH_HAS_BIGENDIAN),true)
    148   LOCAL_CFLAGS += -DTARGET_WORDS_BIGENDIAN
    149 endif
    150 
    151 endif
    152 common_LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
    153 
    154 common_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 #
    167 common_LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare
    168 
    169 ifeq ($(HOST_ARCH),ppc)
    170     common_LOCAL_CFLAGS += -D__powerpc__
    171 endif
    172 
    173 ifeq ($(EMULATOR_TARGET_ARCH),arm)
    174 common_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
    184 endif  # EMULATOR_TARGET_ARCH == arm
    185 
    186 ifeq ($(EMULATOR_TARGET_ARCH), x86)
    187 common_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 
    201 ifeq ($(HOST_OS),darwin)
    202 common_LOCAL_SRC_FILES += \
    203       target-i386/hax-all.c       \
    204       target-i386/hax-darwin.c
    205 endif
    206 
    207 ifeq ($(HOST_OS),windows)
    208 common_LOCAL_SRC_FILES += \
    209       target-i386/hax-all.c       \
    210       target-i386/hax-windows.c
    211 endif
    212 endif  # EMULATOR_TARGET_ARCH == x86
    213 
    214 ifeq ($(EMULATOR_TARGET_ARCH), mips)
    215 common_LOCAL_SRC_FILES += \
    216     target-mips/op_helper.c \
    217     target-mips/helper.c \
    218     target-mips/translate.c \
    219     target-mips/machine.c
    220 endif  # EMULATOR_TARGET_ARCH == mips
    221 
    222 common_LOCAL_SRC_FILES += fpu/softfloat.c
    223 
    224 # compile KVM only if target is x86 on x86 Linux
    225 QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
    226 QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
    227 ifeq ($(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
    233 endif
    234 
    235 common_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.
    241 ifeq ($(HOST_OS),windows)
    242     common_LOCAL_SRC_FILES += os-win32.c util/oslib-win32.c
    243 else
    244     common_LOCAL_SRC_FILES += os-posix.c util/oslib-posix.c
    245 endif
    246 
    247 
    248 ## one for 32-bit
    249 $(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU))
    250 LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
    251 LOCAL_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))
    257 LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
    258 LOCAL_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 
    270 common_LOCAL_LDLIBS =
    271 common_LOCAL_CFLAGS =
    272 common_LOCAL_SRC_FILES =
    273 
    274 
    275 common_LOCAL_STATIC_LIBRARIES := \
    276     emulator-libui \
    277     emulator-libqemu \
    278     emulator-target-$(EMULATOR_TARGET_CPU) \
    279     emulator-common \
    280     emulator-zlib
    281 
    282 common_LOCAL_LDLIBS += \
    283     $(EMULATOR_COMMON_LDLIBS) \
    284     $(EMULATOR_LIBQEMU_LDLIBS) \
    285     $(EMULATOR_LIBUI_LDLIBS) \
    286     $(ELFF_LDLIBS)
    287 
    288 common_LOCAL_CFLAGS += \
    289     $(EMULATOR_TARGET_CFLAGS) \
    290     $(EMULATOR_COMMON_CFLAGS) \
    291     $(EMULATOR_LIBQEMU_CFLAGS) \
    292     $(EMULATOR_LIBUI_CFLAGS)
    293 
    294 common_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
    320 common_LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
    321 common_LOCAL_CFLAGS    += $(HW_OBJ_CFLAGS)
    322 
    323 common_LOCAL_SRC_FILES += $(BLOCK_SOURCES)
    324 common_LOCAL_CFLAGS    += $(BLOCK_CFLAGS)
    325 
    326 common_LOCAL_LDLIBS += -lstdc++
    327 
    328 # Generate a completely static executable if needed.
    329 # Note that this means no sound and graphics on Linux.
    330 #
    331 ifneq ($(strip $(CONFIG_STATIC_EXECUTABLE)$(BUILD_HOST_static)),)
    332     common_LOCAL_SRC_FILES += android/dynlink-static.c
    333     common_LOCAL_LDLIBS    += -static
    334 endif
    335 
    336 ## one for 32-bit
    337 $(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH))
    338 LOCAL_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 
    350 LOCAL_LDLIBS += $(common_LOCAL_LDLIBS)
    351 LOCAL_LDFLAGS += $(common_LOCAL_LDFLAGS)
    352 LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
    353 LOCAL_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 
    357 ifeq ($(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
    363 endif
    364 
    365 $(call end-emulator-program)
    366 
    367 
    368 $(call start-emulator64-program, emulator64-$(EMULATOR_TARGET_ARCH))
    369 LOCAL_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 
    381 LOCAL_LDLIBS += $(common_LOCAL_LDLIBS)
    382 LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
    383 LOCAL_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 
    387 ifeq ($(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
    393 endif
    394 
    395 $(call end-emulator-program)
    396