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