Makefile.android revision 2c538c86c15d597cc875dc926e4e39285c5625df
1ifeq ($(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
12MY_CC := $(HOST_CC)
13
14MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
15ifeq ($(BUILD_DEBUG_EMULATOR),true)
16    MY_OPTIM := -O0 -g
17endif
18
19MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
20
21# 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
28MY_CFLAGS += -DCONFIG_MEMCHECK
29
30MY_LDLIBS :=
31
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)
52    MY_CFLAGS += -mdynamic-no-pic -fno-exceptions
53
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
67        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
69
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
77    endif
78endif
79
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)
94    MY_CFLAGS += -m32
95    MY_LDLIBS += -m32
96  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)
121LOCAL_LDLIBS                    := $(MY_LDLIBS)
122LOCAL_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 \
137    tcg/tcg-runtime.c \
138
139include $(BUILD_HOST_STATIC_LIBRARY)
140
141##############################################################################
142# build the HW emulation support
143#
144include $(CLEAR_VARS)
145
146LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
147LOCAL_CC                        := $(MY_CC)
148LOCAL_MODULE                    := emulator-hw
149
150HW_CFLAGS    := -I$(LOCAL_PATH)/hw
151
152LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
153LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
154LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
155
156HW_SOURCES := \
157    android_arm.c \
158    arm_pic.c \
159    bt.c \
160    bt-hci.c \
161    bt-hid.c \
162    bt-l2cap.c \
163    bt-sdp.c \
164    cdrom.c \
165    dma.c \
166    irq.c \
167    goldfish_audio.c \
168    goldfish_battery.c \
169    goldfish_device.c \
170    goldfish_events_device.c \
171    goldfish_fb.c \
172    goldfish_interrupt.c \
173    goldfish_memlog.c \
174    goldfish_mmc.c \
175    goldfish_nand.c  \
176    goldfish_switch.c \
177    goldfish_timer.c \
178    goldfish_trace.c \
179    goldfish_tty.c \
180    msmouse.c \
181    pci.c \
182    qdev.c \
183    scsi-disk.c \
184    smc91c111.c \
185    sysbus.c \
186    usb-hid.c \
187    usb-hub.c \
188    usb-msd.c \
189    usb-ohci.c \
190    usb.c \
191    watchdog.c \
192
193LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
194
195include $(BUILD_HOST_STATIC_LIBRARY)
196
197##############################################################################
198# build the ELF/DWARF stuff
199# This library is used by emulator's memory checker to extract debug information
200# from the symbol files when reporting memory allocation violations. In
201# particular, this library is used to extract routine name and source file
202# location for the code address where violation has been detected.
203#
204include $(CLEAR_VARS)
205
206LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
207LOCAL_CC                        := $(MY_CC)
208LOCAL_MODULE                    := emulator-elff
209LOCAL_CPP_EXTENSION             := .cc
210
211ELFF_CFLAGS    := -I$(LOCAL_PATH)/elff
212
213LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
214LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
215LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
216
217ELFF_SOURCES := \
218    dwarf_cu.cc \
219    dwarf_die.cc \
220    dwarf_utils.cc \
221    elf_alloc.cc \
222    elf_file.cc \
223    elf_mapped_section.cc \
224    elff_api.cc \
225
226LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
227ELFF_LDLIBS := -lstdc++
228
229include $(BUILD_HOST_STATIC_LIBRARY)
230
231##############################################################################
232# build the memory access checking support
233# Memory access checker uses information collected by instrumented code in
234# libc.so in order to keep track of memory blocks allocated from heap. Memory
235# checker then uses this information to make sure that every access to allocated
236# memory is within allocated block. This information also allows detecting
237# memory leaks and attempts to free/realloc invalid pointers.
238#
239include $(CLEAR_VARS)
240
241LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
242LOCAL_CC                        := $(MY_CC)
243LOCAL_MODULE                    := emulator-memcheck
244
245MCHK_CFLAGS    := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
246
247LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
248LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
249LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
250
251MCHK_SOURCES := \
252    memcheck.c \
253    memcheck_proc_management.c \
254    memcheck_malloc_map.c \
255    memcheck_mmrange_map.c \
256    memcheck_util.c \
257
258LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
259
260include $(BUILD_HOST_STATIC_LIBRARY)
261
262##############################################################################
263# build the ARM-specific emulation engine sources
264#
265include $(CLEAR_VARS)
266
267LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
268LOCAL_CC                        := $(MY_CC)
269LOCAL_MODULE                    := emulator-arm
270LOCAL_LDLIBS                    := $(MY_LDLIBS)
271LOCAL_CFLAGS                    := $(MY_CFLAGS) $(LOCAL_CFLAGS)
272LOCAL_STATIC_LIBRARIES          := emulator-hw
273
274LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
275LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
276
277LOCAL_CFLAGS += -I$(LOCAL_PATH) \
278                -I$(LOCAL_PATH)/target-arm \
279                -I$(LOCAL_PATH)/fpu \
280                $(TCG_CFLAGS) \
281                $(HW_CFLAGS) \
282
283ifeq ($(HOST_ARCH),ppc)
284    LOCAL_CFLAGS += -D__powerpc__
285endif
286
287LOCAL_SRC_FILES += exec.c cpu-exec.c  \
288                   target-arm/op_helper.c \
289                   target-arm/iwmmxt_helper.c \
290                   target-arm/neon_helper.c \
291                   target-arm/helper.c \
292                   target-arm/translate.c \
293                   target-arm/machine.c \
294                   translate-all.c \
295                   hw/armv7m.c \
296                   hw/armv7m_nvic.c \
297                   arm-semi.c \
298                   trace.c \
299                   varint.c \
300                   dcache.c \
301                   softmmu_outside_jit.c \
302
303LOCAL_SRC_FILES += fpu/softfloat.c
304
305include $(BUILD_HOST_STATIC_LIBRARY)
306
307##############################################################################
308# SDL-related definitions
309#
310
311SDL_CONFIG ?= prebuilt/$(HOST_PREBUILT_TAG)/sdl/bin/sdl-config
312SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
313
314# We need to filter out the _GNU_SOURCE variable because it breaks recent
315# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
316# need this macro at all to build the Android emulator.
317SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
318SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
319
320
321##############################################################################
322# determine audio sources, build the prebuilt audio-library if needed
323#
324
325# determine AUDIO sources based on current configuration
326#
327AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
328AUDIO_CFLAGS  := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
329AUDIO_LDLIBS  :=
330
331ifeq ($(HOST_OS),darwin)
332  CONFIG_COREAUDIO ?= yes
333  AUDIO_CFLAGS += -DHOST_BSD=1
334endif
335
336ifeq ($(HOST_OS),windows)
337  CONFIG_WINAUDIO ?= yes
338endif
339
340ifeq ($(HOST_OS),linux)
341  CONFIG_OSS  ?= yes
342  CONFIG_ALSA ?= yes
343  CONFIG_ESD  ?= yes
344endif
345
346ifeq ($(HOST_OS),freebsd)
347  CONFIG_OSS ?= yes
348endif
349
350ifeq ($(CONFIG_COREAUDIO),yes)
351  AUDIO_SOURCES += coreaudio.c
352  AUDIO_CFLAGS  += -DCONFIG_COREAUDIO
353  AUDIO_LDLIBS  += -Wl,-framework,CoreAudio
354endif
355
356ifeq ($(CONFIG_WINAUDIO),yes)
357  AUDIO_SOURCES += winaudio.c
358  AUDIO_CFLAGS  += -DCONFIG_WINAUDIO
359endif
360
361ifeq ($(CONFIG_ALSA),yes)
362  AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
363  AUDIO_CFLAGS  += -DCONFIG_ALSA
364endif
365
366ifeq ($(CONFIG_ESD),yes)
367  AUDIO_SOURCES += esdaudio.c
368  AUDIO_CFLAGS  += -DCONFIG_ESD
369endif
370
371ifeq ($(CONFIG_OSS),yes)
372  AUDIO_SOURCES += ossaudio.c
373  AUDIO_CFLAGS  += -DCONFIG_OSS
374endif
375
376AUDIO_SOURCES := $(AUDIO_SOURCES:%=audio/%)
377
378# determine whether we're going to use the prebuilt
379# audio library (this is useful on Linux to avoid requiring
380# all sound-related development packages to be installed on
381# the build and developer machines).
382#
383# note that you can define BUILD_QEMU_AUDIO_LIB to true
384# in your environment to force recompilation.
385#
386QEMU_AUDIO_LIB :=
387
388ifneq ($(BUILD_STANDALONE_EMULATOR),true)
389  QEMU_AUDIO_LIB := $(wildcard \
390	prebuilt/$(HOST_PREBUILT_TAG)/emulator/libqemu-audio.a)
391endif
392
393ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
394  include $(CLEAR_VARS)
395  LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
396  LOCAL_CC                        := $(MY_CC)
397  LOCAL_MODULE                    := libqemu-audio
398  LOCAL_LDLIBS                    := $(MY_LDLIBS)
399
400  LOCAL_CFLAGS := -Wno-sign-compare \
401                  -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
402                  -I$(LOCAL_PATH) \
403                  -I$(LOCAL_PATH)/target-arm \
404                  -I$(LOCAL_PATH)/fpu \
405
406  # this is very important, otherwise the generated binaries may
407  # not link properly on our build servers
408  ifeq ($(HOST_OS),linux)
409    LOCAL_CFLAGS += -fno-stack-protector
410  endif
411
412  LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
413
414  LOCAL_CFLAGS += $(SDL_CFLAGS)
415
416  LOCAL_SRC_FILES += $(AUDIO_SOURCES)
417
418  include $(BUILD_HOST_STATIC_LIBRARY)
419  QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
420
421endif  # !QEMU_AUDIO_LIB
422
423##############################################################################
424# now build the emulator itself
425#
426include $(CLEAR_VARS)
427
428LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
429LOCAL_CC                        := $(MY_CC)
430LOCAL_MODULE                    := emulator
431LOCAL_STATIC_LIBRARIES          := emulator-memcheck emulator-hw emulator-arm emulator-tcg
432LOCAL_STATIC_LIBRARIES          += emulator-elff
433LOCAL_LDLIBS                    := $(MY_LDLIBS)
434
435# don't remove the -fno-strict-aliasing, or you'll break things
436# (e.g. slirp-android/network support)
437#
438LOCAL_CFLAGS := -fno-PIC -Wno-sign-compare \
439                -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
440
441LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
442
443# add the build ID to the default macro definitions
444LOCAL_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
445
446# For non-standalone builds, extract the major version number from the Android SDK
447# tools revision number.
448ifneq ($(BUILD_STANDALONE_EMULATOR),true)
449    ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
450endif
451
452ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
453ifdef ANDROID_SDK_TOOLS_REVISION
454    LOCAL_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
455endif
456
457# include the Zlib sources
458#
459LOCAL_SRC_FILES += $(ZLIB_SOURCES)
460LOCAL_CFLAGS    += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
461
462# include the Libpng sources
463#
464LOCAL_SRC_FILES += $(LIBPNG_SOURCES)
465LOCAL_CFLAGS    += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
466
467LOCAL_CFLAGS    += -I$(LOCAL_PATH)/ \
468                   -I$(LOCAL_PATH)/target-arm \
469                   -I$(LOCAL_PATH)/fpu \
470                   $(TCG_CFLAGS) \
471                   $(HW_CFLAGS) \
472
473# Needed by the upstream code
474LOCAL_CFLAGS += -DNEED_CPU_H
475
476# include telephony stuff
477#
478TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
479LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
480LOCAL_CFLAGS    += -I$(LOCAL_PATH)/telephony
481
482# include sound support source files. we first try to see if we have a prebuilt audio
483# library. if not, we build things the "hard" way.
484#
485# note that to generate the prebuilt audio library, you should do the following:
486#
487#   cd tools/qemu
488#   ./android-rebuild.sh
489#   distrib/update-audio.sh
490#
491ifeq ($(QEMU_AUDIO_LIB),)
492  LOCAL_SRC_FILES += $(AUDIO_SOURCES)
493endif  # !QEMU_AUDIO_LIB
494
495LOCAL_CFLAGS  += $(AUDIO_CFLAGS)
496LOCAL_LDLIBS  += $(AUDIO_LDLIBS)
497
498# include slirp-android code, i.e. the user-level networking stuff
499#
500SLIRP_SOURCES := bootp.c     cksum.c      debug.c  if.c     ip_icmp.c  ip_input.c   ip_output.c  \
501                 mbuf.c      misc.c       sbuf.c   slirp.c  socket.c   tcp_input.c  tcp_output.c \
502                 tcp_subr.c  tcp_timer.c  tftp.c   udp.c
503
504LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
505LOCAL_CFLAGS    += -I$(LOCAL_PATH)/slirp-android
506
507# socket proxy support
508#
509PROXY_SOURCES := \
510    proxy_common.c \
511    proxy_http.c \
512    proxy_http_connector.c \
513    proxy_http_rewriter.c \
514
515LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
516LOCAL_CFLAGS    += -I$(LOCAL_PATH)/proxy
517
518# the linux-user sources, I doubt we really need these
519#
520#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
521#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
522
523# the skin support sources
524#
525SKIN_SOURCES := rect.c \
526                region.c \
527                image.c \
528                trackball.c \
529                keyboard.c \
530                keyset.c \
531                file.c \
532                window.c \
533                scaler.c \
534                composer.c \
535                surface.c \
536
537LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
538#LOCAL_CFLAGS    += -I$(LOCAL_PATH)/skin
539
540ifeq ($(HOST_ARCH),x86)
541# enable MMX code for our skin scaler
542LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
543endif
544
545# include other sources
546#
547VL_SOURCES := vl-android.c osdep.c cutils.c \
548              block.c readline.c monitor.c console.c loader.c sockets.c \
549              aes.c d3des.c \
550              block/qcow.c \
551              block/qcow2.c \
552              block/qcow2-refcount.c \
553              block/qcow2-snapshot.c \
554              block/qcow2-cluster.c \
555              block/cloop.c \
556              block/dmg.c \
557              block/vvfat.c \
558              buffered_file.c \
559              cbuffer.c \
560              gdbstub.c \
561              vnc-android.c disas.c arm-dis.c \
562              shaper.c charpipe.c loadpng.c \
563              framebuffer.c \
564              tcpdump.c \
565              qemu-char-android.c \
566              qemu-malloc.c \
567              qemu-option.c \
568              savevm.c \
569              net-android.c \
570              acl.c \
571              aio-android.c \
572              dma-helpers.c \
573              qemu-sockets-android.c \
574              keymaps.c \
575              bt-host.c \
576              bt-vhci.c \
577              module.c \
578              android/boot-properties.c \
579              android/charmap.c \
580              android/cmdline-option.c \
581              android/config.c \
582              android/console.c \
583              android/gps.c \
584              android/help.c \
585              android/hw-control.c \
586              android/hw-events.c \
587              android/hw-kmsg.c \
588              android/hw-lcd.c \
589              android/hw-qemud.c \
590              android/hw-sensors.c \
591              android/keycode.c \
592              android/main.c \
593              android/resource.c \
594              android/user-config.c \
595              android/utils/bufprint.c \
596              android/utils/debug.c \
597              android/utils/dirscanner.c \
598              android/utils/ini.c \
599              android/utils/filelock.c \
600              android/utils/misc.c \
601              android/utils/path.c \
602              android/utils/reflist.c \
603              android/utils/stralloc.c \
604              android/utils/system.c \
605              android/utils/tempfile.c \
606              android/utils/timezone.c \
607              android/utils/mapfile.c \
608              android/avd/hw-config.c \
609              android/avd/info.c \
610
611VL_SOURCES += hw/arm_boot.c \
612              hw/android_arm.c \
613
614ifeq ($(HOST_OS),windows)
615  VL_SOURCES += block/raw-win32.c \
616                migration-dummy-android.c \
617                iolooper-select.c
618else
619  VL_SOURCES += block/raw-posix.c \
620                migration.c \
621                migration-exec.c \
622                migration-tcp-android.c \
623                iolooper-select.c
624endif
625
626ifeq ($(HOST_OS),linux)
627    VL_SOURCES += usb-linux.c \
628                  qemu-thread.c
629else
630    VL_SOURCES += usb-dummy-android.c
631endif
632
633ifeq ($(HOST_ARCH),x86)
634    VL_SOURCES += i386-dis.c
635endif
636ifeq ($(HOST_ARCH),x86_64)
637    VL_SOURCES += i386-dis.c
638endif
639ifeq ($(HOST_ARCH),ppc)
640    VL_SOURCES += ppc-dis.c
641endif
642
643ifeq ($(HOST_OS),windows)
644  VL_SOURCES   += tap-win32.c
645  LOCAL_LDLIBS += -mno-cygwin -mwindows -mconsole
646endif
647
648ifeq ($(HOST_OS),freebsd)
649    LOCAL_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
650endif
651
652LOCAL_SRC_FILES += $(VL_SOURCES)
653
654ifeq ($(HOST_OS),linux)
655  LOCAL_LDLIBS += -lutil -lrt
656endif
657
658# add SDL-specific flags
659#
660LOCAL_CFLAGS += $(SDL_CFLAGS)
661LOCAL_LDLIBS += $(SDL_LDLIBS)
662# Circular dependencies between libSDL and libSDLmain;
663# We repeat the libraries in the final link to work around it.
664LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
665LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
666
667# add ELFF-specific flags
668#
669LOCAL_LDLIBS += $(ELFF_LDLIBS)
670
671# on Windows, link the icon file as well into the executable
672# unfortunately, our build system doesn't help us much, so we need
673# to use some weird pathnames to make this work...
674#
675ifeq ($(HOST_OS),windows)
676
677# Locate windres executable
678WINDRES := windres
679ifneq ($(USE_MINGW),)
680  # When building the Windows emulator under Linux, use the MinGW one
681  WINDRES := i586-mingw32msvc-windres
682endif
683
684INTERMEDIATE     := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
685ANDROID_ICON_OBJ := android_icon.o
686ANDROID_ICON_PATH := $(LOCAL_PATH)/images
687$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
688	$(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
689
690# seems to be the only way to add an object file that was not generated from
691# a C/C++/Java source file to our build system. and very unfortunately,
692# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
693# us to put the object file in the source directory...
694#
695LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
696endif
697
698# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
699#
700intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
701
702QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
703$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
704$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
705$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
706	$(transform-generated-source)
707
708$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
709
710LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
711
712# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
713#
714intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
715
716QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
717$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
718$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
719$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
720	$(transform-generated-source)
721
722$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
723
724LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
725
726
727# gdbstub-xml.c contains C-compilable arrays corresponding to the content
728# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
729#
730ifeq ($(QEMU_TARGET_XML_SOURCES),)
731    QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
732    QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
733endif
734
735QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
736$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
737$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
738$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
739$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
740	$(hide) rm -f $@
741	$(transform-generated-source)
742
743$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
744
745LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
746
747# hw-config-defs.h is generated from android/avd/hardware-properties.ini
748#
749QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
750QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
751$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
752$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
753$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
754$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
755	$(hide) rm -f $@
756	$(transform-generated-source)
757
758$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
759
760LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
761
762# this is already done by the Android build system, but is done for the
763# benefit of the stand-alone one.
764#
765ifeq ($(BUILD_STANDALONE_EMULATOR),true)
766  LOCAL_CFLAGS += -I$(intermediates)
767endif
768
769
770
771# other flags
772LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
773LOCAL_LDLIBS += -lm
774
775ifeq ($(HOST_OS),windows)
776    LOCAL_LDLIBS += -lwinmm -lws2_32 -liphlpapi
777else
778    LOCAL_LDLIBS += -lpthread
779endif
780
781LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
782
783# Generate a completely static executable if needed.
784# Note that this means no sound and graphics on Linux.
785#
786ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
787    LOCAL_SRC_FILES += dynlink-static.c
788    LOCAL_LDLIBS    += -static
789endif
790
791LOCAL_MODULE := emulator
792
793include $(BUILD_HOST_EXECUTABLE)
794
795endif  # TARGET_ARCH == arm
796