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