Makefile.android revision 90c6235ce7bdc6f7afbcfe56ea6f2c3d2b128447
1ifeq ($(TARGET_ARCH),arm)
2LOCAL_PATH:= $(call my-dir)
3
4# determine the host tag to use
5QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
6ifneq ($(USE_MINGW),)
7    QEMU_HOST_TAG := windows
8endif
9
10# determine the location of platform-specific directories
11#
12CONFIG_DIRS     := \
13    $(LOCAL_PATH)/android/config \
14    $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
15
16ifeq ($(BUILD_STANDALONE_EMULATOR),true)
17    CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS)
18endif
19
20CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
21
22MY_CC := $(HOST_CC)
23
24MY_OPTIM := -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer
25ifeq ($(BUILD_DEBUG_EMULATOR),true)
26    MY_OPTIM := -O0 -g
27endif
28
29MY_CFLAGS := $(CONFIG_INCLUDES) $(MY_OPTIM)
30
31# 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
38MY_CFLAGS += -DCONFIG_MEMCHECK
39
40MY_LDLIBS :=
41
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)
62    MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
63
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.% 10.4 10.4.%,$(DARWIN_VERSION)),)
68        $(error Building the Android emulator requires OS X 10.5 or above)
69    endif
70    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))
75            $(error Aborting the build.)
76        endif
77        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
79    endif
80endif
81
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    ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache
90    ifneq ($(ccache),$(firstword $(MY_CC)))
91      MY_CC := $(ccache) $(MY_CC)
92    endif
93    ccache :=
94  endif
95endif
96
97
98ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
99  ifneq ($(HOST_ARCH),x86_64)
100    MY_CFLAGS += -m32
101    MY_LDLIBS += -m32
102  endif
103endif
104
105# Enable warning, except those related to missing field initializers
106# (the QEMU coding style loves using these).
107#
108MY_CFLAGS += -Wall -Wno-missing-field-initializers
109
110include $(CLEAR_VARS)
111
112###########################################################
113# Zlib configuration
114#
115ZLIB_DIR := distrib/zlib-1.2.3
116include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
117
118###########################################################
119# Libpng configuration
120#
121LIBPNG_DIR := distrib/libpng-1.2.19
122include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
123
124###############################################################################
125# build the TCG code generator
126#
127include $(CLEAR_VARS)
128
129LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
130LOCAL_CC                        := $(MY_CC)
131LOCAL_CFLAGS                    := $(MY_CFLAGS) $(LOCAL_CFLAGS)
132LOCAL_LDLIBS                    := $(MY_LDLIBS)
133LOCAL_MODULE                    := emulator-tcg
134
135TCG_TARGET := $(HOST_ARCH)
136ifeq ($(TCG_TARGET),x86)
137  TCG_TARGET := i386
138endif
139
140TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
141
142LOCAL_CFLAGS += $(TCG_CFLAGS) -DNEED_CPU_H \
143                -I$(LOCAL_PATH)/target-arm \
144                -I$(LOCAL_PATH)/fpu \
145
146LOCAL_SRC_FILES := \
147    tcg/tcg.c \
148
149include $(BUILD_HOST_STATIC_LIBRARY)
150
151##############################################################################
152# build the HW emulation support
153#
154include $(CLEAR_VARS)
155
156LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
157LOCAL_CC                        := $(MY_CC)
158LOCAL_LDLIBS                    := $(MY_LDLIBS)
159LOCAL_MODULE                    := emulator-hw
160
161HW_CFLAGS    := -I$(LOCAL_PATH)/hw
162
163LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
164LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
165LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
166
167HW_SOURCES := \
168    android_arm.c \
169    arm_pic.c \
170    bt.c \
171    bt-hci.c \
172    bt-hid.c \
173    bt-l2cap.c \
174    bt-sdp.c \
175    cdrom.c \
176    dma.c \
177    irq.c \
178    goldfish_audio.c \
179    goldfish_battery.c \
180    goldfish_device.c \
181    goldfish_events_device.c \
182    goldfish_fb.c \
183    goldfish_interrupt.c \
184    goldfish_memlog.c \
185    goldfish_mmc.c \
186    goldfish_nand.c  \
187    goldfish_switch.c \
188    goldfish_timer.c \
189    goldfish_trace.c \
190    goldfish_tty.c \
191    msmouse.c \
192    pci.c \
193    qdev.c \
194    scsi-disk.c \
195    smc91c111.c \
196    sysbus.c \
197    usb-hid.c \
198    usb-hub.c \
199    usb-msd.c \
200    usb-ohci.c \
201    usb.c \
202    watchdog.c \
203
204LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
205
206include $(BUILD_HOST_STATIC_LIBRARY)
207
208##############################################################################
209# build the ELF/DWARF stuff
210# This library is used by emulator's memory checker to extract debug information
211# from the symbol files when reporting memory allocation violations. In
212# particular, this library is used to extract routine name and source file
213# location for the code address where violation has been detected.
214#
215include $(CLEAR_VARS)
216
217LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
218LOCAL_CC                        := $(MY_CC)
219LOCAL_LDLIBS                    := $(MY_LDLIBS)
220LOCAL_MODULE                    := emulator-elff
221LOCAL_CPP_EXTENSION             := .cc
222
223ELFF_CFLAGS    := -I$(LOCAL_PATH)/elff
224
225LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -fno-exceptions
226LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(ELFF_CFLAGS)
227LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
228
229ELFF_SOURCES := \
230    dwarf_cu.cc \
231    dwarf_die.cc \
232    dwarf_utils.cc \
233    elf_alloc.cc \
234    elf_file.cc \
235    elf_mapped_section.cc \
236    elff_api.cc \
237
238LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
239ELFF_LDLIBS := -lstdc++
240
241include $(BUILD_HOST_STATIC_LIBRARY)
242
243##############################################################################
244# build the memory access checking support
245# Memory access checker uses information collected by instrumented code in
246# libc.so in order to keep track of memory blocks allocated from heap. Memory
247# checker then uses this information to make sure that every access to allocated
248# memory is within allocated block. This information also allows detecting
249# memory leaks and attempts to free/realloc invalid pointers.
250#
251include $(CLEAR_VARS)
252
253LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
254LOCAL_CC                        := $(MY_CC)
255LOCAL_LDLIBS                    := $(MY_LDLIBS)
256LOCAL_MODULE                    := emulator-memcheck
257
258MCHK_CFLAGS    := -I$(LOCAL_PATH)/memcheck -I$(LOCAL_PATH)/elff
259
260LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) -DNEED_CPU_H
261LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(MCHK_CFLAGS)
262LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
263
264MCHK_SOURCES := \
265    memcheck.c \
266    memcheck_proc_management.c \
267    memcheck_malloc_map.c \
268    memcheck_mmrange_map.c \
269    memcheck_util.c \
270
271LOCAL_SRC_FILES += $(MCHK_SOURCES:%=memcheck/%)
272
273include $(BUILD_HOST_STATIC_LIBRARY)
274
275##############################################################################
276# build the ARM-specific emulation engine sources
277#
278include $(CLEAR_VARS)
279
280LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
281LOCAL_CC                        := $(MY_CC)
282LOCAL_MODULE                    := emulator-arm
283LOCAL_LDLIBS                    := $(MY_LDLIBS)
284LOCAL_CFLAGS                    := $(MY_CFLAGS) $(LOCAL_CFLAGS)
285LOCAL_STATIC_LIBRARIES          := emulator-hw
286
287LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
288LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
289
290LOCAL_CFLAGS += -I$(LOCAL_PATH) \
291                -I$(LOCAL_PATH)/target-arm \
292                -I$(LOCAL_PATH)/fpu \
293                $(TCG_CFLAGS) \
294                $(HW_CFLAGS) \
295                -DNEED_CPU_H \
296
297ifeq ($(HOST_ARCH),ppc)
298    LOCAL_CFLAGS += -D__powerpc__
299endif
300
301LOCAL_SRC_FILES += exec.c cpu-exec.c  \
302                   target-arm/op_helper.c \
303                   target-arm/iwmmxt_helper.c \
304                   target-arm/neon_helper.c \
305                   target-arm/helper.c \
306                   target-arm/translate.c \
307                   target-arm/machine.c \
308                   translate-all.c \
309                   hw/armv7m.c \
310                   hw/armv7m_nvic.c \
311                   arm-semi.c \
312                   trace.c \
313                   varint.c \
314                   dcache.c \
315                   softmmu_outside_jit.c \
316
317LOCAL_SRC_FILES += fpu/softfloat.c
318
319include $(BUILD_HOST_STATIC_LIBRARY)
320
321##############################################################################
322# SDL-related definitions
323#
324
325# Build SDL from sources except on linux-x86, to avoid installing all
326# the X11 development packages on our build servers.
327#
328BUILD_SDL_FROM_SOURCES := true
329ifeq ($(QEMU_HOST_TAG),linux-x86)
330    BUILD_SDL_FROM_SOURCES := false
331endif
332ifeq ($(QEMU_HOST_TAG),darwin-x86)
333    BUILD_SDL_FROM_SOURCES := false
334endif
335ifeq ($(BUILD_STANDALONE_EMULATOR),true)
336    BUILD_SDL_FROM_SOURCES := true
337endif
338
339ifneq ($(SDL_CONFIG),)
340    BUILD_SDL_FROM_SOURCES := false
341endif
342
343ifneq ($(BUILD_SDL_FROM_SOURCES),true)
344
345SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
346SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
347
348# We need to filter out the _GNU_SOURCE variable because it breaks recent
349# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
350# need this macro at all to build the Android emulator.
351SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
352SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
353
354# Circular dependencies between libSDL and libSDLmain;
355# We repeat the libraries in the final link to work around it.
356SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
357
358else   # !BUILD_STANDALONE_EMULATOR
359
360SDL_DIR := distrib/sdl-1.2.12
361include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
362
363endif  # !BUILD_STANDALONE_EMULATOR
364
365##############################################################################
366# determine audio sources, build the prebuilt audio-library if needed
367#
368
369# determine AUDIO sources based on current configuration
370#
371AUDIO_SOURCES := audio.c noaudio.c wavaudio.c wavcapture.c mixeng.c
372AUDIO_CFLAGS  := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
373AUDIO_LDLIBS  :=
374
375ifeq ($(HOST_OS),darwin)
376  CONFIG_COREAUDIO ?= yes
377  AUDIO_CFLAGS += -DHOST_BSD=1
378endif
379
380ifeq ($(HOST_OS),windows)
381  CONFIG_WINAUDIO ?= yes
382endif
383
384ifeq ($(HOST_OS),linux)
385  CONFIG_OSS  ?= yes
386  CONFIG_ALSA ?= yes
387  CONFIG_PULSEAUDIO ?= yes
388  CONFIG_ESD  ?= yes
389endif
390
391ifeq ($(HOST_OS),freebsd)
392  CONFIG_OSS ?= yes
393endif
394
395ifeq ($(CONFIG_COREAUDIO),yes)
396  AUDIO_SOURCES += coreaudio.c
397  AUDIO_CFLAGS  += -DCONFIG_COREAUDIO
398  AUDIO_LDLIBS  += -Wl,-framework,CoreAudio
399endif
400
401ifeq ($(CONFIG_WINAUDIO),yes)
402  AUDIO_SOURCES += winaudio.c
403  AUDIO_CFLAGS  += -DCONFIG_WINAUDIO
404endif
405
406ifeq ($(CONFIG_PULSEAUDIO),yes)
407  AUDIO_SOURCES += paaudio.c audio_pt_int.c
408  AUDIO_CFLAGS  += -DCONFIG_PULSEAUDIO
409endif
410
411ifeq ($(CONFIG_ALSA),yes)
412  AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
413  AUDIO_CFLAGS  += -DCONFIG_ALSA
414endif
415
416ifeq ($(CONFIG_ESD),yes)
417  AUDIO_SOURCES += esdaudio.c
418  AUDIO_CFLAGS  += -DCONFIG_ESD
419endif
420
421ifeq ($(CONFIG_OSS),yes)
422  AUDIO_SOURCES += ossaudio.c
423  AUDIO_CFLAGS  += -DCONFIG_OSS
424endif
425
426AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
427
428# determine whether we're going to use the prebuilt
429# audio library (this is useful on Linux to avoid requiring
430# all sound-related development packages to be installed on
431# the build and developer machines).
432#
433# note that you can define BUILD_QEMU_AUDIO_LIB to true
434# in your environment to force recompilation.
435#
436QEMU_AUDIO_LIB :=
437
438ifneq ($(BUILD_STANDALONE_EMULATOR),true)
439  QEMU_AUDIO_LIB := $(wildcard \
440	prebuilt/$(QEMU_HOST_TAG)/emulator/libqemu-audio.a)
441endif
442
443ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
444  include $(CLEAR_VARS)
445  LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
446  LOCAL_CC                        := $(MY_CC)
447  LOCAL_MODULE                    := libqemu-audio
448  LOCAL_LDLIBS                    := $(MY_LDLIBS)
449
450  LOCAL_CFLAGS := -Wno-sign-compare \
451                  -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
452                  -I$(LOCAL_PATH) \
453                  -I$(LOCAL_PATH)/target-arm \
454                  -I$(LOCAL_PATH)/fpu \
455
456  # this is very important, otherwise the generated binaries may
457  # not link properly on our build servers
458  ifeq ($(HOST_OS),linux)
459    LOCAL_CFLAGS += -fno-stack-protector
460  endif
461
462  LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
463
464  LOCAL_CFLAGS += $(SDL_CFLAGS)
465
466  LOCAL_SRC_FILES += $(AUDIO_SOURCES)
467
468  include $(BUILD_HOST_STATIC_LIBRARY)
469  QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
470
471endif  # !QEMU_AUDIO_LIB
472
473##############################################################################
474# Common CFLAGS for UI and Core builds
475
476# add the build ID to the default macro definitions
477UI_AND_CORE_CFLAGS := -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
478
479# For non-standalone builds, extract the major version number from the Android SDK
480# tools revision number.
481ifneq ($(BUILD_STANDALONE_EMULATOR),true)
482    ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
483endif
484
485ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
486ifdef ANDROID_SDK_TOOLS_REVISION
487    UI_AND_CORE_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
488endif
489
490UI_AND_CORE_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
491
492
493##############################################################################
494# Build emulator core library.
495# This library contains "pure" emulation code separated from the intricacies
496# of the UI.
497#
498include $(CLEAR_VARS)
499
500LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
501LOCAL_CC                        := $(MY_CC)
502LOCAL_LDLIBS                    := $(MY_LDLIBS)
503LOCAL_MODULE                    := emulator-core
504
505# don't remove the -fno-strict-aliasing, or you'll break things
506# (e.g. slirp-android/network support)
507#
508EMULATOR_CORE_CFLAGS := -fno-PIC -Wno-sign-compare \
509                -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
510
511# Needed by the upstream code
512EMULATOR_CORE_CFLAGS += -DNEED_CPU_H
513
514# Common includes for the emulator
515EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/ \
516                        -I$(LOCAL_PATH)/target-arm \
517                        -I$(LOCAL_PATH)/fpu \
518                        $(TCG_CFLAGS) \
519                        $(HW_CFLAGS) \
520
521# Required by block.c, default value is empty in upstream
522EMULATOR_CORE_CFLAGS += -DCONFIG_BDRV_WHITELIST=""
523
524# Required
525EMULATOR_CORE_CFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
526# include slirp-android code, i.e. the user-level networking stuff
527#
528SLIRP_SOURCES := bootp.c     cksum.c      debug.c  if.c     ip_icmp.c  ip_input.c   ip_output.c  \
529                 mbuf.c      misc.c       sbuf.c   slirp.c  socket.c   tcp_input.c  tcp_output.c \
530                 tcp_subr.c  tcp_timer.c  tftp.c   udp.c
531
532LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
533EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/slirp-android
534
535# socket proxy support
536#
537PROXY_SOURCES := \
538    proxy_common.c \
539    proxy_http.c \
540    proxy_http_connector.c \
541    proxy_http_rewriter.c \
542
543LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
544EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/proxy
545
546# include telephony stuff
547#
548TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
549LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
550EMULATOR_CORE_CFLAGS += -I$(LOCAL_PATH)/telephony
551
552# include android related stuff
553#
554ANDROID_SOURCES := qemu-setup.c
555LOCAL_SRC_FILES += $(ANDROID_SOURCES:%=android/%)
556
557LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
558LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
559
560include $(BUILD_HOST_STATIC_LIBRARY)
561
562##############################################################################
563# Build emulator UI library.
564# This library contains some emulator related UI components.
565#
566include $(CLEAR_VARS)
567
568LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
569LOCAL_CC                        := $(MY_CC)
570LOCAL_LDLIBS                    := $(MY_LDLIBS)
571LOCAL_MODULE                    := emulator-uilib
572
573EMULATOR_UI_CFLAGS :=
574
575# include the SDL sources
576#
577
578# IMPORTANT: Normally, we should add SDLMAIN_SOURCES here, however this breaks
579#            the Linux mingw32 build. Apparently, the i586-mingw32-ld wants the
580#            implementation of _WinMain@16 to be in an object file on the final
581#            link command used to generate the executable, and will not search
582#            in the static libraries that are used to build it.
583#
584LOCAL_SRC_FILES += $(SDL_SOURCES) #$(SDLMAIN_SOURCES)
585EMULATOR_UI_CFLAGS += $(SDL_CFLAGS) -I$(LOCAL_PATH)/$(SDL_DIR)/include
586
587# the skin support sources
588#
589SKIN_SOURCES := rect.c \
590                region.c \
591                image.c \
592                trackball.c \
593                keyboard.c \
594                keyset.c \
595                file.c \
596                window.c \
597                scaler.c \
598                composer.c \
599                surface.c \
600
601LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
602EMULATOR_UI_CFLAGS += -I$(LOCAL_PATH)/skin
603
604LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
605
606LOCAL_MODULE_TAGS := debug
607
608include $(BUILD_HOST_STATIC_LIBRARY)
609
610##############################################################################
611# lists of source files used to build the emulator core
612#
613
614# block sources
615#
616CORE_BLOCK_SOURCES = block.c \
617                     blockdev.c \
618                     block/qcow.c \
619                     block/qcow2.c \
620                     block/qcow2-refcount.c \
621                     block/qcow2-snapshot.c \
622                     block/qcow2-cluster.c \
623                     block/cloop.c \
624                     block/dmg.c \
625                     block/vvfat.c \
626                     block/raw.c
627ifeq ($(HOST_OS),windows)
628  CORE_BLOCK_SOURCES += block/raw-win32.c
629else
630  CORE_BLOCK_SOURCES += block/raw-posix.c
631endif
632
633# hw sources
634#
635CORE_HW_SOURCES = hw/arm_boot.c \
636                  hw/android_arm.c
637
638# migration sources
639#
640CORE_MIGRATION_SOURCES = iolooper-select.c
641ifeq ($(HOST_OS),windows)
642  CORE_MIGRATION_SOURCES += migration-dummy-android.c
643else
644  CORE_MIGRATION_SOURCES += migration.c \
645                            migration-exec.c \
646                            migration-tcp-android.c
647endif
648
649# misc. sources
650#
651CORE_MISC_SOURCES = vl-android.c \
652                    async.c \
653                    console.c \
654                    qemu-malloc.c \
655                    cutils.c \
656                    osdep.c \
657                    loader.c \
658                    monitor.c \
659                    readline.c \
660                    qemu-char-android.c \
661                    outputchannel.c \
662                    qemu-error.c \
663                    qerror.c \
664                    disas.c \
665                    arm-dis.c \
666                    aes.c \
667                    d3des.c \
668                    vnc-android.c \
669                    acl.c \
670                    keymaps.c \
671                    buffered_file.c \
672                    cbuffer.c \
673                    gdbstub.c \
674                    input.c \
675                    ioport.c \
676                    notify.c \
677                    path.c \
678                    shaper.c \
679                    charpipe.c \
680                    tcpdump.c \
681                    qemu-option.c \
682                    savevm.c \
683                    net-android.c \
684                    aio-android.c \
685                    dma-helpers.c \
686                    qemu-config.c \
687                    qemu-sockets-android.c \
688                    bt-host.c \
689                    bt-vhci.c \
690                    module.c \
691                    qemu-timer.c \
692                    android/boot-properties.c \
693                    android/display.c \
694                    android/hw-kmsg.c \
695                    android/hw-lcd.c \
696                    android/gps.c \
697                    android/hw-events.c \
698                    android/hw-control.c \
699                    android/console.c \
700                    android/hw-sensors.c \
701                    android/hw-qemud.c \
702                    android/core-init-utils.c   \
703                    android/config.c \
704                    android/snapshot.c \
705                    android/utils/timezone.c \
706
707ifeq ($(HOST_ARCH),x86)
708    CORE_MISC_SOURCES += i386-dis.c
709endif
710ifeq ($(HOST_ARCH),x86_64)
711    CORE_MISC_SOURCES += i386-dis.c
712endif
713ifeq ($(HOST_ARCH),ppc)
714    CORE_MISC_SOURCES += ppc-dis.c
715endif
716
717ifeq ($(HOST_OS),linux)
718    CORE_MISC_SOURCES += usb-linux.c \
719                         qemu-thread.c
720else
721    CORE_MISC_SOURCES += usb-dummy-android.c
722endif
723
724ifeq ($(HOST_OS),windows)
725  CORE_MISC_SOURCES   += tap-win32.c
726else
727  CORE_MISC_SOURCES   += posix-aio-compat.c
728endif
729
730# sources inherited from upstream, but not fully
731# integrated into android emulator
732#
733CORE_UPSTREAM_SOURCES = json-lexer.c \
734                        json-parser.c \
735                        json-streamer.c \
736                        qjson.c \
737                        qbool.c \
738                        qdict.c \
739                        qfloat.c \
740                        qint.c \
741                        qlist.c \
742                        qstring.c \
743
744
745CORE_SOURCES = $(CORE_BLOCK_SOURCES) $(CORE_HW_SOURCES)
746CORE_SOURCES += $(CORE_MIGRATION_SOURCES) $(CORE_MISC_SOURCES)
747CORE_SOURCES += $(CORE_UPSTREAM_SOURCES)
748
749CORE_SOURCES += android/audio-test.c
750
751##############################################################################
752# lists of source files used to build the emulator UI
753#
754
755UI_SOURCES = loadpng.c \
756             android/user-config.c \
757             android/resource.c \
758             android/qemulator.c \
759             android/keycode.c \
760             android/help.c \
761             android/avd/info.c \
762
763##############################################################################
764# lists of source files used by both, emulator UI and emulator core
765#
766
767UI_AND_CORE_SOURCES = \
768                      sockets.c \
769                      android/keycode-array.c \
770                      android/charmap.c \
771                      android/async-utils.c \
772                      android/sync-utils.c \
773                      android/async-console.c \
774                      android/utils/assert.c \
775                      android/utils/bufprint.c \
776                      android/utils/debug.c \
777                      android/utils/path.c \
778                      android/utils/dirscanner.c \
779                      android/utils/filelock.c \
780                      android/utils/mapfile.c \
781                      android/utils/misc.c \
782                      android/utils/panic.c \
783                      android/utils/reflist.c \
784                      android/utils/refset.c \
785                      android/utils/stralloc.c \
786                      android/utils/system.c \
787                      android/utils/tempfile.c \
788                      android/utils/vector.c \
789                      android/avd/hw-config.c \
790                      android/utils/ini.c \
791
792# include the Zlib sources
793#
794UI_AND_CORE_SOURCES += $(ZLIB_SOURCES)
795UI_AND_CORE_CFLAGS  += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
796
797# include the Libpng sources
798#
799UI_AND_CORE_SOURCES += $(LIBPNG_SOURCES)
800UI_AND_CORE_CFLAGS  += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
801
802# temp files used to collect UI->Core exchange protocol.
803UI_AND_CORE_SOURCES += android/ui-core-protocol.c android/core-ui-protocol.c
804
805# The common libraries
806#
807QEMU_SYSTEM_LDLIBS := -lm
808ifeq ($(HOST_OS),windows)
809  QEMU_SYSTEM_LDLIBS += -mno-cygwin -mwindows -mconsole
810endif
811
812ifeq ($(HOST_OS),freebsd)
813    QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
814endif
815
816ifeq ($(HOST_OS),linux)
817  QEMU_SYSTEM_LDLIBS += -lutil -lrt
818endif
819
820ifeq ($(HOST_OS),windows)
821  QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
822else
823  QEMU_SYSTEM_LDLIBS += -lpthread
824endif
825
826ifeq ($(HOST_OS),darwin)
827  QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa
828endif
829
830
831##############################################################################
832# now build the emulator itself
833#
834include $(CLEAR_VARS)
835
836LOCAL_GENERATED_SOURCES :=
837LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
838LOCAL_CC                        := $(MY_CC)
839LOCAL_MODULE                    := emulator
840LOCAL_STATIC_LIBRARIES          := emulator-memcheck emulator-hw emulator-arm emulator-tcg
841LOCAL_STATIC_LIBRARIES          += emulator-elff
842LOCAL_STATIC_LIBRARIES          += emulator-core emulator-uilib
843LOCAL_LDLIBS                    := $(MY_LDLIBS)
844
845LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS) $(EMULATOR_UI_CFLAGS)
846
847# add the build ID to the default macro definitions
848LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS)
849
850# include sound support source files. we first try to see if we have a prebuilt audio
851# library. if not, we build things the "hard" way.
852#
853# note that to generate the prebuilt audio library, you should do the following:
854#
855#   cd tools/qemu
856#   ./android-rebuild.sh
857#   distrib/update-audio.sh
858#
859ifeq ($(QEMU_AUDIO_LIB),)
860  LOCAL_SRC_FILES += $(AUDIO_SOURCES)
861endif  # !QEMU_AUDIO_LIB
862
863LOCAL_CFLAGS  += $(AUDIO_CFLAGS)
864LOCAL_LDLIBS  += $(AUDIO_LDLIBS)
865
866# the linux-user sources, I doubt we really need these
867#
868#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
869#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
870
871ifeq ($(HOST_ARCH),x86)
872# enable MMX code for our skin scaler
873LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
874endif
875
876# include other sources
877#
878VL_SOURCES := framebuffer.c \
879              user-events-qemu.c \
880              android/cmdline-option.c \
881              android/looper-qemu.c \
882              android/main.c \
883
884# Add common system libraries
885#
886LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
887
888LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
889
890# add SDL-specific flags
891#
892LOCAL_CFLAGS += $(SDL_CFLAGS)
893LOCAL_LDLIBS += $(SDL_LDLIBS)
894LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
895
896# add ELFF-specific flags
897#
898LOCAL_LDLIBS += $(ELFF_LDLIBS)
899
900# on Windows, link the icon file as well into the executable
901# unfortunately, our build system doesn't help us much, so we need
902# to use some weird pathnames to make this work...
903#
904ifeq ($(HOST_OS),windows)
905
906# Locate windres executable
907WINDRES := windres
908ifneq ($(USE_MINGW),)
909  # When building the Windows emulator under Linux, use the MinGW one
910  WINDRES := i586-mingw32msvc-windres
911endif
912
913INTERMEDIATE     := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
914ANDROID_ICON_OBJ := android_icon.o
915ANDROID_ICON_PATH := $(LOCAL_PATH)/images
916$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
917	$(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
918
919# seems to be the only way to add an object file that was not generated from
920# a C/C++/Java source file to our build system. and very unfortunately,
921# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
922# us to put the object file in the source directory...
923#
924LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
925endif
926
927# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
928#
929intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
930
931QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
932$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
933$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
934$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
935	$(transform-generated-source)
936
937$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
938
939LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
940
941# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
942#
943intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
944
945QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
946$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
947$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
948$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
949	$(transform-generated-source)
950
951$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
952
953LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
954
955
956# gdbstub-xml.c contains C-compilable arrays corresponding to the content
957# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
958#
959ifeq ($(QEMU_TARGET_XML_SOURCES),)
960    QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
961    QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
962endif
963
964QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
965$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
966$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
967$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
968$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
969	$(hide) rm -f $@
970	$(transform-generated-source)
971
972$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
973
974LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
975
976# hw-config-defs.h is generated from android/avd/hardware-properties.ini
977#
978QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
979QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
980$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
981$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
982$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
983$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
984	$(hide) rm -f $@
985	$(transform-generated-source)
986
987$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
988
989LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
990
991# this is already done by the Android build system, but is done for the
992# benefit of the stand-alone one.
993#
994ifeq ($(BUILD_STANDALONE_EMULATOR),true)
995  LOCAL_CFLAGS += -I$(intermediates)
996endif
997
998LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
999
1000# Generate a completely static executable if needed.
1001# Note that this means no sound and graphics on Linux.
1002#
1003ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1004    LOCAL_SRC_FILES += dynlink-static.c
1005    LOCAL_LDLIBS    += -static
1006endif
1007
1008LOCAL_MODULE := emulator
1009
1010# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
1011LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
1012
1013include $(BUILD_HOST_EXECUTABLE)
1014
1015##############################################################################
1016# Build standalone emulator core.
1017#
1018include $(CLEAR_VARS)
1019
1020LOCAL_GENERATED_SOURCES         :=
1021LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
1022LOCAL_CC                        := $(MY_CC)
1023LOCAL_MODULE                    := qemu-android
1024LOCAL_STATIC_LIBRARIES          := emulator-memcheck emulator-hw emulator-arm emulator-tcg
1025LOCAL_STATIC_LIBRARIES          += emulator-elff
1026LOCAL_STATIC_LIBRARIES          += emulator-core
1027LOCAL_LDLIBS                    := $(MY_LDLIBS)
1028
1029LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_CORE_CFLAGS)
1030LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_CORE
1031
1032# include sound support source files. we first try to see if we have a prebuilt audio
1033# library. if not, we build things the "hard" way.
1034#
1035# note that to generate the prebuilt audio library, you should do the following:
1036#
1037#   cd tools/qemu
1038#   ./android-rebuild.sh
1039#   distrib/update-audio.sh
1040#
1041ifeq ($(QEMU_AUDIO_LIB),)
1042  LOCAL_SRC_FILES += $(AUDIO_SOURCES)
1043endif  # !QEMU_AUDIO_LIB
1044
1045LOCAL_CFLAGS  += $(AUDIO_CFLAGS)
1046LOCAL_LDLIBS  += $(AUDIO_LDLIBS)
1047
1048# the linux-user sources, I doubt we really need these
1049#
1050#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
1051#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
1052
1053# include other sources
1054#
1055VL_SOURCES := framebuffer.c \
1056              user-events-qemu.c \
1057              android/looper-qemu.c \
1058              android/looper-generic.c \
1059              android/display-core.c \
1060              android/framebuffer-core.c \
1061
1062# Add common system libraries
1063#
1064LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1065
1066LOCAL_SRC_FILES += $(VL_SOURCES) $(CORE_SOURCES) $(UI_AND_CORE_SOURCES)
1067
1068# add ELFF-specific flags
1069#
1070LOCAL_LDLIBS += $(ELFF_LDLIBS)
1071
1072# on Windows, link the icon file as well into the executable
1073# unfortunately, our build system doesn't help us much, so we need
1074# to use some weird pathnames to make this work...
1075#
1076ifeq ($(HOST_OS),windows)
1077
1078# Locate windres executable
1079WINDRES := windres
1080ifneq ($(USE_MINGW),)
1081  # When building the Windows emulator under Linux, use the MinGW one
1082  WINDRES := i586-mingw32msvc-windres
1083endif
1084
1085INTERMEDIATE     := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1086ANDROID_ICON_OBJ := android_icon.o
1087ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1088$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1089	$(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1090
1091# seems to be the only way to add an object file that was not generated from
1092# a C/C++/Java source file to our build system. and very unfortunately,
1093# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1094# us to put the object file in the source directory...
1095#
1096LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1097endif
1098
1099# qemu-options.h is generated from qemu-options.hx with the "hxtool" shell script
1100#
1101intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1102
1103QEMU_OPTIONS_H := $(intermediates)/qemu-options.h
1104$(QEMU_OPTIONS_H): PRIVATE_PATH := $(LOCAL_PATH)
1105$(QEMU_OPTIONS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1106$(QEMU_OPTIONS_H): $(LOCAL_PATH)/qemu-options.hx $(LOCAL_PATH)/hxtool
1107	$(transform-generated-source)
1108
1109$(intermediates)/vl-android.o: $(QEMU_OPTIONS_H)
1110
1111LOCAL_GENERATED_SOURCES += $(QEMU_OPTIONS_H)
1112
1113# qemu-monitor.h is generated from qemu-monitor.hx with the "hxtool" shell script
1114#
1115intermediates := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1116
1117QEMU_MONITOR_H := $(intermediates)/qemu-monitor.h
1118$(QEMU_MONITOR_H): PRIVATE_PATH := $(LOCAL_PATH)
1119$(QEMU_MONITOR_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/hxtool -h < $< > $@
1120$(QEMU_MONITOR_H): $(LOCAL_PATH)/qemu-monitor.hx $(LOCAL_PATH)/hxtool
1121	$(transform-generated-source)
1122
1123$(intermediates)/vl-android.o: $(QEMU_MONITOR_H)
1124
1125LOCAL_GENERATED_SOURCES += $(QEMU_MONITOR_H)
1126
1127
1128# gdbstub-xml.c contains C-compilable arrays corresponding to the content
1129# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
1130#
1131ifeq ($(QEMU_TARGET_XML_SOURCES),)
1132    QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
1133    QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
1134endif
1135
1136QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
1137$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
1138$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
1139$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
1140$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
1141	$(hide) rm -f $@
1142	$(transform-generated-source)
1143
1144$(intermediates)/vl-android.o: $(QEMU_GDBSTUB_XML_C)
1145
1146LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
1147
1148# this is already done by the Android build system, but is done for the
1149# benefit of the stand-alone one.
1150#
1151ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1152  LOCAL_CFLAGS += -I$(intermediates)
1153endif
1154
1155# other flags
1156ifneq ($(HOST_OS),windows)
1157    LOCAL_LDLIBS += -ldl
1158endif
1159
1160LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
1161
1162ifeq ($(HOST_OS),darwin)
1163    FRAMEWORKS := OpenGL Cocoa QuickTime ApplicationServices Carbon IOKit
1164    LOCAL_LDLIBS += $(FRAMEWORKS:%=-Wl,-framework,%)
1165endif
1166
1167# Generate a completely static executable if needed.
1168# Note that this means no sound and graphics on Linux.
1169#
1170ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1171    LOCAL_SRC_FILES += dynlink-static.c
1172    LOCAL_LDLIBS    += -static
1173endif
1174
1175LOCAL_MODULE := qemu-android
1176LOCAL_MODULE_TAGS := debug
1177
1178include $(BUILD_HOST_EXECUTABLE)
1179
1180##############################################################################
1181# now build the emulator UI
1182#
1183include $(CLEAR_VARS)
1184
1185LOCAL_GENERATED_SOURCES :=
1186LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
1187LOCAL_CC                        := $(MY_CC)
1188LOCAL_MODULE                    := emulator-ui
1189LOCAL_STATIC_LIBRARIES          := emulator-uilib
1190LOCAL_LDLIBS                    := $(MY_LDLIBS)
1191
1192LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(EMULATOR_UI_CFLAGS) $(EMULATOR_CORE_CFLAGS)
1193
1194# add the build ID to the default macro definitions
1195LOCAL_CFLAGS += $(UI_AND_CORE_CFLAGS) -DCONFIG_STANDALONE_UI
1196
1197ifeq ($(HOST_ARCH),x86)
1198# enable MMX code for our skin scaler
1199LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
1200endif
1201
1202# include other sources
1203#
1204VL_SOURCES := framebuffer.c \
1205              user-events-ui.c \
1206              android/cmdline-option.c \
1207              android/config.c \
1208              android/display.c \
1209              android/looper-generic.c \
1210              android/snapshot.c \
1211              android/core-connection.c \
1212              android/main-ui.c \
1213              qemu-timer-ui.c \
1214              vl-android-ui.c \
1215              console-ui.c \
1216              iolooper-select.c \
1217              android/framebuffer-ui.c \
1218
1219# Add common system libraries
1220#
1221LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)
1222
1223LOCAL_SRC_FILES += $(VL_SOURCES) $(UI_SOURCES) $(UI_AND_CORE_SOURCES)
1224
1225# add SDL-specific flags
1226#
1227LOCAL_CFLAGS += $(SDL_CFLAGS)
1228LOCAL_LDLIBS += $(SDL_LDLIBS)
1229LOCAL_STATIC_LIBRARIES += $(SDL_STATIC_LIBRARIES)
1230
1231# on Windows, link the icon file as well into the executable
1232# unfortunately, our build system doesn't help us much, so we need
1233# to use some weird pathnames to make this work...
1234#
1235ifeq ($(HOST_OS),windows)
1236
1237# Locate windres executable
1238WINDRES := windres
1239ifneq ($(USE_MINGW),)
1240  # When building the Windows emulator under Linux, use the MinGW one
1241  WINDRES := i586-mingw32msvc-windres
1242endif
1243
1244INTERMEDIATE     := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
1245ANDROID_ICON_OBJ := android_icon.o
1246ANDROID_ICON_PATH := $(LOCAL_PATH)/images
1247$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
1248	$(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
1249
1250# seems to be the only way to add an object file that was not generated from
1251# a C/C++/Java source file to our build system. and very unfortunately,
1252# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
1253# us to put the object file in the source directory...
1254#
1255LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
1256endif
1257
1258# this is already done by the Android build system, but is done for the
1259# benefit of the stand-alone one.
1260#
1261ifeq ($(BUILD_STANDALONE_EMULATOR),true)
1262  LOCAL_CFLAGS += -I$(intermediates)
1263endif
1264
1265# Generate a completely static executable if needed.
1266# Note that this means no sound and graphics on Linux.
1267#
1268ifeq ($(CONFIG_STATIC_EXECUTABLE),true)
1269    LOCAL_SRC_FILES += dynlink-static.c
1270    LOCAL_LDLIBS    += -static
1271endif
1272
1273# See comment about SDLMAIN_SOURCES in the 'emulator-uilib' module declarations.
1274LOCAL_SRC_FILES += $(SDLMAIN_SOURCES)
1275
1276include $(BUILD_HOST_EXECUTABLE)
1277
1278endif  # TARGET_ARCH == arm
1279