blob: 49dfd1a612a5c37723c4ee28d02da6f3b383244b [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),)
89 MY_CC := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache $(MY_CC)
90 endif
91endif
92
93
94ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
95 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070096 MY_CFLAGS += -m32
97 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080098 endif
99endif
100
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200101# Enable warning, except those related to missing field initializers
102# (the QEMU coding style loves using these).
103#
104MY_CFLAGS += -Wall -Wno-missing-field-initializers
105
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800106include $(CLEAR_VARS)
107
108###########################################################
109# Zlib configuration
110#
111ZLIB_DIR := distrib/zlib-1.2.3
112include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
113
114###########################################################
115# Libpng configuration
116#
117LIBPNG_DIR := distrib/libpng-1.2.19
118include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
119
120###############################################################################
121# build the TCG code generator
122#
123include $(CLEAR_VARS)
124
125LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
126LOCAL_CC := $(MY_CC)
127LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700128LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800129LOCAL_MODULE := emulator-tcg
130
131TCG_TARGET := $(HOST_ARCH)
132ifeq ($(TCG_TARGET),x86)
133 TCG_TARGET := i386
134endif
135
136TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
137
David Turner6a9ef172010-09-09 22:54:36 +0200138LOCAL_CFLAGS += $(TCG_CFLAGS) -DNEED_CPU_H \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800139 -I$(LOCAL_PATH)/target-arm \
140 -I$(LOCAL_PATH)/fpu \
141
142LOCAL_SRC_FILES := \
143 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800144
145include $(BUILD_HOST_STATIC_LIBRARY)
146
147##############################################################################
148# build the HW emulation support
149#
150include $(CLEAR_VARS)
151
152LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
153LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500154LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800155LOCAL_MODULE := emulator-hw
156
157HW_CFLAGS := -I$(LOCAL_PATH)/hw
158
David Turner6a9ef172010-09-09 22:54:36 +0200159LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800160LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
161LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
162
163HW_SOURCES := \
164 android_arm.c \
165 arm_pic.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700166 bt.c \
167 bt-hci.c \
168 bt-hid.c \
169 bt-l2cap.c \
170 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800171 cdrom.c \
172 dma.c \
173 irq.c \
174 goldfish_audio.c \
175 goldfish_battery.c \
176 goldfish_device.c \
177 goldfish_events_device.c \
178 goldfish_fb.c \
179 goldfish_interrupt.c \
180 goldfish_memlog.c \
181 goldfish_mmc.c \
182 goldfish_nand.c \
183 goldfish_switch.c \
184 goldfish_timer.c \
185 goldfish_trace.c \
186 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700187 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800188 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700189 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800190 scsi-disk.c \
191 smc91c111.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700192 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800193 usb-hid.c \
194 usb-hub.c \
195 usb-msd.c \
196 usb-ohci.c \
197 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700198 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800199
200LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
201
202include $(BUILD_HOST_STATIC_LIBRARY)
203
204##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800205# build the ELF/DWARF stuff
206# This library is used by emulator's memory checker to extract debug information
207# from the symbol files when reporting memory allocation violations. In
208# particular, this library is used to extract routine name and source file
209# location for the code address where violation has been detected.
210#
211include $(CLEAR_VARS)
212
213LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
214LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500215LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800216LOCAL_MODULE := emulator-elff
217LOCAL_CPP_EXTENSION := .cc
218
219ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
220
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800221LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800222LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
223LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
224
225ELFF_SOURCES := \
226 dwarf_cu.cc \
227 dwarf_die.cc \
228 dwarf_utils.cc \
229 elf_alloc.cc \
230 elf_file.cc \
231 elf_mapped_section.cc \
232 elff_api.cc \
233
234LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
235ELFF_LDLIBS := -lstdc++
236
237include $(BUILD_HOST_STATIC_LIBRARY)
238
239##############################################################################
240# build the memory access checking support
241# Memory access checker uses information collected by instrumented code in
242# libc.so in order to keep track of memory blocks allocated from heap. Memory
243# checker then uses this information to make sure that every access to allocated
244# memory is within allocated block. This information also allows detecting
245# memory leaks and attempts to free/realloc invalid pointers.
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-memcheck
253
254MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
255
David Turner6a9ef172010-09-09 22:54:36 +0200256LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800257LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
258LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
259
260MCHK_SOURCES := \
261 memcheck.c \
262 memcheck_proc_management.c \
263 memcheck_malloc_map.c \
264 memcheck_mmrange_map.c \
265 memcheck_util.c \
266
267LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
268
269include $(BUILD_HOST_STATIC_LIBRARY)
270
271##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800272# build the ARM-specific emulation engine sources
273#
274include $(CLEAR_VARS)
275
276LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
277LOCAL_CC := $(MY_CC)
278LOCAL_MODULE := emulator-arm
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700279LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800280LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
281LOCAL_STATIC_LIBRARIES := emulator-hw
282
283LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
284LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
285
286LOCAL_CFLAGS += -I$(LOCAL_PATH) \
287 -I$(LOCAL_PATH)/target-arm \
288 -I$(LOCAL_PATH)/fpu \
289 $(TCG_CFLAGS) \
290 $(HW_CFLAGS) \
David Turner6a9ef172010-09-09 22:54:36 +0200291 -DNEED_CPU_H \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800292
293ifeq ($(HOST_ARCH),ppc)
294 LOCAL_CFLAGS += -D__powerpc__
295endif
296
297LOCAL_SRC_FILES += exec.c cpu-exec.c \
298 target-arm/op_helper.c \
299 target-arm/iwmmxt_helper.c \
300 target-arm/neon_helper.c \
301 target-arm/helper.c \
302 target-arm/translate.c \
303 target-arm/machine.c \
304 translate-all.c \
305 hw/armv7m.c \
306 hw/armv7m_nvic.c \
307 arm-semi.c \
308 trace.c \
309 varint.c \
310 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800311 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800312
313LOCAL_SRC_FILES += fpu/softfloat.c
314
315include $(BUILD_HOST_STATIC_LIBRARY)
316
317##############################################################################
318# SDL-related definitions
319#
320
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700321# Build SDL from sources except on linux-x86, to avoid installing all
322# the X11 development packages on our build servers.
323#
324BUILD_SDL_FROM_SOURCES := true
325ifeq ($(QEMU_HOST_TAG),linux-x86)
326 BUILD_SDL_FROM_SOURCES := false
327endif
David 'Digit' Turnerb74c48f2010-05-20 15:17:32 -0700328ifeq ($(QEMU_HOST_TAG),darwin-x86)
329 BUILD_SDL_FROM_SOURCES := false
330endif
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700331ifeq ($(BUILD_STANDALONE_EMULATOR),true)
332 BUILD_SDL_FROM_SOURCES := true
333endif
334
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700335ifneq ($(SDL_CONFIG),)
336 BUILD_SDL_FROM_SOURCES := false
337endif
338
339ifneq ($(BUILD_SDL_FROM_SOURCES),true)
340
341SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800342SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
343
344# We need to filter out the _GNU_SOURCE variable because it breaks recent
345# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
346# need this macro at all to build the Android emulator.
347SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
348SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
349
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700350# Circular dependencies between libSDL and libSDLmain;
351# We repeat the libraries in the final link to work around it.
352SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
353
354else # !BUILD_STANDALONE_EMULATOR
355
356SDL_DIR := distrib/sdl-1.2.12
357include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
358
359endif # !BUILD_STANDALONE_EMULATOR
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800360
361##############################################################################
362# determine audio sources, build the prebuilt audio-library if needed
363#
364
365# determine AUDIO sources based on current configuration
366#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700367AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800368AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
369AUDIO_LDLIBS :=
370
371ifeq ($(HOST_OS),darwin)
372 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700373 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800374endif
375
376ifeq ($(HOST_OS),windows)
377 CONFIG_WINAUDIO ?= yes
378endif
379
380ifeq ($(HOST_OS),linux)
381 CONFIG_OSS ?= yes
382 CONFIG_ALSA ?= yes
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700383 CONFIG_PULSEAUDIO ?= yes
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800384 CONFIG_ESD ?= yes
385endif
386
387ifeq ($(HOST_OS),freebsd)
388 CONFIG_OSS ?= yes
389endif
390
391ifeq ($(CONFIG_COREAUDIO),yes)
392 AUDIO_SOURCES += coreaudio.c
393 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
394 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
395endif
396
397ifeq ($(CONFIG_WINAUDIO),yes)
398 AUDIO_SOURCES += winaudio.c
399 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
400endif
401
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700402ifeq ($(CONFIG_PULSEAUDIO),yes)
403 AUDIO_SOURCES += paaudio.c audio_pt_int.c
404 AUDIO_CFLAGS += -DCONFIG_PULSEAUDIO
405endif
406
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800407ifeq ($(CONFIG_ALSA),yes)
408 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
409 AUDIO_CFLAGS += -DCONFIG_ALSA
410endif
411
412ifeq ($(CONFIG_ESD),yes)
413 AUDIO_SOURCES += esdaudio.c
414 AUDIO_CFLAGS += -DCONFIG_ESD
415endif
416
417ifeq ($(CONFIG_OSS),yes)
418 AUDIO_SOURCES += ossaudio.c
419 AUDIO_CFLAGS += -DCONFIG_OSS
420endif
421
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700422AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800423
424# determine whether we're going to use the prebuilt
425# audio library (this is useful on Linux to avoid requiring
426# all sound-related development packages to be installed on
427# the build and developer machines).
428#
429# note that you can define BUILD_QEMU_AUDIO_LIB to true
430# in your environment to force recompilation.
431#
432QEMU_AUDIO_LIB :=
433
434ifneq ($(BUILD_STANDALONE_EMULATOR),true)
435 QEMU_AUDIO_LIB := $(wildcard \
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700436 prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800437endif
438
439ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
440 include $(CLEAR_VARS)
441 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
442 LOCAL_CC := $(MY_CC)
443 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700444 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800445
446 LOCAL_CFLAGS := -Wno-sign-compare \
447 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
448 -I$(LOCAL_PATH) \
449 -I$(LOCAL_PATH)/target-arm \
450 -I$(LOCAL_PATH)/fpu \
451
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200452 # this is very important, otherwise the generated binaries may
453 # not link properly on our build servers
454 ifeq ($(HOST_OS),linux)
455 LOCAL_CFLAGS += -fno-stack-protector
456 endif
457
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800458 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
459
460 LOCAL_CFLAGS += $(SDL_CFLAGS)
461
462 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
463
464 include $(BUILD_HOST_STATIC_LIBRARY)
465 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
466
467endif # !QEMU_AUDIO_LIB
468
469##############################################################################
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700470# Build emulator core library.
471# This library contains "pure" emulation code separated from the intricacies
472# of the UI.
473#
474include $(CLEAR_VARS)
475
476LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
477LOCAL_CC := $(MY_CC)
478LOCAL_LDLIBS := $(MY_LDLIBS)
479LOCAL_MODULE := emulator-core
480
481# don't remove the -fno-strict-aliasing, or you'll break things
482# (e.g. slirp-android/network support)
483#
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700484EMULATOR_CORE_CFLAGS := -fno-PIC -Wno-sign-compare \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700485 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
486
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700487# Needed by the upstream code
488EMULATOR_CORE_CFLAGS += -DNEED_CPU_H
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700489
490# Common includes for the emulator
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700491EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/ \
492 -I$(LOCAL_PATH)/target-arm \
493 -I$(LOCAL_PATH)/fpu \
494 $(TCG_CFLAGS) \
495 $(HW_CFLAGS) \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700496
497# include slirp-android code, i.e. the user-level networking stuff
498#
499SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
500 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
501 tcp_subr.c tcp_timer.c tftp.c udp.c
502
503LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700504EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/slirp-android
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700505
506# socket proxy support
507#
508PROXY_SOURCES := \
509 proxy_common.c \
510 proxy_http.c \
511 proxy_http_connector.c \
512 proxy_http_rewriter.c \
513
514LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700515EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/proxy
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700516
517# include telephony stuff
518#
519TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
520LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700521EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/telephony
522
Vladimir Chtchetkined81e6d12010-06-15 16:46:32 -0700523# include android related stuff
524#
525ANDROID_SOURCES := qemu-setup.c
526LOCAL_SRC_FILES += $(ANDROID_SOURCES:%=android/%)
527
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700528LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700529
530include $(BUILD_HOST_STATIC_LIBRARY)
531
532##############################################################################
533# Build emulator UI library.
534# This library contains some emulator related UI components.
535#
536include $(CLEAR_VARS)
537
538LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
539LOCAL_CC := $(MY_CC)
540LOCAL_LDLIBS := $(MY_LDLIBS)
541LOCAL_MODULE := emulator-ui
542
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700543EMULATOR_UI_CFLAGS :=
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700544
545# include the SDL sources
546#
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700547
548# IMPORTANT: Normally, we should add SDLMAIN_SOURCES here, however this breaks
549# the Linux mingw32 build. Apparently, the i586-mingw32-ld wants the
550# implementation of _WinMain@16 to be in an object file on the final
551# link command used to generate the executable, and will not search
552# in the static libraries that are used to build it.
553#
554LOCAL_SRC_FILES += $(SDL_SOURCES) #$(SDLMAIN_SOURCES)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700555EMULATOR_UI_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700556
557# the skin support sources
558#
559SKIN_SOURCES := rect.c \
560 region.c \
561 image.c \
562 trackball.c \
563 keyboard.c \
564 keyset.c \
565 file.c \
566 window.c \
567 scaler.c \
568 composer.c \
569 surface.c \
570
571LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700572EMULATOR_UI_CFLAGS += -I$(LOCAL_PATH)/skin
573
574LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700575
576include $(BUILD_HOST_STATIC_LIBRARY)
577
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700578##############################################################################
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700579# Common CFLAGS for UI and Core builds
580
581# add the build ID to the default macro definitions
582UI_AND_CORE_CFLAGS = -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
583
584# For non-standalone builds, extract the major version number from the Android SDK
585# tools revision number.
586ifneq ($(BUILD_STANDALONE_EMULATOR),true)
587 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
588endif
589
590ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
591ifdef ANDROID_SDK_TOOLS_REVISION
592 UI_AND_CORE_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
593endif
594
595UI_AND_CORE_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
596
597##############################################################################
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700598# lists of source files used to build the emulator core
599#
600
601# block sources
602#
603CORE_BLOCK_SOURCES = block.c \
604 block/qcow.c \
605 block/qcow2.c \
606 block/qcow2-refcount.c \
607 block/qcow2-snapshot.c \
608 block/qcow2-cluster.c \
609 block/cloop.c \
610 block/dmg.c \
611 block/vvfat.c
612ifeq ($(HOST_OS),windows)
613 CORE_BLOCK_SOURCES += block/raw-win32.c
614else
615 CORE_BLOCK_SOURCES += block/raw-posix.c
616endif
617
618# hw sources
619#
620CORE_HW_SOURCES = hw/arm_boot.c \
621 hw/android_arm.c
622
623# migration sources
624#
625CORE_MIGRATION_SOURCES = iolooper-select.c
626ifeq ($(HOST_OS),windows)
627 CORE_MIGRATION_SOURCES += migration-dummy-android.c
628else
629 CORE_MIGRATION_SOURCES += migration.c \
630 migration-exec.c \
631 migration-tcp-android.c
632endif
633
634# misc. sources
635#
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700636CORE_MISC_SOURCES = vl-android.c \
637 console.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700638 loader.c \
639 monitor.c \
640 readline.c \
641 qemu-char-android.c \
David Turneredd33962010-09-10 00:17:41 +0200642 qemu-error.c \
643 qerror.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700644 disas.c \
645 arm-dis.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700646 aes.c \
647 d3des.c \
648 vnc-android.c \
649 acl.c \
650 buffered_file.c \
651 cbuffer.c \
652 gdbstub.c \
David Turner025c32f2010-09-10 14:52:42 +0200653 input.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700654 ioport.c \
David Turner025c32f2010-09-10 14:52:42 +0200655 notify.c \
David Turnerb9198052010-09-10 11:50:34 +0200656 path.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700657 shaper.c \
658 charpipe.c \
659 tcpdump.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700660 qemu-option.c \
661 savevm.c \
662 net-android.c \
663 aio-android.c \
664 dma-helpers.c \
David Turnerf52506f2010-09-10 16:11:22 +0200665 qemu-config.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700666 qemu-sockets-android.c \
667 bt-host.c \
668 bt-vhci.c \
669 module.c \
David Turner6a9ef172010-09-09 22:54:36 +0200670 qemu-timer.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700671 android/boot-properties.c \
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700672 android/display.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700673 android/hw-kmsg.c \
Vladimir Chtchetkinea21ac692010-06-28 10:47:18 -0700674 android/hw-lcd.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700675 android/gps.c \
676 android/hw-events.c \
677 android/hw-control.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700678 android/console.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700679 android/hw-sensors.c \
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700680 android/hw-qemud.c \
Vladimir Chtchetkine7746af02010-10-07 05:40:39 -0700681 android/core-init-utils.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700682
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700683ifeq ($(HOST_ARCH),x86)
684 CORE_MISC_SOURCES += i386-dis.c
685endif
686ifeq ($(HOST_ARCH),x86_64)
687 CORE_MISC_SOURCES += i386-dis.c
688endif
689ifeq ($(HOST_ARCH),ppc)
690 CORE_MISC_SOURCES += ppc-dis.c
691endif
692
693ifeq ($(HOST_OS),linux)
694 CORE_MISC_SOURCES += usb-linux.c \
695 qemu-thread.c
696else
697 CORE_MISC_SOURCES += usb-dummy-android.c
698endif
699
700ifeq ($(HOST_OS),windows)
701 CORE_MISC_SOURCES += tap-win32.c
702endif
703
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700704# sources inherited from upstream, but not fully
705# integrated into android emulator
706#
707CORE_UPSTREAM_SOURCES = json-lexer.c \
708 json-parser.c \
709 json-streamer.c \
710 qjson.c \
711 qbool.c \
712 qdict.c \
713 qfloat.c \
714 qint.c \
715 qlist.c \
716 qstring.c \
717
718
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700719CORE_SOURCES = $(CORE_BLOCK_SOURCES) $(CORE_HW_SOURCES)
720CORE_SOURCES += $(CORE_MIGRATION_SOURCES) $(CORE_MISC_SOURCES)
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700721CORE_SOURCES += $(CORE_UPSTREAM_SOURCES)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700722
723##############################################################################
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700724# lists of source files used to build the emulator UI
725#
726
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700727UI_SOURCES = loadpng.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700728 android/user-config.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700729 android/resource.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700730 android/qemulator.c \
731 android/keycode.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700732 android/help.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700733
734##############################################################################
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700735# lists of source files used by both, emulator UI and emulator core
736#
737
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700738UI_AND_CORE_SOURCES = osdep.c \
739 cutils.c \
740 sockets.c \
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700741 keymaps.c \
Vladimir Chtchetkineb5365f32010-08-09 13:33:57 -0700742 qemu-malloc.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700743 android/keycode-array.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700744 android/charmap.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700745 android/utils/bufprint.c \
746 android/utils/debug.c \
747 android/utils/path.c \
748 android/utils/dirscanner.c \
749 android/utils/filelock.c \
750 android/utils/misc.c \
751 android/utils/reflist.c \
752 android/utils/stralloc.c \
753 android/utils/system.c \
754 android/utils/tempfile.c \
755 android/utils/timezone.c \
756 android/utils/mapfile.c \
Vladimir Chtchetkine074d1f92010-08-06 09:29:50 -0700757 android/avd/hw-config.c \
758 android/avd/info.c \
759 android/utils/ini.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700760
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700761# include the Zlib sources
762#
763UI_AND_CORE_SOURCES += $(ZLIB_SOURCES)
764UI_AND_CORE_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
765
766# include the Libpng sources
767#
768UI_AND_CORE_SOURCES += $(LIBPNG_SOURCES)
769UI_AND_CORE_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
770
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700771# temp files used to collect UI->Core exchange protocol.
772UI_AND_CORE_SOURCES += android/ui-core-protocol.c android/core-ui-protocol.c
773
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700774# The common libraries
775#
776QEMU_SYSTEM_LDLIBS := -lm
777ifeq ($(HOST_OS),windows)
778 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
779endif
780
781ifeq ($(HOST_OS),freebsd)
782 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
783endif
784
785ifeq ($(HOST_OS),linux)
786 QEMU_SYSTEM_LDLIBS += -lutil -lrt
787endif
788
789ifeq ($(HOST_OS),windows)
790 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
791else
792 QEMU_SYSTEM_LDLIBS += -lpthread
793endif
794
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700795ifeq ($(HOST_OS),darwin)
796 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa
797endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700798
799
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700800##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800801# now build the emulator itself
802#
803include $(CLEAR_VARS)
804
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700805LOCAL_GENERATED_SOURCES :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800806LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
807LOCAL_CC := $(MY_CC)
808LOCAL_MODULE := emulator
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800809LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
810LOCAL_STATIC_LIBRARIES += emulator-elff
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700811LOCAL_STATIC_LIBRARIES += emulator-core emulator-ui
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700812LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800813
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700814LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800815
816# add the build ID to the default macro definitions
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700817LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800818
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800819# include sound support source files. we first try to see if we have a prebuilt audio
820# library. if not, we build things the "hard" way.
821#
822# note that to generate the prebuilt audio library, you should do the following:
823#
824# cd tools/qemu
825# ./android-rebuild.sh
826# distrib/update-audio.sh
827#
828ifeq ($(QEMU_AUDIO_LIB),)
829 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
830endif # !QEMU_AUDIO_LIB
831
832LOCAL_CFLAGS += $(AUDIO_CFLAGS)
833LOCAL_LDLIBS += $(AUDIO_LDLIBS)
834
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800835# the linux-user sources, I doubt we really need these
836#
837#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
838#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
839
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800840ifeq ($(HOST_ARCH),x86)
841# enable MMX code for our skin scaler
842LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
843endif
844
845# include other sources
846#
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700847VL_SOURCES := framebuffer.c \
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700848 user-events-qemu.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800849 android/cmdline-option.c \
850 android/config.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800851 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800852
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700853# Add common system libraries
854#
855LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100856
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700857LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800858
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800859# add SDL-specific flags
860#
861LOCAL_CFLAGS += $(SDL_CFLAGS)
862LOCAL_LDLIBS += $(SDL_LDLIBS)
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700863LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800864
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800865# add ELFF-specific flags
866#
867LOCAL_LDLIBS += $(ELFF_LDLIBS)
868
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800869# on Windows, link the icon file as well into the executable
870# unfortunately, our build system doesn't help us much, so we need
871# to use some weird pathnames to make this work...
872#
873ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700874
875# Locate windres executable
876WINDRES := windres
877ifneq ($(USE_MINGW),)
878 # When building the Windows emulator under Linux, use the MinGW one
879 WINDRES := i586-mingw32msvc-windres
880endif
881
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800882INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
883ANDROID_ICON_OBJ := android_icon.o
884ANDROID_ICON_PATH := $(LOCAL_PATH)/images
885$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700886 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800887
888# seems to be the only way to add an object file that was not generated from
889# a C/C++/Java source file to our build system. and very unfortunately,
890# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
891# us to put the object file in the source directory...
892#
893LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
894endif
895
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700896# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
897#
898intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
899
900QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
901$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
902$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
903$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
904 $(transform-generated-source)
905
906$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
907
908LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
909
910# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
911#
912intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
913
914QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
915$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
916$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
917$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
918 $(transform-generated-source)
919
920$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
921
922LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
923
924
925# gdbstub-xml.c contains C-compilable arrays corresponding to the content
926# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
927#
928ifeq ($(QEMU_TARGET_XML_SOURCES),)
929 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
930 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
931endif
932
933QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
934$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
935$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
936$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
937$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
938 $(hide) rm -f $@
939 $(transform-generated-source)
940
941$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
942
943LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
944
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700945# hw-config-defs.h is generated from android/avd/hardware-properties.ini
946#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700947QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700948QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
949$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700950$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
951$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
952$(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 -0700953 $(hide) rm -f $@
954 $(transform-generated-source)
955
956$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
957
958LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700959
960# this is already done by the Android build system, but is done for the
961# benefit of the stand-alone one.
962#
963ifeq ($(BUILD_STANDALONE_EMULATOR),true)
964 LOCAL_CFLAGS += -I$(intermediates)
965endif
966
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800967LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
968
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800969# Generate a completely static executable if needed.
970# Note that this means no sound and graphics on Linux.
971#
972ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
973 LOCAL_SRC_FILES += dynlink-static.c
974 LOCAL_LDLIBS += -static
975endif
976
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800977LOCAL_MODULE := emulator
978
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700979# See comment about SDLMAIN_SOURCES in the 'emulator-ui' module declarations.
980LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
981
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800982include $(BUILD_HOST_EXECUTABLE)
983
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700984##############################################################################
985# Build standalone emulator core.
986#
987include $(CLEAR_VARS)
988
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -0700989LOCAL_GENERATED_SOURCES :=
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700990LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
991LOCAL_CC := $(MY_CC)
992LOCAL_MODULE := qemu-android
993LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
994LOCAL_STATIC_LIBRARIES += emulator-elff
995LOCAL_STATIC_LIBRARIES += emulator-core
996LOCAL_LDLIBS := $(MY_LDLIBS)
997
998LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
999LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_CORE
1000
1001# include sound support source files. we first try to see if we have a prebuilt audio
1002# library. if not, we build things the "hard" way.
1003#
1004# note that to generate the prebuilt audio library, you should do the following:
1005#
1006# cd tools/qemu
1007# ./android-rebuild.sh
1008# distrib/update-audio.sh
1009#
1010ifeq ($(QEMU_AUDIO_LIB),)
1011 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
1012endif # !QEMU_AUDIO_LIB
1013
1014LOCAL_CFLAGS += $(AUDIO_CFLAGS)
1015LOCAL_LDLIBS += $(AUDIO_LDLIBS)
1016
1017# the linux-user sources, I doubt we really need these
1018#
1019#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
1020#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
1021
1022# include other sources
1023#
1024VL_SOURCES := framebuffer.c \
1025 user-events-qemu.c \
1026
1027# Add common system libraries
1028#
1029LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1030
1031LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_AND_CORE_SOURCES)
1032
1033# add ELFF-specific flags
1034#
1035LOCAL_LDLIBS += $(ELFF_LDLIBS)
1036
1037# on Windows, link the icon file as well into the executable
1038# unfortunately, our build system doesn't help us much, so we need
1039# to use some weird pathnames to make this work...
1040#
1041ifeq ($(HOST_OS),windows)
1042
1043# Locate windres executable
1044WINDRES := windres
1045ifneq ($(USE_MINGW),)
1046 # When building the Windows emulator under Linux, use the MinGW one
1047 WINDRES := i586-mingw32msvc-windres
1048endif
1049
1050INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1051ANDROID_ICON_OBJ := android_icon.o
1052ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1053$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1054 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1055
1056# seems to be the only way to add an object file that was not generated from
1057# a C/C++/Java source file to our build system. and very unfortunately,
1058# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1059# us to put the object file in the source directory...
1060#
1061LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1062endif
1063
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -07001064# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1065#
1066intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1067
1068QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1069$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1070$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1071$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1072 $(transform-generated-source)
1073
1074$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1075
1076LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1077
1078# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1079#
1080intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1081
1082QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1083$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1084$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1085$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1086 $(transform-generated-source)
1087
1088$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1089
1090LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1091
1092
1093# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1094# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1095#
1096ifeq ($(QEMU_TARGET_XML_SOURCES),)
1097 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1098 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1099endif
1100
1101QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1102$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1103$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1104$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1105$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1106 $(hide) rm -f $@
1107 $(transform-generated-source)
1108
1109$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1110
1111LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1112
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001113# this is already done by the Android build system, but is done for the
1114# benefit of the stand-alone one.
1115#
1116ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1117 LOCAL_CFLAGS += -I$(intermediates)
1118endif
1119
1120# other flags
1121ifneq ($(HOST_OS),windows)
1122 LOCAL_LDLIBS += -ldl
1123endif
1124
1125LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1126
David 'Digit' Turner415a4b12010-07-28 12:20:14 -07001127ifeq ($(HOST_OS),darwin)
1128 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
1129 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
1130endif
1131
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001132# Generate a completely static executable if needed.
1133# Note that this means no sound and graphics on Linux.
1134#
1135ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1136 LOCAL_SRC_FILES += dynlink-static.c
1137 LOCAL_LDLIBS += -static
1138endif
1139
1140LOCAL_MODULE := qemu-android
David 'Digit' Turnerd95fd132010-09-20 12:19:11 +02001141LOCAL_MODULE_TAGS := debug
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001142
1143include $(BUILD_HOST_EXECUTABLE)
1144
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001145endif # TARGET_ARCH == arm