blob: 55198960e8d9e08348145c74cd2ffdfbf4493edb [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))
67 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.%,$(DARWIN_VERSION)),)
68 $(error Building the Android emulator requires OS X 10.4 or above)
69 endif
70 ifeq ($(filter 10.4 10.4.%,$(DARWIN_VERSION)),)
71 # We are on Leopard or above
72 TIGER_SDK := /Developer/SDKs/MacOSX10.4u.sdk
73 ifeq ($(strip $(wildcard $(TIGER_SDK))),)
74 $(info Please install the 10.4 SDK on this machine at $(TIGER_SDK))
75 $(error Aborting the build.)
76 endif
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070077 MY_CFLAGS += -isysroot $(TIGER_SDK) -mmacosx-version-min=10.4 -DMACOSX_DEPLOYMENT_TARGET=10.4
78 MY_LDLIBS += -isysroot $(TIGER_SDK) -Wl,-syslibroot,$(TIGER_SDK) -mmacosx-version-min=10.4
Kenny Root095cd0f2009-09-19 18:32:44 -050079
80 # Beginning with Snow Leopard, the default compiler is GCC 4.2
81 # which is incompatible with the 10.4 SDK, so we must
82 # specify the use of GCC 4.0.
83 ifeq ($(filter 10.5 10.5.%,$(DARWIN_VERSION)),)
84 # We are on Snow Leopard or above
85 MY_CC := gcc-4.0
86 endif
David Turnerbba461c2009-06-03 10:48:15 -070087 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080088endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080089
90# BUILD_STANDALONE_EMULATOR is only defined when building with
91# the android-rebuild.sh script. The script will also provide
92# adequate values for HOST_CC
93#
94ifneq ($(BUILD_STANDALONE_EMULATOR),true)
95
96 ifneq ($(USE_CCACHE),)
97 MY_CC := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache $(MY_CC)
98 endif
99endif
100
101
102ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
103 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700104 MY_CFLAGS += -m32
105 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800106 endif
107endif
108
109include $(CLEAR_VARS)
110
111###########################################################
112# Zlib configuration
113#
114ZLIB_DIR := distrib/zlib-1.2.3
115include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
116
117###########################################################
118# Libpng configuration
119#
120LIBPNG_DIR := distrib/libpng-1.2.19
121include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
122
123###############################################################################
124# build the TCG code generator
125#
126include $(CLEAR_VARS)
127
128LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
129LOCAL_CC := $(MY_CC)
130LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700131LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800132LOCAL_MODULE := emulator-tcg
133
134TCG_TARGET := $(HOST_ARCH)
135ifeq ($(TCG_TARGET),x86)
136 TCG_TARGET := i386
137endif
138
139TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
140
141LOCAL_CFLAGS += $(TCG_CFLAGS) \
142 -I$(LOCAL_PATH)/target-arm \
143 -I$(LOCAL_PATH)/fpu \
144
145LOCAL_SRC_FILES := \
146 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800147
148include $(BUILD_HOST_STATIC_LIBRARY)
149
150##############################################################################
151# build the HW emulation support
152#
153include $(CLEAR_VARS)
154
155LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
156LOCAL_CC := $(MY_CC)
157LOCAL_MODULE := emulator-hw
158
159HW_CFLAGS := -I$(LOCAL_PATH)/hw
160
161LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
162LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
163LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
164
165HW_SOURCES := \
166 android_arm.c \
167 arm_pic.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700168 bt.c \
169 bt-hci.c \
170 bt-hid.c \
171 bt-l2cap.c \
172 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800173 cdrom.c \
174 dma.c \
175 irq.c \
176 goldfish_audio.c \
177 goldfish_battery.c \
178 goldfish_device.c \
179 goldfish_events_device.c \
180 goldfish_fb.c \
181 goldfish_interrupt.c \
182 goldfish_memlog.c \
183 goldfish_mmc.c \
184 goldfish_nand.c \
185 goldfish_switch.c \
186 goldfish_timer.c \
187 goldfish_trace.c \
188 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700189 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800190 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700191 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800192 scsi-disk.c \
193 smc91c111.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700194 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800195 usb-hid.c \
196 usb-hub.c \
197 usb-msd.c \
198 usb-ohci.c \
199 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700200 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800201
202LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
203
204include $(BUILD_HOST_STATIC_LIBRARY)
205
206##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800207# build the ELF/DWARF stuff
208# This library is used by emulator's memory checker to extract debug information
209# from the symbol files when reporting memory allocation violations. In
210# particular, this library is used to extract routine name and source file
211# location for the code address where violation has been detected.
212#
213include $(CLEAR_VARS)
214
215LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
216LOCAL_CC := $(MY_CC)
217LOCAL_MODULE := emulator-elff
218LOCAL_CPP_EXTENSION := .cc
219
220ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
221
David 'Digit' Turner3d66dc72010-01-27 18:18:41 -0800222LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800223LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
224LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
225
226ELFF_SOURCES := \
227 dwarf_cu.cc \
228 dwarf_die.cc \
229 dwarf_utils.cc \
230 elf_alloc.cc \
231 elf_file.cc \
232 elf_mapped_section.cc \
233 elff_api.cc \
234
235LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
236ELFF_LDLIBS := -lstdc++
237
238include $(BUILD_HOST_STATIC_LIBRARY)
239
240##############################################################################
241# build the memory access checking support
242# Memory access checker uses information collected by instrumented code in
243# libc.so in order to keep track of memory blocks allocated from heap. Memory
244# checker then uses this information to make sure that every access to allocated
245# memory is within allocated block. This information also allows detecting
246# memory leaks and attempts to free/realloc invalid pointers.
247#
248include $(CLEAR_VARS)
249
250LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
251LOCAL_CC := $(MY_CC)
252LOCAL_MODULE := emulator-memcheck
253
254MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
255
256LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
257LOCAL_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) \
291
292ifeq ($(HOST_ARCH),ppc)
293 LOCAL_CFLAGS += -D__powerpc__
294endif
295
296LOCAL_SRC_FILES += exec.c cpu-exec.c \
297 target-arm/op_helper.c \
298 target-arm/iwmmxt_helper.c \
299 target-arm/neon_helper.c \
300 target-arm/helper.c \
301 target-arm/translate.c \
302 target-arm/machine.c \
303 translate-all.c \
304 hw/armv7m.c \
305 hw/armv7m_nvic.c \
306 arm-semi.c \
307 trace.c \
308 varint.c \
309 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800310 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800311
312LOCAL_SRC_FILES += fpu/softfloat.c
313
314include $(BUILD_HOST_STATIC_LIBRARY)
315
316##############################################################################
317# SDL-related definitions
318#
319
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700320# Build SDL from sources except on linux-x86, to avoid installing all
321# the X11 development packages on our build servers.
322#
323BUILD_SDL_FROM_SOURCES := true
324ifeq ($(QEMU_HOST_TAG),linux-x86)
325 BUILD_SDL_FROM_SOURCES := false
326endif
327ifneq ($(SDL_CONFIG),)
328 BUILD_SDL_FROM_SOURCES := false
329endif
330
331ifneq ($(BUILD_SDL_FROM_SOURCES),true)
332
333SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800334SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
335
336# We need to filter out the _GNU_SOURCE variable because it breaks recent
337# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
338# need this macro at all to build the Android emulator.
339SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
340SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
341
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700342# Circular dependencies between libSDL and libSDLmain;
343# We repeat the libraries in the final link to work around it.
344SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
345
346else # !BUILD_STANDALONE_EMULATOR
347
348SDL_DIR := distrib/sdl-1.2.12
349include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
350
351endif # !BUILD_STANDALONE_EMULATOR
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800352
353##############################################################################
354# determine audio sources, build the prebuilt audio-library if needed
355#
356
357# determine AUDIO sources based on current configuration
358#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700359AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800360AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
361AUDIO_LDLIBS :=
362
363ifeq ($(HOST_OS),darwin)
364 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700365 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800366endif
367
368ifeq ($(HOST_OS),windows)
369 CONFIG_WINAUDIO ?= yes
370endif
371
372ifeq ($(HOST_OS),linux)
373 CONFIG_OSS ?= yes
374 CONFIG_ALSA ?= yes
375 CONFIG_ESD ?= yes
376endif
377
378ifeq ($(HOST_OS),freebsd)
379 CONFIG_OSS ?= yes
380endif
381
382ifeq ($(CONFIG_COREAUDIO),yes)
383 AUDIO_SOURCES += coreaudio.c
384 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
385 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
386endif
387
388ifeq ($(CONFIG_WINAUDIO),yes)
389 AUDIO_SOURCES += winaudio.c
390 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
391endif
392
393ifeq ($(CONFIG_ALSA),yes)
394 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
395 AUDIO_CFLAGS += -DCONFIG_ALSA
396endif
397
398ifeq ($(CONFIG_ESD),yes)
399 AUDIO_SOURCES += esdaudio.c
400 AUDIO_CFLAGS += -DCONFIG_ESD
401endif
402
403ifeq ($(CONFIG_OSS),yes)
404 AUDIO_SOURCES += ossaudio.c
405 AUDIO_CFLAGS += -DCONFIG_OSS
406endif
407
408AUDIO_SOURCES := $(AUDIO_SOURCES:%=audio/%)
409
410# determine whether we're going to use the prebuilt
411# audio library (this is useful on Linux to avoid requiring
412# all sound-related development packages to be installed on
413# the build and developer machines).
414#
415# note that you can define BUILD_QEMU_AUDIO_LIB to true
416# in your environment to force recompilation.
417#
418QEMU_AUDIO_LIB :=
419
420ifneq ($(BUILD_STANDALONE_EMULATOR),true)
421 QEMU_AUDIO_LIB := $(wildcard \
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700422 prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800423endif
424
425ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
426 include $(CLEAR_VARS)
427 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
428 LOCAL_CC := $(MY_CC)
429 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700430 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800431
432 LOCAL_CFLAGS := -Wno-sign-compare \
433 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
434 -I$(LOCAL_PATH) \
435 -I$(LOCAL_PATH)/target-arm \
436 -I$(LOCAL_PATH)/fpu \
437
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200438 # this is very important, otherwise the generated binaries may
439 # not link properly on our build servers
440 ifeq ($(HOST_OS),linux)
441 LOCAL_CFLAGS += -fno-stack-protector
442 endif
443
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800444 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
445
446 LOCAL_CFLAGS += $(SDL_CFLAGS)
447
448 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
449
450 include $(BUILD_HOST_STATIC_LIBRARY)
451 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
452
453endif # !QEMU_AUDIO_LIB
454
455##############################################################################
456# now build the emulator itself
457#
458include $(CLEAR_VARS)
459
460LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
461LOCAL_CC := $(MY_CC)
462LOCAL_MODULE := emulator
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800463LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
464LOCAL_STATIC_LIBRARIES += emulator-elff
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700465LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800466
467# don't remove the -fno-strict-aliasing, or you'll break things
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700468# (e.g. slirp-android/network support)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800469#
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700470LOCAL_CFLAGS := -fno-PIC -Wno-sign-compare \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800471 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
472
473LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
474
475# add the build ID to the default macro definitions
476LOCAL_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
477
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800478# For non-standalone builds, extract the major version number from the Android SDK
479# tools revision number.
480ifneq ($(BUILD_STANDALONE_EMULATOR),true)
481 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
482endif
483
484ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
485ifdef ANDROID_SDK_TOOLS_REVISION
486 LOCAL_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
487endif
488
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800489# include the Zlib sources
490#
491LOCAL_SRC_FILES += $(ZLIB_SOURCES)
492LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
493
494# include the Libpng sources
495#
496LOCAL_SRC_FILES += $(LIBPNG_SOURCES)
497LOCAL_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
498
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700499# include the SDL sources
500#
501LOCAL_SRC_FILES += $(SDL_SOURCES) $(SDLMAIN_SOURCES)
502LOCAL_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
503
504#
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800505LOCAL_CFLAGS += -I$(LOCAL_PATH)/ \
506 -I$(LOCAL_PATH)/target-arm \
507 -I$(LOCAL_PATH)/fpu \
508 $(TCG_CFLAGS) \
509 $(HW_CFLAGS) \
510
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700511# Needed by the upstream code
512LOCAL_CFLAGS += -DNEED_CPU_H
513
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800514# include telephony stuff
515#
516TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
517LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
518LOCAL_CFLAGS += -I$(LOCAL_PATH)/telephony
519
520# include sound support source files. we first try to see if we have a prebuilt audio
521# library. if not, we build things the "hard" way.
522#
523# note that to generate the prebuilt audio library, you should do the following:
524#
525# cd tools/qemu
526# ./android-rebuild.sh
527# distrib/update-audio.sh
528#
529ifeq ($(QEMU_AUDIO_LIB),)
530 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
531endif # !QEMU_AUDIO_LIB
532
533LOCAL_CFLAGS += $(AUDIO_CFLAGS)
534LOCAL_LDLIBS += $(AUDIO_LDLIBS)
535
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700536# include slirp-android code, i.e. the user-level networking stuff
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800537#
538SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
539 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
540 tcp_subr.c tcp_timer.c tftp.c udp.c
541
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700542LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
543LOCAL_CFLAGS += -I$(LOCAL_PATH)/slirp-android
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800544
545# socket proxy support
546#
547PROXY_SOURCES := \
548 proxy_common.c \
549 proxy_http.c \
550 proxy_http_connector.c \
551 proxy_http_rewriter.c \
552
553LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
554LOCAL_CFLAGS += -I$(LOCAL_PATH)/proxy
555
556# the linux-user sources, I doubt we really need these
557#
558#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
559#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
560
561# the skin support sources
562#
563SKIN_SOURCES := rect.c \
564 region.c \
565 image.c \
566 trackball.c \
567 keyboard.c \
568 keyset.c \
569 file.c \
570 window.c \
571 scaler.c \
572 composer.c \
573 surface.c \
574
575LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
576#LOCAL_CFLAGS += -I$(LOCAL_PATH)/skin
577
578ifeq ($(HOST_ARCH),x86)
579# enable MMX code for our skin scaler
580LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
581endif
582
583# include other sources
584#
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700585VL_SOURCES := vl-android.c osdep.c cutils.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800586 block.c readline.c monitor.c console.c loader.c sockets.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700587 aes.c d3des.c \
588 block/qcow.c \
589 block/qcow2.c \
590 block/qcow2-refcount.c \
591 block/qcow2-snapshot.c \
592 block/qcow2-cluster.c \
593 block/cloop.c \
594 block/dmg.c \
595 block/vvfat.c \
596 buffered_file.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800597 cbuffer.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700598 gdbstub.c \
David 'Digit' Turner3266b512010-05-10 18:44:56 -0700599 ioport.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700600 vnc-android.c disas.c arm-dis.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800601 shaper.c charpipe.c loadpng.c \
602 framebuffer.c \
603 tcpdump.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700604 qemu-char-android.c \
605 qemu-malloc.c \
606 qemu-option.c \
607 savevm.c \
608 net-android.c \
609 acl.c \
610 aio-android.c \
611 dma-helpers.c \
612 qemu-sockets-android.c \
613 keymaps.c \
614 bt-host.c \
615 bt-vhci.c \
616 module.c \
David 'Digit' Turner2910f182010-05-10 18:48:35 -0700617 json-lexer.c \
618 json-parser.c \
619 json-streamer.c \
620 qbool.c \
621 qdict.c \
622 qfloat.c \
623 qint.c \
624 qjson.c \
625 qlist.c \
626 qstring.c \
David Turner9c0c5152009-06-02 12:30:47 -0700627 android/boot-properties.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800628 android/charmap.c \
629 android/cmdline-option.c \
630 android/config.c \
631 android/console.c \
632 android/gps.c \
633 android/help.c \
634 android/hw-control.c \
635 android/hw-events.c \
636 android/hw-kmsg.c \
David 'Digit' Turnerc5b12702009-06-19 00:36:12 +0200637 android/hw-lcd.c \
The Android Open Source Project9877e2e2009-03-18 17:39:44 -0700638 android/hw-qemud.c \
639 android/hw-sensors.c \
David 'Digit' Turner87250c22009-09-17 16:45:03 -0700640 android/keycode.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800641 android/main.c \
Vladimir Chtchetkined27aca12010-05-13 11:04:42 -0700642 android/qemu-setup.c \
Vladimir Chtchetkine01193622010-05-11 13:07:22 -0700643 android/qemulator.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800644 android/resource.c \
645 android/user-config.c \
646 android/utils/bufprint.c \
647 android/utils/debug.c \
648 android/utils/dirscanner.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800649 android/utils/ini.c \
650 android/utils/filelock.c \
651 android/utils/misc.c \
652 android/utils/path.c \
653 android/utils/reflist.c \
654 android/utils/stralloc.c \
655 android/utils/system.c \
656 android/utils/tempfile.c \
657 android/utils/timezone.c \
Vladimir Chtchetkine8339d182010-03-25 10:57:29 -0700658 android/utils/mapfile.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800659 android/avd/hw-config.c \
660 android/avd/info.c \
661
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800662VL_SOURCES += hw/arm_boot.c \
663 hw/android_arm.c \
664
665ifeq ($(HOST_OS),windows)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700666 VL_SOURCES += block/raw-win32.c \
667 migration-dummy-android.c \
668 iolooper-select.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800669else
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700670 VL_SOURCES += block/raw-posix.c \
671 migration.c \
672 migration-exec.c \
673 migration-tcp-android.c \
674 iolooper-select.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800675endif
676
677ifeq ($(HOST_OS),linux)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700678 VL_SOURCES += usb-linux.c \
679 qemu-thread.c
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700680else
681 VL_SOURCES += usb-dummy-android.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800682endif
683
684ifeq ($(HOST_ARCH),x86)
685 VL_SOURCES += i386-dis.c
686endif
687ifeq ($(HOST_ARCH),x86_64)
688 VL_SOURCES += i386-dis.c
689endif
690ifeq ($(HOST_ARCH),ppc)
691 VL_SOURCES += ppc-dis.c
692endif
693
694ifeq ($(HOST_OS),windows)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700695 VL_SOURCES += tap-win32.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800696 LOCAL_LDLIBS += -mno-cygwin -mwindows -mconsole
697endif
698
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100699ifeq ($(HOST_OS),freebsd)
700 LOCAL_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
701endif
702
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800703LOCAL_SRC_FILES += $(VL_SOURCES)
704
705ifeq ($(HOST_OS),linux)
706 LOCAL_LDLIBS += -lutil -lrt
707endif
708
709# add SDL-specific flags
710#
711LOCAL_CFLAGS += $(SDL_CFLAGS)
712LOCAL_LDLIBS += $(SDL_LDLIBS)
David 'Digit' Turner34d16512010-05-18 17:02:33 -0700713LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800714
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800715# add ELFF-specific flags
716#
717LOCAL_LDLIBS += $(ELFF_LDLIBS)
718
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800719# on Windows, link the icon file as well into the executable
720# unfortunately, our build system doesn't help us much, so we need
721# to use some weird pathnames to make this work...
722#
723ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700724
725# Locate windres executable
726WINDRES := windres
727ifneq ($(USE_MINGW),)
728 # When building the Windows emulator under Linux, use the MinGW one
729 WINDRES := i586-mingw32msvc-windres
730endif
731
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800732INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
733ANDROID_ICON_OBJ := android_icon.o
734ANDROID_ICON_PATH := $(LOCAL_PATH)/images
735$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700736 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800737
738# seems to be the only way to add an object file that was not generated from
739# a C/C++/Java source file to our build system. and very unfortunately,
740# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
741# us to put the object file in the source directory...
742#
743LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
744endif
745
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700746# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
747#
748intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
749
750QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
751$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
752$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
753$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
754 $(transform-generated-source)
755
756$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
757
758LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
759
760# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
761#
762intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
763
764QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
765$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
766$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
767$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
768 $(transform-generated-source)
769
770$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
771
772LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
773
774
775# gdbstub-xml.c contains C-compilable arrays corresponding to the content
776# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
777#
778ifeq ($(QEMU_TARGET_XML_SOURCES),)
779 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
780 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
781endif
782
783QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
784$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
785$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
786$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
787$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
788 $(hide) rm -f $@
789 $(transform-generated-source)
790
791$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
792
793LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
794
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700795# hw-config-defs.h is generated from android/avd/hardware-properties.ini
796#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700797QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700798QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
799$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700800$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
801$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
802$(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 -0700803 $(hide) rm -f $@
804 $(transform-generated-source)
805
806$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
807
808LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700809
810# this is already done by the Android build system, but is done for the
811# benefit of the stand-alone one.
812#
813ifeq ($(BUILD_STANDALONE_EMULATOR),true)
814 LOCAL_CFLAGS += -I$(intermediates)
815endif
816
817
818
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800819# other flags
820LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
Raphaelaea1b872010-04-14 12:16:28 -0700821LOCAL_LDLIBS += -lm
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800822
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800823ifeq ($(HOST_OS),windows)
824 LOCAL_LDLIBS += -lwinmm -lws2_32 -liphlpapi
Raphaelaea1b872010-04-14 12:16:28 -0700825else
826 LOCAL_LDLIBS += -lpthread
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800827endif
828
829LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
830
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800831# Generate a completely static executable if needed.
832# Note that this means no sound and graphics on Linux.
833#
834ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
835 LOCAL_SRC_FILES += dynlink-static.c
836 LOCAL_LDLIBS += -static
837endif
838
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800839LOCAL_MODULE := emulator
840
841include $(BUILD_HOST_EXECUTABLE)
842
843endif # TARGET_ARCH == arm