blob: bec91ba7aa989f785cfb90c57a08f7c2414fc685 [file] [log] [blame]
Jun Nakajima334ab472011-02-02 23:49:59 -08001ifneq (,$(filter $(TARGET_ARCH),arm x86))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08002LOCAL_PATH:= $(call my-dir)
3
Jun Nakajima334ab472011-02-02 23:49:59 -08004# determine the target cpu
5ifeq ($(TARGET_ARCH),arm)
6EMULATOR_TARGET_CPU := target-arm
7else
8EMULATOR_TARGET_CPU := target-i386
9endif
10
David 'Digit' Turner34d16512010-05-18 17:02:33 -070011# determine the host tag to use
12QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
13ifneq ($(USE_MINGW),)
14 QEMU_HOST_TAG := windows
15endif
16
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080017# determine the location of platform-specific directories
18#
19CONFIG_DIRS := \
20 $(LOCAL_PATH)/android/config \
David 'Digit' Turner34d16512010-05-18 17:02:33 -070021 $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
22
23ifeq ($(BUILD_STANDALONE_EMULATOR),true)
24 CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS)
25endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080026
27CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
28
Kenny Root095cd0f2009-09-19 18:32:44 -050029MY_CC := $(HOST_CC)
30
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070031MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
32ifeq ($(BUILD_DEBUG_EMULATOR),true)
33 MY_OPTIM := -O0 -g
34endif
35
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080036MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080037
David 'Digit' Turner466f5482009-07-30 15:50:19 +020038# Overwrite configuration for debug builds.
39#
40ifeq ($(BUILD_DEBUG_EMULATOR),true)
41 MY_CFLAGS := $(CONFIG_INCLUDES) -O0 -g \
42 -fno-PIC -falign-functions=0
43endif
44
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080045MY_CFLAGS += -DCONFIG_MEMCHECK
46
Jun Nakajima334ab472011-02-02 23:49:59 -080047# prepare config.h for x86
48ifeq ($(TARGET_ARCH),x86)
49MY_CFLAGS += -DARCH_FLAGS_x86
50endif
51
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070052MY_LDLIBS :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080053
54# this is needed to build the emulator on 64-bit Linux systems
55ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
56 MY_CFLAGS += -Wa,--32
57endif
58
59ifeq ($(HOST_OS),freebsd)
60 MY_CFLAGS += -Wa,--32 -I /usr/local/include
61endif
62
63ifeq ($(HOST_OS),windows)
64 MY_CFLAGS += -D_WIN32 -mno-cygwin
65 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
66 MY_CFLAGS += -DWINVER=0x501
67endif
68
69ifeq ($(HOST_ARCH),ppc)
70 MY_CFLAGS += -D__powerpc__
71endif
72
73ifeq ($(HOST_OS),darwin)
David 'Digit' Turner747f7d12011-01-06 22:24:26 +010074 MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
David Turnerbba461c2009-06-03 10:48:15 -070075
76 # When building on Leopard or above, we need to use the 10.4 SDK
77 # or the generated binary will not run on Tiger.
78 DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
Jeff Hamiltond0d97342010-05-27 11:41:41 -050079 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(DARWIN_VERSION)),)
80 $(error Building the Android emulator requires OS X 10.5 or above)
David Turnerbba461c2009-06-03 10:48:15 -070081 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050082 ifeq ($(filter 10.5 10.5.%,$(DARWIN_VERSION)),)
83 # We are on Snow Leopard or above
84 LEOPARD_SDK := /Developer/SDKs/MacOSX10.5.sdk
85 ifeq ($(strip $(wildcard $(LEOPARD_SDK))),)
86 $(info Please install the 10.5 SDK on this machine at $(LEOPARD_SDK))
David Turnerbba461c2009-06-03 10:48:15 -070087 $(error Aborting the build.)
88 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050089 MY_CFLAGS += -isysroot $(LEOPARD_SDK) -mmacosx-version-min=10.5 -DMACOSX_DEPLOYMENT_TARGET=10.5
90 MY_LDLIBS += -isysroot $(LEOPARD_SDK) -Wl,-syslibroot,$(LEOPARD_SDK) -mmacosx-version-min=10.5
David Turnerbba461c2009-06-03 10:48:15 -070091 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080092endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080093
94# BUILD_STANDALONE_EMULATOR is only defined when building with
95# the android-rebuild.sh script. The script will also provide
96# adequate values for HOST_CC
97#
98ifneq ($(BUILD_STANDALONE_EMULATOR),true)
99
100 ifneq ($(USE_CCACHE),)
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700101 ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache
102 ifneq ($(ccache),$(firstword $(MY_CC)))
103 MY_CC := $(ccache) $(MY_CC)
104 endif
105 ccache :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800106 endif
107endif
108
109
110ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
111 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700112 MY_CFLAGS += -m32
113 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800114 endif
115endif
116
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200117# Enable warning, except those related to missing field initializers
118# (the QEMU coding style loves using these).
119#
120MY_CFLAGS += -Wall -Wno-missing-field-initializers
121
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800122include $(CLEAR_VARS)
123
124###########################################################
125# Zlib configuration
126#
127ZLIB_DIR := distrib/zlib-1.2.3
128include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
129
130###########################################################
131# Libpng configuration
132#
133LIBPNG_DIR := distrib/libpng-1.2.19
134include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
135
136###############################################################################
137# build the TCG code generator
138#
139include $(CLEAR_VARS)
140
141LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
142LOCAL_CC := $(MY_CC)
143LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700144LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800145LOCAL_MODULE := emulator-tcg
146
147TCG_TARGET := $(HOST_ARCH)
148ifeq ($(TCG_TARGET),x86)
149 TCG_TARGET := i386
150endif
151
152TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
153
David Turner6a9ef172010-09-09 22:54:36 +0200154LOCAL_CFLAGS += $(TCG_CFLAGS) -DNEED_CPU_H \
Jun Nakajima334ab472011-02-02 23:49:59 -0800155 -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800156 -I$(LOCAL_PATH)/fpu \
157
158LOCAL_SRC_FILES := \
159 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800160
161include $(BUILD_HOST_STATIC_LIBRARY)
162
163##############################################################################
164# build the HW emulation support
165#
166include $(CLEAR_VARS)
167
168LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
169LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500170LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800171LOCAL_MODULE := emulator-hw
172
173HW_CFLAGS := -I$(LOCAL_PATH)/hw
174
David Turner6a9ef172010-09-09 22:54:36 +0200175LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
Jun Nakajima334ab472011-02-02 23:49:59 -0800176LOCAL_CFLAGS += -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800177LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
178
179HW_SOURCES := \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700180 bt.c \
181 bt-hci.c \
182 bt-hid.c \
183 bt-l2cap.c \
184 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800185 cdrom.c \
186 dma.c \
187 irq.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800188 goldfish_device.c \
189 goldfish_events_device.c \
190 goldfish_fb.c \
Jun Nakajima334ab472011-02-02 23:49:59 -0800191 goldfish_battery.c \
192 goldfish_mmc.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800193 goldfish_memlog.c \
Jun Nakajima334ab472011-02-02 23:49:59 -0800194 goldfish_nand.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800195 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700196 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800197 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700198 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800199 scsi-disk.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700200 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800201 usb-hid.c \
202 usb-hub.c \
203 usb-msd.c \
204 usb-ohci.c \
205 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700206 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800207
Jun Nakajima334ab472011-02-02 23:49:59 -0800208ifeq ($(TARGET_ARCH),arm)
209HW_SOURCES += android_arm.c \
210 arm_pic.c \
211 smc91c111.c \
212 goldfish_audio.c \
213 goldfish_interrupt.c \
214 goldfish_switch.c \
215 goldfish_timer.c \
216 goldfish_trace.c \
217
218endif
219
220ifeq ($(TARGET_ARCH),x86)
221HW_SOURCES += pc.c \
222 apic.c \
223 i8259.c \
224 mc146818rtc.c \
225 piix_pci.c \
226 i8254.c \
227 ne2000.c \
228 pckbd.c \
229 ioapic.c \
230 ps2.c \
231 smbios.c \
232 fw_cfg.c \
233
234endif
235
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800236LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
237
238include $(BUILD_HOST_STATIC_LIBRARY)
239
240##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800241# build the ELF/DWARF stuff
242# This library is used by emulator's memory checker to extract debug information
243# from the symbol files when reporting memory allocation violations. In
244# particular, this library is used to extract routine name and source file
245# location for the code address where violation has been detected.
246#
247include $(CLEAR_VARS)
248
249LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
250LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500251LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800252LOCAL_MODULE := emulator-elff
253LOCAL_CPP_EXTENSION := .cc
254
255ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
256
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800257LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
Jun Nakajima334ab472011-02-02 23:49:59 -0800258LOCAL_CFLAGS += -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800259LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
260
261ELFF_SOURCES := \
262 dwarf_cu.cc \
263 dwarf_die.cc \
264 dwarf_utils.cc \
265 elf_alloc.cc \
266 elf_file.cc \
267 elf_mapped_section.cc \
268 elff_api.cc \
269
270LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
271ELFF_LDLIBS := -lstdc++
272
273include $(BUILD_HOST_STATIC_LIBRARY)
274
275##############################################################################
276# build the memory access checking support
277# Memory access checker uses information collected by instrumented code in
278# libc.so in order to keep track of memory blocks allocated from heap. Memory
279# checker then uses this information to make sure that every access to allocated
280# memory is within allocated block. This information also allows detecting
281# memory leaks and attempts to free/realloc invalid pointers.
282#
283include $(CLEAR_VARS)
284
285LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
286LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500287LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800288LOCAL_MODULE := emulator-memcheck
289
290MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
291
David Turner6a9ef172010-09-09 22:54:36 +0200292LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
Jun Nakajima334ab472011-02-02 23:49:59 -0800293LOCAL_CFLAGS += -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800294LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
295
296MCHK_SOURCES := \
297 memcheck.c \
298 memcheck_proc_management.c \
299 memcheck_malloc_map.c \
300 memcheck_mmrange_map.c \
301 memcheck_util.c \
302
303LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
304
305include $(BUILD_HOST_STATIC_LIBRARY)
306
307##############################################################################
Jun Nakajima334ab472011-02-02 23:49:59 -0800308# build the CPU-specific emulation engine sources
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800309#
310include $(CLEAR_VARS)
311
Jun Nakajima334ab472011-02-02 23:49:59 -0800312ifeq ($(TARGET_ARCH),arm)
313LOCAL_MODULE := emulator-arm
314endif
315ifeq ($(TARGET_ARCH),x86)
316LOCAL_MODULE := emulator-i386
317LOCAL_MODULE_TAGS := optional
318endif
319
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800320LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
321LOCAL_CC := $(MY_CC)
Jun Nakajima334ab472011-02-02 23:49:59 -0800322LOCAL_MODULE := $(LOCAL_MODULE)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700323LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800324LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
325LOCAL_STATIC_LIBRARIES := emulator-hw
326
327LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
328LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
329
330LOCAL_CFLAGS += -I$(LOCAL_PATH) \
Jun Nakajima334ab472011-02-02 23:49:59 -0800331 -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800332 -I$(LOCAL_PATH)/fpu \
333 $(TCG_CFLAGS) \
334 $(HW_CFLAGS) \
David Turner6a9ef172010-09-09 22:54:36 +0200335 -DNEED_CPU_H \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800336
337ifeq ($(HOST_ARCH),ppc)
338 LOCAL_CFLAGS += -D__powerpc__
339endif
340
Jun Nakajima334ab472011-02-02 23:49:59 -0800341ifeq ($(TARGET_ARCH),arm)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800342LOCAL_SRC_FILES += exec.c cpu-exec.c \
Jun Nakajima334ab472011-02-02 23:49:59 -0800343 $(EMULATOR_TARGET_CPU)/op_helper.c \
344 $(EMULATOR_TARGET_CPU)/iwmmxt_helper.c \
345 $(EMULATOR_TARGET_CPU)/neon_helper.c \
346 $(EMULATOR_TARGET_CPU)/helper.c \
347 $(EMULATOR_TARGET_CPU)/translate.c \
348 $(EMULATOR_TARGET_CPU)/machine.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800349 translate-all.c \
350 hw/armv7m.c \
351 hw/armv7m_nvic.c \
352 arm-semi.c \
353 trace.c \
354 varint.c \
355 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800356 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800357
358LOCAL_SRC_FILES += fpu/softfloat.c
Jun Nakajima334ab472011-02-02 23:49:59 -0800359endif
360
361ifeq ($(TARGET_ARCH), x86)
362LOCAL_SRC_FILES += exec.c cpu-exec.c \
363 $(EMULATOR_TARGET_CPU)/op_helper.c \
364 $(EMULATOR_TARGET_CPU)/helper.c \
365 $(EMULATOR_TARGET_CPU)/translate.c \
366 $(EMULATOR_TARGET_CPU)/machine.c \
367 translate-all.c \
368 trace.c \
369 varint.c \
370 dcache.c \
371 softmmu_outside_jit.c \
372
373LOCAL_SRC_FILES += fpu/softfloat-native.c
374endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800375
376include $(BUILD_HOST_STATIC_LIBRARY)
377
378##############################################################################
379# SDL-related definitions
380#
381
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700382# Build SDL from sources except on linux-x86, to avoid installing all
383# the X11 development packages on our build servers.
384#
385BUILD_SDL_FROM_SOURCES := true
386ifeq ($(QEMU_HOST_TAG),linux-x86)
387 BUILD_SDL_FROM_SOURCES := false
388endif
David 'Digit' Turnerb74c48f2010-05-20 15:17:32 -0700389ifeq ($(QEMU_HOST_TAG),darwin-x86)
390 BUILD_SDL_FROM_SOURCES := false
391endif
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700392ifeq ($(BUILD_STANDALONE_EMULATOR),true)
393 BUILD_SDL_FROM_SOURCES := true
394endif
395
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700396ifneq ($(SDL_CONFIG),)
397 BUILD_SDL_FROM_SOURCES := false
398endif
399
400ifneq ($(BUILD_SDL_FROM_SOURCES),true)
401
402SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800403SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
404
405# We need to filter out the _GNU_SOURCE variable because it breaks recent
406# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
407# need this macro at all to build the Android emulator.
408SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
409SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
410
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700411# Circular dependencies between libSDL and libSDLmain;
412# We repeat the libraries in the final link to work around it.
413SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
414
415else # !BUILD_STANDALONE_EMULATOR
416
417SDL_DIR := distrib/sdl-1.2.12
418include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
419
420endif # !BUILD_STANDALONE_EMULATOR
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800421
422##############################################################################
423# determine audio sources, build the prebuilt audio-library if needed
424#
425
426# determine AUDIO sources based on current configuration
427#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700428AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800429AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
430AUDIO_LDLIBS :=
431
432ifeq ($(HOST_OS),darwin)
433 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700434 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800435endif
436
437ifeq ($(HOST_OS),windows)
438 CONFIG_WINAUDIO ?= yes
439endif
440
441ifeq ($(HOST_OS),linux)
442 CONFIG_OSS ?= yes
443 CONFIG_ALSA ?= yes
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700444 CONFIG_PULSEAUDIO ?= yes
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800445 CONFIG_ESD ?= yes
446endif
447
448ifeq ($(HOST_OS),freebsd)
449 CONFIG_OSS ?= yes
450endif
451
452ifeq ($(CONFIG_COREAUDIO),yes)
453 AUDIO_SOURCES += coreaudio.c
454 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
455 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
456endif
457
458ifeq ($(CONFIG_WINAUDIO),yes)
459 AUDIO_SOURCES += winaudio.c
460 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
461endif
462
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700463ifeq ($(CONFIG_PULSEAUDIO),yes)
464 AUDIO_SOURCES += paaudio.c audio_pt_int.c
465 AUDIO_CFLAGS += -DCONFIG_PULSEAUDIO
466endif
467
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800468ifeq ($(CONFIG_ALSA),yes)
469 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
470 AUDIO_CFLAGS += -DCONFIG_ALSA
471endif
472
473ifeq ($(CONFIG_ESD),yes)
474 AUDIO_SOURCES += esdaudio.c
475 AUDIO_CFLAGS += -DCONFIG_ESD
476endif
477
478ifeq ($(CONFIG_OSS),yes)
479 AUDIO_SOURCES += ossaudio.c
480 AUDIO_CFLAGS += -DCONFIG_OSS
481endif
482
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700483AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800484
485# determine whether we're going to use the prebuilt
486# audio library (this is useful on Linux to avoid requiring
487# all sound-related development packages to be installed on
488# the build and developer machines).
489#
490# note that you can define BUILD_QEMU_AUDIO_LIB to true
491# in your environment to force recompilation.
492#
493QEMU_AUDIO_LIB :=
494
495ifneq ($(BUILD_STANDALONE_EMULATOR),true)
496 QEMU_AUDIO_LIB := $(wildcard \
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700497 prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800498endif
499
500ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
501 include $(CLEAR_VARS)
502 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
503 LOCAL_CC := $(MY_CC)
504 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700505 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800506
507 LOCAL_CFLAGS := -Wno-sign-compare \
508 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
509 -I$(LOCAL_PATH) \
Jun Nakajima334ab472011-02-02 23:49:59 -0800510 -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800511 -I$(LOCAL_PATH)/fpu \
512
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200513 # this is very important, otherwise the generated binaries may
514 # not link properly on our build servers
515 ifeq ($(HOST_OS),linux)
516 LOCAL_CFLAGS += -fno-stack-protector
517 endif
518
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800519 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
520
521 LOCAL_CFLAGS += $(SDL_CFLAGS)
522
523 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
524
525 include $(BUILD_HOST_STATIC_LIBRARY)
526 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
527
528endif # !QEMU_AUDIO_LIB
529
530##############################################################################
David 'Digit' Turner04a18e52010-10-23 01:52:33 +0200531# Common CFLAGS for UI and Core builds
532
533# add the build ID to the default macro definitions
534UI_AND_CORE_CFLAGS := -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
535
536# For non-standalone builds, extract the major version number from the Android SDK
537# tools revision number.
538ifneq ($(BUILD_STANDALONE_EMULATOR),true)
539 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
540endif
541
542ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
543ifdef ANDROID_SDK_TOOLS_REVISION
544 UI_AND_CORE_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
545endif
546
547UI_AND_CORE_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
548
549
550##############################################################################
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700551# Build emulator core library.
552# This library contains "pure" emulation code separated from the intricacies
553# of the UI.
554#
555include $(CLEAR_VARS)
556
557LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
558LOCAL_CC := $(MY_CC)
559LOCAL_LDLIBS := $(MY_LDLIBS)
560LOCAL_MODULE := emulator-core
561
562# don't remove the -fno-strict-aliasing, or you'll break things
563# (e.g. slirp-android/network support)
564#
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700565EMULATOR_CORE_CFLAGS := -fno-PIC -Wno-sign-compare \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700566 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
567
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700568# Needed by the upstream code
569EMULATOR_CORE_CFLAGS += -DNEED_CPU_H
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700570
571# Common includes for the emulator
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700572EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/ \
Jun Nakajima334ab472011-02-02 23:49:59 -0800573 -I$(LOCAL_PATH)/$(EMULATOR_TARGET_CPU) \
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700574 -I$(LOCAL_PATH)/fpu \
575 $(TCG_CFLAGS) \
576 $(HW_CFLAGS) \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700577
David 'Digit' Turnercb42a1b2010-12-23 02:54:08 +0100578# Required by block.c, default value is empty in upstream
579EMULATOR_CORE_CFLAGS += -DCONFIG_BDRV_WHITELIST=""
580
581# Required
582EMULATOR_CORE_CFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700583# include slirp-android code, i.e. the user-level networking stuff
584#
585SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
586 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
587 tcp_subr.c tcp_timer.c tftp.c udp.c
588
589LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700590EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/slirp-android
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700591
592# socket proxy support
593#
594PROXY_SOURCES := \
595 proxy_common.c \
596 proxy_http.c \
597 proxy_http_connector.c \
598 proxy_http_rewriter.c \
599
600LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700601EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/proxy
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700602
603# include telephony stuff
604#
605TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
606LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700607EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/telephony
608
Vladimir Chtchetkined81e6d12010-06-15 16:46:32 -0700609# include android related stuff
610#
611ANDROID_SOURCES := qemu-setup.c
612LOCAL_SRC_FILES += $(ANDROID_SOURCES:%=android/%)
613
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700614LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
David 'Digit' Turner04a18e52010-10-23 01:52:33 +0200615LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700616
617include $(BUILD_HOST_STATIC_LIBRARY)
618
619##############################################################################
620# Build emulator UI library.
621# This library contains some emulator related UI components.
622#
623include $(CLEAR_VARS)
624
625LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
626LOCAL_CC := $(MY_CC)
627LOCAL_LDLIBS := $(MY_LDLIBS)
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200628LOCAL_MODULE := emulator-uilib
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700629
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700630EMULATOR_UI_CFLAGS :=
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700631
632# include the SDL sources
633#
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700634
635# IMPORTANT: Normally, we should add SDLMAIN_SOURCES here, however this breaks
636# the Linux mingw32 build. Apparently, the i586-mingw32-ld wants the
637# implementation of _WinMain@16 to be in an object file on the final
638# link command used to generate the executable, and will not search
639# in the static libraries that are used to build it.
640#
641LOCAL_SRC_FILES += $(SDL_SOURCES) #$(SDLMAIN_SOURCES)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700642EMULATOR_UI_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700643
644# the skin support sources
645#
646SKIN_SOURCES := rect.c \
647 region.c \
648 image.c \
649 trackball.c \
650 keyboard.c \
651 keyset.c \
652 file.c \
653 window.c \
654 scaler.c \
655 composer.c \
656 surface.c \
657
658LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700659EMULATOR_UI_CFLAGS += -I$(LOCAL_PATH)/skin
660
661LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700662
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200663LOCAL_MODULE_TAGS := debug
664
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700665include $(BUILD_HOST_STATIC_LIBRARY)
666
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700667##############################################################################
668# lists of source files used to build the emulator core
669#
670
671# block sources
672#
673CORE_BLOCK_SOURCES = block.c \
David 'Digit' Turnercb42a1b2010-12-23 02:54:08 +0100674 blockdev.c \
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700675 block/qcow.c \
676 block/qcow2.c \
677 block/qcow2-refcount.c \
678 block/qcow2-snapshot.c \
679 block/qcow2-cluster.c \
680 block/cloop.c \
681 block/dmg.c \
David 'Digit' Turnercb42a1b2010-12-23 02:54:08 +0100682 block/vvfat.c \
683 block/raw.c
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700684ifeq ($(HOST_OS),windows)
685 CORE_BLOCK_SOURCES += block/raw-win32.c
686else
687 CORE_BLOCK_SOURCES += block/raw-posix.c
688endif
689
690# hw sources
691#
Jun Nakajima334ab472011-02-02 23:49:59 -0800692ifeq ($(TARGET_ARCH),arm)
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700693CORE_HW_SOURCES = hw/arm_boot.c \
694 hw/android_arm.c
Jun Nakajima334ab472011-02-02 23:49:59 -0800695endif
696
697ifeq ($(TARGET_ARCH),x86)
698CORE_HW_SOURCES = hw/pc.c
699endif
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700700
701# migration sources
702#
703CORE_MIGRATION_SOURCES = iolooper-select.c
704ifeq ($(HOST_OS),windows)
705 CORE_MIGRATION_SOURCES += migration-dummy-android.c
706else
707 CORE_MIGRATION_SOURCES += migration.c \
708 migration-exec.c \
709 migration-tcp-android.c
710endif
711
712# misc. sources
713#
Vladimir Chtchetkine008c97e2010-10-08 08:22:06 -0700714CORE_MISC_SOURCES = vl-android.c \
David 'Digit' Turner707c8a82010-12-22 22:35:58 +0100715 async.c \
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700716 console.c \
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200717 qemu-malloc.c \
718 cutils.c \
719 osdep.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700720 loader.c \
721 monitor.c \
722 readline.c \
723 qemu-char-android.c \
Ot ten Thije2ff39a32010-10-06 17:48:15 +0100724 outputchannel.c \
David Turneredd33962010-09-10 00:17:41 +0200725 qemu-error.c \
726 qerror.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700727 disas.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700728 aes.c \
729 d3des.c \
730 vnc-android.c \
731 acl.c \
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200732 keymaps.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700733 buffered_file.c \
734 cbuffer.c \
735 gdbstub.c \
David Turner025c32f2010-09-10 14:52:42 +0200736 input.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700737 ioport.c \
David Turner025c32f2010-09-10 14:52:42 +0200738 notify.c \
David Turnerb9198052010-09-10 11:50:34 +0200739 path.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700740 shaper.c \
741 charpipe.c \
742 tcpdump.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700743 qemu-option.c \
744 savevm.c \
745 net-android.c \
746 aio-android.c \
747 dma-helpers.c \
David Turnerf52506f2010-09-10 16:11:22 +0200748 qemu-config.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700749 qemu-sockets-android.c \
750 bt-host.c \
751 bt-vhci.c \
752 module.c \
David Turner6a9ef172010-09-09 22:54:36 +0200753 qemu-timer.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700754 android/boot-properties.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700755 android/hw-kmsg.c \
Vladimir Chtchetkinea21ac692010-06-28 10:47:18 -0700756 android/hw-lcd.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700757 android/gps.c \
758 android/hw-events.c \
759 android/hw-control.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700760 android/console.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700761 android/hw-sensors.c \
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700762 android/hw-qemud.c \
Vladimir Chtchetkine7746af02010-10-07 05:40:39 -0700763 android/core-init-utils.c \
Jaime Lopez1a000852010-07-21 18:03:58 -0700764 android/config.c \
Ot ten Thijeae835ac2010-10-18 13:37:37 +0100765 android/snapshot.c \
Vladimir Chtchetkine90c62352011-01-13 11:24:07 -0800766 android/utils/timezone.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700767
Jun Nakajima334ab472011-02-02 23:49:59 -0800768ifeq ($(TARGET_ARCH),arm)
769 CORE_MISC_SOURCES += arm-dis.c
770endif
771
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700772ifeq ($(HOST_ARCH),x86)
773 CORE_MISC_SOURCES += i386-dis.c
774endif
775ifeq ($(HOST_ARCH),x86_64)
776 CORE_MISC_SOURCES += i386-dis.c
777endif
778ifeq ($(HOST_ARCH),ppc)
Marcus Comstedt5e8728d2010-09-26 00:37:30 +0200779 CORE_MISC_SOURCES += ppc-dis.c \
780 cache-utils.c
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700781endif
782
783ifeq ($(HOST_OS),linux)
784 CORE_MISC_SOURCES += usb-linux.c \
785 qemu-thread.c
786else
787 CORE_MISC_SOURCES += usb-dummy-android.c
788endif
789
790ifeq ($(HOST_OS),windows)
791 CORE_MISC_SOURCES += tap-win32.c
David 'Digit' Turnercb42a1b2010-12-23 02:54:08 +0100792else
793 CORE_MISC_SOURCES += posix-aio-compat.c
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700794endif
795
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700796# sources inherited from upstream, but not fully
797# integrated into android emulator
798#
799CORE_UPSTREAM_SOURCES = json-lexer.c \
800 json-parser.c \
801 json-streamer.c \
802 qjson.c \
803 qbool.c \
804 qdict.c \
805 qfloat.c \
806 qint.c \
807 qlist.c \
808 qstring.c \
809
810
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700811CORE_SOURCES = $(CORE_BLOCK_SOURCES) $(CORE_HW_SOURCES)
812CORE_SOURCES += $(CORE_MIGRATION_SOURCES) $(CORE_MISC_SOURCES)
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700813CORE_SOURCES += $(CORE_UPSTREAM_SOURCES)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700814
David 'Digit' Turnerca29fbb2011-01-02 13:17:22 +0100815CORE_SOURCES += android/audio-test.c
816
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700817##############################################################################
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700818# lists of source files used to build the emulator UI
819#
820
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700821UI_SOURCES = loadpng.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700822 android/user-config.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700823 android/resource.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700824 android/qemulator.c \
825 android/keycode.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700826 android/help.c \
Vladimir Chtchetkine90c62352011-01-13 11:24:07 -0800827 android/avd/info.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700828
829##############################################################################
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700830# lists of source files used by both, emulator UI and emulator core
831#
832
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200833UI_AND_CORE_SOURCES = \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700834 sockets.c \
835 android/keycode-array.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700836 android/charmap.c \
David 'Digit' Turner6d448802010-11-18 16:14:03 +0100837 android/async-utils.c \
Vladimir Chtchetkinea8fc4912010-11-30 09:32:55 -0800838 android/sync-utils.c \
David 'Digit' Turner6d448802010-11-18 16:14:03 +0100839 android/async-console.c \
David 'Digit' Turner4c0f7452010-11-17 17:55:17 +0100840 android/utils/assert.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700841 android/utils/bufprint.c \
842 android/utils/debug.c \
David 'Digit' Turner7a17b602010-11-17 17:58:29 +0100843 android/utils/path.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700844 android/utils/dirscanner.c \
845 android/utils/filelock.c \
David 'Digit' Turner4c0f7452010-11-17 17:55:17 +0100846 android/utils/mapfile.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700847 android/utils/misc.c \
David 'Digit' Turner4c0f7452010-11-17 17:55:17 +0100848 android/utils/panic.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700849 android/utils/reflist.c \
David 'Digit' Turner4c0f7452010-11-17 17:55:17 +0100850 android/utils/refset.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700851 android/utils/stralloc.c \
852 android/utils/system.c \
853 android/utils/tempfile.c \
David 'Digit' Turner4c0f7452010-11-17 17:55:17 +0100854 android/utils/vector.c \
Vladimir Chtchetkine074d1f92010-08-06 09:29:50 -0700855 android/avd/hw-config.c \
Vladimir Chtchetkine074d1f92010-08-06 09:29:50 -0700856 android/utils/ini.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700857
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700858# include the Zlib sources
859#
860UI_AND_CORE_SOURCES += $(ZLIB_SOURCES)
861UI_AND_CORE_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
862
863# include the Libpng sources
864#
865UI_AND_CORE_SOURCES += $(LIBPNG_SOURCES)
866UI_AND_CORE_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
867
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700868# The common libraries
869#
870QEMU_SYSTEM_LDLIBS := -lm
871ifeq ($(HOST_OS),windows)
872 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
873endif
874
875ifeq ($(HOST_OS),freebsd)
876 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
877endif
878
879ifeq ($(HOST_OS),linux)
880 QEMU_SYSTEM_LDLIBS += -lutil -lrt
881endif
882
883ifeq ($(HOST_OS),windows)
884 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
885else
886 QEMU_SYSTEM_LDLIBS += -lpthread
887endif
888
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700889ifeq ($(HOST_OS),darwin)
890 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa
891endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700892
893
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700894##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800895# now build the emulator itself
896#
897include $(CLEAR_VARS)
898
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700899LOCAL_GENERATED_SOURCES :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800900LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
901LOCAL_CC := $(MY_CC)
902LOCAL_MODULE := emulator
Jun Nakajima334ab472011-02-02 23:49:59 -0800903ifeq ($(TARGET_ARCH),arm)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800904LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
Jun Nakajima334ab472011-02-02 23:49:59 -0800905endif
906ifeq ($(TARGET_ARCH),x86)
907LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-i386 emulator-tcg
908endif
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800909LOCAL_STATIC_LIBRARIES += emulator-elff
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200910LOCAL_STATIC_LIBRARIES += emulator-core emulator-uilib
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700911LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800912
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700913LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800914
915# add the build ID to the default macro definitions
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700916LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800917
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800918# include sound support source files. we first try to see if we have a prebuilt audio
919# library. if not, we build things the "hard" way.
920#
921# note that to generate the prebuilt audio library, you should do the following:
922#
923# cd tools/qemu
924# ./android-rebuild.sh
925# distrib/update-audio.sh
926#
927ifeq ($(QEMU_AUDIO_LIB),)
928 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
929endif # !QEMU_AUDIO_LIB
930
931LOCAL_CFLAGS += $(AUDIO_CFLAGS)
932LOCAL_LDLIBS += $(AUDIO_LDLIBS)
933
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800934# the linux-user sources, I doubt we really need these
935#
936#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
937#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
938
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800939ifeq ($(HOST_ARCH),x86)
940# enable MMX code for our skin scaler
Jun Nakajima334ab472011-02-02 23:49:59 -0800941LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx -DNEED_CPU_H
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800942endif
943
944# include other sources
945#
David 'Digit' Turnere3fdd072011-02-02 14:43:23 +0100946VL_SOURCES := android/framebuffer.c \
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700947 user-events-qemu.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800948 android/cmdline-option.c \
David 'Digit' Turner07db3492011-02-02 17:36:34 +0100949 android/display.c \
David 'Digit' Turner7a17b602010-11-17 17:58:29 +0100950 android/looper-qemu.c \
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -0800951 android/protocol/ui-commands-qemu.c \
952 android/protocol/core-commands-qemu.c \
David 'Digit' Turnerf8456272011-02-02 12:34:14 +0100953 android/main-common.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800954 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800955
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700956# Add common system libraries
957#
958LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100959
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700960LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800961
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800962# add SDL-specific flags
963#
964LOCAL_CFLAGS += $(SDL_CFLAGS)
965LOCAL_LDLIBS += $(SDL_LDLIBS)
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700966LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800967
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800968# add ELFF-specific flags
969#
970LOCAL_LDLIBS += $(ELFF_LDLIBS)
971
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800972# on Windows, link the icon file as well into the executable
973# unfortunately, our build system doesn't help us much, so we need
974# to use some weird pathnames to make this work...
975#
976ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700977
978# Locate windres executable
979WINDRES := windres
980ifneq ($(USE_MINGW),)
981 # When building the Windows emulator under Linux, use the MinGW one
982 WINDRES := i586-mingw32msvc-windres
983endif
984
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800985INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
986ANDROID_ICON_OBJ := android_icon.o
987ANDROID_ICON_PATH := $(LOCAL_PATH)/images
988$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700989 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800990
991# seems to be the only way to add an object file that was not generated from
992# a C/C++/Java source file to our build system. and very unfortunately,
993# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
994# us to put the object file in the source directory...
995#
996LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
997endif
998
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700999# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1000#
1001intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1002
1003QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1004$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1005$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1006$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1007 $(transform-generated-source)
1008
1009$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1010
1011LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1012
1013# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1014#
1015intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1016
1017QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1018$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1019$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1020$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1021 $(transform-generated-source)
1022
1023$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1024
1025LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1026
1027
1028# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1029# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1030#
1031ifeq ($(QEMU_TARGET_XML_SOURCES),)
1032 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1033 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1034endif
1035
1036QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1037$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1038$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1039$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1040$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1041 $(hide) rm -f $@
1042 $(transform-generated-source)
1043
1044$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1045
1046LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1047
David 'Digit' Turner065242d2009-10-07 13:43:33 -07001048# hw-config-defs.h is generated from android/avd/hardware-properties.ini
1049#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -07001050QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -07001051QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
1052$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -07001053$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
1054$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
1055$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
David 'Digit' Turner065242d2009-10-07 13:43:33 -07001056 $(hide) rm -f $@
1057 $(transform-generated-source)
1058
1059$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
1060
1061LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -07001062
1063# this is already done by the Android build system, but is done for the
1064# benefit of the stand-alone one.
1065#
1066ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1067 LOCAL_CFLAGS += -I$(intermediates)
1068endif
1069
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001070LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1071
David 'Digit' Turnerab873b72010-03-08 18:33:50 -08001072# Generate a completely static executable if needed.
1073# Note that this means no sound and graphics on Linux.
1074#
1075ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1076 LOCAL_SRC_FILES += dynlink-static.c
1077 LOCAL_LDLIBS += -static
1078endif
1079
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001080LOCAL_MODULE := emulator
1081
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001082# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -07001083LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
1084
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001085include $(BUILD_HOST_EXECUTABLE)
1086
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001087##############################################################################
1088# Build standalone emulator core.
1089#
1090include $(CLEAR_VARS)
1091
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -07001092LOCAL_GENERATED_SOURCES :=
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001093LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
1094LOCAL_CC := $(MY_CC)
1095LOCAL_MODULE := qemu-android
Jun Nakajima334ab472011-02-02 23:49:59 -08001096ifeq ($(TARGET_ARCH),arm)
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001097LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
Jun Nakajima334ab472011-02-02 23:49:59 -08001098endif
1099ifeq ($(TARGET_ARCH),x86)
1100LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-i386 emulator-tcg
1101endif
1102
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001103LOCAL_STATIC_LIBRARIES += emulator-elff
1104LOCAL_STATIC_LIBRARIES += emulator-core
1105LOCAL_LDLIBS := $(MY_LDLIBS)
1106
1107LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
1108LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_CORE
1109
1110# include sound support source files. we first try to see if we have a prebuilt audio
1111# library. if not, we build things the "hard" way.
1112#
1113# note that to generate the prebuilt audio library, you should do the following:
1114#
1115# cd tools/qemu
1116# ./android-rebuild.sh
1117# distrib/update-audio.sh
1118#
1119ifeq ($(QEMU_AUDIO_LIB),)
1120 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
1121endif # !QEMU_AUDIO_LIB
1122
1123LOCAL_CFLAGS += $(AUDIO_CFLAGS)
1124LOCAL_LDLIBS += $(AUDIO_LDLIBS)
1125
1126# the linux-user sources, I doubt we really need these
1127#
1128#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
1129#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
1130
1131# include other sources
1132#
David 'Digit' Turnere3fdd072011-02-02 14:43:23 +01001133VL_SOURCES := android/framebuffer.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001134 user-events-qemu.c \
David 'Digit' Turner7a17b602010-11-17 17:58:29 +01001135 android/looper-qemu.c \
1136 android/looper-generic.c \
Vladimir Chtchetkine72d83df2010-12-14 09:24:02 -08001137 android/display-core.c \
Vladimir Chtchetkine85276802011-01-31 15:18:45 -08001138 android/protocol/attach-ui-proxy.c \
Vladimir Chtchetkine94a2fba2011-01-31 10:49:06 -08001139 android/protocol/fb-updates-proxy.c \
Vladimir Chtchetkine250b2e02011-01-28 10:56:16 -08001140 android/protocol/user-events-impl.c \
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -08001141 android/protocol/ui-commands-proxy.c \
1142 android/protocol/core-commands-impl.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001143
1144# Add common system libraries
1145#
1146LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1147
1148LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_AND_CORE_SOURCES)
1149
1150# add ELFF-specific flags
1151#
1152LOCAL_LDLIBS += $(ELFF_LDLIBS)
1153
1154# on Windows, link the icon file as well into the executable
1155# unfortunately, our build system doesn't help us much, so we need
1156# to use some weird pathnames to make this work...
1157#
1158ifeq ($(HOST_OS),windows)
1159
1160# Locate windres executable
1161WINDRES := windres
1162ifneq ($(USE_MINGW),)
1163 # When building the Windows emulator under Linux, use the MinGW one
1164 WINDRES := i586-mingw32msvc-windres
1165endif
1166
1167INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1168ANDROID_ICON_OBJ := android_icon.o
1169ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1170$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1171 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1172
1173# seems to be the only way to add an object file that was not generated from
1174# a C/C++/Java source file to our build system. and very unfortunately,
1175# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1176# us to put the object file in the source directory...
1177#
1178LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1179endif
1180
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -07001181# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1182#
1183intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1184
1185QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1186$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1187$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1188$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1189 $(transform-generated-source)
1190
1191$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1192
1193LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1194
1195# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1196#
1197intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1198
1199QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1200$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1201$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1202$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1203 $(transform-generated-source)
1204
1205$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1206
1207LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1208
1209
1210# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1211# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1212#
1213ifeq ($(QEMU_TARGET_XML_SOURCES),)
1214 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1215 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1216endif
1217
1218QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1219$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1220$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1221$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1222$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1223 $(hide) rm -f $@
1224 $(transform-generated-source)
1225
1226$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1227
1228LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1229
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001230# this is already done by the Android build system, but is done for the
1231# benefit of the stand-alone one.
1232#
1233ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1234 LOCAL_CFLAGS += -I$(intermediates)
1235endif
1236
1237# other flags
1238ifneq ($(HOST_OS),windows)
1239 LOCAL_LDLIBS += -ldl
1240endif
1241
1242LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1243
David 'Digit' Turner415a4b12010-07-28 12:20:14 -07001244ifeq ($(HOST_OS),darwin)
1245 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
1246 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
1247endif
1248
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001249# Generate a completely static executable if needed.
1250# Note that this means no sound and graphics on Linux.
1251#
1252ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1253 LOCAL_SRC_FILES += dynlink-static.c
1254 LOCAL_LDLIBS += -static
1255endif
1256
1257LOCAL_MODULE := qemu-android
David 'Digit' Turnerd95fd132010-09-20 12:19:11 +02001258LOCAL_MODULE_TAGS := debug
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001259
1260include $(BUILD_HOST_EXECUTABLE)
1261
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001262##############################################################################
1263# now build the emulator UI
1264#
1265include $(CLEAR_VARS)
1266
1267LOCAL_GENERATED_SOURCES :=
1268LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
1269LOCAL_CC := $(MY_CC)
1270LOCAL_MODULE := emulator-ui
1271LOCAL_STATIC_LIBRARIES := emulator-uilib
1272LOCAL_LDLIBS := $(MY_LDLIBS)
1273
Jean-Baptiste Queru79949d62010-10-22 20:57:47 -07001274LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_UI_CFLAGS) $(EMULATOR_CORE_CFLAGS)
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001275
1276# add the build ID to the default macro definitions
1277LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_UI
1278
1279ifeq ($(HOST_ARCH),x86)
1280# enable MMX code for our skin scaler
1281LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
1282endif
1283
1284# include other sources
1285#
David 'Digit' Turnere3fdd072011-02-02 14:43:23 +01001286VL_SOURCES := android/framebuffer.c \
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001287 android/cmdline-option.c \
1288 android/config.c \
David 'Digit' Turner7a17b602010-11-17 17:58:29 +01001289 android/looper-generic.c \
Ot ten Thijeae835ac2010-10-18 13:37:37 +01001290 android/snapshot.c \
David 'Digit' Turnerf8456272011-02-02 12:34:14 +01001291 android/main-common.c \
Vladimir Chtchetkined2c51cf2010-11-24 08:49:08 -08001292 android/main-ui.c \
Vladimir Chtchetkine008c97e2010-10-08 08:22:06 -07001293 vl-android-ui.c \
David 'Digit' Turner7a17b602010-11-17 17:58:29 +01001294 iolooper-select.c \
David 'Digit' Turnere9931262011-02-02 14:05:23 +01001295 android/protocol/core-connection.c \
Vladimir Chtchetkine85276802011-01-31 15:18:45 -08001296 android/protocol/attach-ui-impl.c \
Vladimir Chtchetkine94a2fba2011-01-31 10:49:06 -08001297 android/protocol/fb-updates-impl.c \
Vladimir Chtchetkine777eb682011-01-26 11:19:19 -08001298 android/protocol/ui-commands-impl.c \
1299 android/protocol/core-commands-proxy.c \
Vladimir Chtchetkine250b2e02011-01-28 10:56:16 -08001300 android/protocol/user-events-proxy.c \
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001301
1302# Add common system libraries
1303#
1304LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1305
1306LOCAL_SRC_FILES += $(VL_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
1307
1308# add SDL-specific flags
1309#
1310LOCAL_CFLAGS += $(SDL_CFLAGS)
1311LOCAL_LDLIBS += $(SDL_LDLIBS)
1312LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
1313
1314# on Windows, link the icon file as well into the executable
1315# unfortunately, our build system doesn't help us much, so we need
1316# to use some weird pathnames to make this work...
1317#
1318ifeq ($(HOST_OS),windows)
1319
1320# Locate windres executable
1321WINDRES := windres
1322ifneq ($(USE_MINGW),)
1323 # When building the Windows emulator under Linux, use the MinGW one
1324 WINDRES := i586-mingw32msvc-windres
1325endif
1326
1327INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1328ANDROID_ICON_OBJ := android_icon.o
1329ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1330$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1331 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1332
1333# seems to be the only way to add an object file that was not generated from
1334# a C/C++/Java source file to our build system. and very unfortunately,
1335# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1336# us to put the object file in the source directory...
1337#
1338LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1339endif
1340
1341# this is already done by the Android build system, but is done for the
1342# benefit of the stand-alone one.
1343#
1344ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1345 LOCAL_CFLAGS += -I$(intermediates)
1346endif
1347
1348# Generate a completely static executable if needed.
1349# Note that this means no sound and graphics on Linux.
1350#
1351ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1352 LOCAL_SRC_FILES += dynlink-static.c
1353 LOCAL_LDLIBS += -static
1354endif
1355
1356# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
1357LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
1358
1359include $(BUILD_HOST_EXECUTABLE)
1360
Jun Nakajima334ab472011-02-02 23:49:59 -08001361endif # TARGET_ARCH == arm || TARGET_ARCH == x86