Makefile.common revision aa8236dc1b1ea300ab18716db5b8fab42aca3ca7
1# When building this project, we actually generate several components which
2# are the following:
3#
4#  - the emulator-ui program (which is target-agnostic)
5#  - the target-specific qemu-android-$ARCH programs (headless emulation engines)
6#  - the "standalone" emulator programs (embed both UI and engine in a single
7#    binary and process), i.e. "emulator" for ARM and "emulator-x86" for x86.
8#
9# This file defines static host libraries that will be used by at least two
10# of these components.
11#
12
13##############################################################################
14##############################################################################
15###
16###  gen-hw-config-defs: Generate hardware configuration definitions header
17###
18###  The 'gen-hw-config.py' script is used to generate the hw-config-defs.h
19###  header from the an .ini file like android/avd/hardware-properties.ini
20###
21###  Due to the way the Android build system works, we need to regenerate
22###  it for each module (the output will go into a module-specific directory).
23###
24###  This defines a function that can be used inside a module definition
25###
26###  $(call gen-hw-config-defs)
27###
28
29# First, define a rule to generate a dummy "emulator_hw_config_defs" module
30# which purpose is simply to host the generated header in its output directory.
31intermediates := $(call intermediates-dir-for,SHARED_LIBRARIES,emulator_hw_config_defs,true)
32
33QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
34QEMU_HW_CONFIG_DEFS_H := $(intermediates)/android/avd/hw-config-defs.h
35$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
36$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $< $@
37$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
38	$(hide) rm -f $@
39	$(transform-generated-source)
40
41QEMU_HW_CONFIG_DEFS_INCLUDES := $(intermediates)
42
43# Second, define a function that needs to be called inside each module that contains
44# a source file that includes the generated header file.
45gen-hw-config-defs = \
46  $(eval LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H))\
47  $(eval LOCAL_C_INCLUDES += $(QEMU_HW_CONFIG_DEFS_INCLUDES))
48
49##############################################################################
50##############################################################################
51###
52###  emulator-common: LIBRARY OF COMMON FUNCTIONS
53###
54###  THESE ARE POTENTIALLY USED BY ALL COMPONENTS
55###
56
57common_LOCAL_CFLAGS =
58common_LOCAL_SRC_FILES =
59
60EMULATOR_COMMON_CFLAGS :=
61
62# Needed by everything about the host
63EMULATOR_COMMON_CFLAGS += \
64    -I$(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
65
66# add the build ID to the default macro definitions
67ifeq ($(BUILD_STANDALONE_EMULATOR),)
68EMULATOR_COMMON_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
69endif
70
71# For non-standalone builds, extract the major version number from the Android SDK
72# tools revision number.
73ifneq ($(BUILD_STANDALONE_EMULATOR),true)
74    ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
75endif
76
77ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
78ifdef ANDROID_SDK_TOOLS_REVISION
79    EMULATOR_COMMON_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
80endif
81
82# Enable large-file support (i.e. make off_t a 64-bit value)
83ifeq ($(HOST_OS),linux)
84EMULATOR_COMMON_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
85endif
86
87
88###########################################################
89# Zlib sources
90#
91ZLIB_DIR := distrib/zlib-1.2.3
92include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
93EMULATOR_COMMON_CFLAGS += -I$(LOCAL_PATH)/$(ZLIB_DIR)
94
95common_LOCAL_SRC_FILES += $(ZLIB_SOURCES)
96
97###########################################################
98# GLib sources
99#
100GLIB_DIR := distrib/mini-glib
101include $(LOCAL_PATH)/$(GLIB_DIR)/sources.make
102EMULATOR_COMMON_CFLAGS += -I$(GLIB_INCLUDE_DIR)
103
104common_LOCAL_SRC_FILES += $(GLIB_SOURCES)
105
106###########################################################
107# Android utility functions
108#
109common_LOCAL_SRC_FILES += \
110	android/async-console.c \
111	android/async-utils.c \
112	android/charmap.c \
113	android/framebuffer.c \
114	android/iolooper-select.c \
115	android/keycode-array.c \
116	android/avd/hw-config.c \
117	android/avd/info.c \
118	android/avd/util.c \
119	android/sockets.c \
120	android/sync-utils.c \
121	android/utils/assert.c \
122	android/utils/bufprint.c \
123	android/utils/debug.c \
124	android/utils/dll.c \
125	android/utils/dirscanner.c \
126	android/utils/filelock.c \
127	android/utils/ini.c \
128	android/utils/intmap.c \
129	android/utils/lineinput.c \
130	android/utils/mapfile.c \
131	android/utils/misc.c \
132	android/utils/panic.c \
133	android/utils/path.c \
134	android/utils/reflist.c \
135	android/utils/refset.c \
136	android/utils/stralloc.c \
137	android/utils/system.c \
138	android/utils/tempfile.c \
139	android/utils/vector.c \
140
141common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
142
143
144## one for 32-bit
145$(call start-emulator-library, emulator-common)
146LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
147LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
148$(call gen-hw-config-defs)
149$(call end-emulator-library)
150
151## another for 64-bit
152# NOTE: only linux and darwin in non-standalone mode is supported, because
153#  1) For Windows: amd64-mingw32msvc-gcc doesn't work, see http://b/issue?id=5949152.
154#  2) Standalone has --try-64
155ifneq ($(filter linux darwin,$(HOST_OS)),)
156  ifneq ($(BUILD_STANDALONE_EMULATOR),true)
157    $(call start-emulator-library, emulator64-common)
158    LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -m64
159    LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
160    $(call gen-hw-config-defs)
161    $(call end-emulator-library)
162  endif # BUILD_STANDALONE_EMULATOR == nil
163endif # HOST_OS == linux || darwin
164
165##############################################################################
166##############################################################################
167###
168###  emulator-libui: LIBRARY OF UI-RELATED FUNCTIONS
169###
170###  THESE ARE USED BY 'emulator-ui' AND THE STANDALONE PROGRAMS
171###
172
173common_LOCAL_CFLAGS =
174common_LOCAL_SRC_FILES =
175
176ifneq ($(QEMU_OPENGLES_INCLUDE),)
177    EMULATOR_LIBUI_CFLAGS := -I$(QEMU_OPENGLES_INCLUDE)
178endif
179
180common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
181
182###########################################################
183# Libpng configuration
184#
185LIBPNG_DIR := distrib/libpng-1.2.19
186include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
187
188EMULATOR_LIBUI_CFLAGS += \
189    $(LIBPNG_CFLAGS) \
190    -I$(LOCAL_PATH)/$(LIBPNG_DIR)
191
192common_LOCAL_SRC_FILES += $(LIBPNG_SOURCES) android/loadpng.c
193
194##############################################################################
195# SDL-related definitions
196#
197
198# Build SDL from sources except in certain cases where we use
199# prebuilt libraries instead.
200#
201BUILD_SDL_FROM_SOURCES := true
202
203# On linux-x86, using the prebuilts avoid installing all the X11
204# development packages on our build servers.
205#
206ifeq ($(QEMU_HOST_TAG),linux-x86)
207    BUILD_SDL_FROM_SOURCES := false
208endif
209
210# If we're building with android-configure.sh && make, always build from
211# sources to catch regressions as soon as they happen.
212#
213ifeq ($(BUILD_STANDALONE_EMULATOR),true)
214    BUILD_SDL_FROM_SOURCES := true
215endif
216
217# Except if we used android-configure.sh --sdl-config=<script>
218#
219ifneq ($(QEMU_SDL_CONFIG),)
220   BUILD_SDL_FROM_SOURCES := false
221   SDL_CONFIG := $(QEMU_SDL_CONFIG)
222endif
223
224ifneq ($(BUILD_SDL_FROM_SOURCES),true)
225
226    SDL_CONFIG ?= prebuilts/tools/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
227    SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
228
229    # We need to filter out the _GNU_SOURCE variable because it breaks recent
230    # releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
231    # need this macro at all to build the Android emulator.
232    SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
233    SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
234
235    # Circular dependencies between libSDL and libSDLmain
236    # We repeat the libraries in the final link to work around it
237    SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
238    SDL_STATIC_LIBRARIES_64 := lib64SDL lib64SDLmain lib64SDL lib64SDLmain
239
240else # BUILD_SDL_FROM_SOURCES
241
242    SDL_DIR := distrib/sdl-1.2.15
243    include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
244    common_LOCAL_SRC_FILES += $(SDL_SOURCES)
245
246    EMULATOR_LIBUI_CFLAGS += \
247        -I$(LOCAL_PATH)/$(SDL_DIR)/include
248
249    SDL_STATIC_LIBRARIES :=
250
251endif # BUILD_SDL_FROM_SOURCES
252
253EMULATOR_LIBUI_CFLAGS += $(SDL_CFLAGS)
254EMULATOR_LIBUI_LDLIBS += $(SDL_LDLIBS)
255
256# The following is needed by SDL_LoadObject
257ifneq ($(HOST_OS),windows)
258    EMULATOR_LIBUI_LDLIBS += -ldl
259endif
260
261# the skin support sources
262#
263SKIN_SOURCES := rect.c \
264                region.c \
265                image.c \
266                trackball.c \
267                keyboard.c \
268                keyset.c \
269                file.c \
270                window.c \
271                scaler.c \
272                composer.c \
273                surface.c \
274
275common_LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
276
277common_LOCAL_SRC_FILES += \
278             android/user-config.c \
279             android/resource.c \
280             android/qemulator.c \
281             android/keycode.c \
282
283# enable MMX code for our skin scaler
284ifeq ($(HOST_ARCH),x86)
285common_LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
286endif
287
288common_LOCAL_CFLAGS += $(EMULATOR_LIBUI_CFLAGS)
289
290
291## one for 32-bit
292$(call start-emulator-library, emulator-libui)
293LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
294LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
295$(call gen-hw-config-defs)
296$(call end-emulator-library)
297
298
299## another for 64-bit, see note in emulator64-common
300ifneq ($(filter linux darwin,$(HOST_OS)),)
301  ifneq ($(BUILD_STANDALONE_EMULATOR),true)
302    $(call start-emulator-library, emulator64-libui)
303    LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -m64
304    LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
305    $(call gen-hw-config-defs)
306    $(call end-emulator-library)
307  endif # BUILD_STANDALONE_EMULATOR == nil
308endif # HOST_OS == linux || darwin
309
310
311##############################################################################
312##############################################################################
313###
314###  emulator-libqemu: TARGET-INDEPENDENT QEMU FUNCTIONS
315###
316###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui'
317###
318
319common_LOCAL_CFLAGS =
320common_LOCAL_SRC_FILES =
321
322
323EMULATOR_LIBQEMU_CFLAGS :=
324
325common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
326
327AUDIO_SOURCES := noaudio.c wavaudio.c wavcapture.c mixeng.c
328AUDIO_CFLAGS  := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
329AUDIO_LDLIBS  :=
330
331common_LOCAL_CFLAGS += -Wall $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)
332
333ifeq ($(HOST_OS),darwin)
334  CONFIG_COREAUDIO ?= yes
335  AUDIO_CFLAGS += -DHOST_BSD=1
336endif
337
338ifeq ($(HOST_OS),windows)
339  CONFIG_WINAUDIO ?= yes
340endif
341
342ifeq ($(HOST_OS),linux)
343  CONFIG_OSS  ?= yes
344  CONFIG_ALSA ?= yes
345  CONFIG_PULSEAUDIO ?= yes
346  CONFIG_ESD  ?= yes
347endif
348
349ifeq ($(HOST_OS),freebsd)
350  CONFIG_OSS ?= yes
351endif
352
353ifeq ($(CONFIG_COREAUDIO),yes)
354  AUDIO_SOURCES += coreaudio.c
355  AUDIO_CFLAGS  += -DCONFIG_COREAUDIO
356  AUDIO_LDLIBS  += -Wl,-framework,CoreAudio
357endif
358
359ifeq ($(CONFIG_WINAUDIO),yes)
360  AUDIO_SOURCES += winaudio.c
361  AUDIO_CFLAGS  += -DCONFIG_WINAUDIO
362endif
363
364ifeq ($(CONFIG_PULSEAUDIO),yes)
365  AUDIO_SOURCES += paaudio.c audio_pt_int.c
366  AUDIO_CFLAGS  += -DCONFIG_PULSEAUDIO
367endif
368
369ifeq ($(CONFIG_ALSA),yes)
370  AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
371  AUDIO_CFLAGS  += -DCONFIG_ALSA
372endif
373
374ifeq ($(CONFIG_ESD),yes)
375  AUDIO_SOURCES += esdaudio.c
376  AUDIO_CFLAGS  += -DCONFIG_ESD
377endif
378
379ifeq ($(CONFIG_OSS),yes)
380  AUDIO_SOURCES += ossaudio.c
381  AUDIO_CFLAGS  += -DCONFIG_OSS
382endif
383
384AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
385
386common_LOCAL_CFLAGS += -Wno-sign-compare \
387                -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
388
389# this is very important, otherwise the generated binaries may
390# not link properly on our build servers
391ifeq ($(HOST_OS),linux)
392common_LOCAL_CFLAGS += -fno-stack-protector
393endif
394
395common_LOCAL_SRC_FILES += $(AUDIO_SOURCES)
396common_LOCAL_SRC_FILES += \
397    android/audio-test.c
398
399# other flags
400ifneq ($(HOST_OS),windows)
401    AUDIO_LDLIBS += -ldl
402else
403endif
404
405
406EMULATOR_LIBQEMU_CFLAGS += $(AUDIO_CFLAGS)
407EMULATOR_LIBQEMU_LDLIBS += $(AUDIO_LDLIBS)
408
409common_LOCAL_CFLAGS += $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)
410
411# migration sources
412#
413ifeq ($(HOST_OS),windows)
414  common_LOCAL_SRC_FILES += migration-dummy-android.c
415else
416  common_LOCAL_SRC_FILES += migration.c \
417                     migration-exec.c \
418                     migration-tcp-android.c
419endif
420
421# misc. sources
422#
423CORE_MISC_SOURCES = \
424    aio-android.c \
425    async.c \
426    bt-host.c \
427    bt-vhci.c \
428    buffered_file.c \
429    iohandler.c \
430    ioport.c \
431    qemu-char.c \
432    readline.c \
433    savevm.c \
434    android/boot-properties.c \
435    android/cbuffer.c \
436    android/charpipe.c \
437    android/config.c \
438    android/core-init-utils.c   \
439    android/gps.c \
440    android/hw-kmsg.c \
441    android/hw-lcd.c \
442    android/hw-events.c \
443    android/hw-control.c \
444    android/hw-sensors.c \
445    android/hw-qemud.c \
446    android/looper-qemu.c \
447    android/hw-pipe-net.c \
448    android/qemu-setup.c \
449    android/qemu-tcpdump.c \
450    android/shaper.c \
451    android/snapshot.c \
452    android/async-socket-connector.c \
453    android/async-socket.c \
454    android/sdk-controller-socket.c \
455    android/sensors-port.c \
456    android/utils/timezone.c \
457    android/camera/camera-format-converters.c \
458    android/camera/camera-service.c \
459    android/adb-server.c \
460    android/adb-qemud.c \
461    android/snaphost-android.c \
462    android/multitouch-screen.c \
463    android/multitouch-port.c \
464    android/utils/jpeg-compress.c \
465    net/net-android.c \
466    qobject/qerror.c \
467    ui/console.c \
468    ui/d3des.c \
469    ui/input.c \
470    ui/vnc-android.c \
471    util/acl.c \
472    util/aes.c \
473    util/cutils.c \
474    util/module.c \
475    util/notify.c \
476    util/osdep.c \
477    util/path.c \
478    util/qemu-config.c \
479    util/qemu-error.c \
480    util/qemu-option.c \
481    util/qemu-sockets-android.c \
482
483ifeq ($(HOST_ARCH),x86)
484    CORE_MISC_SOURCES += disas/i386.c
485endif
486ifeq ($(HOST_ARCH),x86_64)
487    CORE_MISC_SOURCES += disas/i386.c
488endif
489ifeq ($(HOST_ARCH),ppc)
490    CORE_MISC_SOURCES += disas/ppc.c \
491                         util/cache-utils.c
492endif
493
494ifeq ($(HOST_OS),linux)
495    CORE_MISC_SOURCES += hw/usb/usb-linux.c \
496                         util/qemu-thread.c \
497                         android/camera/camera-capture-linux.c
498else
499    CORE_MISC_SOURCES += hw/usb/usb-dummy-android.c
500endif
501
502ifeq ($(HOST_OS),windows)
503  CORE_MISC_SOURCES   += tap-win32.c \
504                         android/camera/camera-capture-windows.c
505
506else
507  CORE_MISC_SOURCES   += posix-aio-compat.c
508endif
509
510ifeq ($(HOST_OS),darwin)
511  CORE_MISC_SOURCES   += android/camera/camera-capture-mac.m
512endif
513
514common_LOCAL_SRC_FILES += $(CORE_MISC_SOURCES)
515
516# Required
517common_LOCAL_CFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1 -I$(LOCAL_PATH)/distrib/jpeg-6b
518
519SLIRP_SOURCES := \
520    bootp.c \
521    cksum.c \
522    debug.c \
523    if.c \
524    ip_icmp.c \
525    ip_input.c \
526    ip_output.c \
527    mbuf.c \
528    misc.c \
529    sbuf.c \
530    slirp.c \
531    socket.c \
532    tcp_input.c \
533    tcp_output.c \
534    tcp_subr.c \
535    tcp_timer.c \
536    tftp.c \
537    udp.c
538
539common_LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
540EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/slirp-android
541
542# socket proxy support
543#
544PROXY_SOURCES := \
545    proxy_common.c \
546    proxy_http.c \
547    proxy_http_connector.c \
548    proxy_http_rewriter.c \
549
550common_LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
551EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/proxy
552
553# include telephony stuff
554#
555TELEPHONY_SOURCES := \
556    android_modem.c \
557    modem_driver.c \
558    gsm.c \
559    sim_card.c \
560    sysdeps_qemu.c \
561    sms.c \
562    remote_call.c
563
564common_LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
565EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/telephony
566
567# sources inherited from upstream, but not fully
568# integrated into android emulator
569#
570common_LOCAL_SRC_FILES += \
571    qobject/json-lexer.c \
572    qobject/json-parser.c \
573    qobject/json-streamer.c \
574    qobject/qjson.c \
575    qobject/qbool.c \
576    qobject/qdict.c \
577    qobject/qfloat.c \
578    qobject/qint.c \
579    qobject/qlist.c \
580    qobject/qstring.c \
581
582ifeq ($(QEMU_TARGET_XML_SOURCES),)
583    QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
584    QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
585endif
586
587common_LOCAL_CFLAGS += $(EMULATOR_LIBQEMU_CFLAGS)
588
589
590## one for 32-bit
591$(call start-emulator-library, emulator-libqemu)
592# gdbstub-xml.c contains C-compilable arrays corresponding to the content
593# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
594#
595intermediates = $(call intermediates-dir-for,STATIC_LIBRARIES,$(LOCAL_MODULE),true)
596QEMU_GDBSTUB_XML_C = $(intermediates)/gdbstub-xml.c
597$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
598$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
599$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
600$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
601	$(hide) rm -f $@
602	$(transform-generated-source)
603LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
604LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -I$(intermediates)
605LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
606$(call gen-hw-config-defs)
607$(call end-emulator-library)
608
609
610## another for 64-bit, see note in emulator64-common
611ifneq ($(filter linux darwin,$(HOST_OS)),)
612  ifneq ($(BUILD_STANDALONE_EMULATOR),true)
613    $(call start-emulator-library, emulator64-libqemu)
614    # gdbstub-xml.c contains C-compilable arrays corresponding to the content
615    # of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
616    #
617    intermediates = $(call intermediates-dir-for,STATIC_LIBRARIES,$(LOCAL_MODULE),true)
618    QEMU_GDBSTUB_XML_C = $(intermediates)/gdbstub-xml.c
619    $(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
620    $(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
621    $(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
622    $(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
623	$(hide) rm -f $@
624	$(transform-generated-source)
625    LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
626    LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -I$(intermediates) -m64
627    LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
628    $(call gen-hw-config-defs)
629    $(call end-emulator-library)
630  endif # BUILD_STANDALONE_EMULATOR == nil
631endif # HOST_OS == linux || darwin
632
633
634# Block sources, we must compile them with each executable because they
635# are only referenced by the rest of the code using constructor functions.
636# If their object files are put in a static library, these are never compiled
637# into the final linked executable that uses them.
638#
639# Normally, one would solve thus using LOCAL_WHOLE_STATIC_LIBRARIES, but
640# the Darwin linker doesn't support -Wl,--whole-archive or equivalent :-(
641#
642BLOCK_SOURCES += \
643    block.c \
644    blockdev.c \
645    block/qcow.c \
646    block/qcow2.c \
647    block/qcow2-refcount.c \
648    block/qcow2-snapshot.c \
649    block/qcow2-cluster.c \
650    block/cloop.c \
651    block/dmg.c \
652    block/vvfat.c \
653    block/raw.c
654
655ifeq ($(HOST_OS),windows)
656    BLOCK_SOURCES += block/raw-win32.c
657else
658    BLOCK_SOURCES += block/raw-posix.c
659endif
660
661BLOCK_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
662BLOCK_CFLAGS += -DCONFIG_BDRV_WHITELIST=""
663
664##############################################################################
665##############################################################################
666###
667###  emulator-libjpeg: TARGET-INDEPENDENT QEMU FUNCTIONS
668###
669###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui'
670###
671
672common_LOCAL_CFLAGS =
673common_LOCAL_SRC_FILES =
674
675###########################################################
676# Jpeg configuration
677#
678LIBJPEG_DIR := distrib/jpeg-6b
679include $(LOCAL_PATH)/$(LIBJPEG_DIR)/sources.make
680
681common_LOCAL_SRC_FILES += $(LIBJPEG_SOURCES)
682
683common_LOCAL_CFLAGS += \
684    $(LIBJPEG_CFLAGS) \
685    -I$(LOCAL_PATH)/$(LIBJPEG_DIR)
686
687## one for 32-bit
688$(call start-emulator-library, emulator-libjpeg)
689LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
690LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
691$(call end-emulator-library)
692
693
694## another for 64-bit, see note in emulator64-common
695ifneq ($(filter linux darwin,$(HOST_OS)),)
696  ifneq ($(BUILD_STANDALONE_EMULATOR),true)
697    $(call start-emulator-library, emulator64-libjpeg)
698    LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -m64
699    LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
700    $(call end-emulator-library)
701  endif # BUILD_STANDALONE_EMULATOR == nil
702endif # HOST_OS == linux
703
704
705##############################################################################
706##############################################################################
707###
708###  emulator-libelff: TARGET-INDEPENDENT ELF/DWARD PARSER
709###
710###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui', BUT WE CANNOT PUT
711###  THEM IN emulator-libqemu SINCE THE SOURCES ARE C++
712###
713
714common_LOCAL_CFLAGS =
715common_LOCAL_SRC_FILES =
716
717ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
718ELFF_LDLIBS := -lstdc++
719
720ELFF_SOURCES := \
721    dwarf_cu.cc \
722    dwarf_die.cc \
723    dwarf_utils.cc \
724    elf_alloc.cc \
725    elf_file.cc \
726    elf_mapped_section.cc \
727    elff_api.cc \
728
729common_LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
730
731common_LOCAL_CFLAGS += \
732    -fno-exceptions \
733    $(ELFF_CFLAGS) \
734
735
736## one for 32-bit
737$(call start-emulator-library, emulator-libelff)
738LOCAL_CPP_EXTENSION := .cc
739LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
740LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
741$(call end-emulator-library)
742
743
744## another for 64-bit, see note in emulator64-common
745ifneq ($(filter linux darwin,$(HOST_OS)),)
746  ifneq ($(BUILD_STANDALONE_EMULATOR),true)
747    $(call start-emulator-library, emulator64-libelff)
748    LOCAL_CPP_EXTENSION := .cc
749    LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -m64
750    LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
751    $(call end-emulator-library)
752  endif # BUILD_STANDALONE_EMULATOR == nil
753endif # HOST_OS == linux || darwin
754
755
756##############################################################################
757##############################################################################
758###
759###  gen-hx-header: Generate headers from .hx file with "hxtool" script.
760###
761###  The 'hxtool' script is used to generate header files from an input
762###  file with the .hx suffix. I.e. foo.hx --> foo.h
763###
764###  Due to the way the Android build system works, we need to regenerate
765###  it for each module (the output will go into a module-specific directory).
766###
767###  This defines a function that can be used inside a module definition
768###
769###  $(call gen-hx-header,<input>,<output>,<source-files>)
770###
771###  Where: <input> is the input file, with a .hx suffix (e.g. foo.hx)
772###         <output> is the output file, with a .h or .def suffix
773###         <source-files> is a list of source files that include the header
774###
775
776
777gen-hx-header = $(eval $(call gen-hx-header-ev,$1,$2,$3))
778
779define gen-hx-header-ev
780intermediates := $$(call intermediates-dir-for,$$(LOCAL_MODULE_CLASS),$$(LOCAL_MODULE),true)
781
782QEMU_HEADER_H := $$(intermediates)/$$2
783$$(QEMU_HEADER_H): PRIVATE_PATH := $$(LOCAL_PATH)
784$$(QEMU_HEADER_H): PRIVATE_CUSTOM_TOOL = $$(PRIVATE_PATH)/hxtool -h < $$< > $$@
785$$(QEMU_HEADER_H): $$(LOCAL_PATH)/$$1 $$(LOCAL_PATH)/hxtool
786	$$(transform-generated-source)
787
788LOCAL_GENERATED_SOURCES += $$(QEMU_HEADER_H)
789LOCAL_C_INCLUDES += $$(intermediates)
790endef
791
792