blob: 8692115536cbfc88c90b459aef70c265f5cd8aff [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
101include $(CLEAR_VARS)
102
103###########################################################
104# Zlib configuration
105#
106ZLIB_DIR := distrib/zlib-1.2.3
107include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
108
109###########################################################
110# Libpng configuration
111#
112LIBPNG_DIR := distrib/libpng-1.2.19
113include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
114
115###############################################################################
116# build the TCG code generator
117#
118include $(CLEAR_VARS)
119
120LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
121LOCAL_CC := $(MY_CC)
122LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700123LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800124LOCAL_MODULE := emulator-tcg
125
126TCG_TARGET := $(HOST_ARCH)
127ifeq ($(TCG_TARGET),x86)
128 TCG_TARGET := i386
129endif
130
131TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
132
133LOCAL_CFLAGS += $(TCG_CFLAGS) \
134 -I$(LOCAL_PATH)/target-arm \
135 -I$(LOCAL_PATH)/fpu \
136
137LOCAL_SRC_FILES := \
138 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800139
140include $(BUILD_HOST_STATIC_LIBRARY)
141
142##############################################################################
143# build the HW emulation support
144#
145include $(CLEAR_VARS)
146
147LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
148LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500149LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800150LOCAL_MODULE := emulator-hw
151
152HW_CFLAGS := -I$(LOCAL_PATH)/hw
153
154LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
155LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
156LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
157
158HW_SOURCES := \
159 android_arm.c \
160 arm_pic.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700161 bt.c \
162 bt-hci.c \
163 bt-hid.c \
164 bt-l2cap.c \
165 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800166 cdrom.c \
167 dma.c \
168 irq.c \
169 goldfish_audio.c \
170 goldfish_battery.c \
171 goldfish_device.c \
172 goldfish_events_device.c \
173 goldfish_fb.c \
174 goldfish_interrupt.c \
175 goldfish_memlog.c \
176 goldfish_mmc.c \
177 goldfish_nand.c \
178 goldfish_switch.c \
179 goldfish_timer.c \
180 goldfish_trace.c \
181 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700182 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800183 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700184 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800185 scsi-disk.c \
186 smc91c111.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700187 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800188 usb-hid.c \
189 usb-hub.c \
190 usb-msd.c \
191 usb-ohci.c \
192 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700193 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800194
195LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
196
197include $(BUILD_HOST_STATIC_LIBRARY)
198
199##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800200# build the ELF/DWARF stuff
201# This library is used by emulator's memory checker to extract debug information
202# from the symbol files when reporting memory allocation violations. In
203# particular, this library is used to extract routine name and source file
204# location for the code address where violation has been detected.
205#
206include $(CLEAR_VARS)
207
208LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
209LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500210LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800211LOCAL_MODULE := emulator-elff
212LOCAL_CPP_EXTENSION := .cc
213
214ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
215
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800216LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800217LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
218LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
219
220ELFF_SOURCES := \
221 dwarf_cu.cc \
222 dwarf_die.cc \
223 dwarf_utils.cc \
224 elf_alloc.cc \
225 elf_file.cc \
226 elf_mapped_section.cc \
227 elff_api.cc \
228
229LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
230ELFF_LDLIBS := -lstdc++
231
232include $(BUILD_HOST_STATIC_LIBRARY)
233
234##############################################################################
235# build the memory access checking support
236# Memory access checker uses information collected by instrumented code in
237# libc.so in order to keep track of memory blocks allocated from heap. Memory
238# checker then uses this information to make sure that every access to allocated
239# memory is within allocated block. This information also allows detecting
240# memory leaks and attempts to free/realloc invalid pointers.
241#
242include $(CLEAR_VARS)
243
244LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
245LOCAL_CC := $(MY_CC)
Jeff Hamiltond0d97342010-05-27 11:41:41 -0500246LOCAL_LDLIBS := $(MY_LDLIBS)
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800247LOCAL_MODULE := emulator-memcheck
248
249MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
250
251LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
252LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
253LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
254
255MCHK_SOURCES := \
256 memcheck.c \
257 memcheck_proc_management.c \
258 memcheck_malloc_map.c \
259 memcheck_mmrange_map.c \
260 memcheck_util.c \
261
262LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
263
264include $(BUILD_HOST_STATIC_LIBRARY)
265
266##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800267# build the ARM-specific emulation engine sources
268#
269include $(CLEAR_VARS)
270
271LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
272LOCAL_CC := $(MY_CC)
273LOCAL_MODULE := emulator-arm
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700274LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800275LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
276LOCAL_STATIC_LIBRARIES := emulator-hw
277
278LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
279LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
280
281LOCAL_CFLAGS += -I$(LOCAL_PATH) \
282 -I$(LOCAL_PATH)/target-arm \
283 -I$(LOCAL_PATH)/fpu \
284 $(TCG_CFLAGS) \
285 $(HW_CFLAGS) \
286
287ifeq ($(HOST_ARCH),ppc)
288 LOCAL_CFLAGS += -D__powerpc__
289endif
290
291LOCAL_SRC_FILES += exec.c cpu-exec.c \
292 target-arm/op_helper.c \
293 target-arm/iwmmxt_helper.c \
294 target-arm/neon_helper.c \
295 target-arm/helper.c \
296 target-arm/translate.c \
297 target-arm/machine.c \
298 translate-all.c \
299 hw/armv7m.c \
300 hw/armv7m_nvic.c \
301 arm-semi.c \
302 trace.c \
303 varint.c \
304 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800305 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800306
307LOCAL_SRC_FILES += fpu/softfloat.c
308
309include $(BUILD_HOST_STATIC_LIBRARY)
310
311##############################################################################
312# SDL-related definitions
313#
314
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700315# Build SDL from sources except on linux-x86, to avoid installing all
316# the X11 development packages on our build servers.
317#
318BUILD_SDL_FROM_SOURCES := true
319ifeq ($(QEMU_HOST_TAG),linux-x86)
320 BUILD_SDL_FROM_SOURCES := false
321endif
David 'Digit' Turnerb74c48f2010-05-20 15:17:32 -0700322ifeq ($(QEMU_HOST_TAG),darwin-x86)
323 BUILD_SDL_FROM_SOURCES := false
324endif
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700325ifeq ($(BUILD_STANDALONE_EMULATOR),true)
326 BUILD_SDL_FROM_SOURCES := true
327endif
328
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700329ifneq ($(SDL_CONFIG),)
330 BUILD_SDL_FROM_SOURCES := false
331endif
332
333ifneq ($(BUILD_SDL_FROM_SOURCES),true)
334
335SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800336SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
337
338# We need to filter out the _GNU_SOURCE variable because it breaks recent
339# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
340# need this macro at all to build the Android emulator.
341SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
342SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
343
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700344# Circular dependencies between libSDL and libSDLmain;
345# We repeat the libraries in the final link to work around it.
346SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
347
348else # !BUILD_STANDALONE_EMULATOR
349
350SDL_DIR := distrib/sdl-1.2.12
351include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
352
353endif # !BUILD_STANDALONE_EMULATOR
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800354
355##############################################################################
356# determine audio sources, build the prebuilt audio-library if needed
357#
358
359# determine AUDIO sources based on current configuration
360#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700361AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800362AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
363AUDIO_LDLIBS :=
364
365ifeq ($(HOST_OS),darwin)
366 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700367 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800368endif
369
370ifeq ($(HOST_OS),windows)
371 CONFIG_WINAUDIO ?= yes
372endif
373
374ifeq ($(HOST_OS),linux)
375 CONFIG_OSS ?= yes
376 CONFIG_ALSA ?= yes
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700377 CONFIG_PULSEAUDIO ?= yes
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800378 CONFIG_ESD ?= yes
379endif
380
381ifeq ($(HOST_OS),freebsd)
382 CONFIG_OSS ?= yes
383endif
384
385ifeq ($(CONFIG_COREAUDIO),yes)
386 AUDIO_SOURCES += coreaudio.c
387 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
388 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
389endif
390
391ifeq ($(CONFIG_WINAUDIO),yes)
392 AUDIO_SOURCES += winaudio.c
393 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
394endif
395
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700396ifeq ($(CONFIG_PULSEAUDIO),yes)
397 AUDIO_SOURCES += paaudio.c audio_pt_int.c
398 AUDIO_CFLAGS += -DCONFIG_PULSEAUDIO
399endif
400
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800401ifeq ($(CONFIG_ALSA),yes)
402 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
403 AUDIO_CFLAGS += -DCONFIG_ALSA
404endif
405
406ifeq ($(CONFIG_ESD),yes)
407 AUDIO_SOURCES += esdaudio.c
408 AUDIO_CFLAGS += -DCONFIG_ESD
409endif
410
411ifeq ($(CONFIG_OSS),yes)
412 AUDIO_SOURCES += ossaudio.c
413 AUDIO_CFLAGS += -DCONFIG_OSS
414endif
415
David 'Digit' Turner415a4b12010-07-28 12:20:14 -0700416AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800417
418# determine whether we're going to use the prebuilt
419# audio library (this is useful on Linux to avoid requiring
420# all sound-related development packages to be installed on
421# the build and developer machines).
422#
423# note that you can define BUILD_QEMU_AUDIO_LIB to true
424# in your environment to force recompilation.
425#
426QEMU_AUDIO_LIB :=
427
428ifneq ($(BUILD_STANDALONE_EMULATOR),true)
429 QEMU_AUDIO_LIB := $(wildcard \
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700430 prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800431endif
432
433ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
434 include $(CLEAR_VARS)
435 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
436 LOCAL_CC := $(MY_CC)
437 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700438 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800439
440 LOCAL_CFLAGS := -Wno-sign-compare \
441 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
442 -I$(LOCAL_PATH) \
443 -I$(LOCAL_PATH)/target-arm \
444 -I$(LOCAL_PATH)/fpu \
445
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200446 # this is very important, otherwise the generated binaries may
447 # not link properly on our build servers
448 ifeq ($(HOST_OS),linux)
449 LOCAL_CFLAGS += -fno-stack-protector
450 endif
451
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800452 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
453
454 LOCAL_CFLAGS += $(SDL_CFLAGS)
455
456 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
457
458 include $(BUILD_HOST_STATIC_LIBRARY)
459 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
460
461endif # !QEMU_AUDIO_LIB
462
463##############################################################################
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700464# Build emulator core library.
465# This library contains "pure" emulation code separated from the intricacies
466# of the UI.
467#
468include $(CLEAR_VARS)
469
470LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
471LOCAL_CC := $(MY_CC)
472LOCAL_LDLIBS := $(MY_LDLIBS)
473LOCAL_MODULE := emulator-core
474
475# don't remove the -fno-strict-aliasing, or you'll break things
476# (e.g. slirp-android/network support)
477#
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700478EMULATOR_CORE_CFLAGS := -fno-PIC -Wno-sign-compare \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700479 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
480
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700481# Needed by the upstream code
482EMULATOR_CORE_CFLAGS += -DNEED_CPU_H
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700483
484# Common includes for the emulator
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700485EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/ \
486 -I$(LOCAL_PATH)/target-arm \
487 -I$(LOCAL_PATH)/fpu \
488 $(TCG_CFLAGS) \
489 $(HW_CFLAGS) \
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700490
491# include slirp-android code, i.e. the user-level networking stuff
492#
493SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
494 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
495 tcp_subr.c tcp_timer.c tftp.c udp.c
496
497LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700498EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/slirp-android
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700499
500# socket proxy support
501#
502PROXY_SOURCES := \
503 proxy_common.c \
504 proxy_http.c \
505 proxy_http_connector.c \
506 proxy_http_rewriter.c \
507
508LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700509EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/proxy
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700510
511# include telephony stuff
512#
513TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
514LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700515EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/telephony
516
Vladimir Chtchetkined81e6d12010-06-15 16:46:32 -0700517# include android related stuff
518#
519ANDROID_SOURCES := qemu-setup.c
520LOCAL_SRC_FILES += $(ANDROID_SOURCES:%=android/%)
521
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700522LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700523
524include $(BUILD_HOST_STATIC_LIBRARY)
525
526##############################################################################
527# Build emulator UI library.
528# This library contains some emulator related UI components.
529#
530include $(CLEAR_VARS)
531
532LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
533LOCAL_CC := $(MY_CC)
534LOCAL_LDLIBS := $(MY_LDLIBS)
535LOCAL_MODULE := emulator-ui
536
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700537EMULATOR_UI_CFLAGS :=
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700538
539# include the SDL sources
540#
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700541
542# IMPORTANT: Normally, we should add SDLMAIN_SOURCES here, however this breaks
543# the Linux mingw32 build. Apparently, the i586-mingw32-ld wants the
544# implementation of _WinMain@16 to be in an object file on the final
545# link command used to generate the executable, and will not search
546# in the static libraries that are used to build it.
547#
548LOCAL_SRC_FILES += $(SDL_SOURCES) #$(SDLMAIN_SOURCES)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700549EMULATOR_UI_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700550
551# the skin support sources
552#
553SKIN_SOURCES := rect.c \
554 region.c \
555 image.c \
556 trackball.c \
557 keyboard.c \
558 keyset.c \
559 file.c \
560 window.c \
561 scaler.c \
562 composer.c \
563 surface.c \
564
565LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700566EMULATOR_UI_CFLAGS += -I$(LOCAL_PATH)/skin
567
568LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700569
570include $(BUILD_HOST_STATIC_LIBRARY)
571
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700572##############################################################################
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700573# Common CFLAGS for UI and Core builds
574
575# add the build ID to the default macro definitions
576UI_AND_CORE_CFLAGS = -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
577
578# For non-standalone builds, extract the major version number from the Android SDK
579# tools revision number.
580ifneq ($(BUILD_STANDALONE_EMULATOR),true)
581 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
582endif
583
584ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
585ifdef ANDROID_SDK_TOOLS_REVISION
586 UI_AND_CORE_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
587endif
588
589UI_AND_CORE_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
590
591##############################################################################
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700592# lists of source files used to build the emulator core
593#
594
595# block sources
596#
597CORE_BLOCK_SOURCES = block.c \
598 block/qcow.c \
599 block/qcow2.c \
600 block/qcow2-refcount.c \
601 block/qcow2-snapshot.c \
602 block/qcow2-cluster.c \
603 block/cloop.c \
604 block/dmg.c \
605 block/vvfat.c
606ifeq ($(HOST_OS),windows)
607 CORE_BLOCK_SOURCES += block/raw-win32.c
608else
609 CORE_BLOCK_SOURCES += block/raw-posix.c
610endif
611
612# hw sources
613#
614CORE_HW_SOURCES = hw/arm_boot.c \
615 hw/android_arm.c
616
617# migration sources
618#
619CORE_MIGRATION_SOURCES = iolooper-select.c
620ifeq ($(HOST_OS),windows)
621 CORE_MIGRATION_SOURCES += migration-dummy-android.c
622else
623 CORE_MIGRATION_SOURCES += migration.c \
624 migration-exec.c \
625 migration-tcp-android.c
626endif
627
628# misc. sources
629#
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700630CORE_MISC_SOURCES = vl-android.c \
631 console.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700632 loader.c \
633 monitor.c \
634 readline.c \
635 qemu-char-android.c \
636 disas.c \
637 arm-dis.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700638 aes.c \
639 d3des.c \
640 vnc-android.c \
641 acl.c \
642 buffered_file.c \
643 cbuffer.c \
644 gdbstub.c \
645 ioport.c \
646 shaper.c \
647 charpipe.c \
648 tcpdump.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700649 qemu-option.c \
650 savevm.c \
651 net-android.c \
652 aio-android.c \
653 dma-helpers.c \
654 qemu-sockets-android.c \
655 bt-host.c \
656 bt-vhci.c \
657 module.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700658 android/boot-properties.c \
David 'Digit' Turner055ae422010-07-27 11:34:16 -0700659 android/display.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700660 android/hw-kmsg.c \
Vladimir Chtchetkinea21ac692010-06-28 10:47:18 -0700661 android/hw-lcd.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700662 android/gps.c \
663 android/hw-events.c \
664 android/hw-control.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700665 android/console.c \
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700666 android/hw-sensors.c \
Vladimir Chtchetkinecefa7442010-09-01 09:17:11 -0700667 android/hw-qemud.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700668
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700669ifeq ($(HOST_ARCH),x86)
670 CORE_MISC_SOURCES += i386-dis.c
671endif
672ifeq ($(HOST_ARCH),x86_64)
673 CORE_MISC_SOURCES += i386-dis.c
674endif
675ifeq ($(HOST_ARCH),ppc)
676 CORE_MISC_SOURCES += ppc-dis.c
677endif
678
679ifeq ($(HOST_OS),linux)
680 CORE_MISC_SOURCES += usb-linux.c \
681 qemu-thread.c
682else
683 CORE_MISC_SOURCES += usb-dummy-android.c
684endif
685
686ifeq ($(HOST_OS),windows)
687 CORE_MISC_SOURCES += tap-win32.c
688endif
689
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700690# sources inherited from upstream, but not fully
691# integrated into android emulator
692#
693CORE_UPSTREAM_SOURCES = json-lexer.c \
694 json-parser.c \
695 json-streamer.c \
696 qjson.c \
697 qbool.c \
698 qdict.c \
699 qfloat.c \
700 qint.c \
701 qlist.c \
702 qstring.c \
703
704
Vladimir Chtchetkineceb0fd02010-06-22 10:07:00 -0700705CORE_SOURCES = $(CORE_BLOCK_SOURCES) $(CORE_HW_SOURCES)
706CORE_SOURCES += $(CORE_MIGRATION_SOURCES) $(CORE_MISC_SOURCES)
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700707CORE_SOURCES += $(CORE_UPSTREAM_SOURCES)
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700708
709##############################################################################
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700710# lists of source files used to build the emulator UI
711#
712
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700713UI_SOURCES = loadpng.c \
Vladimir Chtchetkine7258f6b2010-07-14 10:04:01 -0700714 android/user-config.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700715 android/resource.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700716 android/qemulator.c \
717 android/keycode.c \
Vladimir Chtchetkine40575612010-07-08 10:25:06 -0700718 android/help.c \
Vladimir Chtchetkine13682a02010-06-23 16:39:44 -0700719
720##############################################################################
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700721# lists of source files used by both, emulator UI and emulator core
722#
723
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700724UI_AND_CORE_SOURCES = osdep.c \
725 cutils.c \
726 sockets.c \
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700727 keymaps.c \
Vladimir Chtchetkineb5365f32010-08-09 13:33:57 -0700728 qemu-malloc.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700729 android/keycode-array.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700730 android/charmap.c \
Vladimir Chtchetkinea6781382010-07-09 09:19:37 -0700731 android/utils/bufprint.c \
732 android/utils/debug.c \
733 android/utils/path.c \
734 android/utils/dirscanner.c \
735 android/utils/filelock.c \
736 android/utils/misc.c \
737 android/utils/reflist.c \
738 android/utils/stralloc.c \
739 android/utils/system.c \
740 android/utils/tempfile.c \
741 android/utils/timezone.c \
742 android/utils/mapfile.c \
Vladimir Chtchetkine074d1f92010-08-06 09:29:50 -0700743 android/avd/hw-config.c \
744 android/avd/info.c \
745 android/utils/ini.c \
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700746
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700747# include the Zlib sources
748#
749UI_AND_CORE_SOURCES += $(ZLIB_SOURCES)
750UI_AND_CORE_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
751
752# include the Libpng sources
753#
754UI_AND_CORE_SOURCES += $(LIBPNG_SOURCES)
755UI_AND_CORE_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
756
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700757# temp files used to collect UI->Core exchange protocol.
758UI_AND_CORE_SOURCES += android/ui-core-protocol.c android/core-ui-protocol.c
759
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700760# The common libraries
761#
762QEMU_SYSTEM_LDLIBS := -lm
763ifeq ($(HOST_OS),windows)
764 QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
765endif
766
767ifeq ($(HOST_OS),freebsd)
768 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
769endif
770
771ifeq ($(HOST_OS),linux)
772 QEMU_SYSTEM_LDLIBS += -lutil -lrt
773endif
774
775ifeq ($(HOST_OS),windows)
776 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
777else
778 QEMU_SYSTEM_LDLIBS += -lpthread
779endif
780
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700781ifeq ($(HOST_OS),darwin)
782 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa
783endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700784
785
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700786##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800787# now build the emulator itself
788#
789include $(CLEAR_VARS)
790
Vladimir Chtchetkine2fa51732010-07-16 11:19:48 -0700791LOCAL_GENERATED_SOURCES :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800792LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
793LOCAL_CC := $(MY_CC)
794LOCAL_MODULE := emulator
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800795LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
796LOCAL_STATIC_LIBRARIES += emulator-elff
Vladimir Chtchetkinea05284d2010-06-10 10:45:55 -0700797LOCAL_STATIC_LIBRARIES += emulator-core emulator-ui
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700798LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800799
Vladimir Chtchetkine526a9912010-06-10 11:15:27 -0700800LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800801
802# add the build ID to the default macro definitions
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700803LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800804
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800805# include sound support source files. we first try to see if we have a prebuilt audio
806# library. if not, we build things the "hard" way.
807#
808# note that to generate the prebuilt audio library, you should do the following:
809#
810# cd tools/qemu
811# ./android-rebuild.sh
812# distrib/update-audio.sh
813#
814ifeq ($(QEMU_AUDIO_LIB),)
815 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
816endif # !QEMU_AUDIO_LIB
817
818LOCAL_CFLAGS += $(AUDIO_CFLAGS)
819LOCAL_LDLIBS += $(AUDIO_LDLIBS)
820
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800821# the linux-user sources, I doubt we really need these
822#
823#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
824#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
825
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800826ifeq ($(HOST_ARCH),x86)
827# enable MMX code for our skin scaler
828LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
829endif
830
831# include other sources
832#
Vladimir Chtchetkineeb838252010-07-15 12:27:56 -0700833VL_SOURCES := framebuffer.c \
David 'Digit' Turner34f29742010-05-25 18:16:10 -0700834 user-events-qemu.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800835 android/cmdline-option.c \
836 android/config.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800837 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800838
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700839# Add common system libraries
840#
841LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100842
Vladimir Chtchetkine71bb14f2010-07-07 15:57:00 -0700843LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800844
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800845# add SDL-specific flags
846#
847LOCAL_CFLAGS += $(SDL_CFLAGS)
848LOCAL_LDLIBS += $(SDL_LDLIBS)
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700849LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800850
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800851# add ELFF-specific flags
852#
853LOCAL_LDLIBS += $(ELFF_LDLIBS)
854
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800855# on Windows, link the icon file as well into the executable
856# unfortunately, our build system doesn't help us much, so we need
857# to use some weird pathnames to make this work...
858#
859ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700860
861# Locate windres executable
862WINDRES := windres
863ifneq ($(USE_MINGW),)
864 # When building the Windows emulator under Linux, use the MinGW one
865 WINDRES := i586-mingw32msvc-windres
866endif
867
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800868INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
869ANDROID_ICON_OBJ := android_icon.o
870ANDROID_ICON_PATH := $(LOCAL_PATH)/images
871$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700872 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800873
874# seems to be the only way to add an object file that was not generated from
875# a C/C++/Java source file to our build system. and very unfortunately,
876# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
877# us to put the object file in the source directory...
878#
879LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
880endif
881
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700882# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
883#
884intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
885
886QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
887$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
888$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
889$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
890 $(transform-generated-source)
891
892$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
893
894LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
895
896# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
897#
898intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
899
900QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
901$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
902$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
903$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
904 $(transform-generated-source)
905
906$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
907
908LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
909
910
911# gdbstub-xml.c contains C-compilable arrays corresponding to the content
912# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
913#
914ifeq ($(QEMU_TARGET_XML_SOURCES),)
915 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
916 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
917endif
918
919QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
920$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
921$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
922$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
923$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
924 $(hide) rm -f $@
925 $(transform-generated-source)
926
927$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
928
929LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
930
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700931# hw-config-defs.h is generated from android/avd/hardware-properties.ini
932#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700933QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700934QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
935$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700936$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
937$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
938$(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 -0700939 $(hide) rm -f $@
940 $(transform-generated-source)
941
942$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
943
944LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700945
946# this is already done by the Android build system, but is done for the
947# benefit of the stand-alone one.
948#
949ifeq ($(BUILD_STANDALONE_EMULATOR),true)
950 LOCAL_CFLAGS += -I$(intermediates)
951endif
952
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800953LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
954
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800955# Generate a completely static executable if needed.
956# Note that this means no sound and graphics on Linux.
957#
958ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
959 LOCAL_SRC_FILES += dynlink-static.c
960 LOCAL_LDLIBS += -static
961endif
962
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800963LOCAL_MODULE := emulator
964
David 'Digit' Turnerca85ee22010-06-10 15:14:55 -0700965# See comment about SDLMAIN_SOURCES in the 'emulator-ui' module declarations.
966LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
967
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800968include $(BUILD_HOST_EXECUTABLE)
969
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700970##############################################################################
971# Build standalone emulator core.
972#
973include $(CLEAR_VARS)
974
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -0700975LOCAL_GENERATED_SOURCES :=
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700976LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
977LOCAL_CC := $(MY_CC)
978LOCAL_MODULE := qemu-android
979LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
980LOCAL_STATIC_LIBRARIES += emulator-elff
981LOCAL_STATIC_LIBRARIES += emulator-core
982LOCAL_LDLIBS := $(MY_LDLIBS)
983
984LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
985LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_CORE
986
987# include sound support source files. we first try to see if we have a prebuilt audio
988# library. if not, we build things the "hard" way.
989#
990# note that to generate the prebuilt audio library, you should do the following:
991#
992# cd tools/qemu
993# ./android-rebuild.sh
994# distrib/update-audio.sh
995#
996ifeq ($(QEMU_AUDIO_LIB),)
997 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
998endif # !QEMU_AUDIO_LIB
999
1000LOCAL_CFLAGS += $(AUDIO_CFLAGS)
1001LOCAL_LDLIBS += $(AUDIO_LDLIBS)
1002
1003# the linux-user sources, I doubt we really need these
1004#
1005#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
1006#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
1007
1008# include other sources
1009#
1010VL_SOURCES := framebuffer.c \
1011 user-events-qemu.c \
1012
1013# Add common system libraries
1014#
1015LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1016
1017LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_AND_CORE_SOURCES)
1018
1019# add ELFF-specific flags
1020#
1021LOCAL_LDLIBS += $(ELFF_LDLIBS)
1022
1023# on Windows, link the icon file as well into the executable
1024# unfortunately, our build system doesn't help us much, so we need
1025# to use some weird pathnames to make this work...
1026#
1027ifeq ($(HOST_OS),windows)
1028
1029# Locate windres executable
1030WINDRES := windres
1031ifneq ($(USE_MINGW),)
1032 # When building the Windows emulator under Linux, use the MinGW one
1033 WINDRES := i586-mingw32msvc-windres
1034endif
1035
1036INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1037ANDROID_ICON_OBJ := android_icon.o
1038ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1039$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1040 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1041
1042# seems to be the only way to add an object file that was not generated from
1043# a C/C++/Java source file to our build system. and very unfortunately,
1044# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1045# us to put the object file in the source directory...
1046#
1047LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1048endif
1049
Vladimir Chtchetkine3f166802010-08-26 08:25:06 -07001050# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1051#
1052intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1053
1054QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1055$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1056$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1057$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1058 $(transform-generated-source)
1059
1060$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1061
1062LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1063
1064# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1065#
1066intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1067
1068QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1069$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1070$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1071$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1072 $(transform-generated-source)
1073
1074$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1075
1076LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1077
1078
1079# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1080# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1081#
1082ifeq ($(QEMU_TARGET_XML_SOURCES),)
1083 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1084 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1085endif
1086
1087QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1088$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1089$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1090$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1091$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1092 $(hide) rm -f $@
1093 $(transform-generated-source)
1094
1095$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1096
1097LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1098
1099# hw-config-defs.h is generated from android/avd/hardware-properties.ini
1100#
1101QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
1102QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
1103$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
1104$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
1105$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
1106$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
1107 $(hide) rm -f $@
1108 $(transform-generated-source)
1109
1110$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
1111
1112LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
1113
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001114# this is already done by the Android build system, but is done for the
1115# benefit of the stand-alone one.
1116#
1117ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1118 LOCAL_CFLAGS += -I$(intermediates)
1119endif
1120
1121# other flags
1122ifneq ($(HOST_OS),windows)
1123 LOCAL_LDLIBS += -ldl
1124endif
1125
1126LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1127
David 'Digit' Turner415a4b12010-07-28 12:20:14 -07001128ifeq ($(HOST_OS),darwin)
1129 FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
1130 LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
1131endif
1132
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -07001133# Generate a completely static executable if needed.
1134# Note that this means no sound and graphics on Linux.
1135#
1136ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1137 LOCAL_SRC_FILES += dynlink-static.c
1138 LOCAL_LDLIBS += -static
1139endif
1140
1141LOCAL_MODULE := qemu-android
1142
1143include $(BUILD_HOST_EXECUTABLE)
1144
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001145endif # TARGET_ARCH == arm