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