Makefile.common revision 74efb2c2aa3475d937f631eb8d81aa21e197c049
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.8
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/base/containers/PodVector.cpp \
122	android/base/containers/StringVector.cpp \
123	android/base/files/PathUtils.cpp \
124	android/base/Log.cpp \
125	android/base/String.cpp \
126	android/base/StringFormat.cpp \
127	android/base/StringView.cpp \
128	android/emulation/CpuAccelerator.cpp \
129	android/filesystems/ext4_utils.cpp \
130	android/kernel/kernel_utils.cpp \
131	android/utils/assert.c \
132	android/utils/bufprint.c \
133	android/utils/debug.c \
134	android/utils/dll.c \
135	android/utils/dirscanner.c \
136	android/utils/eintr_wrapper.c \
137	android/utils/filelock.c \
138	android/utils/file_data.c \
139	android/utils/host_bitness.c \
140	android/utils/ini.c \
141	android/utils/intmap.c \
142	android/utils/lineinput.c \
143	android/utils/mapfile.c \
144	android/utils/misc.c \
145	android/utils/panic.c \
146	android/utils/path.c \
147	android/utils/property_file.c \
148	android/utils/reflist.c \
149	android/utils/refset.c \
150	android/utils/stralloc.c \
151	android/utils/system.c \
152	android/utils/tempfile.c \
153	android/utils/vector.c \
154	android/utils/win32_cmdline_quote.c \
155
156common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
157
158
159## one for 32-bit
160$(call start-emulator-library, emulator-common)
161LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
162LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
163$(call gen-hw-config-defs)
164$(call end-emulator-library)
165
166$(call start-emulator64-library, emulator64-common)
167LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
168LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
169$(call gen-hw-config-defs)
170$(call end-emulator-library)
171
172##############################################################################
173##############################################################################
174###
175###  emulator-libui: LIBRARY OF UI-RELATED FUNCTIONS
176###
177###  THESE ARE USED BY 'emulator-ui' AND THE STANDALONE PROGRAMS
178###
179
180common_LOCAL_CFLAGS =
181common_LOCAL_SRC_FILES =
182common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
183
184###########################################################
185# Libpng configuration
186#
187LIBPNG_DIR := distrib/libpng-1.2.46
188include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
189
190EMULATOR_LIBUI_CFLAGS += \
191    $(LIBPNG_CFLAGS) \
192    -I$(LOCAL_PATH)/$(LIBPNG_DIR)
193
194common_LOCAL_SRC_FILES += $(LIBPNG_SOURCES) android/loadpng.c
195
196##############################################################################
197# SDL-related definitions
198#
199
200# Build SDL from sources except in certain cases where we use
201# prebuilt libraries instead.
202#
203BUILD_SDL_FROM_SOURCES := true
204
205# On linux-x86, using the prebuilts avoid installing all the X11
206# development packages on our build servers. Note: When building 64-bit
207# host binaries, don't use 32-bit SDL prebuilts.
208ifeq ($(strip $(QEMU_HOST_TAG)$(HOST_IS_64_BIT)),linux-x86)
209    BUILD_SDL_FROM_SOURCES := false
210endif
211
212# If we're building with android-configure.sh && make, always build from
213# sources to catch regressions as soon as they happen.
214#
215ifeq ($(BUILD_STANDALONE_EMULATOR),true)
216    BUILD_SDL_FROM_SOURCES := true
217endif
218
219# Except if we used android-configure.sh --sdl-config=<script>
220#
221ifneq ($(QEMU_SDL_CONFIG),)
222   BUILD_SDL_FROM_SOURCES := false
223   SDL_CONFIG := $(QEMU_SDL_CONFIG)
224endif
225
226ifneq ($(BUILD_SDL_FROM_SOURCES),true)
227
228    SDL_CONFIG ?= prebuilts/tools/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
229    SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
230
231    # We need to filter out the _GNU_SOURCE variable because it breaks recent
232    # releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
233    # need this macro at all to build the Android emulator.
234    SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
235    SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
236
237    # Circular dependencies between libSDL and libSDLmain
238    # We repeat the libraries in the final link to work around it
239    SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
240    SDL_STATIC_LIBRARIES_64 := lib64SDL lib64SDLmain lib64SDL lib64SDLmain
241
242else # BUILD_SDL_FROM_SOURCES
243
244    SDL_DIR := distrib/sdl-1.2.15
245    include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
246
247    SDL_STATIC_LIBRARIES := emulator_libSDL emulator_libSDLmain emulator_libSDL emulator_libSDLmain
248    SDL_STATIC_LIBRARIES_64 := emulator_lib64SDL emulator_lib64SDLmain emulator_lib64SDL emulator_lib64SDLmain
249
250    EMULATOR_LIBUI_CFLAGS += \
251        -I$(LOCAL_PATH)/$(SDL_DIR)/include
252
253endif # BUILD_SDL_FROM_SOURCES
254
255EMULATOR_LIBUI_CFLAGS += $(SDL_CFLAGS)
256EMULATOR_LIBUI_LDLIBS += $(SDL_LDLIBS)
257
258# The following is needed by SDL_LoadObject
259ifneq ($(HOST_OS),windows)
260    EMULATOR_LIBUI_LDLIBS += -ldl
261endif
262
263# the skin support sources
264#
265SKIN_SOURCES := rect.c \
266                region.c \
267                image.c \
268                trackball.c \
269                keyboard.c \
270                keyset.c \
271                file.c \
272                window.c \
273                scaler.c \
274                composer.c \
275                surface.c \
276
277common_LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
278
279common_LOCAL_SRC_FILES += \
280             android/user-config.c \
281             android/resource.c \
282             android/qemulator.c \
283             android/keycode.c \
284
285# enable MMX code for our skin scaler
286ifeq ($(HOST_ARCH),x86)
287common_LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
288endif
289
290common_LOCAL_CFLAGS += $(EMULATOR_LIBUI_CFLAGS)
291
292
293## one for 32-bit
294$(call start-emulator-library, emulator-libui)
295LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
296LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
297$(call gen-hw-config-defs)
298$(call end-emulator-library)
299
300
301$(call start-emulator64-library, emulator64-libui)
302LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
303LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
304$(call gen-hw-config-defs)
305$(call end-emulator-library)
306
307
308##############################################################################
309##############################################################################
310###
311###  emulator-libqemu: TARGET-INDEPENDENT QEMU FUNCTIONS
312###
313###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui'
314###
315
316common_LOCAL_CFLAGS =
317common_LOCAL_SRC_FILES =
318
319
320EMULATOR_LIBQEMU_CFLAGS :=
321
322common_LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
323
324AUDIO_SOURCES := noaudio.c wavaudio.c wavcapture.c mixeng.c
325AUDIO_CFLAGS  := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
326AUDIO_LDLIBS  :=
327
328common_LOCAL_CFLAGS += -Wall $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)
329
330ifeq ($(HOST_OS),darwin)
331  CONFIG_COREAUDIO ?= yes
332  AUDIO_CFLAGS += -DHOST_BSD=1
333endif
334
335ifeq ($(HOST_OS),windows)
336  CONFIG_WINAUDIO ?= yes
337endif
338
339ifeq ($(HOST_OS),linux)
340  CONFIG_OSS  ?= yes
341  CONFIG_ALSA ?= yes
342  CONFIG_PULSEAUDIO ?= 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_PULSEAUDIO),yes)
362  AUDIO_SOURCES += paaudio.c audio_pt_int.c
363  AUDIO_CFLAGS  += -DCONFIG_PULSEAUDIO
364endif
365
366ifeq ($(CONFIG_ALSA),yes)
367  AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
368  AUDIO_CFLAGS  += -DCONFIG_ALSA
369endif
370
371ifeq ($(CONFIG_ESD),yes)
372  AUDIO_SOURCES += esdaudio.c
373  AUDIO_CFLAGS  += -DCONFIG_ESD
374endif
375
376ifeq ($(CONFIG_OSS),yes)
377  AUDIO_SOURCES += ossaudio.c
378  AUDIO_CFLAGS  += -DCONFIG_OSS
379endif
380
381AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
382
383common_LOCAL_CFLAGS += -Wno-sign-compare \
384                -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
385
386# this is very important, otherwise the generated binaries may
387# not link properly on our build servers
388ifeq ($(HOST_OS),linux)
389common_LOCAL_CFLAGS += -fno-stack-protector
390endif
391
392common_LOCAL_SRC_FILES += $(AUDIO_SOURCES)
393common_LOCAL_SRC_FILES += \
394    android/audio-test.c
395
396# other flags
397ifneq ($(HOST_OS),windows)
398    AUDIO_LDLIBS += -ldl
399else
400endif
401
402
403EMULATOR_LIBQEMU_CFLAGS += $(AUDIO_CFLAGS)
404EMULATOR_LIBQEMU_LDLIBS += $(AUDIO_LDLIBS)
405
406common_LOCAL_CFLAGS += $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)
407
408# misc. sources
409#
410CORE_MISC_SOURCES = \
411    aio-android.c \
412    async.c \
413    iohandler.c \
414    ioport.c \
415    migration-dummy-android.c \
416    qemu-char.c \
417    qemu-log.c \
418    savevm.c \
419    android/boot-properties.c \
420    android/cbuffer.c \
421    android/charpipe.c \
422    android/config-file.c \
423    android/core-init-utils.c   \
424    android/gps.c \
425    android/hw-kmsg.c \
426    android/hw-lcd.c \
427    android/hw-events.c \
428    android/hw-control.c \
429    android/hw-sensors.c \
430    android/hw-qemud.c \
431    android/looper-qemu.c \
432    android/hw-pipe-net.c \
433    android/qemu-setup.c \
434    android/qemu-tcpdump.c \
435    android/shaper.c \
436    android/snapshot.c \
437    android/async-socket-connector.c \
438    android/async-socket.c \
439    android/sdk-controller-socket.c \
440    android/sensors-port.c \
441    android/utils/timezone.c \
442    android/camera/camera-format-converters.c \
443    android/camera/camera-service.c \
444    android/adb-server.c \
445    android/adb-qemud.c \
446    android/snaphost-android.c \
447    android/multitouch-screen.c \
448    android/multitouch-port.c \
449    android/utils/jpeg-compress.c \
450    net/net-android.c \
451    qobject/qerror.c \
452    qom/container.c \
453    qom/object.c \
454    qom/qom-qobject.c \
455    ui/console.c \
456    ui/d3des.c \
457    ui/input.c \
458    ui/vnc-android.c \
459    util/aes.c \
460    util/cutils.c \
461    util/error.c \
462    util/hexdump.c \
463    util/iov.c \
464    util/module.c \
465    util/notify.c \
466    util/osdep.c \
467    util/path.c \
468    util/qemu-config.c \
469    util/qemu-error.c \
470    util/qemu-option.c \
471    util/qemu-sockets-android.c \
472    util/unicode.c \
473    util/yield-android.c \
474
475ifeq ($(HOST_ARCH),x86)
476    CORE_MISC_SOURCES += disas/i386.c
477endif
478ifeq ($(HOST_ARCH),x86_64)
479    CORE_MISC_SOURCES += disas/i386.c
480endif
481ifeq ($(HOST_ARCH),ppc)
482    CORE_MISC_SOURCES += disas/ppc.c \
483                         util/cache-utils.c
484endif
485
486ifeq ($(HOST_OS),linux)
487    CORE_MISC_SOURCES += util/compatfd.c \
488                         util/qemu-thread-posix.c \
489                         android/camera/camera-capture-linux.c
490endif
491
492ifeq ($(HOST_OS),windows)
493  CORE_MISC_SOURCES   += tap-win32.c \
494                         android/camera/camera-capture-windows.c \
495                         util/qemu-thread-win32.c
496
497else
498  CORE_MISC_SOURCES   += posix-aio-compat.c
499endif
500
501ifeq ($(HOST_OS),darwin)
502  CORE_MISC_SOURCES   += android/camera/camera-capture-mac.m \
503                         util/compatfd.c \
504                         util/qemu-thread-posix.c
505endif
506
507common_LOCAL_SRC_FILES += $(CORE_MISC_SOURCES)
508
509# Required
510common_LOCAL_CFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1 -I$(LOCAL_PATH)/distrib/jpeg-6b
511
512SLIRP_SOURCES := \
513    bootp.c \
514    cksum.c \
515    debug.c \
516    if.c \
517    ip_icmp.c \
518    ip_input.c \
519    ip_output.c \
520    mbuf.c \
521    misc.c \
522    sbuf.c \
523    slirp.c \
524    socket.c \
525    tcp_input.c \
526    tcp_output.c \
527    tcp_subr.c \
528    tcp_timer.c \
529    tftp.c \
530    udp.c
531
532common_LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
533EMULATOR_LIBQEMU_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
543common_LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
544EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/proxy
545
546# include telephony stuff
547#
548TELEPHONY_SOURCES := \
549    android_modem.c \
550    modem_driver.c \
551    gsm.c \
552    sim_card.c \
553    sysdeps_qemu.c \
554    sms.c \
555    remote_call.c
556
557common_LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
558EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/telephony
559
560# sources inherited from upstream, but not fully
561# integrated into android emulator
562#
563common_LOCAL_SRC_FILES += \
564    qobject/json-lexer.c \
565    qobject/json-parser.c \
566    qobject/json-streamer.c \
567    qobject/qjson.c \
568    qobject/qbool.c \
569    qobject/qdict.c \
570    qobject/qfloat.c \
571    qobject/qint.c \
572    qobject/qlist.c \
573    qobject/qstring.c \
574
575ifeq ($(QEMU_TARGET_XML_SOURCES),)
576    QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
577    QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
578endif
579
580common_LOCAL_CFLAGS += $(EMULATOR_LIBQEMU_CFLAGS)
581
582
583## one for 32-bit
584$(call start-emulator-library, emulator-libqemu)
585# gdbstub-xml.c contains C-compilable arrays corresponding to the content
586# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
587#
588intermediates = $(call intermediates-dir-for,STATIC_LIBRARIES,$(LOCAL_MODULE),true)
589QEMU_GDBSTUB_XML_C = $(intermediates)/gdbstub-xml.c
590$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
591$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
592$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
593$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
594	$(hide) rm -f $@
595	$(transform-generated-source)
596LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
597LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -I$(intermediates)
598LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
599$(call gen-hw-config-defs)
600$(call end-emulator-library)
601
602
603## another for 64-bit, see note in emulator64-common
604$(call start-emulator64-library, emulator64-libqemu)
605# gdbstub-xml.c contains C-compilable arrays corresponding to the content
606# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
607#
608intermediates = $(call intermediates-dir-for,STATIC_LIBRARIES,$(LOCAL_MODULE),true)
609QEMU_GDBSTUB_XML_C = $(intermediates)/gdbstub-xml.c
610$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
611$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
612$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
613$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
614	$(hide) rm -f $@
615	$(transform-generated-source)
616LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
617LOCAL_CFLAGS += $(common_LOCAL_CFLAGS) -I$(intermediates)
618LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
619$(call gen-hw-config-defs)
620$(call end-emulator-library)
621
622
623# Block sources, we must compile them with each executable because they
624# are only referenced by the rest of the code using constructor functions.
625# If their object files are put in a static library, these are never compiled
626# into the final linked executable that uses them.
627#
628# Normally, one would solve thus using LOCAL_WHOLE_STATIC_LIBRARIES, but
629# the Darwin linker doesn't support -Wl,--whole-archive or equivalent :-(
630#
631BLOCK_SOURCES += \
632    block.c \
633    blockdev.c \
634    block/qcow2.c \
635    block/qcow2-refcount.c \
636    block/qcow2-snapshot.c \
637    block/qcow2-cluster.c \
638    block/raw.c
639
640ifeq ($(HOST_OS),windows)
641    BLOCK_SOURCES += block/raw-win32.c
642else
643    BLOCK_SOURCES += block/raw-posix.c
644endif
645
646BLOCK_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
647BLOCK_CFLAGS += -DCONFIG_BDRV_WHITELIST=\"\"
648
649##############################################################################
650##############################################################################
651###
652###  emulator-libjpeg: TARGET-INDEPENDENT QEMU FUNCTIONS
653###
654###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui'
655###
656
657common_LOCAL_CFLAGS =
658common_LOCAL_SRC_FILES =
659
660###########################################################
661# Jpeg configuration
662#
663LIBJPEG_DIR := distrib/jpeg-6b
664include $(LOCAL_PATH)/$(LIBJPEG_DIR)/sources.make
665
666common_LOCAL_SRC_FILES += $(LIBJPEG_SOURCES)
667
668common_LOCAL_CFLAGS += \
669    $(LIBJPEG_CFLAGS) \
670    -I$(LOCAL_PATH)/$(LIBJPEG_DIR)
671
672## one for 32-bit
673$(call start-emulator-library, emulator-libjpeg)
674LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
675LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
676$(call end-emulator-library)
677
678
679## another for 64-bit, see note in emulator64-common
680$(call start-emulator64-library, emulator64-libjpeg)
681LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
682LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
683$(call end-emulator-library)
684
685
686##############################################################################
687##############################################################################
688###
689###  emulator-libelff: TARGET-INDEPENDENT ELF/DWARF PARSER
690###
691###  THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui', BUT WE CANNOT PUT
692###  THEM IN emulator-libqemu SINCE THE SOURCES ARE C++
693###
694
695common_LOCAL_CFLAGS =
696common_LOCAL_SRC_FILES =
697
698ELFF_CFLAGS := -I$(LOCAL_PATH)/distrib/elff
699ELFF_LDLIBS := -lstdc++
700
701ELFF_SOURCES := \
702    dwarf_cu.cc \
703    dwarf_die.cc \
704    dwarf_utils.cc \
705    elf_alloc.cc \
706    elf_file.cc \
707    elf_mapped_section.cc \
708    elff_api.cc \
709
710common_LOCAL_SRC_FILES += $(ELFF_SOURCES:%=distrib/elff/elff/%)
711
712common_LOCAL_CFLAGS += \
713    -fno-exceptions \
714    $(ELFF_CFLAGS) \
715
716
717## one for 32-bit
718$(call start-emulator-library, emulator-libelff)
719LOCAL_CPP_EXTENSION := .cc
720LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
721LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
722$(call end-emulator-library)
723
724
725$(call start-emulator64-library, emulator64-libelff)
726LOCAL_CPP_EXTENSION := .cc
727LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
728LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
729$(call end-emulator-library)
730
731
732##############################################################################
733##############################################################################
734###
735###  gen-hx-header: Generate headers from .hx file with "hxtool" script.
736###
737###  The 'hxtool' script is used to generate header files from an input
738###  file with the .hx suffix. I.e. foo.hx --> foo.h
739###
740###  Due to the way the Android build system works, we need to regenerate
741###  it for each module (the output will go into a module-specific directory).
742###
743###  This defines a function that can be used inside a module definition
744###
745###  $(call gen-hx-header,<input>,<output>,<source-files>)
746###
747###  Where: <input> is the input file, with a .hx suffix (e.g. foo.hx)
748###         <output> is the output file, with a .h or .def suffix
749###         <source-files> is a list of source files that include the header
750###
751
752
753gen-hx-header = $(eval $(call gen-hx-header-ev,$1,$2,$3))
754
755define gen-hx-header-ev
756intermediates := $$(call intermediates-dir-for,$$(LOCAL_MODULE_CLASS),$$(LOCAL_MODULE),true)
757
758QEMU_HEADER_H := $$(intermediates)/$$2
759$$(QEMU_HEADER_H): PRIVATE_PATH := $$(LOCAL_PATH)
760$$(QEMU_HEADER_H): PRIVATE_CUSTOM_TOOL = $$(PRIVATE_PATH)/hxtool -h < $$< > $$@
761$$(QEMU_HEADER_H): $$(LOCAL_PATH)/$$1 $$(LOCAL_PATH)/hxtool
762	$$(transform-generated-source)
763
764LOCAL_GENERATED_SOURCES += $$(QEMU_HEADER_H)
765LOCAL_C_INCLUDES += $$(intermediates)
766endef
767