blob: 0639bfd2d2746ead92749b43d277264ce63241b3 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001ifeq ($(TARGET_ARCH),arm)
2LOCAL_PATH:= $(call my-dir)
3
4# determine the location of platform-specific directories
5#
6CONFIG_DIRS := \
7 $(LOCAL_PATH)/android/config \
8 $(LOCAL_PATH)/android/config/$(HOST_PREBUILT_TAG)
9
10CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
11
Kenny Root095cd0f2009-09-19 18:32:44 -050012MY_CC := $(HOST_CC)
13
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -070014MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
15ifeq ($(BUILD_DEBUG_EMULATOR),true)
16 MY_OPTIM := -O0 -g
17endif
18
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080019MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080020
David 'Digit' Turner466f5482009-07-30 15:50:19 +020021# Overwrite configuration for debug builds.
22#
23ifeq ($(BUILD_DEBUG_EMULATOR),true)
24 MY_CFLAGS := $(CONFIG_INCLUDES) -O0 -g \
25 -fno-PIC -falign-functions=0
26endif
27
David 'Digit' Turner9a0f1fb2010-02-25 14:22:29 -080028MY_CFLAGS += -DCONFIG_MEMCHECK
29
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070030MY_LDLIBS :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080031
32# this is needed to build the emulator on 64-bit Linux systems
33ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
34 MY_CFLAGS += -Wa,--32
35endif
36
37ifeq ($(HOST_OS),freebsd)
38 MY_CFLAGS += -Wa,--32 -I /usr/local/include
39endif
40
41ifeq ($(HOST_OS),windows)
42 MY_CFLAGS += -D_WIN32 -mno-cygwin
43 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
44 MY_CFLAGS += -DWINVER=0x501
45endif
46
47ifeq ($(HOST_ARCH),ppc)
48 MY_CFLAGS += -D__powerpc__
49endif
50
51ifeq ($(HOST_OS),darwin)
David 'Digit' Turner2c538c82010-05-10 16:48:20 -070052 MY_CFLAGS += -mdynamic-no-pic -fno-exceptions
David Turnerbba461c2009-06-03 10:48:15 -070053
54 # When building on Leopard or above, we need to use the 10.4 SDK
55 # or the generated binary will not run on Tiger.
56 DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
57 ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.%,$(DARWIN_VERSION)),)
58 $(error Building the Android emulator requires OS X 10.4 or above)
59 endif
60 ifeq ($(filter 10.4 10.4.%,$(DARWIN_VERSION)),)
61 # We are on Leopard or above
62 TIGER_SDK := /Developer/SDKs/MacOSX10.4u.sdk
63 ifeq ($(strip $(wildcard $(TIGER_SDK))),)
64 $(info Please install the 10.4 SDK on this machine at $(TIGER_SDK))
65 $(error Aborting the build.)
66 endif
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070067 MY_CFLAGS += -isysroot $(TIGER_SDK) -mmacosx-version-min=10.4 -DMACOSX_DEPLOYMENT_TARGET=10.4
68 MY_LDLIBS += -isysroot $(TIGER_SDK) -Wl,-syslibroot,$(TIGER_SDK) -mmacosx-version-min=10.4
Kenny Root095cd0f2009-09-19 18:32:44 -050069
70 # Beginning with Snow Leopard, the default compiler is GCC 4.2
71 # which is incompatible with the 10.4 SDK, so we must
72 # specify the use of GCC 4.0.
73 ifeq ($(filter 10.5 10.5.%,$(DARWIN_VERSION)),)
74 # We are on Snow Leopard or above
75 MY_CC := gcc-4.0
76 endif
David Turnerbba461c2009-06-03 10:48:15 -070077 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080078endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080079
80# BUILD_STANDALONE_EMULATOR is only defined when building with
81# the android-rebuild.sh script. The script will also provide
82# adequate values for HOST_CC
83#
84ifneq ($(BUILD_STANDALONE_EMULATOR),true)
85
86 ifneq ($(USE_CCACHE),)
87 MY_CC := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache $(MY_CC)
88 endif
89endif
90
91
92ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
93 ifneq ($(HOST_ARCH),x86_64)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070094 MY_CFLAGS += -m32
95 MY_LDLIBS += -m32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080096 endif
97endif
98
99include $(CLEAR_VARS)
100
101###########################################################
102# Zlib configuration
103#
104ZLIB_DIR := distrib/zlib-1.2.3
105include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
106
107###########################################################
108# Libpng configuration
109#
110LIBPNG_DIR := distrib/libpng-1.2.19
111include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
112
113###############################################################################
114# build the TCG code generator
115#
116include $(CLEAR_VARS)
117
118LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
119LOCAL_CC := $(MY_CC)
120LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700121LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800122LOCAL_MODULE := emulator-tcg
123
124TCG_TARGET := $(HOST_ARCH)
125ifeq ($(TCG_TARGET),x86)
126 TCG_TARGET := i386
127endif
128
129TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
130
131LOCAL_CFLAGS += $(TCG_CFLAGS) \
132 -I$(LOCAL_PATH)/target-arm \
133 -I$(LOCAL_PATH)/fpu \
134
135LOCAL_SRC_FILES := \
136 tcg/tcg.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800137
138include $(BUILD_HOST_STATIC_LIBRARY)
139
140##############################################################################
141# build the HW emulation support
142#
143include $(CLEAR_VARS)
144
145LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
146LOCAL_CC := $(MY_CC)
147LOCAL_MODULE := emulator-hw
148
149HW_CFLAGS := -I$(LOCAL_PATH)/hw
150
151LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
152LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
153LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
154
155HW_SOURCES := \
156 android_arm.c \
157 arm_pic.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700158 bt.c \
159 bt-hci.c \
160 bt-hid.c \
161 bt-l2cap.c \
162 bt-sdp.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800163 cdrom.c \
164 dma.c \
165 irq.c \
166 goldfish_audio.c \
167 goldfish_battery.c \
168 goldfish_device.c \
169 goldfish_events_device.c \
170 goldfish_fb.c \
171 goldfish_interrupt.c \
172 goldfish_memlog.c \
173 goldfish_mmc.c \
174 goldfish_nand.c \
175 goldfish_switch.c \
176 goldfish_timer.c \
177 goldfish_trace.c \
178 goldfish_tty.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700179 msmouse.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800180 pci.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700181 qdev.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800182 scsi-disk.c \
183 smc91c111.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700184 sysbus.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800185 usb-hid.c \
186 usb-hub.c \
187 usb-msd.c \
188 usb-ohci.c \
189 usb.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700190 watchdog.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800191
192LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
193
194include $(BUILD_HOST_STATIC_LIBRARY)
195
196##############################################################################
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800197# build the ELF/DWARF stuff
198# This library is used by emulator's memory checker to extract debug information
199# from the symbol files when reporting memory allocation violations. In
200# particular, this library is used to extract routine name and source file
201# location for the code address where violation has been detected.
202#
203include $(CLEAR_VARS)
204
205LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
206LOCAL_CC := $(MY_CC)
207LOCAL_MODULE := emulator-elff
208LOCAL_CPP_EXTENSION := .cc
209
210ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
211
212LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
213LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
214LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
215
216ELFF_SOURCES := \
217 dwarf_cu.cc \
218 dwarf_die.cc \
219 dwarf_utils.cc \
220 elf_alloc.cc \
221 elf_file.cc \
222 elf_mapped_section.cc \
223 elff_api.cc \
224
225LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
226ELFF_LDLIBS := -lstdc++
227
228include $(BUILD_HOST_STATIC_LIBRARY)
229
230##############################################################################
231# build the memory access checking support
232# Memory access checker uses information collected by instrumented code in
233# libc.so in order to keep track of memory blocks allocated from heap. Memory
234# checker then uses this information to make sure that every access to allocated
235# memory is within allocated block. This information also allows detecting
236# memory leaks and attempts to free/realloc invalid pointers.
237#
238include $(CLEAR_VARS)
239
240LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
241LOCAL_CC := $(MY_CC)
242LOCAL_MODULE := emulator-memcheck
243
244MCHK_CFLAGS := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
245
246LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
247LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
248LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
249
250MCHK_SOURCES := \
251 memcheck.c \
252 memcheck_proc_management.c \
253 memcheck_malloc_map.c \
254 memcheck_mmrange_map.c \
255 memcheck_util.c \
256
257LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
258
259include $(BUILD_HOST_STATIC_LIBRARY)
260
261##############################################################################
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800262# build the ARM-specific emulation engine sources
263#
264include $(CLEAR_VARS)
265
266LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
267LOCAL_CC := $(MY_CC)
268LOCAL_MODULE := emulator-arm
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700269LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800270LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
271LOCAL_STATIC_LIBRARIES := emulator-hw
272
273LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
274LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
275
276LOCAL_CFLAGS += -I$(LOCAL_PATH) \
277 -I$(LOCAL_PATH)/target-arm \
278 -I$(LOCAL_PATH)/fpu \
279 $(TCG_CFLAGS) \
280 $(HW_CFLAGS) \
281
282ifeq ($(HOST_ARCH),ppc)
283 LOCAL_CFLAGS += -D__powerpc__
284endif
285
286LOCAL_SRC_FILES += exec.c cpu-exec.c \
287 target-arm/op_helper.c \
288 target-arm/iwmmxt_helper.c \
289 target-arm/neon_helper.c \
290 target-arm/helper.c \
291 target-arm/translate.c \
292 target-arm/machine.c \
293 translate-all.c \
294 hw/armv7m.c \
295 hw/armv7m_nvic.c \
296 arm-semi.c \
297 trace.c \
298 varint.c \
299 dcache.c \
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800300 softmmu_outside_jit.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800301
302LOCAL_SRC_FILES += fpu/softfloat.c
303
304include $(BUILD_HOST_STATIC_LIBRARY)
305
306##############################################################################
307# SDL-related definitions
308#
309
310SDL_CONFIG ?= prebuilt/$(HOST_PREBUILT_TAG)/sdl/bin/sdl-config
311SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
312
313# We need to filter out the _GNU_SOURCE variable because it breaks recent
314# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
315# need this macro at all to build the Android emulator.
316SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
317SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
318
319
320##############################################################################
321# determine audio sources, build the prebuilt audio-library if needed
322#
323
324# determine AUDIO sources based on current configuration
325#
Vladimir Chtchetkineeeac0132010-05-03 10:46:28 -0700326AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800327AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
328AUDIO_LDLIBS :=
329
330ifeq ($(HOST_OS),darwin)
331 CONFIG_COREAUDIO ?= yes
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700332 AUDIO_CFLAGS += -DHOST_BSD=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800333endif
334
335ifeq ($(HOST_OS),windows)
336 CONFIG_WINAUDIO ?= yes
337endif
338
339ifeq ($(HOST_OS),linux)
340 CONFIG_OSS ?= yes
341 CONFIG_ALSA ?= yes
342 CONFIG_ESD ?= yes
343endif
344
345ifeq ($(HOST_OS),freebsd)
346 CONFIG_OSS ?= yes
347endif
348
349ifeq ($(CONFIG_COREAUDIO),yes)
350 AUDIO_SOURCES += coreaudio.c
351 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
352 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
353endif
354
355ifeq ($(CONFIG_WINAUDIO),yes)
356 AUDIO_SOURCES += winaudio.c
357 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
358endif
359
360ifeq ($(CONFIG_ALSA),yes)
361 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
362 AUDIO_CFLAGS += -DCONFIG_ALSA
363endif
364
365ifeq ($(CONFIG_ESD),yes)
366 AUDIO_SOURCES += esdaudio.c
367 AUDIO_CFLAGS += -DCONFIG_ESD
368endif
369
370ifeq ($(CONFIG_OSS),yes)
371 AUDIO_SOURCES += ossaudio.c
372 AUDIO_CFLAGS += -DCONFIG_OSS
373endif
374
375AUDIO_SOURCES := $(AUDIO_SOURCES:%=audio/%)
376
377# determine whether we're going to use the prebuilt
378# audio library (this is useful on Linux to avoid requiring
379# all sound-related development packages to be installed on
380# the build and developer machines).
381#
382# note that you can define BUILD_QEMU_AUDIO_LIB to true
383# in your environment to force recompilation.
384#
385QEMU_AUDIO_LIB :=
386
387ifneq ($(BUILD_STANDALONE_EMULATOR),true)
388 QEMU_AUDIO_LIB := $(wildcard \
389 prebuilt/$(HOST_PREBUILT_TAG)/emulator/libqemu-audio.a)
390endif
391
392ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
393 include $(CLEAR_VARS)
394 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
395 LOCAL_CC := $(MY_CC)
396 LOCAL_MODULE := libqemu-audio
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700397 LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800398
399 LOCAL_CFLAGS := -Wno-sign-compare \
400 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
401 -I$(LOCAL_PATH) \
402 -I$(LOCAL_PATH)/target-arm \
403 -I$(LOCAL_PATH)/fpu \
404
David 'Digit' Turner46be4872009-06-04 16:07:01 +0200405 # this is very important, otherwise the generated binaries may
406 # not link properly on our build servers
407 ifeq ($(HOST_OS),linux)
408 LOCAL_CFLAGS += -fno-stack-protector
409 endif
410
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800411 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
412
413 LOCAL_CFLAGS += $(SDL_CFLAGS)
414
415 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
416
417 include $(BUILD_HOST_STATIC_LIBRARY)
418 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
419
420endif # !QEMU_AUDIO_LIB
421
422##############################################################################
423# now build the emulator itself
424#
425include $(CLEAR_VARS)
426
427LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
428LOCAL_CC := $(MY_CC)
429LOCAL_MODULE := emulator
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800430LOCAL_STATIC_LIBRARIES := emulator-memcheck emulator-hw emulator-arm emulator-tcg
431LOCAL_STATIC_LIBRARIES += emulator-elff
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -0700432LOCAL_LDLIBS := $(MY_LDLIBS)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800433
434# don't remove the -fno-strict-aliasing, or you'll break things
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700435# (e.g. slirp-android/network support)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800436#
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700437LOCAL_CFLAGS := -fno-PIC -Wno-sign-compare \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800438 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
439
440LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
441
442# add the build ID to the default macro definitions
443LOCAL_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
444
David 'Digit' Turnera383d022009-12-03 13:50:00 -0800445# For non-standalone builds, extract the major version number from the Android SDK
446# tools revision number.
447ifneq ($(BUILD_STANDALONE_EMULATOR),true)
448 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
449endif
450
451ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
452ifdef ANDROID_SDK_TOOLS_REVISION
453 LOCAL_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
454endif
455
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800456# include the Zlib sources
457#
458LOCAL_SRC_FILES += $(ZLIB_SOURCES)
459LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
460
461# include the Libpng sources
462#
463LOCAL_SRC_FILES += $(LIBPNG_SOURCES)
464LOCAL_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
465
466LOCAL_CFLAGS += -I$(LOCAL_PATH)/ \
467 -I$(LOCAL_PATH)/target-arm \
468 -I$(LOCAL_PATH)/fpu \
469 $(TCG_CFLAGS) \
470 $(HW_CFLAGS) \
471
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700472# Needed by the upstream code
473LOCAL_CFLAGS += -DNEED_CPU_H
474
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800475# include telephony stuff
476#
477TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
478LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
479LOCAL_CFLAGS += -I$(LOCAL_PATH)/telephony
480
481# include sound support source files. we first try to see if we have a prebuilt audio
482# library. if not, we build things the "hard" way.
483#
484# note that to generate the prebuilt audio library, you should do the following:
485#
486# cd tools/qemu
487# ./android-rebuild.sh
488# distrib/update-audio.sh
489#
490ifeq ($(QEMU_AUDIO_LIB),)
491 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
492endif # !QEMU_AUDIO_LIB
493
494LOCAL_CFLAGS += $(AUDIO_CFLAGS)
495LOCAL_LDLIBS += $(AUDIO_LDLIBS)
496
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700497# include slirp-android code, i.e. the user-level networking stuff
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800498#
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
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700503LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
504LOCAL_CFLAGS += -I$(LOCAL_PATH)/slirp-android
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800505
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/%)
515LOCAL_CFLAGS += -I$(LOCAL_PATH)/proxy
516
517# the linux-user sources, I doubt we really need these
518#
519#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
520#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
521
522# the skin support sources
523#
524SKIN_SOURCES := rect.c \
525 region.c \
526 image.c \
527 trackball.c \
528 keyboard.c \
529 keyset.c \
530 file.c \
531 window.c \
532 scaler.c \
533 composer.c \
534 surface.c \
535
536LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
537#LOCAL_CFLAGS += -I$(LOCAL_PATH)/skin
538
539ifeq ($(HOST_ARCH),x86)
540# enable MMX code for our skin scaler
541LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
542endif
543
544# include other sources
545#
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700546VL_SOURCES := vl-android.c osdep.c cutils.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800547 block.c readline.c monitor.c console.c loader.c sockets.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700548 aes.c d3des.c \
549 block/qcow.c \
550 block/qcow2.c \
551 block/qcow2-refcount.c \
552 block/qcow2-snapshot.c \
553 block/qcow2-cluster.c \
554 block/cloop.c \
555 block/dmg.c \
556 block/vvfat.c \
557 buffered_file.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800558 cbuffer.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700559 gdbstub.c \
560 vnc-android.c disas.c arm-dis.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800561 shaper.c charpipe.c loadpng.c \
562 framebuffer.c \
563 tcpdump.c \
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700564 qemu-char-android.c \
565 qemu-malloc.c \
566 qemu-option.c \
567 savevm.c \
568 net-android.c \
569 acl.c \
570 aio-android.c \
571 dma-helpers.c \
572 qemu-sockets-android.c \
573 keymaps.c \
574 bt-host.c \
575 bt-vhci.c \
576 module.c \
David Turner9c0c5152009-06-02 12:30:47 -0700577 android/boot-properties.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800578 android/charmap.c \
579 android/cmdline-option.c \
580 android/config.c \
581 android/console.c \
582 android/gps.c \
583 android/help.c \
584 android/hw-control.c \
585 android/hw-events.c \
586 android/hw-kmsg.c \
David 'Digit' Turnerc5b12702009-06-19 00:36:12 +0200587 android/hw-lcd.c \
The Android Open Source Project9877e2e2009-03-18 17:39:44 -0700588 android/hw-qemud.c \
589 android/hw-sensors.c \
David 'Digit' Turner87250c22009-09-17 16:45:03 -0700590 android/keycode.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800591 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800592 android/resource.c \
593 android/user-config.c \
594 android/utils/bufprint.c \
595 android/utils/debug.c \
596 android/utils/dirscanner.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800597 android/utils/ini.c \
598 android/utils/filelock.c \
599 android/utils/misc.c \
600 android/utils/path.c \
601 android/utils/reflist.c \
602 android/utils/stralloc.c \
603 android/utils/system.c \
604 android/utils/tempfile.c \
605 android/utils/timezone.c \
Vladimir Chtchetkine8339d182010-03-25 10:57:29 -0700606 android/utils/mapfile.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800607 android/avd/hw-config.c \
608 android/avd/info.c \
609
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800610VL_SOURCES += hw/arm_boot.c \
611 hw/android_arm.c \
612
613ifeq ($(HOST_OS),windows)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700614 VL_SOURCES += block/raw-win32.c \
615 migration-dummy-android.c \
616 iolooper-select.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800617else
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700618 VL_SOURCES += block/raw-posix.c \
619 migration.c \
620 migration-exec.c \
621 migration-tcp-android.c \
622 iolooper-select.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800623endif
624
625ifeq ($(HOST_OS),linux)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700626 VL_SOURCES += usb-linux.c \
627 qemu-thread.c
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700628else
629 VL_SOURCES += usb-dummy-android.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800630endif
631
632ifeq ($(HOST_ARCH),x86)
633 VL_SOURCES += i386-dis.c
634endif
635ifeq ($(HOST_ARCH),x86_64)
636 VL_SOURCES += i386-dis.c
637endif
638ifeq ($(HOST_ARCH),ppc)
639 VL_SOURCES += ppc-dis.c
640endif
641
642ifeq ($(HOST_OS),windows)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700643 VL_SOURCES += tap-win32.c
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800644 LOCAL_LDLIBS += -mno-cygwin -mwindows -mconsole
645endif
646
Alexey Tarasov43fbac12009-06-15 14:28:15 +1100647ifeq ($(HOST_OS),freebsd)
648 LOCAL_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
649endif
650
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800651LOCAL_SRC_FILES += $(VL_SOURCES)
652
653ifeq ($(HOST_OS),linux)
654 LOCAL_LDLIBS += -lutil -lrt
655endif
656
657# add SDL-specific flags
658#
659LOCAL_CFLAGS += $(SDL_CFLAGS)
660LOCAL_LDLIBS += $(SDL_LDLIBS)
Raphaelaea1b872010-04-14 12:16:28 -0700661# Circular dependencies between libSDL and libSDLmain;
662# We repeat the libraries in the final link to work around it.
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800663LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
664LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
665
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800666# add ELFF-specific flags
667#
668LOCAL_LDLIBS += $(ELFF_LDLIBS)
669
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800670# on Windows, link the icon file as well into the executable
671# unfortunately, our build system doesn't help us much, so we need
672# to use some weird pathnames to make this work...
673#
674ifeq ($(HOST_OS),windows)
Raphaelaea1b872010-04-14 12:16:28 -0700675
676# Locate windres executable
677WINDRES := windres
678ifneq ($(USE_MINGW),)
679 # When building the Windows emulator under Linux, use the MinGW one
680 WINDRES := i586-mingw32msvc-windres
681endif
682
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800683INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
684ANDROID_ICON_OBJ := android_icon.o
685ANDROID_ICON_PATH := $(LOCAL_PATH)/images
686$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
Raphaelaea1b872010-04-14 12:16:28 -0700687 $(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800688
689# seems to be the only way to add an object file that was not generated from
690# a C/C++/Java source file to our build system. and very unfortunately,
691# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
692# us to put the object file in the source directory...
693#
694LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
695endif
696
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700697# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
698#
699intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
700
701QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
702$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
703$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
704$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
705 $(transform-generated-source)
706
707$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
708
709LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
710
711# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
712#
713intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
714
715QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
716$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
717$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
718$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
719 $(transform-generated-source)
720
721$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
722
723LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
724
725
726# gdbstub-xml.c contains C-compilable arrays corresponding to the content
727# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
728#
729ifeq ($(QEMU_TARGET_XML_SOURCES),)
730 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
731 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
732endif
733
734QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
735$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
736$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
737$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
738$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
739 $(hide) rm -f $@
740 $(transform-generated-source)
741
742$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
743
744LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
745
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700746# hw-config-defs.h is generated from android/avd/hardware-properties.ini
747#
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700748QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
David 'Digit' Turner065242d2009-10-07 13:43:33 -0700749QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
750$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
David 'Digit' Turner2ec45592009-10-07 14:48:19 -0700751$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
752$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
753$(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 -0700754 $(hide) rm -f $@
755 $(transform-generated-source)
756
757$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
758
759LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
David 'Digit' Turner5d8f37a2009-09-14 14:32:27 -0700760
761# this is already done by the Android build system, but is done for the
762# benefit of the stand-alone one.
763#
764ifeq ($(BUILD_STANDALONE_EMULATOR),true)
765 LOCAL_CFLAGS += -I$(intermediates)
766endif
767
768
769
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800770# other flags
771LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
Raphaelaea1b872010-04-14 12:16:28 -0700772LOCAL_LDLIBS += -lm
Vladimir Chtchetkine5389aa12010-02-16 10:38:35 -0800773
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800774ifeq ($(HOST_OS),windows)
775 LOCAL_LDLIBS += -lwinmm -lws2_32 -liphlpapi
Raphaelaea1b872010-04-14 12:16:28 -0700776else
777 LOCAL_LDLIBS += -lpthread
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800778endif
779
780LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
781
David 'Digit' Turnerab873b72010-03-08 18:33:50 -0800782# Generate a completely static executable if needed.
783# Note that this means no sound and graphics on Linux.
784#
785ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
786 LOCAL_SRC_FILES += dynlink-static.c
787 LOCAL_LDLIBS += -static
788endif
789
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800790LOCAL_MODULE := emulator
791
792include $(BUILD_HOST_EXECUTABLE)
793
794endif # TARGET_ARCH == arm