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