blob: 600be7cb36c0bae0609ab6cb15a89032d2eb7c70 [file] [log] [blame]
Andrew Hsiehef0a2332012-08-23 17:39:26 +08001ifneq ($(filter true% %true,$(BUILD_EMULATOR)$(BUILD_STANDALONE_EMULATOR)),)
Joe Onoratoedb86c32012-07-25 14:28:40 -07002
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08003LOCAL_PATH:= $(call my-dir)
4
David 'Digit' Turner34d16512010-05-18 17:02:33 -07005# determine the host tag to use
6QEMU_HOST_TAG := $(HOST_PREBUILT_TAG)
7ifneq ($(USE_MINGW),)
8 QEMU_HOST_TAG := windows
9endif
10
David 'Digit' Turner9669d492014-06-12 01:20:53 +020011# This defines EMULATOR_BUILD_64BITS to indicate that 64-bit binaries
12# must be generated by the build system. For now, only do it for
13# Linux and Darwin, since we the sources do not compile with Mingw-w64
14# yet due to differing procedure call ABI conventions.
15EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin,$(HOST_OS)))
16
17# Disable 64-bit build for Darwin platform builds.
18ifeq ($(HOST_OS),darwin)
19ifneq (true,$(BUILD_STANDALONE_EMULATOR))
20EMULATOR_BUILD_64BITS := $(strip $(empty))
21endif # BUILD_STANDALONE_EMULATOR != true
22endif # HOST_OS == darwin
23
24# A function that includes a file only if 32-bit binaries are necessary.
25# This is always the case, but later used with include-if-bitness-64.
26# $1: Build file to include.
27include-if-bitness-32 = $(eval include $1)
28
29# A function that includes a file only of EMULATOR_BUILD_64BITS is not empty.
30# $1: Build file to include.
31include-if-bitness-64 = $(if $(strip $(EMULATOR_BUILD_64BITS)),$(eval include $1))
32
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080033# determine the location of platform-specific directories
34#
35CONFIG_DIRS := \
David 'Digit' Turner34d16512010-05-18 17:02:33 -070036 $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG)
37
38ifeq ($(BUILD_STANDALONE_EMULATOR),true)
39 CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS)
40endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080041
42CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%)
43
David 'Digit' Turner0a349b82011-03-02 12:49:26 +010044MY_CC := $(HOST_CC)
45MY_CXX := $(HOST_CXX)
David 'Digit' Turner1af82152014-03-03 20:41:37 +010046MY_LD := $(HOST_LD)
David 'Digit' Turner0a349b82011-03-02 12:49:26 +010047MY_AR := $(HOST_AR)
Kenny Root095cd0f2009-09-19 18:32:44 -050048
David 'Digit' Turnerb42e1f92014-06-12 00:29:35 +020049MY_CFLAGS := $(CONFIG_INCLUDES) -g -falign-functions=0
David 'Digit' Turner466f5482009-07-30 15:50:19 +020050ifeq ($(BUILD_DEBUG_EMULATOR),true)
David 'Digit' Turnerb42e1f92014-06-12 00:29:35 +020051 MY_CFLAGS += -O0
52else
53 MY_CFLAGS += -O2
David 'Digit' Turner466f5482009-07-30 15:50:19 +020054endif
55
David 'Digit' Turnerb42e1f92014-06-12 00:29:35 +020056# Generate position-independent binaries. Don't add -fPIC when targetting
57# Windows, because newer toolchain complain loudly about it, since all
58# Windows code is position-independent.
59ifneq (windows,$(HOST_OS))
60 MY_CFLAGS += -fPIC
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080061endif
62
David 'Digit' Turner9669d492014-06-12 01:20:53 +020063MY_CFLAGS32 :=
64MY_CFLAGS64 :=
65
David 'Digit' Turnerb95f8922009-08-21 23:10:16 -070066MY_LDLIBS :=
David 'Digit' Turner9669d492014-06-12 01:20:53 +020067MY_LDLIBS32 :=
68MY_LDLIBS64 :=
69
David 'Digit' Turner1af82152014-03-03 20:41:37 +010070MY_LDFLAGS :=
David 'Digit' Turner9669d492014-06-12 01:20:53 +020071MY_LDFLAGS32 :=
72MY_LDFLAGS64 :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080073
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080074ifeq ($(HOST_OS),freebsd)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070075 MY_CFLAGS += -I /usr/local/include
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080076endif
77
78ifeq ($(HOST_OS),windows)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070079 # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080080 MY_CFLAGS += -DWINVER=0x501
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070081 MY_CFLAGS += -D_WIN32
Hadi Muliawan3d0cbda2013-07-22 11:50:57 -070082 # LARGEADDRESSAWARE gives more address space to 32-bit process
David 'Digit' Turner9669d492014-06-12 01:20:53 +020083 MY_LDFLAGS32 += -Xlinker --large-address-aware
Ying Wang52e9ecf2014-04-23 18:24:30 -070084 ifneq ($(HOST_IS_64_BIT),)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -070085 # Microsoft 64-bit compiler define both _WIN32 and _WIN64
86 MY_CFLAGS += -D_WIN64
87 # amd64-mingw32msvc- toolchain still name it vfw32. May change it once amd64-mingw32msvc-
88 # is stabilized
89 MY_LDLIBS += -lvfw32
90 else
91 MY_LDLIBS += -lvfw32
92 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080093endif
94
95ifeq ($(HOST_ARCH),ppc)
96 MY_CFLAGS += -D__powerpc__
97endif
98
99ifeq ($(HOST_OS),darwin)
David 'Digit' Turnera07421f2014-01-18 14:26:43 +0100100 MY_CFLAGS += -D_DARWIN_C_SOURCE=1
Andrew Hsieha5d8f652012-11-09 21:18:22 -0800101 ifneq ($(host_toolchain_header),)
102 MY_CFLAGS += -isystem $(host_toolchain_header)
David 'Digit' Turnera07421f2014-01-18 14:26:43 +0100103 else
104 ifneq (,$(mac_sdk_root))
105 MY_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
106 MY_LDLIBS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
Andrew Hsiehc2f0b962012-08-09 18:21:33 +0800107
David 'Digit' Turnera07421f2014-01-18 14:26:43 +0100108 # Clang complains about this flag being not useful anymore.
109 MY_CFLAGS := $(filter-out -falign-functions=0,$(MY_CFLAGS))
110 endif
111 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800112endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800113
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100114# NOTE: The following definitions are only used by the standalone build.
115MY_EXEEXT :=
116MY_DLLEXT := .so
117ifeq ($(HOST_OS),windows)
118 MY_EXEEXT := .exe
119 MY_DLLEXT := .dll
120endif
121ifeq ($(HOST_OS),darwin)
122 MY_DLLEXT := .dylib
123endif
124
Raphael Moll9e319a92012-11-28 13:48:25 -0800125# Some CFLAGS below use -Wno-missing-field-initializers but this is not
126# supported on GCC 3.x which is still present under Cygwin.
127# Find out by probing GCC for support of this flag. Note that the test
128# itself only works on GCC 4.x anyway.
129GCC_W_NO_MISSING_FIELD_INITIALIZERS := -Wno-missing-field-initializers
130ifeq ($(HOST_OS),windows)
Raphael Moll9e319a92012-11-28 13:48:25 -0800131 ifeq (,$(shell gcc -Q --help=warnings 2>/dev/null | grep missing-field-initializers))
132 $(info emulator: Ignoring unsupported GCC flag $(GCC_W_NO_MISSING_FIELD_INITIALIZERS))
133 GCC_W_NO_MISSING_FIELD_INITIALIZERS :=
134 endif
Raphael Moll9e319a92012-11-28 13:48:25 -0800135endif
136
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800137# BUILD_STANDALONE_EMULATOR is only defined when building with
138# the android-rebuild.sh script. The script will also provide
139# adequate values for HOST_CC
140#
141ifneq ($(BUILD_STANDALONE_EMULATOR),true)
Ying Wang52e9ecf2014-04-23 18:24:30 -0700142 # On Linux, use our custom 32-bit host toolchain (unless HOST_IS_64_BIT=true)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700143 # which contains the relevant headers and 32-bit libraries for audio (The host 64-bit
144 # Lucid doesn't provide these anymore, only their 64-bit versions).
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100145 ifeq ($(HOST_OS),linux)
Andrew Hsieh7db680c2014-03-13 04:18:13 -0700146 HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-
147 ifeq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)gcc)))
148 # fallback to the previous host toolchain if new one isn't available
149 HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk/
150 endif
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100151 # Don't do anything if the toolchain is not there
Andrew Hsieh7db680c2014-03-13 04:18:13 -0700152 ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)gcc)))
153 MY_CC := $(HOST_SDK_TOOLCHAIN_PREFIX)gcc
154 MY_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)g++
155 MY_AR := $(HOST_SDK_TOOLCHAIN_PREFIX)ar
156 endif # $(HOST_SDK_TOOLCHAIN_PREFIX)gcc exists
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100157 endif # HOST_OS == linux
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800158
159 ifneq ($(USE_CCACHE),)
Ying Wang762d5de2012-01-09 11:53:58 -0800160 ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
David 'Digit' Turner4ed818f2011-03-12 13:05:15 +0100161 ccache := $(strip $(wildcard $(ccache)))
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700162 ifneq ($(ccache),$(firstword $(MY_CC)))
163 MY_CC := $(ccache) $(MY_CC)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700164 MY_CXX := $(ccache) $(MY_CXX)
Ying Wang7bf9d7f2010-10-07 15:12:11 -0700165 endif
166 ccache :=
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800167 endif
168endif
169
170
171ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true)
Ying Wang52e9ecf2014-04-23 18:24:30 -0700172 ifneq ($(HOST_IS_64_BIT),)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700173 MY_CFLAGS += -m64
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100174 MY_LDFLAGS += -m64
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700175 else
176 ifneq ($(HOST_ARCH),x86_64)
177 MY_CFLAGS += -m32
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100178 MY_LDFLAGS += -m32
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700179 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800180 endif
Andrew Hsieh632a0e12012-04-28 00:48:53 +0800181
182 ifneq ($(BUILD_HOST_static),)
183 MY_LDLIBS += -static
184 endif
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800185endif
186
David 'Digit' Turner7891dd32014-04-28 10:59:47 +0200187ifeq ($(HOST_OS)-$(BUILD_STANDALONE_EMULATOR),windows-true)
188 # Ensure that printf() et al use GNU printf format specifiers as required
189 # by QEMU. This is important when using the newer Mingw64 cross-toolchain.
190 # See http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf
191 MY_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
192endif
193
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200194# Enable warning, except those related to missing field initializers
195# (the QEMU coding style loves using these).
196#
Raphael Moll9e319a92012-11-28 13:48:25 -0800197MY_CFLAGS += -Wall $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)
David 'Digit' Turner4e024bb2010-09-22 14:19:28 +0200198
David 'Digit' Turnerd6e32c82014-06-06 05:30:20 +0200199# When using clang and ccache, disable the spammy warnings about unused
200# parameters during compilation, and re-enable colored output.
201#
202# See http://petereisentraut.blogspot.fr/2011/05/ccache-and-clang.html
203ifneq (,$(filter %ccache,$(MY_CC)))
204 ifneq (,$(filter LLVM,$(shell $(HOST_CC) -v 2>&1)))
205 MY_CFLAGS := -Qunused-arguments -fcolor-diagnostics $(MY_CFLAGS)
206 endif
207endif
208
David 'Digit' Turnere2288402014-01-09 18:35:14 +0100209# Needed to build block.c on Linux/x86_64.
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100210MY_CFLAGS += -D_GNU_SOURCE=1
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800211
David 'Digit' Turner6e9d1d42013-12-13 17:29:58 +0100212MY_CFLAGS += -I$(LOCAL_PATH)/include
213
David 'Digit' Turner910aea92014-01-15 16:53:38 +0100214# Need to include "qapi-types.h" and other auto-generated files from
215# android-configure.sh
216MY_CFLAGS += -I$(LOCAL_PATH)/qapi-auto-generated
217
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100218ifneq (true,$(BUILD_STANDALONE_EMULATOR))
219my-host-tool = $(MY_$1)
220else
221my-host-tool = $(if $(strip $(LOCAL_HOST_BUILD)),$(BUILD_$1),$(MY_$1))
222endif
223
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100224# A useful function that can be used to start the declaration of a host
225# module. Avoids repeating the same stuff again and again.
226# Usage:
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800227#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100228# $(call start-emulator-library, <module-name>)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800229#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100230# ... declarations
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800231#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100232# $(call end-emulator-library)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800233#
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100234start-emulator-library = \
235 $(eval include $(CLEAR_VARS)) \
236 $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \
David 'Digit' Turner317c9d52011-05-10 06:38:21 +0200237 $(eval LOCAL_MODULE := $1) \
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200238 $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES) \
239 $(eval LOCAL_MODULE_BITS := 32)
240
241start-emulator64-library = \
242 $(call start-emulator-library, $1) \
243 $(eval LOCAL_MODULE_BITS := 64)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800244
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100245# Used with start-emulator-library
246end-emulator-library = \
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100247 $(eval $(end-emulator-module-ev)) \
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200248 $(call include-if-bitness-$(LOCAL_MODULE_BITS), $(BUILD_HOST_STATIC_LIBRARY))
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800249
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100250# A variant of start-emulator-library to start the definition of a host
251# program instead. Use with end-emulator-program
David 'Digit' Turner088edf82011-05-09 15:59:28 +0200252start-emulator-program = \
253 $(call start-emulator-library,$1) \
David 'Digit' Turner42fc4492011-06-29 13:16:16 +0200254 $(eval LOCAL_MODULE_CLASS := EXECUTABLES)
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800255
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200256start-emulator64-program = \
257 $(call start-emulator-program, $1) \
258 $(eval LOCAL_MODULE_BITS := 64)
259
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100260# A varient of end-emulator-library for host programs instead
261end-emulator-program = \
262 $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100263 $(eval $(end-emulator-module-ev)) \
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200264 $(call include-if-bitness-$(LOCAL_MODULE_BITS), $(BUILD_HOST_EXECUTABLE))
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800265
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100266define end-emulator-module-ev
267LOCAL_CC := $$(call my-host-tool,CC)
268LOCAL_CXX := $$(call my-host-tool,CXX)
269LOCAL_AR := $$(call my-host-tool,AR)
270LOCAL_LD := $$(call my-host-tool,LD)
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200271
272LOCAL_CFLAGS := \
273 $$(call my-host-tool,CFLAGS$$(LOCAL_MODULE_BITS)) \
274 $$(call my-host-tool,CFLAGS) \
275 $$(LOCAL_CFLAGS)
276
277LOCAL_LDFLAGS := \
278 $$(call my-host-tool,LDFLAGS$$(LOCAL_MODULE_BITS)) \
279 $$(call my-host-tool,LDFLAGS) \
280 $$(LOCAL_LDFLAGS)
281
282LOCAL_LDLIBS := \
283 $$(LOCAL_LDLIBS) \
284 $$(call my-host-tool,LDLIBS) \
285 $$(call my-host-tool,LDLIBS$$(LOCAL_MODULE_BITS))
286
287# Ensure only one of -m32 or -m64 is being used and place it first.
288LOCAL_CFLAGS := \
289 -m$$(LOCAL_MODULE_BITS) \
290 $$(filter-out -m32 -m64, $$(LOCAL_CFLAGS))
291
292LOCAL_LDFLAGS := \
293 -m$$(LOCAL_MODULE_BITS) \
294 $$(filter-out -m32 -m64, $$(LOCAL_LDFLAGS))
295
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100296endef
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700297
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700298# The common libraries
299#
300QEMU_SYSTEM_LDLIBS := -lm
301ifeq ($(HOST_OS),windows)
David 'Digit' Turner7891dd32014-04-28 10:59:47 +0200302 QEMU_SYSTEM_LDLIBS += -mwindows -mconsole
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700303endif
304
305ifeq ($(HOST_OS),freebsd)
306 QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil
307endif
308
309ifeq ($(HOST_OS),linux)
310 QEMU_SYSTEM_LDLIBS += -lutil -lrt
311endif
312
313ifeq ($(HOST_OS),windows)
Andrew Hsiehc7389bd2012-03-13 02:13:40 -0700314 # amd64-mingw32msvc- toolchain still name it ws2_32. May change it once amd64-mingw32msvc-
315 # is stabilized
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700316 QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi
317else
318 QEMU_SYSTEM_LDLIBS += -lpthread
319endif
320
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700321ifeq ($(HOST_OS),darwin)
Vladimir Chtchetkine955a9972011-10-12 15:40:17 -0700322 QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo
Andrew Hsiehc2f0b962012-08-09 18:21:33 +0800323
David 'Digit' Turner9669d492014-06-12 01:20:53 +0200324 # Required to avoid compilation errors when targetting i386 with newer
325 # XCode toolchain.
326 MY_LDFLAGS32 += -Wl,-read_only_relocs,suppress
327
Andrew Hsiehc2f0b962012-08-09 18:21:33 +0800328 # SDK 10.6+ doesn't have __dyld_func_lookup anymore. Dynamic library lookup symbols
329 # are instead resolved at runtime
330 OSX_VERSION_MAJOR := $(shell echo $(mac_sdk_version) | cut -d . -f 2)
331 OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6 := $(shell [ $(OSX_VERSION_MAJOR) -ge 6 ] && echo true)
332 ifeq ($(OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6),true)
Al Sutton49dd3f32012-01-04 15:19:05 -0800333 QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup
Al Suttonc3c9c6f2011-12-21 13:16:22 -0800334 endif
David 'Digit' Turner393c0f12010-07-28 12:20:56 -0700335endif
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700336
David 'Digit' Turnerdddfa642014-06-12 18:48:17 +0200337# Build libext4_utils and related modules/
338include $(LOCAL_PATH)/distrib/zlib-1.2.8/sources.make
339include $(LOCAL_PATH)/distrib/libsparse/sources.mk
340include $(LOCAL_PATH)/distrib/libselinux/sources.mk
341include $(LOCAL_PATH)/distrib/ext4_utils/sources.mk
342
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100343include $(LOCAL_PATH)/Makefile.common
344
Raphael Mollcdbea232012-05-04 15:04:27 -0700345ifeq ($(HOST_OS),windows)
346 # on Windows, link the icon file as well into the executable
347 # unfortunately, our build system doesn't help us much, so we need
348 # to use some weird pathnames to make this work...
349
350 # Locate windres executable
351 WINDRES := windres
352 ifneq ($(USE_MINGW),)
353 # When building the Windows emulator under Linux, use the MinGW one
354 WINDRES := i586-mingw32msvc-windres
355 endif
356
357 # Usage: $(eval $(call insert-windows-icon))
358 define insert-windows-icon
359 LOCAL_PREBUILT_OBJ_FILES += images/emulator_icon.o
360 endef
361
362# This seems to be the only way to add an object file that was not generated from
363# a C/C++/Java source file to our build system. and very unfortunately,
364# $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces
365# us to put the object file in the source directory.
366$(LOCAL_PATH)/images/emulator_icon.o: $(LOCAL_PATH)/images/android_icon.rc
367 $(WINDRES) $< -I $(LOCAL_PATH)/images -o $@
368endif
369
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100370# We want to build all variants of the emulator binaries. This makes
371# it easier to catch target-specific regressions during emulator development.
372EMULATOR_TARGET_ARCH := arm
373include $(LOCAL_PATH)/Makefile.target
374
David 'Digit' Turnerdc781222014-03-07 16:53:45 +0100375# Note: the same binary handles x86 and x86_64
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100376EMULATOR_TARGET_ARCH := x86
377include $(LOCAL_PATH)/Makefile.target
Vladimir Chtchetkineba1f57f2010-07-27 14:14:15 -0700378
Bhanu Chetlapalli741dc132012-05-08 17:16:03 -0700379EMULATOR_TARGET_ARCH := mips
380include $(LOCAL_PATH)/Makefile.target
381
David 'Digit' Turner7654e7e2014-07-11 14:12:35 +0200382EMULATOR_TARGET_ARCH := arm64
383include $(LOCAL_PATH)/Makefile.qemu-launcher
384
Xavier Ducrohetfc8ed802011-02-09 18:04:23 -0800385##############################################################################
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100386##############################################################################
387###
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +0100388### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR
389###
390###
391$(call start-emulator-program, emulator)
392
393LOCAL_SRC_FILES := android/main-emulator.c
394LOCAL_STATIC_LIBRARIES := emulator-common
395
Raphael Mollcdbea232012-05-04 15:04:27 -0700396ifeq ($(HOST_OS),windows)
397$(eval $(call insert-windows-icon))
398endif
399
David 'Digit' Turner2d238fd2011-03-25 10:34:47 +0100400$(call end-emulator-program)
401
David 'Digit' Turner57deae32014-01-21 03:30:13 +0100402include $(LOCAL_PATH)/Makefile.tests
403
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100404##############################################################################
405##############################################################################
406###
407### GPU emulation libraries
408###
409### Build directly from sources when using the standalone build.
410###
411ifeq (true,$(BUILD_STANDALONE_EMULATOR))
412 ifeq (,$(strip $(wildcard $(EMULATOR_EMUGL_SOURCES_DIR))))
413 $(error Cannot find GPU emulation sources directory: $(EMULATOR_EMUGL_SOURCES_DIR))
414 endif
415
David 'Digit' Turner1bf34432014-05-11 11:03:28 +0200416 # TODO(digit): Remove the line below.
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100417 BUILD_EMULATOR_OPENGL := true
David 'Digit' Turner1bf34432014-05-11 11:03:28 +0200418 BUILD_EMULATOR_HOST_OPENGL := true
David 'Digit' Turner1af82152014-03-03 20:41:37 +0100419 include $(EMULATOR_EMUGL_SOURCES_DIR)/Android.mk
420endif
421
David 'Digit' Turneraff94b82011-02-07 18:10:54 +0100422## VOILA!!
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200423
Andrew Hsiehef0a2332012-08-23 17:39:26 +0800424endif # BUILD_EMULATOR == true || BUILD_STANDALONE_EMULATOR == true