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