blob: 15d680129745b3ec1ca8d3c2330c72925654a3a5 [file] [log] [blame]
David 'Digit' Turneraff94b82011-02-07 18:10:54 +01001# 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### emulator-common: LIBRARY OF COMMON FUNCTIONS
17###
18### THESE ARE POTENTIALLY USED BY ALL COMPONENTS
19###
20
21$(call start-emulator-library, emulator-common)
22
23EMULATOR_COMMON_CFLAGS :=
24
25# Needed by everything about the host
26EMULATOR_COMMON_CFLAGS += \
27 -I$(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
28
29# add the build ID to the default macro definitions
30ifeq ($(BUILD_STANDALONE_EMULATOR),)
31EMULATOR_COMMON_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
32endif
33
34# For non-standalone builds, extract the major version number from the Android SDK
35# tools revision number.
36ifneq ($(BUILD_STANDALONE_EMULATOR),true)
37 ANDROID_SDK_TOOLS_REVISION := $(shell awk -F= '/Pkg.Revision/ { print $$2; }' sdk/files/tools_source.properties)
38endif
39
40ANDROID_SDK_TOOLS_REVISION := $(strip $(ANDROID_SDK_TOOLS_REVISION))
41ifdef ANDROID_SDK_TOOLS_REVISION
42 EMULATOR_COMMON_CFLAGS += -DANDROID_SDK_TOOLS_REVISION=$(ANDROID_SDK_TOOLS_REVISION)
43endif
44
45# Enable large-file support (i.e. make off_t a 64-bit value)
46ifeq ($(HOST_OS),linux)
47EMULATOR_COMMON_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
48endif
49
50###########################################################
51# Zlib sources
52#
53ZLIB_DIR := distrib/zlib-1.2.3
54include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
55EMULATOR_COMMON_CFLAGS += -I$(LOCAL_PATH)/$(ZLIB_DIR)
56
57LOCAL_SRC_FILES += $(ZLIB_SOURCES)
58
59###########################################################
60# Android utility functions
61#
62LOCAL_SRC_FILES += \
63 sockets.c \
64 iolooper-select.c \
65 android/async-console.c \
66 android/async-utils.c \
67 android/charmap.c \
68 android/framebuffer.c \
69 android/keycode-array.c \
70 android/avd/hw-config.c \
71 android/avd/info.c \
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +010072 android/avd/util.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010073 android/sync-utils.c \
74 android/utils/assert.c \
75 android/utils/bufprint.c \
76 android/utils/debug.c \
77 android/utils/dirscanner.c \
78 android/utils/filelock.c \
79 android/utils/ini.c \
David 'Digit' Turnerbbb81042011-03-17 14:48:44 +010080 android/utils/intmap.c \
David 'Digit' Turner0a879bf2011-05-12 18:45:18 +020081 android/utils/lineinput.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +010082 android/utils/mapfile.c \
83 android/utils/misc.c \
84 android/utils/panic.c \
85 android/utils/path.c \
86 android/utils/reflist.c \
87 android/utils/refset.c \
88 android/utils/stralloc.c \
89 android/utils/system.c \
90 android/utils/tempfile.c \
91 android/utils/vector.c \
92
93LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
94
95$(call end-emulator-library)
96
97##############################################################################
98##############################################################################
99###
100### emulator-libui: LIBRARY OF UI-RELATED FUNCTIONS
101###
102### THESE ARE USED BY 'emulator-ui' AND THE STANDALONE PROGRAMS
103###
104
105$(call start-emulator-library, emulator-libui)
106
107EMULATOR_LIBUI_CFLAGS :=
108
109LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
110
111###########################################################
112# Libpng configuration
113#
114LIBPNG_DIR := distrib/libpng-1.2.19
115include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
116
117EMULATOR_LIBUI_CFLAGS += \
118 $(LIBPNG_CFLAGS) \
119 -I$(LOCAL_PATH)/$(LIBPNG_DIR)
120
121LOCAL_SRC_FILES += $(LIBPNG_SOURCES) loadpng.c
122
123##############################################################################
124# SDL-related definitions
125#
126
127# Build SDL from sources except in certain cases where we use
128# prebuilt libraries instead.
129#
130BUILD_SDL_FROM_SOURCES := true
131
132# On linux-x86, using the prebuilts avoid installing all the X11
133# development packages on our build servers.
134#
135ifeq ($(QEMU_HOST_TAG),linux-x86)
136 BUILD_SDL_FROM_SOURCES := false
137endif
138
139# On darwin-x86, a bug in the Android build system prevents the compilation
140# of Objective-C sources. Fixed recently in AOSP, but we still use the
141# prebuilts for the benefit of older platform branches.
142#
143ifeq ($(QEMU_HOST_TAG),darwin-x86)
144 BUILD_SDL_FROM_SOURCES := false
145endif
146
147# If we're building with android-configure.sh && make, always build from
148# sources to catch regressions as soon as they happen.
149#
150ifeq ($(BUILD_STANDALONE_EMULATOR),true)
151 BUILD_SDL_FROM_SOURCES := true
152endif
153
154# Except if we used android-configure.sh --sdl-config=<script>
155#
156ifneq ($(SDL_CONFIG),)
157 BUILD_SDL_FROM_SOURCES := false
158endif
159
160ifneq ($(BUILD_SDL_FROM_SOURCES),true)
161
162 SDL_CONFIG ?= prebuilt/$(QEMU_HOST_TAG)/sdl/bin/sdl-config
163 SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
164
165 # We need to filter out the _GNU_SOURCE variable because it breaks recent
166 # releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
167 # need this macro at all to build the Android emulator.
168 SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
169 SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
170
171 # Circular dependencies between libSDL and libSDLmain
172 # We repeat the libraries in the final link to work around it
173 SDL_STATIC_LIBRARIES := libSDL libSDLmain libSDL libSDLmain
174
175else # BUILD_SDL_FROM_SOURCES
176
177 SDL_DIR := distrib/sdl-1.2.12
178 include $(LOCAL_PATH)/$(SDL_DIR)/sources.make
179 LOCAL_SRC_FILES += $(SDL_SOURCES)
180
181 EMULATOR_LIBUI_CFLAGS += \
182 -I$(LOCAL_PATH)/$(SDL_DIR)/include
183
184 SDL_STATIC_LIBRARIES :=
185
186endif # BUILD_SDL_FROM_SOURCES
187
188EMULATOR_LIBUI_CFLAGS += $(SDL_CFLAGS)
189EMULATOR_LIBUI_LDLIBS += $(SDL_LDLIBS)
190
191# The following is needed by SDL_LoadObject
192ifneq ($(HOST_OS),windows)
193 EMULATOR_LIBUI_LDLIBS += -ldl
194endif
195
196# the skin support sources
197#
198SKIN_SOURCES := rect.c \
199 region.c \
200 image.c \
201 trackball.c \
202 keyboard.c \
203 keyset.c \
204 file.c \
205 window.c \
206 scaler.c \
207 composer.c \
208 surface.c \
209
210LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
211
212LOCAL_SRC_FILES += \
213 android/user-config.c \
214 android/resource.c \
215 android/qemulator.c \
216 android/keycode.c \
217
218# enable MMX code for our skin scaler
219ifeq ($(HOST_ARCH),x86)
220LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
221endif
222
223LOCAL_CFLAGS += $(EMULATOR_LIBUI_CFLAGS)
224
225$(call end-emulator-library)
226
227##############################################################################
228##############################################################################
229###
230### emulator-libqemu: TARGET-INDEPENDENT QEMU FUNCTIONS
231###
232### THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui'
233###
234
235$(call start-emulator-library, emulator-libqemu)
236
237EMULATOR_LIBQEMU_CFLAGS :=
238
239LOCAL_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
240
241AUDIO_SOURCES := noaudio.c wavaudio.c wavcapture.c mixeng.c
242AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
243AUDIO_LDLIBS :=
244
245LOCAL_CFLAGS += -Wall -Wno-missing-field-initializers
246
247ifeq ($(HOST_OS),darwin)
248 CONFIG_COREAUDIO ?= yes
249 AUDIO_CFLAGS += -DHOST_BSD=1
250endif
251
252ifeq ($(HOST_OS),windows)
253 CONFIG_WINAUDIO ?= yes
254endif
255
256ifeq ($(HOST_OS),linux)
257 CONFIG_OSS ?= yes
258 CONFIG_ALSA ?= yes
259 CONFIG_PULSEAUDIO ?= yes
260 CONFIG_ESD ?= yes
261endif
262
263ifeq ($(HOST_OS),freebsd)
264 CONFIG_OSS ?= yes
265endif
266
267ifeq ($(CONFIG_COREAUDIO),yes)
268 AUDIO_SOURCES += coreaudio.c
269 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
270 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
271endif
272
273ifeq ($(CONFIG_WINAUDIO),yes)
274 AUDIO_SOURCES += winaudio.c
275 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
276endif
277
278ifeq ($(CONFIG_PULSEAUDIO),yes)
279 AUDIO_SOURCES += paaudio.c audio_pt_int.c
280 AUDIO_CFLAGS += -DCONFIG_PULSEAUDIO
281endif
282
283ifeq ($(CONFIG_ALSA),yes)
284 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
285 AUDIO_CFLAGS += -DCONFIG_ALSA
286endif
287
288ifeq ($(CONFIG_ESD),yes)
289 AUDIO_SOURCES += esdaudio.c
290 AUDIO_CFLAGS += -DCONFIG_ESD
291endif
292
293ifeq ($(CONFIG_OSS),yes)
294 AUDIO_SOURCES += ossaudio.c
295 AUDIO_CFLAGS += -DCONFIG_OSS
296endif
297
298AUDIO_SOURCES := $(call sort,$(AUDIO_SOURCES:%=audio/%))
299
300LOCAL_CFLAGS += -Wno-sign-compare \
301 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
302
303# this is very important, otherwise the generated binaries may
304# not link properly on our build servers
305ifeq ($(HOST_OS),linux)
306LOCAL_CFLAGS += -fno-stack-protector
307endif
308
309LOCAL_SRC_FILES += $(AUDIO_SOURCES)
310LOCAL_SRC_FILES += \
311 android/audio-test.c
312
313# other flags
314ifneq ($(HOST_OS),windows)
315 AUDIO_LDLIBS += -ldl
316else
317endif
318
319
320EMULATOR_LIBQEMU_CFLAGS += $(AUDIO_CFLAGS)
321EMULATOR_LIBQEMU_LDLIBS += $(AUDIO_LDLIBS)
322
323LOCAL_CFLAGS += -Wno-missing-field-initializers
324
325# migration sources
326#
327ifeq ($(HOST_OS),windows)
328 LOCAL_SRC_FILES += migration-dummy-android.c
329else
330 LOCAL_SRC_FILES += migration.c \
331 migration-exec.c \
332 migration-tcp-android.c
333endif
334
335# misc. sources
336#
337CORE_MISC_SOURCES = \
338 acl.c \
339 aes.c \
340 aio-android.c \
341 async.c \
342 bt-host.c \
343 bt-vhci.c \
344 buffered_file.c \
345 cbuffer.c \
346 charpipe.c \
347 console.c \
348 cutils.c \
349 d3des.c \
350 input.c \
351 ioport.c \
352 module.c \
353 net-android.c \
354 notify.c \
355 osdep.c \
356 outputchannel.c \
357 path.c \
358 qemu-char-android.c \
359 qemu-config.c \
360 qemu-error.c \
361 qemu-malloc.c \
362 qemu-option.c \
363 qemu-sockets-android.c \
364 qerror.c \
365 readline.c \
366 savevm.c \
367 shaper.c \
368 tcpdump.c \
369 vnc-android.c \
370 android/boot-properties.c \
371 android/config.c \
372 android/core-init-utils.c \
373 android/gps.c \
374 android/hw-kmsg.c \
375 android/hw-lcd.c \
376 android/hw-events.c \
377 android/hw-control.c \
378 android/hw-sensors.c \
379 android/hw-qemud.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100380 android/looper-qemu.c \
David 'Digit' Turnerc0ac7332011-05-02 15:05:35 +0200381 android/hw-pipe-net.c \
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100382 android/qemu-setup.c \
383 android/snapshot.c \
384 android/utils/timezone.c \
385
386ifeq ($(HOST_ARCH),x86)
387 CORE_MISC_SOURCES += i386-dis.c
388endif
389ifeq ($(HOST_ARCH),x86_64)
390 CORE_MISC_SOURCES += i386-dis.c
391endif
392ifeq ($(HOST_ARCH),ppc)
393 CORE_MISC_SOURCES += ppc-dis.c \
394 cache-utils.c
395endif
396
397ifeq ($(HOST_OS),linux)
398 CORE_MISC_SOURCES += usb-linux.c \
399 qemu-thread.c
400else
401 CORE_MISC_SOURCES += usb-dummy-android.c
402endif
403
404ifeq ($(HOST_OS),windows)
405 CORE_MISC_SOURCES += tap-win32.c
406else
407 CORE_MISC_SOURCES += posix-aio-compat.c
408endif
409
410LOCAL_SRC_FILES += $(CORE_MISC_SOURCES)
411
412# Required
413LOCAL_CFLAGS += -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
414
415SLIRP_SOURCES := \
416 bootp.c \
417 cksum.c \
418 debug.c \
419 if.c \
420 ip_icmp.c \
421 ip_input.c \
422 ip_output.c \
423 mbuf.c \
424 misc.c \
425 sbuf.c \
426 slirp.c \
427 socket.c \
428 tcp_input.c \
429 tcp_output.c \
430 tcp_subr.c \
431 tcp_timer.c \
432 tftp.c \
433 udp.c
434
435LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp-android/%)
436EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/slirp-android
437
438# socket proxy support
439#
440PROXY_SOURCES := \
441 proxy_common.c \
442 proxy_http.c \
443 proxy_http_connector.c \
444 proxy_http_rewriter.c \
445
446LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
447EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/proxy
448
449# include telephony stuff
450#
451TELEPHONY_SOURCES := \
452 android_modem.c \
453 modem_driver.c \
454 gsm.c \
455 sim_card.c \
456 sysdeps_qemu.c \
457 sms.c \
458 remote_call.c
459
460LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
461EMULATOR_LIBQEMU_CFLAGS += -I$(LOCAL_PATH)/telephony
462
463# sources inherited from upstream, but not fully
464# integrated into android emulator
465#
466LOCAL_SRC_FILES += \
467 json-lexer.c \
468 json-parser.c \
469 json-streamer.c \
470 qjson.c \
471 qbool.c \
472 qdict.c \
473 qfloat.c \
474 qint.c \
475 qlist.c \
476 qstring.c \
477
478# hw-config-defs.h is generated from android/avd/hardware-properties.ini
479#
480QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
481QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
482$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
483$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
484$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
485$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
486 $(hide) rm -f $@
487 $(transform-generated-source)
488
489$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
490
491# gdbstub-xml.c contains C-compilable arrays corresponding to the content
492# of $(LOCAL_PATH)/gdb-xml/, and is generated with the 'feature_to_c.sh' script.
493#
494intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,$(LOCAL_MODULE),true)
495
496ifeq ($(QEMU_TARGET_XML_SOURCES),)
497 QEMU_TARGET_XML_SOURCES := arm-core arm-neon arm-vfp arm-vfp3
498 QEMU_TARGET_XML_SOURCES := $(QEMU_TARGET_XML_SOURCES:%=$(LOCAL_PATH)/gdb-xml/%.xml)
499endif
500
501QEMU_GDBSTUB_XML_C := $(intermediates)/gdbstub-xml.c
502$(QEMU_GDBSTUB_XML_C): PRIVATE_PATH := $(LOCAL_PATH)
503$(QEMU_GDBSTUB_XML_C): PRIVATE_SOURCES := $(TARGET_XML_SOURCES)
504$(QEMU_GDBSTUB_XML_C): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/feature_to_c.sh $@ $(QEMU_TARGET_XML_SOURCES)
505$(QEMU_GDBSTUB_XML_C): $(QEMU_TARGET_XML_SOURCES) $(LOCAL_PATH)/feature_to_c.sh
506 $(hide) rm -f $@
507 $(transform-generated-source)
508
509LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
510
511EMULATOR_LIBQEMU_CFLAGS += -I$(intermediates)
512
513LOCAL_CFLAGS += $(EMULATOR_LIBQEMU_CFLAGS)
514
515$(call end-emulator-library)
516
517# Block sources, we must compile them with each executable because they
518# are only referenced by the rest of the code using constructor functions.
519# If their object files are put in a static library, these are never compiled
520# into the final linked executable that uses them.
521#
522# Normally, one would solve thus using LOCAL_WHOLE_STATIC_LIBRARIES, but
523# the Darwin linker doesn't support -Wl,--whole-archive or equivalent :-(
524#
525BLOCK_SOURCES += \
526 block.c \
527 blockdev.c \
528 block/qcow.c \
529 block/qcow2.c \
530 block/qcow2-refcount.c \
531 block/qcow2-snapshot.c \
532 block/qcow2-cluster.c \
533 block/cloop.c \
534 block/dmg.c \
535 block/vvfat.c \
536 block/raw.c
537
538ifeq ($(HOST_OS),windows)
539 BLOCK_SOURCES += block/raw-win32.c
540else
541 BLOCK_SOURCES += block/raw-posix.c
542endif
543
544BLOCK_CFLAGS += $(EMULATOR_COMMON_CFLAGS)
545BLOCK_CFLAGS += -DCONFIG_BDRV_WHITELIST=""
546
547
548##############################################################################
549##############################################################################
550###
551### emulator-libelff: TARGET-INDEPENDENT ELF/DWARD PARSER
552###
553### THESE ARE USED BY EVERYTHING EXCEPT 'emulator-ui', BUT WE CANNOT PUT
554### THEM IN emulator-libqemu SINCE THE SOURCES ARE C++
555###
556
557$(call start-emulator-library, emulator-libelff)
558
559LOCAL_CPP_EXTENSION := .cc
560
561ELFF_CFLAGS := -I$(LOCAL_PATH)/elff
562ELFF_LDLIBS := -lstdc++
563
564ELFF_SOURCES := \
565 dwarf_cu.cc \
566 dwarf_die.cc \
567 dwarf_utils.cc \
568 elf_alloc.cc \
569 elf_file.cc \
570 elf_mapped_section.cc \
571 elff_api.cc \
572
573LOCAL_SRC_FILES += $(ELFF_SOURCES:%=elff/%)
574
575LOCAL_CFLAGS += \
576 -fno-exceptions \
577 $(ELFF_CFLAGS) \
578
579$(call end-emulator-library)
580
581
582##############################################################################
583##############################################################################
584###
585### gen-hx-header: Generate headers from .hx file with "hxtool" script.
586###
587### The 'hxtool' script is used to generate header files from an input
588### file with the .hx suffix. I.e. foo.hx --> foo.h
589###
590### Due to the way the Android build system works, we need to regenerate
591### it for each module (the output will go into a module-specific directory).
592###
593### This defines a function that can be used inside a module definition
594###
595### $(call gen-hx-header,<input>,<source-files>)
596###
597### Where: <input> is the input file, with a .hx suffix (e.g. foo.hx)
598### <source-files> is a list of source files that include the header
599###
600
601
602gen-hx-header = $(eval $(call gen-hx-header-ev,$1,$2,$3))
603
604define gen-hx-header-ev
605intermediates := $$(call intermediates-dir-for,EXECUTABLES,$$(LOCAL_MODULE),true)
606
607QEMU_HEADER_H := $$(intermediates)/$$(1:%.hx=%.h)
608$$(QEMU_HEADER_H): PRIVATE_PATH := $$(LOCAL_PATH)
609$$(QEMU_HEADER_H): PRIVATE_CUSTOM_TOOL = $$(PRIVATE_PATH)/hxtool -h < $$< > $$@
610$$(QEMU_HEADER_H): $$(LOCAL_PATH)/$$1 $$(LOCAL_PATH)/hxtool
611 $$(transform-generated-source)
612
613LOCAL_GENERATED_SOURCES += $$(QEMU_HEADER_H)
614_objects := $$(patsubst %,$$(intermediates)/%,$$(2:.c=.o))
615$$(_objects): $$(QEMU_HEADER_H)
616endef
617