blob: c9ed5953e1b9ffa43bd6ad76d7f40fdc3e4d8faa [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001ifeq ($(TARGET_ARCH),arm)
2LOCAL_PATH:= $(call my-dir)
3
David 'Digit' Turner34d16512010-05-18 17:02:33 -07004# determine the host tag to use
5QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
6ifneq ($(USE_MINGW),)
7 QEMU_HOST_TAG := windows
8endif
9
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080010# determine the location of platform-specific directories
11#
12CONFIG_DIRS := \
13 $(LOCAL_PATH)/android/config \
David 'Digit' Turner34d16512010-05-18 17:02:33 -070014 $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
15
16ifeq ($(BUILD_STANDALONE_EMULATOR),true)
17 CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS)
18endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080019
20CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
21
Kenny Root095cd0f2009-09-19 18:32:44 -050022MY_CC := $(HOST_CC)
23
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070024MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
25ifeq ($(BUILD_DEBUG_EMULATOR),true)
26 MY_OPTIM := -O0 -g
27endif
28
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080029MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080030
David 'Digit' Turner466f5482009-07-30 15:50:19 +020031# Overwrite configuration for debug builds.
32#
33ifeq ($(BUILD_DEBUG_EMULATOR),true)
34 MY_CFLAGS := $(CONFIG_INCLUDES) -O0 -g \
35 -fno-PIC -falign-functions=0
36endif
37
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080038MY_CFLAGS += -DCONFIG_MEMCHECK
39
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070040MY_LDLIBS :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080041
42# this is needed to build the emulator on 64-bit Linux systems
43ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
44 MY_CFLAGS += -Wa,--32
45endif
46
47ifeq ($(HOST_OS),freebsd)
48 MY_CFLAGS += -Wa,--32 -I /usr/local/include
49endif
50
51ifeq ($(HOST_OS),windows)
52 MY_CFLAGS += -D_WIN32 -mno-cygwin
53 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
54 MY_CFLAGS += -DWINVER=0x501
55endif
56
57ifeq ($(HOST_ARCH),ppc)
58 MY_CFLAGS += -D__powerpc__
59endif
60
61ifeq ($(HOST_OS),darwin)
David 'Digit' Turner2910f182010-05-10 18:48:35 -070062 MY_CFLAGS += -mdynamic-no-pic
David Turnerbba461c2009-06-03 10:48:15 -070063
64 # When building on Leopard or above, we need to use the 10.4 SDK
65 # or the generated binary will not run on Tiger.
66 DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
Jeff Hamiltond0d97342010-05-27 11:41:41 -050067 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(DARWIN_VERSION)),)
68 $(error Building the Android emulator requires OS X 10.5 or above)
David Turnerbba461c2009-06-03 10:48:15 -070069 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050070 ifeq ($(filter 10.5 10.5.%,$(DARWIN_VERSION)),)
71 # We are on Snow Leopard or above
72 LEOPARD_SDK := /Developer/SDKs/MacOSX10.5.sdk
73 ifeq ($(strip $(wildcard $(LEOPARD_SDK))),)
74 $(info Please install the 10.5 SDK on this machine at $(LEOPARD_SDK))
David Turnerbba461c2009-06-03 10:48:15 -070075 $(error Aborting the build.)
76 endif
Jeff Hamiltond0d97342010-05-27 11:41:41 -050077 MY_CFLAGS += -isysroot $(LEOPARD_SDK) -mmacosx-version-min=10.5 -DMACOSX_DEPLOYMENT_TARGET=10.5
78 MY_LDLIBS += -isysroot $(LEOPARD_SDK) -Wl,-syslibroot,$(LEOPARD_SDK) -mmacosx-version-min=10.5
David Turnerbba461c2009-06-03 10:48:15 -070079 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080080endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080081
82# BUILD_STANDALONE_EMULATOR is only defined when building with
83# the android-rebuild.sh script. The script will also provide
84# adequate values for HOST_CC
85#
86ifneq ($(BUILD_STANDALONE_EMULATOR),true)
87
88 ifneq ($(USE_CCACHE),)
Ying Wang7bf9d7f2010-10-07 15:12:11 -070089 ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache
90 ifneq ($(ccache),$(firstword $(MY_CC)))
91 MY_CC := $(ccache) $(MY_CC)
92 endif
93 ccache :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080094 endif
95endif
96
97
98ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
99 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700100 MY_CFLAGS += -m32
101 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800102 endif
103endif
104
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200105# Enable warning, except those related to missing field initializers
106# (the QEMU coding style loves using these).
107#
108MY_CFLAGS += -Wall -Wno-missing-field-initializers
109
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800110include $(CLEAR_VARS)
111
112###########################################################
113# Zlib configuration
114#
115ZLIB_DIR := distrib/zlib-1.2.3
116include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
117
118###########################################################
119# Libpng configuration
120#
121LIBPNG_DIR := distrib/libpng-1.2.19
122include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
123
124###############################################################################
125# build the TCG code generator
126#
127include $(CLEAR_VARS)
128
129LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
130LOCAL_CC := $(MY_CC)
131LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700132LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800133LOCAL_MODULE := emulator-tcg
134
135TCG_TARGET := $(HOST_ARCH)
136ifeq ($(TCG_TARGET),x86)
137 TCG_TARGET := i386
138endif
139
140TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
141
David Turner6a9ef172010-09-09 22:54:36 +0200142LOCAL_CFLAGS += $(TCG_CFLAGS) -DNEED_CPU_H \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800143 -I$(LOCAL_PATH)/target-arm \
144 -I$(LOCAL_PATH)/fpu \
145
146LOCAL_SRC_FILES := \
147 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800148
149include $(BUILD_HOST_STATIC_LIBRARY)
150
151##############################################################################
152# build the HW emulation support
153#
154include $(CLEAR_VARS)
155
156LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
157LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500158LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800159LOCAL_MODULE := emulator-hw
160
161HW_CFLAGS := -I$(LOCAL_PATH)/hw
162
David Turner6a9ef172010-09-09 22:54:36 +0200163LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800164LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
165LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
166
167HW_SOURCES := \
168 android_arm.c \
169 arm_pic.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700170 bt.c \
171 bt-hci.c \
172 bt-hid.c \
173 bt-l2cap.c \
174 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800175 cdrom.c \
176 dma.c \
177 irq.c \
178 goldfish_audio.c \
179 goldfish_battery.c \
180 goldfish_device.c \
181 goldfish_events_device.c \
182 goldfish_fb.c \
183 goldfish_interrupt.c \
184 goldfish_memlog.c \
185 goldfish_mmc.c \
186 goldfish_nand.c \
187 goldfish_switch.c \
188 goldfish_timer.c \
189 goldfish_trace.c \
190 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700191 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800192 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700193 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800194 scsi-disk.c \
195 smc91c111.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700196 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800197 usb-hid.c \
198 usb-hub.c \
199 usb-msd.c \
200 usb-ohci.c \
201 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700202 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800203
204LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
205
206include $(BUILD_HOST_STATIC_LIBRARY)
207
208##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800209# build the ELF/DWARF stuff
210# This library is used by emulator's memory checker to extract debug information
211# from the symbol files when reporting memory allocation violations. In
212# particular, this library is used to extract routine name and source file
213# location for the code address where violation has been detected.
214#
215include $(CLEAR_VARS)
216
217LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
218LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500219LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800220LOCAL_MODULE := emulator-elff
221LOCAL_CPP_EXTENSION := .cc
222
223ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
224
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800225LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800226LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
227LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
228
229ELFF_SOURCES := \
230 dwarf_cu.cc \
231 dwarf_die.cc \
232 dwarf_utils.cc \
233 elf_alloc.cc \
234 elf_file.cc \
235 elf_mapped_section.cc \
236 elff_api.cc \
237
238LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
239ELFF_LDLIBS := -lstdc++
240
241include $(BUILD_HOST_STATIC_LIBRARY)
242
243##############################################################################
244# build the memory access checking support
245# Memory access checker uses information collected by instrumented code in
246# libc.so in order to keep track of memory blocks allocated from heap. Memory
247# checker then uses this information to make sure that every access to allocated
248# memory is within allocated block. This information also allows detecting
249# memory leaks and attempts to free/realloc invalid pointers.
250#
251include $(CLEAR_VARS)
252
253LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
254LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500255LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800256LOCAL_MODULE := emulator-memcheck
257
258MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
259
David Turner6a9ef172010-09-09 22:54:36 +0200260LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800261LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
262LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
263
264MCHK_SOURCES := \
265 memcheck.c \
266 memcheck_proc_management.c \
267 memcheck_malloc_map.c \
268 memcheck_mmrange_map.c \
269 memcheck_util.c \
270
271LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
272
273include $(BUILD_HOST_STATIC_LIBRARY)
274
275##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800276# build the ARM-specific emulation engine sources
277#
278include $(CLEAR_VARS)
279
280LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
281LOCAL_CC := $(MY_CC)
282LOCAL_MODULE := emulator-arm
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700283LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800284LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
285LOCAL_STATIC_LIBRARIES := emulator-hw
286
287LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
288LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
289
290LOCAL_CFLAGS += -I$(LOCAL_PATH) \
291 -I$(LOCAL_PATH)/target-arm \
292 -I$(LOCAL_PATH)/fpu \
293 $(TCG_CFLAGS) \
294 $(HW_CFLAGS) \
David Turner6a9ef172010-09-09 22:54:36 +0200295 -DNEED_CPU_H \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800296
297ifeq ($(HOST_ARCH),ppc)
298 LOCAL_CFLAGS += -D__powerpc__
299endif
300
301LOCAL_SRC_FILES += exec.c cpu-exec.c \
302 target-arm/op_helper.c \
303 target-arm/iwmmxt_helper.c \
304 target-arm/neon_helper.c \
305 target-arm/helper.c \
306 target-arm/translate.c \
307 target-arm/machine.c \
308 translate-all.c \
309 hw/armv7m.c \
310 hw/armv7m_nvic.c \
311 arm-semi.c \
312 trace.c \
313 varint.c \
314 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800315 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800316
317LOCAL_SRC_FILES += fpu/softfloat.c
318
319include $(BUILD_HOST_STATIC_LIBRARY)
320
321##############################################################################
322# SDL-related definitions
323#
324
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700325# Build SDL from sources except on linux-x86, to avoid installing all
326# the X11 development packages on our build servers.
327#
328BUILD_SDL_FROM_SOURCES := true
329ifeq ($(QEMU_HOST_TAG),linux-x86)
330 BUILD_SDL_FROM_SOURCES := false
331endif
David 'Digit' Turnerb74c48f2010-05-20 15:17:32 -0700332ifeq ($(QEMU_HOST_TAG),darwin-x86)
333 BUILD_SDL_FROM_SOURCES := false
334endif
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700335ifeq ($(BUILD_STANDALONE_EMULATOR),true)
336 BUILD_SDL_FROM_SOURCES := true
337endif
338
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700339ifneq ($(SDL_CONFIG),)
340 BUILD_SDL_FROM_SOURCES := false
341endif
342
343ifneq ($(BUILD_SDL_FROM_SOURCES),true)
344
345SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800346SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
347
348# We need to filter out the _GNU_SOURCE variable because it breaks recent
349# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
350# need this macro at all to build the Android emulator.
351SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
352SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
353
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700354# Circular dependencies between libSDL and libSDLmain;
355# We repeat the libraries in the final link to work around it.
356SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
357
358else # !BUILD_STANDALONE_EMULATOR
359
360SDL_DIR := distrib/sdl-1.2.12
361include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
362
363endif # !BUILD_STANDALONE_EMULATOR
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800364
365##############################################################################
366# determine audio sources, build the prebuilt audio-library if needed
367#
368
369# determine AUDIO sources based on current configuration
370#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700371AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800372AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
373AUDIO_LDLIBS :=
374
375ifeq ($(HOST_OS),darwin)
376 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700377 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800378endif
379
380ifeq ($(HOST_OS),windows)
381 CONFIG_WINAUDIO ?= yes
382endif
383
384ifeq ($(HOST_OS),linux)
385 CONFIG_OSS ?= yes
386 CONFIG_ALSA ?= yes
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700387 CONFIG_PULSEAUDIO ?= yes
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800388 CONFIG_ESD ?= yes
389endif
390
391ifeq ($(HOST_OS),freebsd)
392 CONFIG_OSS ?= yes
393endif
394
395ifeq ($(CONFIG_COREAUDIO),yes)
396 AUDIO_SOURCES += coreaudio.c
397 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
398 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
399endif
400
401ifeq ($(CONFIG_WINAUDIO),yes)
402 AUDIO_SOURCES += winaudio.c
403 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
404endif
405
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700406ifeq ($(CONFIG_PULSEAUDIO),yes)
407 AUDIO_SOURCES += paaudio.c audio_pt_int.c
408 AUDIO_CFLAGS += -DCONFIG_PULSEAUDIO
409endif
410
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800411ifeq ($(CONFIG_ALSA),yes)
412 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
413 AUDIO_CFLAGS += -DCONFIG_ALSA
414endif
415
416ifeq ($(CONFIG_ESD),yes)
417 AUDIO_SOURCES += esdaudio.c
418 AUDIO_CFLAGS += -DCONFIG_ESD
419endif
420
421ifeq ($(CONFIG_OSS),yes)
422 AUDIO_SOURCES += ossaudio.c
423 AUDIO_CFLAGS += -DCONFIG_OSS
424endif
425
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700426AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800427
428# determine whether we're going to use the prebuilt
429# audio library (this is useful on Linux to avoid requiring
430# all sound-related development packages to be installed on
431# the build and developer machines).
432#
433# note that you can define BUILD_QEMU_AUDIO_LIB to true
434# in your environment to force recompilation.
435#
436QEMU_AUDIO_LIB :=
437
438ifneq ($(BUILD_STANDALONE_EMULATOR),true)
439 QEMU_AUDIO_LIB := $(wildcard \
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700440 prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800441endif
442
443ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
444 include $(CLEAR_VARS)
445 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
446 LOCAL_CC := $(MY_CC)
447 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700448 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800449
450 LOCAL_CFLAGS := -Wno-sign-compare \
451 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
452 -I$(LOCAL_PATH) \
453 -I$(LOCAL_PATH)/target-arm \
454 -I$(LOCAL_PATH)/fpu \
455
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200456 # this is very important, otherwise the generated binaries may
457 # not link properly on our build servers
458 ifeq ($(HOST_OS),linux)
459 LOCAL_CFLAGS += -fno-stack-protector
460 endif
461
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800462 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
463
464 LOCAL_CFLAGS += $(SDL_CFLAGS)
465
466 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
467
468 include $(BUILD_HOST_STATIC_LIBRARY)
469 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
470
471endif # !QEMU_AUDIO_LIB
472
473##############################################################################
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700474# Build emulator core library.
475# This library contains "pure" emulation code separated from the intricacies
476# of the UI.
477#
478include $(CLEAR_VARS)
479
480LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
481LOCAL_CC := $(MY_CC)
482LOCAL_LDLIBS := $(MY_LDLIBS)
483LOCAL_MODULE := emulator-core
484
485# don't remove the -fno-strict-aliasing, or you'll break things
486# (e.g. slirp-android/network support)
487#
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700488EMULATOR_CORE_CFLAGS := -fno-PIC -Wno-sign-compare \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700489 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
490
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700491# Needed by the upstream code
492EMULATOR_CORE_CFLAGS += -DNEED_CPU_H
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700493
494# Common includes for the emulator
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700495EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/ \
496 -I$(LOCAL_PATH)/target-arm \
497 -I$(LOCAL_PATH)/fpu \
498 $(TCG_CFLAGS) \
499 $(HW_CFLAGS) \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700500
501# include slirp-android code, i.e. the user-level networking stuff
502#
503SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
504 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
505 tcp_subr.c tcp_timer.c tftp.c udp.c
506
507LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700508EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/slirp-android
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700509
510# socket proxy support
511#
512PROXY_SOURCES := \
513 proxy_common.c \
514 proxy_http.c \
515 proxy_http_connector.c \
516 proxy_http_rewriter.c \
517
518LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700519EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/proxy
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700520
521# include telephony stuff
522#
523TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
524LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700525EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/telephony
526
Vladimir Chtchetkined81e6d12010-06-15 16:46:32 -0700527# include android related stuff
528#
529ANDROID_SOURCES := qemu-setup.c
530LOCAL_SRC_FILES += $(ANDROID_SOURCES:%=android/%)
531
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700532LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700533
534include $(BUILD_HOST_STATIC_LIBRARY)
535
536##############################################################################
537# Build emulator UI library.
538# This library contains some emulator related UI components.
539#
540include $(CLEAR_VARS)
541
542LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
543LOCAL_CC := $(MY_CC)
544LOCAL_LDLIBS := $(MY_LDLIBS)
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200545LOCAL_MODULE := emulator-uilib
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700546
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700547EMULATOR_UI_CFLAGS :=
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700548
549# include the SDL sources
550#
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700551
552# IMPORTANT: Normally, we should add SDLMAIN_SOURCES here, however this breaks
553# the Linux mingw32 build. Apparently, the i586-mingw32-ld wants the
554# implementation of _WinMain@16 to be in an object file on the final
555# link command used to generate the executable, and will not search
556# in the static libraries that are used to build it.
557#
558LOCAL_SRC_FILES += $(SDL_SOURCES) #$(SDLMAIN_SOURCES)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700559EMULATOR_UI_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700560
561# the skin support sources
562#
563SKIN_SOURCES := rect.c \
564 region.c \
565 image.c \
566 trackball.c \
567 keyboard.c \
568 keyset.c \
569 file.c \
570 window.c \
571 scaler.c \
572 composer.c \
573 surface.c \
574
575LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700576EMULATOR_UI_CFLAGS += -I$(LOCAL_PATH)/skin
577
578LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700579
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200580LOCAL_MODULE_TAGS := debug
581
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700582include $(BUILD_HOST_STATIC_LIBRARY)
583
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700584##############################################################################
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700585# Common CFLAGS for UI and Core builds
586
587# add the build ID to the default macro definitions
588UI_AND_CORE_CFLAGS = -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
589
590# For non-standalone builds, extract the major version number from the Android SDK
591# tools revision number.
592ifneq ($(BUILD_STANDALONE_EMULATOR),true)
593 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
594endif
595
596ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
597ifdef ANDROID_SDK_TOOLS_REVISION
598 UI_AND_CORE_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
599endif
600
601UI_AND_CORE_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
602
603##############################################################################
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700604# lists of source files used to build the emulator core
605#
606
607# block sources
608#
609CORE_BLOCK_SOURCES = block.c \
610 block/qcow.c \
611 block/qcow2.c \
612 block/qcow2-refcount.c \
613 block/qcow2-snapshot.c \
614 block/qcow2-cluster.c \
615 block/cloop.c \
616 block/dmg.c \
617 block/vvfat.c
618ifeq ($(HOST_OS),windows)
619 CORE_BLOCK_SOURCES += block/raw-win32.c
620else
621 CORE_BLOCK_SOURCES += block/raw-posix.c
622endif
623
624# hw sources
625#
626CORE_HW_SOURCES = hw/arm_boot.c \
627 hw/android_arm.c
628
629# migration sources
630#
631CORE_MIGRATION_SOURCES = iolooper-select.c
632ifeq ($(HOST_OS),windows)
633 CORE_MIGRATION_SOURCES += migration-dummy-android.c
634else
635 CORE_MIGRATION_SOURCES += migration.c \
636 migration-exec.c \
637 migration-tcp-android.c
638endif
639
640# misc. sources
641#
Vladimir Chtchetkine008c97e2010-10-08 08:22:06 -0700642CORE_MISC_SOURCES = vl-android.c \
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700643 console.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700644 loader.c \
645 monitor.c \
646 readline.c \
647 qemu-char-android.c \
David Turneredd33962010-09-10 00:17:41 +0200648 qemu-error.c \
649 qerror.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700650 disas.c \
651 arm-dis.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700652 aes.c \
653 d3des.c \
654 vnc-android.c \
655 acl.c \
656 buffered_file.c \
657 cbuffer.c \
658 gdbstub.c \
David Turner025c32f2010-09-10 14:52:42 +0200659 input.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700660 ioport.c \
David Turner025c32f2010-09-10 14:52:42 +0200661 notify.c \
David Turnerb9198052010-09-10 11:50:34 +0200662 path.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700663 shaper.c \
664 charpipe.c \
665 tcpdump.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700666 qemu-option.c \
667 savevm.c \
668 net-android.c \
669 aio-android.c \
670 dma-helpers.c \
David Turnerf52506f2010-09-10 16:11:22 +0200671 qemu-config.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700672 qemu-sockets-android.c \
673 bt-host.c \
674 bt-vhci.c \
675 module.c \
David Turner6a9ef172010-09-09 22:54:36 +0200676 qemu-timer.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700677 android/boot-properties.c \
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700678 android/display.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700679 android/hw-kmsg.c \
Vladimir Chtchetkinea21ac692010-06-28 10:47:18 -0700680 android/hw-lcd.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700681 android/gps.c \
682 android/hw-events.c \
683 android/hw-control.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700684 android/console.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700685 android/hw-sensors.c \
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700686 android/hw-qemud.c \
Vladimir Chtchetkine7746af02010-10-07 05:40:39 -0700687 android/core-init-utils.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700688
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700689ifeq ($(HOST_ARCH),x86)
690 CORE_MISC_SOURCES += i386-dis.c
691endif
692ifeq ($(HOST_ARCH),x86_64)
693 CORE_MISC_SOURCES += i386-dis.c
694endif
695ifeq ($(HOST_ARCH),ppc)
696 CORE_MISC_SOURCES += ppc-dis.c
697endif
698
699ifeq ($(HOST_OS),linux)
700 CORE_MISC_SOURCES += usb-linux.c \
701 qemu-thread.c
702else
703 CORE_MISC_SOURCES += usb-dummy-android.c
704endif
705
706ifeq ($(HOST_OS),windows)
707 CORE_MISC_SOURCES += tap-win32.c
708endif
709
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700710# sources inherited from upstream, but not fully
711# integrated into android emulator
712#
713CORE_UPSTREAM_SOURCES = json-lexer.c \
714 json-parser.c \
715 json-streamer.c \
716 qjson.c \
717 qbool.c \
718 qdict.c \
719 qfloat.c \
720 qint.c \
721 qlist.c \
722 qstring.c \
723
724
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700725CORE_SOURCES = $(CORE_BLOCK_SOURCES) $(CORE_HW_SOURCES)
726CORE_SOURCES += $(CORE_MIGRATION_SOURCES) $(CORE_MISC_SOURCES)
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700727CORE_SOURCES += $(CORE_UPSTREAM_SOURCES)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700728
729##############################################################################
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700730# lists of source files used to build the emulator UI
731#
732
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700733UI_SOURCES = loadpng.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700734 android/user-config.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700735 android/resource.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700736 android/qemulator.c \
737 android/keycode.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700738 android/help.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700739
740##############################################################################
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700741# lists of source files used by both, emulator UI and emulator core
742#
743
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700744UI_AND_CORE_SOURCES = osdep.c \
745 cutils.c \
746 sockets.c \
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700747 keymaps.c \
Vladimir Chtchetkineb5365f32010-08-09 13:33:57 -0700748 qemu-malloc.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700749 android/keycode-array.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700750 android/charmap.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700751 android/utils/bufprint.c \
752 android/utils/debug.c \
753 android/utils/path.c \
754 android/utils/dirscanner.c \
755 android/utils/filelock.c \
756 android/utils/misc.c \
757 android/utils/reflist.c \
758 android/utils/stralloc.c \
759 android/utils/system.c \
760 android/utils/tempfile.c \
761 android/utils/timezone.c \
762 android/utils/mapfile.c \
Vladimir Chtchetkine074d1f92010-08-06 09:29:50 -0700763 android/avd/hw-config.c \
764 android/avd/info.c \
765 android/utils/ini.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700766
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700767# include the Zlib sources
768#
769UI_AND_CORE_SOURCES += $(ZLIB_SOURCES)
770UI_AND_CORE_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
771
772# include the Libpng sources
773#
774UI_AND_CORE_SOURCES += $(LIBPNG_SOURCES)
775UI_AND_CORE_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
776
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700777# temp files used to collect UI->Core exchange protocol.
778UI_AND_CORE_SOURCES += android/ui-core-protocol.c android/core-ui-protocol.c
779
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700780# The common libraries
781#
782QEMU_SYSTEM_LDLIBS := -lm
783ifeq ($(HOST_OS),windows)
784 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
785endif
786
787ifeq ($(HOST_OS),freebsd)
788 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
789endif
790
791ifeq ($(HOST_OS),linux)
792 QEMU_SYSTEM_LDLIBS += -lutil -lrt
793endif
794
795ifeq ($(HOST_OS),windows)
796 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
797else
798 QEMU_SYSTEM_LDLIBS += -lpthread
799endif
800
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700801ifeq ($(HOST_OS),darwin)
802 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa
803endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700804
805
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700806##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800807# now build the emulator itself
808#
809include $(CLEAR_VARS)
810
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700811LOCAL_GENERATED_SOURCES :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800812LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
813LOCAL_CC := $(MY_CC)
814LOCAL_MODULE := emulator
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800815LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
816LOCAL_STATIC_LIBRARIES += emulator-elff
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200817LOCAL_STATIC_LIBRARIES += emulator-core emulator-uilib
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700818LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800819
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700820LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800821
822# add the build ID to the default macro definitions
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700823LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800824
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800825# include sound support source files. we first try to see if we have a prebuilt audio
826# library. if not, we build things the "hard" way.
827#
828# note that to generate the prebuilt audio library, you should do the following:
829#
830# cd tools/qemu
831# ./android-rebuild.sh
832# distrib/update-audio.sh
833#
834ifeq ($(QEMU_AUDIO_LIB),)
835 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
836endif # !QEMU_AUDIO_LIB
837
838LOCAL_CFLAGS += $(AUDIO_CFLAGS)
839LOCAL_LDLIBS += $(AUDIO_LDLIBS)
840
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800841# the linux-user sources, I doubt we really need these
842#
843#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
844#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
845
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800846ifeq ($(HOST_ARCH),x86)
847# enable MMX code for our skin scaler
848LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
849endif
850
851# include other sources
852#
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700853VL_SOURCES := framebuffer.c \
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700854 user-events-qemu.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800855 android/cmdline-option.c \
856 android/config.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800857 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800858
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700859# Add common system libraries
860#
861LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100862
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700863LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800864
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800865# add SDL-specific flags
866#
867LOCAL_CFLAGS += $(SDL_CFLAGS)
868LOCAL_LDLIBS += $(SDL_LDLIBS)
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700869LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800870
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800871# add ELFF-specific flags
872#
873LOCAL_LDLIBS += $(ELFF_LDLIBS)
874
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800875# on Windows, link the icon file as well into the executable
876# unfortunately, our build system doesn't help us much, so we need
877# to use some weird pathnames to make this work...
878#
879ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700880
881# Locate windres executable
882WINDRES := windres
883ifneq ($(USE_MINGW),)
884 # When building the Windows emulator under Linux, use the MinGW one
885 WINDRES := i586-mingw32msvc-windres
886endif
887
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800888INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
889ANDROID_ICON_OBJ := android_icon.o
890ANDROID_ICON_PATH := $(LOCAL_PATH)/images
891$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700892 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800893
894# seems to be the only way to add an object file that was not generated from
895# a C/C++/Java source file to our build system. and very unfortunately,
896# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
897# us to put the object file in the source directory...
898#
899LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
900endif
901
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700902# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
903#
904intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
905
906QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
907$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
908$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
909$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
910 $(transform-generated-source)
911
912$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
913
914LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
915
916# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
917#
918intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
919
920QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
921$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
922$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
923$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
924 $(transform-generated-source)
925
926$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
927
928LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
929
930
931# gdbstub-xml.c contains C-compilable arrays corresponding to the content
932# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
933#
934ifeq ($(QEMU_TARGET_XML_SOURCES),)
935 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
936 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
937endif
938
939QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
940$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
941$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
942$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
943$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
944 $(hide) rm -f $@
945 $(transform-generated-source)
946
947$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
948
949LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
950
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700951# hw-config-defs.h is generated from android/avd/hardware-properties.ini
952#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700953QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700954QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
955$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700956$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
957$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
958$(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 -0700959 $(hide) rm -f $@
960 $(transform-generated-source)
961
962$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
963
964LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700965
966# this is already done by the Android build system, but is done for the
967# benefit of the stand-alone one.
968#
969ifeq ($(BUILD_STANDALONE_EMULATOR),true)
970 LOCAL_CFLAGS += -I$(intermediates)
971endif
972
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800973LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
974
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800975# Generate a completely static executable if needed.
976# Note that this means no sound and graphics on Linux.
977#
978ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
979 LOCAL_SRC_FILES += dynlink-static.c
980 LOCAL_LDLIBS += -static
981endif
982
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800983LOCAL_MODULE := emulator
984
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200985# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700986LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
987
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800988include $(BUILD_HOST_EXECUTABLE)
989
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700990##############################################################################
991# Build standalone emulator core.
992#
993include $(CLEAR_VARS)
994
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -0700995LOCAL_GENERATED_SOURCES :=
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700996LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
997LOCAL_CC := $(MY_CC)
998LOCAL_MODULE := qemu-android
999LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
1000LOCAL_STATIC_LIBRARIES += emulator-elff
1001LOCAL_STATIC_LIBRARIES += emulator-core
1002LOCAL_LDLIBS := $(MY_LDLIBS)
1003
1004LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
1005LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_CORE
1006
1007# include sound support source files. we first try to see if we have a prebuilt audio
1008# library. if not, we build things the "hard" way.
1009#
1010# note that to generate the prebuilt audio library, you should do the following:
1011#
1012# cd tools/qemu
1013# ./android-rebuild.sh
1014# distrib/update-audio.sh
1015#
1016ifeq ($(QEMU_AUDIO_LIB),)
1017 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
1018endif # !QEMU_AUDIO_LIB
1019
1020LOCAL_CFLAGS += $(AUDIO_CFLAGS)
1021LOCAL_LDLIBS += $(AUDIO_LDLIBS)
1022
1023# the linux-user sources, I doubt we really need these
1024#
1025#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
1026#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
1027
1028# include other sources
1029#
1030VL_SOURCES := framebuffer.c \
1031 user-events-qemu.c \
1032
1033# Add common system libraries
1034#
1035LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1036
1037LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_AND_CORE_SOURCES)
1038
1039# add ELFF-specific flags
1040#
1041LOCAL_LDLIBS += $(ELFF_LDLIBS)
1042
1043# on Windows, link the icon file as well into the executable
1044# unfortunately, our build system doesn't help us much, so we need
1045# to use some weird pathnames to make this work...
1046#
1047ifeq ($(HOST_OS),windows)
1048
1049# Locate windres executable
1050WINDRES := windres
1051ifneq ($(USE_MINGW),)
1052 # When building the Windows emulator under Linux, use the MinGW one
1053 WINDRES := i586-mingw32msvc-windres
1054endif
1055
1056INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1057ANDROID_ICON_OBJ := android_icon.o
1058ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1059$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1060 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1061
1062# seems to be the only way to add an object file that was not generated from
1063# a C/C++/Java source file to our build system. and very unfortunately,
1064# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1065# us to put the object file in the source directory...
1066#
1067LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1068endif
1069
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -07001070# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1071#
1072intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1073
1074QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1075$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1076$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1077$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1078 $(transform-generated-source)
1079
1080$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1081
1082LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1083
1084# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1085#
1086intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1087
1088QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1089$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1090$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1091$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1092 $(transform-generated-source)
1093
1094$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1095
1096LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1097
1098
1099# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1100# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1101#
1102ifeq ($(QEMU_TARGET_XML_SOURCES),)
1103 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1104 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1105endif
1106
1107QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1108$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1109$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1110$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1111$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1112 $(hide) rm -f $@
1113 $(transform-generated-source)
1114
1115$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1116
1117LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1118
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001119# this is already done by the Android build system, but is done for the
1120# benefit of the stand-alone one.
1121#
1122ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1123 LOCAL_CFLAGS += -I$(intermediates)
1124endif
1125
1126# other flags
1127ifneq ($(HOST_OS),windows)
1128 LOCAL_LDLIBS += -ldl
1129endif
1130
1131LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1132
David 'Digit' Turner415a4b12010-07-28 12:20:14 -07001133ifeq ($(HOST_OS),darwin)
1134 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
1135 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
1136endif
1137
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001138# Generate a completely static executable if needed.
1139# Note that this means no sound and graphics on Linux.
1140#
1141ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1142 LOCAL_SRC_FILES += dynlink-static.c
1143 LOCAL_LDLIBS += -static
1144endif
1145
1146LOCAL_MODULE := qemu-android
David 'Digit' Turnerd95fd132010-09-20 12:19:11 +02001147LOCAL_MODULE_TAGS := debug
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001148
1149include $(BUILD_HOST_EXECUTABLE)
1150
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001151##############################################################################
1152# now build the emulator UI
1153#
1154include $(CLEAR_VARS)
1155
1156LOCAL_GENERATED_SOURCES :=
1157LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
1158LOCAL_CC := $(MY_CC)
1159LOCAL_MODULE := emulator-ui
1160LOCAL_STATIC_LIBRARIES := emulator-uilib
1161LOCAL_LDLIBS := $(MY_LDLIBS)
1162
1163LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
1164
1165# add the build ID to the default macro definitions
1166LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_UI
1167
1168ifeq ($(HOST_ARCH),x86)
1169# enable MMX code for our skin scaler
1170LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
1171endif
1172
1173# include other sources
1174#
1175VL_SOURCES := framebuffer.c \
1176 user-events-ui.c \
1177 android/cmdline-option.c \
1178 android/config.c \
1179 android/display.c \
1180 android/main.c \
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001181 qemu-timer-ui.c \
Vladimir Chtchetkine008c97e2010-10-08 08:22:06 -07001182 vl-android-ui.c \
1183 console-ui.c \
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001184
1185# Add common system libraries
1186#
1187LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1188
1189LOCAL_SRC_FILES += $(VL_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
1190
1191# add SDL-specific flags
1192#
1193LOCAL_CFLAGS += $(SDL_CFLAGS)
1194LOCAL_LDLIBS += $(SDL_LDLIBS)
1195LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
1196
1197# on Windows, link the icon file as well into the executable
1198# unfortunately, our build system doesn't help us much, so we need
1199# to use some weird pathnames to make this work...
1200#
1201ifeq ($(HOST_OS),windows)
1202
1203# Locate windres executable
1204WINDRES := windres
1205ifneq ($(USE_MINGW),)
1206 # When building the Windows emulator under Linux, use the MinGW one
1207 WINDRES := i586-mingw32msvc-windres
1208endif
1209
1210INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1211ANDROID_ICON_OBJ := android_icon.o
1212ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1213$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1214 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1215
1216# seems to be the only way to add an object file that was not generated from
1217# a C/C++/Java source file to our build system. and very unfortunately,
1218# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1219# us to put the object file in the source directory...
1220#
1221LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1222endif
1223
1224# this is already done by the Android build system, but is done for the
1225# benefit of the stand-alone one.
1226#
1227ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1228 LOCAL_CFLAGS += -I$(intermediates)
1229endif
1230
1231# Generate a completely static executable if needed.
1232# Note that this means no sound and graphics on Linux.
1233#
1234ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1235 LOCAL_SRC_FILES += dynlink-static.c
1236 LOCAL_LDLIBS += -static
1237endif
1238
1239# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
1240LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
1241
1242include $(BUILD_HOST_EXECUTABLE)
1243
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001244endif # TARGET_ARCH == arm