blob: 4c697fbbf2ca6230edb206ddf6909e9c9289f9d4 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001ifeq ($(TARGET_ARCH),arm)
2LOCAL_PATH:= $(call my-dir)
3
4# determine the location of platform-specific directories
5#
6CONFIG_DIRS := \
7 $(LOCAL_PATH)/android/config \
8 $(LOCAL_PATH)/android/config/$(HOST_PREBUILT_TAG)
9
10CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
11
12MY_CFLAGS := $(CONFIG_INCLUDES) -O2 -g \
13 -fno-PIC \
14 -falign-functions=0 \
15 -fomit-frame-pointer \
16
The Android Open Source Project9877e2e2009-03-18 17:39:44 -070017:wqMY_LDFLAGS :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080018
19# this is needed to build the emulator on 64-bit Linux systems
20ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
21 MY_CFLAGS += -Wa,--32
22endif
23
24ifeq ($(HOST_OS),freebsd)
25 MY_CFLAGS += -Wa,--32 -I /usr/local/include
26endif
27
28ifeq ($(HOST_OS),windows)
29 MY_CFLAGS += -D_WIN32 -mno-cygwin
30 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
31 MY_CFLAGS += -DWINVER=0x501
32endif
33
34ifeq ($(HOST_ARCH),ppc)
35 MY_CFLAGS += -D__powerpc__
36endif
37
38ifeq ($(HOST_OS),darwin)
39 MY_CFLAGS += -mdynamic-no-pic
40endif
41MY_CC := $(HOST_CC)
42
43# BUILD_STANDALONE_EMULATOR is only defined when building with
44# the android-rebuild.sh script. The script will also provide
45# adequate values for HOST_CC
46#
47ifneq ($(BUILD_STANDALONE_EMULATOR),true)
48
49 ifneq ($(USE_CCACHE),)
50 MY_CC := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache $(MY_CC)
51 endif
52endif
53
54
55ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
56 ifneq ($(HOST_ARCH),x86_64)
57 MY_CFLAGS += -m32
58 MY_LDFLAGS += -m32
59 endif
60endif
61
62include $(CLEAR_VARS)
63
64###########################################################
65# Zlib configuration
66#
67ZLIB_DIR := distrib/zlib-1.2.3
68include $(LOCAL_PATH)/$(ZLIB_DIR)/sources.make
69
70###########################################################
71# Libpng configuration
72#
73LIBPNG_DIR := distrib/libpng-1.2.19
74include $(LOCAL_PATH)/$(LIBPNG_DIR)/sources.make
75
76###############################################################################
77# build the TCG code generator
78#
79include $(CLEAR_VARS)
80
81LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
82LOCAL_CC := $(MY_CC)
83LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
84LOCAL_LDFLAGS := $(MY_LDFLAGS)
85LOCAL_MODULE := emulator-tcg
86
87TCG_TARGET := $(HOST_ARCH)
88ifeq ($(TCG_TARGET),x86)
89 TCG_TARGET := i386
90endif
91
92TCG_CFLAGS := -I$(LOCAL_PATH)/tcg -I$(LOCAL_PATH)/tcg/$(TCG_TARGET)
93
94LOCAL_CFLAGS += $(TCG_CFLAGS) \
95 -I$(LOCAL_PATH)/target-arm \
96 -I$(LOCAL_PATH)/fpu \
97
98LOCAL_SRC_FILES := \
99 tcg/tcg.c \
100 tcg/tcg-dyngen.c \
101 tcg/tcg-runtime.c \
102
103include $(BUILD_HOST_STATIC_LIBRARY)
104
105##############################################################################
106# build the HW emulation support
107#
108include $(CLEAR_VARS)
109
110LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
111LOCAL_CC := $(MY_CC)
112LOCAL_MODULE := emulator-hw
113
114HW_CFLAGS := -I$(LOCAL_PATH)/hw
115
116LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
117LOCAL_CFLAGS += -I$(LOCAL_PATH)/target-arm -I$(LOCAL_PATH)/fpu $(HW_CFLAGS)
118LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
119
120HW_SOURCES := \
121 android_arm.c \
122 arm_pic.c \
123 cdrom.c \
124 dma.c \
125 irq.c \
126 goldfish_audio.c \
127 goldfish_battery.c \
128 goldfish_device.c \
129 goldfish_events_device.c \
130 goldfish_fb.c \
131 goldfish_interrupt.c \
132 goldfish_memlog.c \
133 goldfish_mmc.c \
134 goldfish_nand.c \
135 goldfish_switch.c \
136 goldfish_timer.c \
137 goldfish_trace.c \
138 goldfish_tty.c \
139 pci.c \
140 scsi-disk.c \
141 smc91c111.c \
142 usb-hid.c \
143 usb-hub.c \
144 usb-msd.c \
145 usb-ohci.c \
146 usb.c \
147
148LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)
149
150include $(BUILD_HOST_STATIC_LIBRARY)
151
152##############################################################################
153# build the ARM-specific emulation engine sources
154#
155include $(CLEAR_VARS)
156
157LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
158LOCAL_CC := $(MY_CC)
159LOCAL_MODULE := emulator-arm
160LOCAL_LDFLAGS := $(MY_LDFLAGS)
161LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
162LOCAL_STATIC_LIBRARIES := emulator-hw
163
164LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare
165LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
166
167LOCAL_CFLAGS += -I$(LOCAL_PATH) \
168 -I$(LOCAL_PATH)/target-arm \
169 -I$(LOCAL_PATH)/fpu \
170 $(TCG_CFLAGS) \
171 $(HW_CFLAGS) \
172
173ifeq ($(HOST_ARCH),ppc)
174 LOCAL_CFLAGS += -D__powerpc__
175endif
176
177LOCAL_SRC_FILES += exec.c cpu-exec.c \
178 target-arm/op_helper.c \
179 target-arm/iwmmxt_helper.c \
180 target-arm/neon_helper.c \
181 target-arm/helper.c \
182 target-arm/translate.c \
183 target-arm/machine.c \
184 translate-all.c \
185 hw/armv7m.c \
186 hw/armv7m_nvic.c \
187 arm-semi.c \
188 trace.c \
189 varint.c \
190 dcache.c \
191
192LOCAL_SRC_FILES += fpu/softfloat.c
193
194include $(BUILD_HOST_STATIC_LIBRARY)
195
196##############################################################################
197# SDL-related definitions
198#
199
200SDL_CONFIG ?= prebuilt/$(HOST_PREBUILT_TAG)/sdl/bin/sdl-config
201SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
202
203# We need to filter out the _GNU_SOURCE variable because it breaks recent
204# releases of Cygwin when using the -mno-cygwin option. Moreover, we don't
205# need this macro at all to build the Android emulator.
206SDL_CFLAGS := $(filter-out -D_GNU_SOURCE=1,$(SDL_CFLAGS))
207SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
208
209
210##############################################################################
211# determine audio sources, build the prebuilt audio-library if needed
212#
213
214# determine AUDIO sources based on current configuration
215#
216AUDIO_SOURCES := audio.c noaudio.c wavaudio.c sdlaudio.c wavcapture.c mixeng.c
217AUDIO_CFLAGS := -I$(LOCAL_PATH)/audio -DHAS_AUDIO
218AUDIO_LDLIBS :=
219
220ifeq ($(HOST_OS),darwin)
221 CONFIG_COREAUDIO ?= yes
222endif
223
224ifeq ($(HOST_OS),windows)
225 CONFIG_WINAUDIO ?= yes
226endif
227
228ifeq ($(HOST_OS),linux)
229 CONFIG_OSS ?= yes
230 CONFIG_ALSA ?= yes
231 CONFIG_ESD ?= yes
232endif
233
234ifeq ($(HOST_OS),freebsd)
235 CONFIG_OSS ?= yes
236endif
237
238ifeq ($(CONFIG_COREAUDIO),yes)
239 AUDIO_SOURCES += coreaudio.c
240 AUDIO_CFLAGS += -DCONFIG_COREAUDIO
241 AUDIO_LDLIBS += -Wl,-framework,CoreAudio
242endif
243
244ifeq ($(CONFIG_WINAUDIO),yes)
245 AUDIO_SOURCES += winaudio.c
246 AUDIO_CFLAGS += -DCONFIG_WINAUDIO
247endif
248
249ifeq ($(CONFIG_ALSA),yes)
250 AUDIO_SOURCES += alsaaudio.c audio_pt_int.c
251 AUDIO_CFLAGS += -DCONFIG_ALSA
252endif
253
254ifeq ($(CONFIG_ESD),yes)
255 AUDIO_SOURCES += esdaudio.c
256 AUDIO_CFLAGS += -DCONFIG_ESD
257endif
258
259ifeq ($(CONFIG_OSS),yes)
260 AUDIO_SOURCES += ossaudio.c
261 AUDIO_CFLAGS += -DCONFIG_OSS
262endif
263
264AUDIO_SOURCES := $(AUDIO_SOURCES:%=audio/%)
265
266# determine whether we're going to use the prebuilt
267# audio library (this is useful on Linux to avoid requiring
268# all sound-related development packages to be installed on
269# the build and developer machines).
270#
271# note that you can define BUILD_QEMU_AUDIO_LIB to true
272# in your environment to force recompilation.
273#
274QEMU_AUDIO_LIB :=
275
276ifneq ($(BUILD_STANDALONE_EMULATOR),true)
277 QEMU_AUDIO_LIB := $(wildcard \
278 prebuilt/$(HOST_PREBUILT_TAG)/emulator/libqemu-audio.a)
279endif
280
281ifeq ($(BUILD_QEMU_AUDIO_LIB),true)
282 include $(CLEAR_VARS)
283 LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
284 LOCAL_CC := $(MY_CC)
285 LOCAL_MODULE := libqemu-audio
286 LOCAL_LDFLAGS := $(MY_LDFLAGS)
287
288 LOCAL_CFLAGS := -Wno-sign-compare \
289 -fno-strict-aliasing -W -Wall -Wno-unused-parameter \
290 -I$(LOCAL_PATH) \
291 -I$(LOCAL_PATH)/target-arm \
292 -I$(LOCAL_PATH)/fpu \
293
294 LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS) $(AUDIO_CFLAGS)
295
296 LOCAL_CFLAGS += $(SDL_CFLAGS)
297
298 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
299
300 include $(BUILD_HOST_STATIC_LIBRARY)
301 QEMU_AUDIO_LIB := $(LOCAL_BUILT_MODULE)
302
303endif # !QEMU_AUDIO_LIB
304
305##############################################################################
306# now build the emulator itself
307#
308include $(CLEAR_VARS)
309
310LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
311LOCAL_CC := $(MY_CC)
312LOCAL_MODULE := emulator
313LOCAL_STATIC_LIBRARIES := emulator-hw emulator-arm emulator-tcg
314LOCAL_LDFLAGS := $(MY_LDFLAGS)
315
316# don't remove the -fno-strict-aliasing, or you'll break things
317# (e.g. slirp2/network support)
318#
319LOCAL_CFLAGS := -fno-PIC -fomit-frame-pointer -Wno-sign-compare \
320 -fno-strict-aliasing -g -W -Wall -Wno-unused-parameter
321
322LOCAL_CFLAGS := $(MY_CFLAGS) $(LOCAL_CFLAGS)
323
324# add the build ID to the default macro definitions
325LOCAL_CFLAGS += -DANDROID_BUILD_ID="$(strip $(BUILD_ID))-$(strip $(BUILD_NUMBER))"
326
327# include the Zlib sources
328#
329LOCAL_SRC_FILES += $(ZLIB_SOURCES)
330LOCAL_CFLAGS += $(ZLIB_CFLAGS) -I$(LOCAL_PATH)/$(ZLIB_DIR)
331
332# include the Libpng sources
333#
334LOCAL_SRC_FILES += $(LIBPNG_SOURCES)
335LOCAL_CFLAGS += $(LIBPNG_CFLAGS) -I$(LOCAL_PATH)/$(LIBPNG_DIR)
336
337LOCAL_CFLAGS += -I$(LOCAL_PATH)/ \
338 -I$(LOCAL_PATH)/target-arm \
339 -I$(LOCAL_PATH)/fpu \
340 $(TCG_CFLAGS) \
341 $(HW_CFLAGS) \
342
343# include telephony stuff
344#
345TELEPHONY_SOURCES := android_modem.c modem_driver.c gsm.c sim_card.c sysdeps_qemu.c sms.c remote_call.c
346LOCAL_SRC_FILES += $(TELEPHONY_SOURCES:%=telephony/%)
347LOCAL_CFLAGS += -I$(LOCAL_PATH)/telephony
348
349# include sound support source files. we first try to see if we have a prebuilt audio
350# library. if not, we build things the "hard" way.
351#
352# note that to generate the prebuilt audio library, you should do the following:
353#
354# cd tools/qemu
355# ./android-rebuild.sh
356# distrib/update-audio.sh
357#
358ifeq ($(QEMU_AUDIO_LIB),)
359 LOCAL_SRC_FILES += $(AUDIO_SOURCES)
360endif # !QEMU_AUDIO_LIB
361
362LOCAL_CFLAGS += $(AUDIO_CFLAGS)
363LOCAL_LDLIBS += $(AUDIO_LDLIBS)
364
365# include slirp2 code, i.e. the user-level networking stuff
366#
367SLIRP_SOURCES := bootp.c cksum.c debug.c if.c ip_icmp.c ip_input.c ip_output.c \
368 mbuf.c misc.c sbuf.c slirp.c socket.c tcp_input.c tcp_output.c \
369 tcp_subr.c tcp_timer.c tftp.c udp.c
370
371LOCAL_SRC_FILES += $(SLIRP_SOURCES:%=slirp2/%)
372LOCAL_CFLAGS += -I$(LOCAL_PATH)/slirp2
373
374# socket proxy support
375#
376PROXY_SOURCES := \
377 proxy_common.c \
378 proxy_http.c \
379 proxy_http_connector.c \
380 proxy_http_rewriter.c \
381
382LOCAL_SRC_FILES += $(PROXY_SOURCES:%=proxy/%)
383LOCAL_CFLAGS += -I$(LOCAL_PATH)/proxy
384
385# the linux-user sources, I doubt we really need these
386#
387#LINUX_SOURCES := main.c elfload.c mmap.c signal.c path.c syscall.c
388#LOCAL_SRC_FILES += $(LINUX_SOURCES:%=linux-user/%)
389
390# the skin support sources
391#
392SKIN_SOURCES := rect.c \
393 region.c \
394 image.c \
395 trackball.c \
396 keyboard.c \
397 keyset.c \
398 file.c \
399 window.c \
400 scaler.c \
401 composer.c \
402 surface.c \
403
404LOCAL_SRC_FILES += $(SKIN_SOURCES:%=android/skin/%)
405#LOCAL_CFLAGS += -I$(LOCAL_PATH)/skin
406
407ifeq ($(HOST_ARCH),x86)
408# enable MMX code for our skin scaler
409LOCAL_CFLAGS += -DUSE_MMX=1 -mmmx
410endif
411
412# include other sources
413#
414VL_SOURCES := vl.c osdep.c cutils.c \
415 block.c readline.c monitor.c console.c loader.c sockets.c \
416 block-qcow.c aes.c d3des.c block-cloop.c block-dmg.c block-vvfat.c \
417 block-qcow2.c block-cow.c \
418 cbuffer.c \
419 gdbstub.c usb-linux.c \
420 vnc.c disas.c arm-dis.c \
421 shaper.c charpipe.c loadpng.c \
422 framebuffer.c \
423 tcpdump.c \
424 android/charmap.c \
425 android/cmdline-option.c \
426 android/config.c \
427 android/console.c \
428 android/gps.c \
429 android/help.c \
430 android/hw-control.c \
431 android/hw-events.c \
432 android/hw-kmsg.c \
The Android Open Source Project9877e2e2009-03-18 17:39:44 -0700433 android/hw-qemud.c \
434 android/hw-sensors.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800435 android/main.c \
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800436 android/resource.c \
437 android/user-config.c \
438 android/utils/bufprint.c \
439 android/utils/debug.c \
440 android/utils/dirscanner.c \
441 android/utils/display.c \
442 android/utils/ini.c \
443 android/utils/filelock.c \
444 android/utils/misc.c \
445 android/utils/path.c \
446 android/utils/reflist.c \
447 android/utils/stralloc.c \
448 android/utils/system.c \
449 android/utils/tempfile.c \
450 android/utils/timezone.c \
451 android/avd/hw-config.c \
452 android/avd/info.c \
453
454# we need to add a Quartz-specific file
455ifeq ($(HOST_OS),darwin)
456 # Alas, the Android build system doesn't know how to deal
457 # with Objective C sources yet.
458 ifeq ($(BUILD_STANDALONE_EMULATOR),true)
459 VL_SOURCES += android/utils/display-quartz.m
460 else
461 LOCAL_CFLAGS += -DCONFIG_NO_COCOA
462 endif
463endif
464
465VL_SOURCES += hw/arm_boot.c \
466 hw/android_arm.c \
467
468ifeq ($(HOST_OS),windows)
469 VL_SOURCES += block-raw-win32.c
470else
471 VL_SOURCES += block-raw-posix.c
472endif
473
474ifeq ($(HOST_OS),linux)
475 LOCAL_LDLIBS += -lX11
476endif
477
478ifeq ($(HOST_ARCH),x86)
479 VL_SOURCES += i386-dis.c
480endif
481ifeq ($(HOST_ARCH),x86_64)
482 VL_SOURCES += i386-dis.c
483endif
484ifeq ($(HOST_ARCH),ppc)
485 VL_SOURCES += ppc-dis.c
486endif
487
488ifeq ($(HOST_OS),windows)
489 #VL_SOURCES += tap-win32.c
490 LOCAL_LDLIBS += -mno-cygwin -mwindows -mconsole
491endif
492
493LOCAL_SRC_FILES += $(VL_SOURCES)
494
495ifeq ($(HOST_OS),linux)
496 LOCAL_LDLIBS += -lutil -lrt
497endif
498
499# add SDL-specific flags
500#
501LOCAL_CFLAGS += $(SDL_CFLAGS)
502LOCAL_LDLIBS += $(SDL_LDLIBS)
503LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
504LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
505
506# on Windows, link the icon file as well into the executable
507# unfortunately, our build system doesn't help us much, so we need
508# to use some weird pathnames to make this work...
509#
510ifeq ($(HOST_OS),windows)
511INTERMEDIATE := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
512ANDROID_ICON_OBJ := android_icon.o
513ANDROID_ICON_PATH := $(LOCAL_PATH)/images
514$(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
515 windres $< -I $(ANDROID_ICON_PATH) -o $@
516
517# seems to be the only way to add an object file that was not generated from
518# a C/C++/Java source file to our build system. and very unfortunately,
519# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
520# us to put the object file in the source directory...
521#
522LOCAL_PREBUILT_OBJ_FILES += images/$(ANDROID_ICON_OBJ)
523endif
524
525# other flags
526LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
527LOCAL_LDLIBS += -lm -lpthread
528
529ifeq ($(HOST_OS),windows)
530 LOCAL_LDLIBS += -lwinmm -lws2_32 -liphlpapi
531endif
532
533LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
534
535LOCAL_MODULE := emulator
536
537include $(BUILD_HOST_EXECUTABLE)
538
539endif # TARGET_ARCH == arm