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