blob: 07940bbaf873bd6850a8d4a10f89b23780376329 [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
179LOCAL_SRC_FILES += fpu/softfloat-native.c
180endif
181
Jun Nakajima1321c762011-03-04 17:17:45 -0800182# compile KVM only if target is x86 on x86 Linux
David 'Digit' Turner36597752011-05-20 01:18:01 +0200183QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
184QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
185ifeq ($(QEMU_DO_KVM),true)
186 LOCAL_SRC_FILES += \
187 target-i386/kvm.c \
Jun Nakajimabb0140b2011-05-27 18:24:21 -0700188 target-i386/kvm-gs-restore.c \
David 'Digit' Turner36597752011-05-20 01:18:01 +0200189 kvm-all.c \
190 kvm-android.c
Jun Nakajima1321c762011-03-04 17:17:45 -0800191endif
192
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100193##############################################################################
194# Memory-access checking support.
195# Memory access checker uses information collected by instrumented code in
196# libc.so in order to keep track of memory blocks allocated from heap. Memory
197# checker then uses this information to make sure that every access to allocated
198# memory is within allocated block. This information also allows detecting
199# memory leaks and attempts to free/realloc invalid pointers.
200#
201LOCAL_CFLAGS += \
202 -I$(LOCAL_PATH)/memcheck \
203 -I$(LOCAL_PATH)/elff
204
205MCHK_SOURCES := \
206 memcheck.c \
207 memcheck_proc_management.c \
208 memcheck_malloc_map.c \
209 memcheck_mmrange_map.c \
210 memcheck_util.c \
211
212LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
213
David 'Digit' Turnerae3098a2011-05-11 16:01:57 +0200214LOCAL_SRC_FILES += \
215 cpus.c \
216 arch_init.c
217
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200218# What a mess, os-posix.c depends on the exact values of options
219# which are target specific.
220ifeq ($(HOST_OS),windows)
221 LOCAL_SRC_FILES += os-win32.c oslib-win32.c
222else
223 LOCAL_SRC_FILES += os-posix.c oslib-posix.c
224endif
225$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100226
227$(call end-emulator-library)
228
229##############################################################################
230##############################################################################
231###
232### qemu-android-$CPU: headless emulator core program
233###
234###
235$(call start-emulator-program, qemu-android-$(EMULATOR_TARGET_ARCH))
236
237LOCAL_CFLAGS += \
238 $(EMULATOR_COMMON_CFLAGS) \
239 $(ELFF_CFLAGS) \
240 $(EMULATOR_LIBQEMU_CFLAGS) \
241 $(EMULATOR_TARGET_CFLAGS) \
242 -DCONFIG_STANDALONE_CORE \
243
244LOCAL_CFLAGS += -Wno-missing-field-initializers
245
246
247LOCAL_STATIC_LIBRARIES := \
248 emulator-libqemu \
249 emulator-target-$(EMULATOR_TARGET_CPU) \
250 emulator-libelff \
251 emulator-common \
252
253
254LOCAL_LDLIBS += \
255 $(EMULATOR_COMMON_LDLIBS) \
256 $(EMULATOR_LIBQEMU_LDLIBS) \
257 $(ELFF_LDLIBS) \
258
259LOCAL_SRC_FILES := \
260 audio/audio.c \
261 disas.c \
262 dma-helpers.c \
263 gdbstub.c \
264 keymaps.c \
265 loader.c \
266 monitor.c \
267 qemu-timer.c \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200268 qemu-timer-common.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100269 user-events-qemu.c \
270 vl-android.c \
271 android/console.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200272 android/opengles.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100273 android/display-core.c \
274 android/protocol/attach-ui-proxy.c \
275 android/protocol/fb-updates-proxy.c \
276 android/protocol/user-events-impl.c \
277 android/protocol/ui-commands-proxy.c \
278 android/protocol/core-commands-impl.c \
279 android/protocol/core-commands-qemu.c \
280
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200281$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200282$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200283$(call gen-hw-config-defs)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100284
285ifeq ($(HOST_OS),darwin)
286 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
287 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
288endif
289
290# Generate a completely static executable if needed.
291# Note that this means no sound and graphics on Linux.
292#
293ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
294 LOCAL_SRC_FILES += dynlink-static.c
295 LOCAL_LDLIBS += -static
296endif
297
298# The following files cannot be in static libraries because they contain
299# constructor functions that are otherwise stripped by the final linker
300LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
301LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
302
303LOCAL_SRC_FILES += $(BLOCK_SOURCES)
304LOCAL_CFLAGS += $(BLOCK_CFLAGS)
305
306LOCAL_MODULE_TAGS := debug
307
308$(call end-emulator-program)
309
310##############################################################################
311##############################################################################
312###
313### emulator-$ARCH: Standalone emulator program
314###
315###
316
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100317$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH))
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100318
319LOCAL_STATIC_LIBRARIES := \
320 emulator-libui \
321 emulator-libqemu \
322 emulator-target-$(EMULATOR_TARGET_CPU) \
323 emulator-libelff \
324 emulator-common \
325
326LOCAL_LDLIBS += \
327 $(EMULATOR_COMMON_LDLIBS) \
328 $(EMULATOR_LIBQEMU_LDLIBS) \
329 $(EMULATOR_LIBUI_LDLIBS) \
330 $(ELFF_LDLIBS) \
331
332LOCAL_CFLAGS += \
333 $(EMULATOR_TARGET_CFLAGS) \
334 $(EMULATOR_COMMON_CFLAGS) \
335 $(EMULATOR_LIBQEMU_CFLAGS) \
336 $(EMULATOR_LIBUI_CFLAGS)
337
338LOCAL_SRC_FILES := \
339 audio/audio.c \
340 disas.c \
341 dma-helpers.c \
342 gdbstub.c \
343 keymaps.c \
344 loader.c \
345 monitor.c \
346 qemu-timer.c \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200347 qemu-timer-common.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100348 user-events-qemu.c \
349 vl-android.c \
350 android/cmdline-option.c \
351 android/console.c \
352 android/display.c \
353 android/display-core.c \
354 android/help.c \
355 android/main-common.c \
356 android/main.c \
David 'Digit' Turnercb88e792011-08-26 01:35:14 +0200357 android/opengles.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100358 android/protocol/core-commands-qemu.c \
359 android/protocol/ui-commands-qemu.c \
360 android/
361
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200362$(call gen-hx-header,qemu-monitor.hx,qemu-monitor.h,monitor.c)
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200363$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200364$(call gen-hw-config-defs)
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100365
366# The following files cannot be in static libraries because they contain
367# constructor functions that are otherwise stripped by the final linker
368LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
369LOCAL_CFLAGS += $(HW_OBJ_CFLAGS)
370
371LOCAL_SRC_FILES += $(BLOCK_SOURCES)
372LOCAL_CFLAGS += $(BLOCK_CFLAGS)
373
374LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
375
376# Generate a completely static executable if needed.
377# Note that this means no sound and graphics on Linux.
378#
379ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
380 LOCAL_SRC_FILES += dynlink-static.c
381 LOCAL_LDLIBS += -static
382endif
383
384LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
385
386$(call end-emulator-program)