blob: e1c4e28709cae202fc7d9a89f0a609473f034bf3 [file] [log] [blame]
David 'Digit' Turneraff94b82011-02-07 18:10:54 +01001# 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)
David 'Digit' Turnerf1d9bf12011-05-11 18:19:41 +020032ifeq ($(HOST_ARCH),x86)
33 TCG_TARGET := i386
34endif
35ifeq ($(HOST_ARCH),x86_64)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010036 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
45$(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU))
46
47# The following is to ensure that "config.h" will map to a target-specific
48# configuration file header.
49LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS)
50
51LOCAL_SRC_FILES += \
52 tcg/tcg.c \
53
54##############################################################################
55# Emulated hardware devices.
56#
57
58HW_SOURCES := \
59 bt.c \
60 bt-hci.c \
61 bt-hid.c \
62 bt-l2cap.c \
63 bt-sdp.c \
64 cdrom.c \
65 dma.c \
66 irq.c \
Jun Nakajima6f198362011-02-24 13:16:01 -080067 goldfish_audio.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010068 goldfish_device.c \
69 goldfish_events_device.c \
70 goldfish_fb.c \
71 goldfish_battery.c \
72 goldfish_mmc.c \
73 goldfish_memlog.c \
74 goldfish_nand.c \
David 'Digit' Turner89217f52011-03-21 17:51:03 +010075 goldfish_pipe.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010076 goldfish_tty.c \
77 msmouse.c \
78 pci.c \
79 qdev.c \
80 scsi-disk.c \
81 sysbus.c \
82 usb-hid.c \
83 usb-hub.c \
84 usb-msd.c \
85 usb-ohci.c \
86 usb.c \
87 watchdog.c
88
David 'Digit' Turner42fc4492011-06-29 13:16:16 +020089$(call gen-hw-config-defs)
90
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010091ifeq ($(EMULATOR_TARGET_ARCH),arm)
92HW_SOURCES += android_arm.c \
93 arm_pic.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010094 goldfish_interrupt.c \
95 goldfish_switch.c \
96 goldfish_timer.c \
97 goldfish_trace.c \
98 arm_boot.c \
99
100# The following sources must be compiled with the final executables
101# because they contain device_init() or machine_init() statements.
102HW_OBJ_SOURCES := hw/smc91c111.c
103HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
104
105LOCAL_SRC_FILES += arm-dis.c
106
107# smc91c111.c requires <zlib.h>
108LOCAL_CFLAGS += $(ZLIB_CFLAGS)
109endif
110
David 'Digit' Turner764a3c92011-05-05 12:40:49 +0200111# required to ensure we properly initialize virtual audio hardware
112LOCAL_CFLAGS += -DHAS_AUDIO
113
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100114ifeq ($(EMULATOR_TARGET_ARCH),x86)
115HW_SOURCES += \
116 apic.c \
117 i8259.c \
118 mc146818rtc.c \
119 piix_pci.c \
120 i8254.c \
121 pckbd.c \
122 ioapic.c \
123 ps2.c \
124 smbios.c \
125 fw_cfg.c
126
127# The following sources must be compiled with the final executables
128# because they contain device_init() or machine_init() statements.
129HW_OBJ_SOURCES := \
130 hw/ne2000.c \
131 hw/pc.c
132
133HW_OBJ_CFLAGS := $(EMULATOR_TARGET_CFLAGS)
134
135endif
136
137LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
138
139LOCAL_SRC_FILES += \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100140 cpu-exec.c \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200141 exec.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100142 translate-all.c \
143 trace.c \
144 varint.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100145 softmmu_outside_jit.c \
146
147##############################################################################
148# CPU-specific emulation.
149#
150LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare
151
152ifeq ($(HOST_ARCH),ppc)
153 LOCAL_CFLAGS += -D__powerpc__
154endif
155
156ifeq ($(EMULATOR_TARGET_ARCH),arm)
157LOCAL_SRC_FILES += \
158 target-arm/op_helper.c \
159 target-arm/iwmmxt_helper.c \
160 target-arm/neon_helper.c \
161 target-arm/helper.c \
David 'Digit' Turner288208c2011-05-11 19:37:35 +0200162 target-arm/helper-android.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100163 target-arm/translate.c \
164 target-arm/machine.c \
165 hw/armv7m.c \
166 hw/armv7m_nvic.c \
167 arm-semi.c \
168
169LOCAL_SRC_FILES += fpu/softfloat.c
170endif
171
172ifeq ($(EMULATOR_TARGET_ARCH), x86)
173LOCAL_SRC_FILES += \
174 target-i386/op_helper.c \
175 target-i386/helper.c \
176 target-i386/translate.c \
177 target-i386/machine.c \
178
Jun Nakajimae4a3c782011-12-17 19:22:12 -0800179ifeq ($(HOST_OS),darwin)
180LOCAL_SRC_FILES += \
181 target-i386/hax-all.c \
182 target-i386/hax-darwin.c
183endif
184
185ifeq ($(HOST_OS),windows)
186LOCAL_SRC_FILES += \
187 target-i386/hax-all.c \
188 target-i386/hax-windows.c
189endif
190
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100191LOCAL_SRC_FILES += fpu/softfloat-native.c
192endif
193
Jun Nakajima1321c762011-03-04 17:17:45 -0800194# compile KVM only if target is x86 on x86 Linux
David 'Digit' Turner36597752011-05-20 01:18:01 +0200195QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
196QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
197ifeq ($(QEMU_DO_KVM),true)
198 LOCAL_SRC_FILES += \
199 target-i386/kvm.c \
Jun Nakajimabb0140b2011-05-27 18:24:21 -0700200 target-i386/kvm-gs-restore.c \
David 'Digit' Turner36597752011-05-20 01:18:01 +0200201 kvm-all.c \
202 kvm-android.c
Jun Nakajima1321c762011-03-04 17:17:45 -0800203endif
204
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100205##############################################################################
206# Memory-access checking support.
207# Memory access checker uses information collected by instrumented code in
208# libc.so in order to keep track of memory blocks allocated from heap. Memory
209# checker then uses this information to make sure that every access to allocated
210# memory is within allocated block. This information also allows detecting
211# memory leaks and attempts to free/realloc invalid pointers.
212#
213LOCAL_CFLAGS += \
214 -I$(LOCAL_PATH)/memcheck \
215 -I$(LOCAL_PATH)/elff
216
217MCHK_SOURCES := \
218 memcheck.c \
219 memcheck_proc_management.c \
220 memcheck_malloc_map.c \
221 memcheck_mmrange_map.c \
222 memcheck_util.c \
223
224LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
225
David 'Digit' Turnerae3098a2011-05-11 16:01:57 +0200226LOCAL_SRC_FILES += \
227 cpus.c \
228 arch_init.c
229
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200230# What a mess, os-posix.c depends on the exact values of options
231# which are target specific.
232ifeq ($(HOST_OS),windows)
233 LOCAL_SRC_FILES += os-win32.c oslib-win32.c
234else
235 LOCAL_SRC_FILES += os-posix.c oslib-posix.c
236endif
237$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100238
239$(call end-emulator-library)
240
241##############################################################################
242##############################################################################
243###
244### qemu-android-$CPU: headless emulator core program
245###
246###
247$(call start-emulator-program, qemu-android-$(EMULATOR_TARGET_ARCH))
248
249LOCAL_CFLAGS += \
250 $(EMULATOR_COMMON_CFLAGS) \
251 $(ELFF_CFLAGS) \
252 $(EMULATOR_LIBQEMU_CFLAGS) \
253 $(EMULATOR_TARGET_CFLAGS) \
254 -DCONFIG_STANDALONE_CORE \
255
256LOCAL_CFLAGS += -Wno-missing-field-initializers
257
258
259LOCAL_STATIC_LIBRARIES := \
260 emulator-libqemu \
261 emulator-target-$(EMULATOR_TARGET_CPU) \
262 emulator-libelff \
263 emulator-common \
264
265
266LOCAL_LDLIBS += \
267 $(EMULATOR_COMMON_LDLIBS) \
268 $(EMULATOR_LIBQEMU_LDLIBS) \
269 $(ELFF_LDLIBS) \
270
271LOCAL_SRC_FILES := \
272 audio/audio.c \
273 disas.c \
274 dma-helpers.c \
275 gdbstub.c \
276 keymaps.c \
277 loader.c \
278 monitor.c \
279 qemu-timer.c \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200280 qemu-timer-common.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100281 user-events-qemu.c \
282 vl-android.c \
283 android/console.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200284 android/opengles.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100285 android/display-core.c \
286 android/protocol/attach-ui-proxy.c \
287 android/protocol/fb-updates-proxy.c \
288 android/protocol/user-events-impl.c \
289 android/protocol/ui-commands-proxy.c \
290 android/protocol/core-commands-impl.c \
291 android/protocol/core-commands-qemu.c \
292
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200293$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200294$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200295$(call gen-hw-config-defs)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100296
297ifeq ($(HOST_OS),darwin)
298 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
299 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
300endif
301
302# Generate a completely static executable if needed.
303# Note that this means no sound and graphics on Linux.
304#
305ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
306 LOCAL_SRC_FILES += dynlink-static.c
307 LOCAL_LDLIBS += -static
308endif
309
310# The following files cannot be in static libraries because they contain
311# constructor functions that are otherwise stripped by the final linker
312LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
313LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
314
315LOCAL_SRC_FILES += $(BLOCK_SOURCES)
316LOCAL_CFLAGS += $(BLOCK_CFLAGS)
317
318LOCAL_MODULE_TAGS := debug
319
320$(call end-emulator-program)
321
322##############################################################################
323##############################################################################
324###
325### emulator-$ARCH: Standalone emulator program
326###
327###
328
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100329$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH))
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100330
331LOCAL_STATIC_LIBRARIES := \
332 emulator-libui \
333 emulator-libqemu \
334 emulator-target-$(EMULATOR_TARGET_CPU) \
335 emulator-libelff \
336 emulator-common \
337
338LOCAL_LDLIBS += \
339 $(EMULATOR_COMMON_LDLIBS) \
340 $(EMULATOR_LIBQEMU_LDLIBS) \
341 $(EMULATOR_LIBUI_LDLIBS) \
342 $(ELFF_LDLIBS) \
343
344LOCAL_CFLAGS += \
345 $(EMULATOR_TARGET_CFLAGS) \
346 $(EMULATOR_COMMON_CFLAGS) \
347 $(EMULATOR_LIBQEMU_CFLAGS) \
348 $(EMULATOR_LIBUI_CFLAGS)
349
350LOCAL_SRC_FILES := \
351 audio/audio.c \
352 disas.c \
353 dma-helpers.c \
354 gdbstub.c \
355 keymaps.c \
356 loader.c \
357 monitor.c \
358 qemu-timer.c \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200359 qemu-timer-common.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100360 user-events-qemu.c \
361 vl-android.c \
362 android/cmdline-option.c \
363 android/console.c \
364 android/display.c \
365 android/display-core.c \
366 android/help.c \
367 android/main-common.c \
368 android/main.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200369 android/opengles.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100370 android/protocol/core-commands-qemu.c \
371 android/protocol/ui-commands-qemu.c \
372 android/
373
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200374$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200375$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200376$(call gen-hw-config-defs)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100377
378# The following files cannot be in static libraries because they contain
379# constructor functions that are otherwise stripped by the final linker
380LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
381LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
382
383LOCAL_SRC_FILES += $(BLOCK_SOURCES)
384LOCAL_CFLAGS += $(BLOCK_CFLAGS)
385
386LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
387
388# Generate a completely static executable if needed.
389# Note that this means no sound and graphics on Linux.
390#
391ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
392 LOCAL_SRC_FILES += dynlink-static.c
393 LOCAL_LDLIBS += -static
394endif
395
396LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
397
398$(call end-emulator-program)