Andrew Hsieh | ef0a233 | 2012-08-23 17:39:26 +0800 | [diff] [blame] | 1 | ifneq ($(filter true% %true,$(BUILD_EMULATOR)$(BUILD_STANDALONE_EMULATOR)),) |
Joe Onorato | edb86c3 | 2012-07-25 14:28:40 -0700 | [diff] [blame] | 2 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 3 | LOCAL_PATH:= $(call my-dir) |
| 4 | |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 5 | # determine the host tag to use |
| 6 | QEMU_HOST_TAG := $(HOST_PREBUILT_TAG) |
| 7 | ifneq ($(USE_MINGW),) |
| 8 | QEMU_HOST_TAG := windows |
| 9 | endif |
| 10 | |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 11 | # 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. |
| 15 | EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin,$(HOST_OS))) |
| 16 | |
| 17 | # Disable 64-bit build for Darwin platform builds. |
| 18 | ifeq ($(HOST_OS),darwin) |
| 19 | ifneq (true,$(BUILD_STANDALONE_EMULATOR)) |
| 20 | EMULATOR_BUILD_64BITS := $(strip $(empty)) |
| 21 | endif # BUILD_STANDALONE_EMULATOR != true |
| 22 | endif # 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. |
| 27 | include-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. |
| 31 | include-if-bitness-64 = $(if $(strip $(EMULATOR_BUILD_64BITS)),$(eval include $1)) |
| 32 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 33 | # determine the location of platform-specific directories |
| 34 | # |
| 35 | CONFIG_DIRS := \ |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 36 | $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG) |
| 37 | |
| 38 | ifeq ($(BUILD_STANDALONE_EMULATOR),true) |
| 39 | CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS) |
| 40 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 41 | |
| 42 | CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%) |
| 43 | |
David 'Digit' Turner | 0a349b8 | 2011-03-02 12:49:26 +0100 | [diff] [blame] | 44 | MY_CC := $(HOST_CC) |
| 45 | MY_CXX := $(HOST_CXX) |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 46 | MY_LD := $(HOST_LD) |
David 'Digit' Turner | 0a349b8 | 2011-03-02 12:49:26 +0100 | [diff] [blame] | 47 | MY_AR := $(HOST_AR) |
Kenny Root | 095cd0f | 2009-09-19 18:32:44 -0500 | [diff] [blame] | 48 | |
David 'Digit' Turner | b42e1f9 | 2014-06-12 00:29:35 +0200 | [diff] [blame] | 49 | MY_CFLAGS := $(CONFIG_INCLUDES) -g -falign-functions=0 |
David 'Digit' Turner | 466f548 | 2009-07-30 15:50:19 +0200 | [diff] [blame] | 50 | ifeq ($(BUILD_DEBUG_EMULATOR),true) |
David 'Digit' Turner | b42e1f9 | 2014-06-12 00:29:35 +0200 | [diff] [blame] | 51 | MY_CFLAGS += -O0 |
| 52 | else |
| 53 | MY_CFLAGS += -O2 |
David 'Digit' Turner | 466f548 | 2009-07-30 15:50:19 +0200 | [diff] [blame] | 54 | endif |
| 55 | |
David 'Digit' Turner | b42e1f9 | 2014-06-12 00:29:35 +0200 | [diff] [blame] | 56 | # 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. |
| 59 | ifneq (windows,$(HOST_OS)) |
| 60 | MY_CFLAGS += -fPIC |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 61 | endif |
| 62 | |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 63 | MY_CFLAGS32 := |
| 64 | MY_CFLAGS64 := |
| 65 | |
David 'Digit' Turner | b95f892 | 2009-08-21 23:10:16 -0700 | [diff] [blame] | 66 | MY_LDLIBS := |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 67 | MY_LDLIBS32 := |
| 68 | MY_LDLIBS64 := |
| 69 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 70 | MY_LDFLAGS := |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 71 | MY_LDFLAGS32 := |
| 72 | MY_LDFLAGS64 := |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 73 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 74 | ifeq ($(HOST_OS),freebsd) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 75 | MY_CFLAGS += -I /usr/local/include |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 76 | endif |
| 77 | |
| 78 | ifeq ($(HOST_OS),windows) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 79 | # we need Win32 features that are available since Windows 2000 Professional/Server (NT 5.0) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 80 | MY_CFLAGS += -DWINVER=0x501 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 81 | MY_CFLAGS += -D_WIN32 |
Hadi Muliawan | 3d0cbda | 2013-07-22 11:50:57 -0700 | [diff] [blame] | 82 | # LARGEADDRESSAWARE gives more address space to 32-bit process |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 83 | MY_LDFLAGS32 += -Xlinker --large-address-aware |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame] | 84 | ifneq ($(HOST_IS_64_BIT),) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 85 | # 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 Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 93 | endif |
| 94 | |
| 95 | ifeq ($(HOST_ARCH),ppc) |
| 96 | MY_CFLAGS += -D__powerpc__ |
| 97 | endif |
| 98 | |
| 99 | ifeq ($(HOST_OS),darwin) |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 100 | MY_CFLAGS += -D_DARWIN_C_SOURCE=1 |
Andrew Hsieh | a5d8f65 | 2012-11-09 21:18:22 -0800 | [diff] [blame] | 101 | ifneq ($(host_toolchain_header),) |
| 102 | MY_CFLAGS += -isystem $(host_toolchain_header) |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 103 | 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 Hsieh | c2f0b96 | 2012-08-09 18:21:33 +0800 | [diff] [blame] | 107 | |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 108 | # 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 Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 112 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 113 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 114 | # NOTE: The following definitions are only used by the standalone build. |
| 115 | MY_EXEEXT := |
| 116 | MY_DLLEXT := .so |
| 117 | ifeq ($(HOST_OS),windows) |
| 118 | MY_EXEEXT := .exe |
| 119 | MY_DLLEXT := .dll |
| 120 | endif |
| 121 | ifeq ($(HOST_OS),darwin) |
| 122 | MY_DLLEXT := .dylib |
| 123 | endif |
| 124 | |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 125 | # 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. |
| 129 | GCC_W_NO_MISSING_FIELD_INITIALIZERS := -Wno-missing-field-initializers |
| 130 | ifeq ($(HOST_OS),windows) |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 131 | 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 Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 135 | endif |
| 136 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 137 | # 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 | # |
| 141 | ifneq ($(BUILD_STANDALONE_EMULATOR),true) |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame] | 142 | # On Linux, use our custom 32-bit host toolchain (unless HOST_IS_64_BIT=true) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 143 | # 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' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 145 | ifeq ($(HOST_OS),linux) |
Andrew Hsieh | 7db680c | 2014-03-13 04:18:13 -0700 | [diff] [blame] | 146 | 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' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 151 | # Don't do anything if the toolchain is not there |
Andrew Hsieh | 7db680c | 2014-03-13 04:18:13 -0700 | [diff] [blame] | 152 | 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' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 157 | endif # HOST_OS == linux |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 158 | |
| 159 | ifneq ($(USE_CCACHE),) |
Ying Wang | 762d5de | 2012-01-09 11:53:58 -0800 | [diff] [blame] | 160 | ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache |
David 'Digit' Turner | 4ed818f | 2011-03-12 13:05:15 +0100 | [diff] [blame] | 161 | ccache := $(strip $(wildcard $(ccache))) |
Ying Wang | 7bf9d7f | 2010-10-07 15:12:11 -0700 | [diff] [blame] | 162 | ifneq ($(ccache),$(firstword $(MY_CC))) |
| 163 | MY_CC := $(ccache) $(MY_CC) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 164 | MY_CXX := $(ccache) $(MY_CXX) |
Ying Wang | 7bf9d7f | 2010-10-07 15:12:11 -0700 | [diff] [blame] | 165 | endif |
| 166 | ccache := |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 167 | endif |
| 168 | endif |
| 169 | |
| 170 | |
| 171 | ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true) |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame] | 172 | ifneq ($(HOST_IS_64_BIT),) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 173 | MY_CFLAGS += -m64 |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 174 | MY_LDFLAGS += -m64 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 175 | else |
| 176 | ifneq ($(HOST_ARCH),x86_64) |
| 177 | MY_CFLAGS += -m32 |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 178 | MY_LDFLAGS += -m32 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 179 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 180 | endif |
Andrew Hsieh | 632a0e1 | 2012-04-28 00:48:53 +0800 | [diff] [blame] | 181 | |
| 182 | ifneq ($(BUILD_HOST_static),) |
| 183 | MY_LDLIBS += -static |
| 184 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 185 | endif |
| 186 | |
David 'Digit' Turner | 7891dd3 | 2014-04-28 10:59:47 +0200 | [diff] [blame] | 187 | ifeq ($(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 |
| 192 | endif |
| 193 | |
David 'Digit' Turner | 4e024bb | 2010-09-22 14:19:28 +0200 | [diff] [blame] | 194 | # Enable warning, except those related to missing field initializers |
| 195 | # (the QEMU coding style loves using these). |
| 196 | # |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 197 | MY_CFLAGS += -Wall $(GCC_W_NO_MISSING_FIELD_INITIALIZERS) |
David 'Digit' Turner | 4e024bb | 2010-09-22 14:19:28 +0200 | [diff] [blame] | 198 | |
David 'Digit' Turner | d6e32c8 | 2014-06-06 05:30:20 +0200 | [diff] [blame] | 199 | # 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 |
| 203 | ifneq (,$(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 |
| 207 | endif |
| 208 | |
David 'Digit' Turner | e228840 | 2014-01-09 18:35:14 +0100 | [diff] [blame] | 209 | # Needed to build block.c on Linux/x86_64. |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 210 | MY_CFLAGS += -D_GNU_SOURCE=1 |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 211 | |
David 'Digit' Turner | 6e9d1d4 | 2013-12-13 17:29:58 +0100 | [diff] [blame] | 212 | MY_CFLAGS += -I$(LOCAL_PATH)/include |
| 213 | |
David 'Digit' Turner | 910aea9 | 2014-01-15 16:53:38 +0100 | [diff] [blame] | 214 | # Need to include "qapi-types.h" and other auto-generated files from |
| 215 | # android-configure.sh |
| 216 | MY_CFLAGS += -I$(LOCAL_PATH)/qapi-auto-generated |
| 217 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 218 | ifneq (true,$(BUILD_STANDALONE_EMULATOR)) |
| 219 | my-host-tool = $(MY_$1) |
| 220 | else |
| 221 | my-host-tool = $(if $(strip $(LOCAL_HOST_BUILD)),$(BUILD_$1),$(MY_$1)) |
| 222 | endif |
| 223 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 224 | # 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 Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 227 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 228 | # $(call start-emulator-library, <module-name>) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 229 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 230 | # ... declarations |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 231 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 232 | # $(call end-emulator-library) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 233 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 234 | start-emulator-library = \ |
| 235 | $(eval include $(CLEAR_VARS)) \ |
| 236 | $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \ |
David 'Digit' Turner | 317c9d5 | 2011-05-10 06:38:21 +0200 | [diff] [blame] | 237 | $(eval LOCAL_MODULE := $1) \ |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 238 | $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES) \ |
| 239 | $(eval LOCAL_MODULE_BITS := 32) |
| 240 | |
| 241 | start-emulator64-library = \ |
| 242 | $(call start-emulator-library, $1) \ |
| 243 | $(eval LOCAL_MODULE_BITS := 64) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 244 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 245 | # Used with start-emulator-library |
| 246 | end-emulator-library = \ |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 247 | $(eval $(end-emulator-module-ev)) \ |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 248 | $(call include-if-bitness-$(LOCAL_MODULE_BITS), $(BUILD_HOST_STATIC_LIBRARY)) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 249 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 250 | # A variant of start-emulator-library to start the definition of a host |
| 251 | # program instead. Use with end-emulator-program |
David 'Digit' Turner | 088edf8 | 2011-05-09 15:59:28 +0200 | [diff] [blame] | 252 | start-emulator-program = \ |
| 253 | $(call start-emulator-library,$1) \ |
David 'Digit' Turner | 42fc449 | 2011-06-29 13:16:16 +0200 | [diff] [blame] | 254 | $(eval LOCAL_MODULE_CLASS := EXECUTABLES) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 255 | |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 256 | start-emulator64-program = \ |
| 257 | $(call start-emulator-program, $1) \ |
| 258 | $(eval LOCAL_MODULE_BITS := 64) |
| 259 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 260 | # A varient of end-emulator-library for host programs instead |
| 261 | end-emulator-program = \ |
| 262 | $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \ |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 263 | $(eval $(end-emulator-module-ev)) \ |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 264 | $(call include-if-bitness-$(LOCAL_MODULE_BITS), $(BUILD_HOST_EXECUTABLE)) |
Xavier Ducrohet | fc8ed80 | 2011-02-09 18:04:23 -0800 | [diff] [blame] | 265 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 266 | define end-emulator-module-ev |
| 267 | LOCAL_CC := $$(call my-host-tool,CC) |
| 268 | LOCAL_CXX := $$(call my-host-tool,CXX) |
| 269 | LOCAL_AR := $$(call my-host-tool,AR) |
| 270 | LOCAL_LD := $$(call my-host-tool,LD) |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 271 | |
| 272 | LOCAL_CFLAGS := \ |
| 273 | $$(call my-host-tool,CFLAGS$$(LOCAL_MODULE_BITS)) \ |
| 274 | $$(call my-host-tool,CFLAGS) \ |
| 275 | $$(LOCAL_CFLAGS) |
| 276 | |
| 277 | LOCAL_LDFLAGS := \ |
| 278 | $$(call my-host-tool,LDFLAGS$$(LOCAL_MODULE_BITS)) \ |
| 279 | $$(call my-host-tool,LDFLAGS) \ |
| 280 | $$(LOCAL_LDFLAGS) |
| 281 | |
| 282 | LOCAL_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. |
| 288 | LOCAL_CFLAGS := \ |
| 289 | -m$$(LOCAL_MODULE_BITS) \ |
| 290 | $$(filter-out -m32 -m64, $$(LOCAL_CFLAGS)) |
| 291 | |
| 292 | LOCAL_LDFLAGS := \ |
| 293 | -m$$(LOCAL_MODULE_BITS) \ |
| 294 | $$(filter-out -m32 -m64, $$(LOCAL_LDFLAGS)) |
| 295 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 296 | endef |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 297 | |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 298 | # The common libraries |
| 299 | # |
| 300 | QEMU_SYSTEM_LDLIBS := -lm |
| 301 | ifeq ($(HOST_OS),windows) |
David 'Digit' Turner | 7891dd3 | 2014-04-28 10:59:47 +0200 | [diff] [blame] | 302 | QEMU_SYSTEM_LDLIBS += -mwindows -mconsole |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 303 | endif |
| 304 | |
| 305 | ifeq ($(HOST_OS),freebsd) |
| 306 | QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil |
| 307 | endif |
| 308 | |
| 309 | ifeq ($(HOST_OS),linux) |
| 310 | QEMU_SYSTEM_LDLIBS += -lutil -lrt |
| 311 | endif |
| 312 | |
| 313 | ifeq ($(HOST_OS),windows) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 314 | # amd64-mingw32msvc- toolchain still name it ws2_32. May change it once amd64-mingw32msvc- |
| 315 | # is stabilized |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 316 | QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi |
| 317 | else |
| 318 | QEMU_SYSTEM_LDLIBS += -lpthread |
| 319 | endif |
| 320 | |
David 'Digit' Turner | 393c0f1 | 2010-07-28 12:20:56 -0700 | [diff] [blame] | 321 | ifeq ($(HOST_OS),darwin) |
Vladimir Chtchetkine | 955a997 | 2011-10-12 15:40:17 -0700 | [diff] [blame] | 322 | QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo |
Andrew Hsieh | c2f0b96 | 2012-08-09 18:21:33 +0800 | [diff] [blame] | 323 | |
David 'Digit' Turner | 9669d49 | 2014-06-12 01:20:53 +0200 | [diff] [blame] | 324 | # Required to avoid compilation errors when targetting i386 with newer |
| 325 | # XCode toolchain. |
| 326 | MY_LDFLAGS32 += -Wl,-read_only_relocs,suppress |
| 327 | |
Andrew Hsieh | c2f0b96 | 2012-08-09 18:21:33 +0800 | [diff] [blame] | 328 | # 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 Sutton | 49dd3f3 | 2012-01-04 15:19:05 -0800 | [diff] [blame] | 333 | QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup |
Al Sutton | c3c9c6f | 2011-12-21 13:16:22 -0800 | [diff] [blame] | 334 | endif |
David 'Digit' Turner | 393c0f1 | 2010-07-28 12:20:56 -0700 | [diff] [blame] | 335 | endif |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 336 | |
David 'Digit' Turner | dddfa64 | 2014-06-12 18:48:17 +0200 | [diff] [blame] | 337 | # Build libext4_utils and related modules/ |
| 338 | include $(LOCAL_PATH)/distrib/zlib-1.2.8/sources.make |
| 339 | include $(LOCAL_PATH)/distrib/libsparse/sources.mk |
| 340 | include $(LOCAL_PATH)/distrib/libselinux/sources.mk |
| 341 | include $(LOCAL_PATH)/distrib/ext4_utils/sources.mk |
| 342 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 343 | include $(LOCAL_PATH)/Makefile.common |
| 344 | |
Raphael Moll | cdbea23 | 2012-05-04 15:04:27 -0700 | [diff] [blame] | 345 | ifeq ($(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 $@ |
| 368 | endif |
| 369 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 370 | # We want to build all variants of the emulator binaries. This makes |
| 371 | # it easier to catch target-specific regressions during emulator development. |
| 372 | EMULATOR_TARGET_ARCH := arm |
| 373 | include $(LOCAL_PATH)/Makefile.target |
| 374 | |
David 'Digit' Turner | dc78122 | 2014-03-07 16:53:45 +0100 | [diff] [blame] | 375 | # Note: the same binary handles x86 and x86_64 |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 376 | EMULATOR_TARGET_ARCH := x86 |
| 377 | include $(LOCAL_PATH)/Makefile.target |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 378 | |
Bhanu Chetlapalli | 741dc13 | 2012-05-08 17:16:03 -0700 | [diff] [blame] | 379 | EMULATOR_TARGET_ARCH := mips |
| 380 | include $(LOCAL_PATH)/Makefile.target |
| 381 | |
David 'Digit' Turner | 7654e7e | 2014-07-11 14:12:35 +0200 | [diff] [blame] | 382 | EMULATOR_TARGET_ARCH := arm64 |
| 383 | include $(LOCAL_PATH)/Makefile.qemu-launcher |
| 384 | |
Xavier Ducrohet | fc8ed80 | 2011-02-09 18:04:23 -0800 | [diff] [blame] | 385 | ############################################################################## |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 386 | ############################################################################## |
| 387 | ### |
David 'Digit' Turner | 2d238fd | 2011-03-25 10:34:47 +0100 | [diff] [blame] | 388 | ### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR |
| 389 | ### |
| 390 | ### |
| 391 | $(call start-emulator-program, emulator) |
| 392 | |
| 393 | LOCAL_SRC_FILES := android/main-emulator.c |
| 394 | LOCAL_STATIC_LIBRARIES := emulator-common |
| 395 | |
Raphael Moll | cdbea23 | 2012-05-04 15:04:27 -0700 | [diff] [blame] | 396 | ifeq ($(HOST_OS),windows) |
| 397 | $(eval $(call insert-windows-icon)) |
| 398 | endif |
| 399 | |
David 'Digit' Turner | 2d238fd | 2011-03-25 10:34:47 +0100 | [diff] [blame] | 400 | $(call end-emulator-program) |
| 401 | |
David 'Digit' Turner | 57deae3 | 2014-01-21 03:30:13 +0100 | [diff] [blame] | 402 | include $(LOCAL_PATH)/Makefile.tests |
| 403 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 404 | ############################################################################## |
| 405 | ############################################################################## |
| 406 | ### |
| 407 | ### GPU emulation libraries |
| 408 | ### |
| 409 | ### Build directly from sources when using the standalone build. |
| 410 | ### |
| 411 | ifeq (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' Turner | 1bf3443 | 2014-05-11 11:03:28 +0200 | [diff] [blame] | 416 | # TODO(digit): Remove the line below. |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 417 | BUILD_EMULATOR_OPENGL := true |
David 'Digit' Turner | 1bf3443 | 2014-05-11 11:03:28 +0200 | [diff] [blame] | 418 | BUILD_EMULATOR_HOST_OPENGL := true |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 419 | include $(EMULATOR_EMUGL_SOURCES_DIR)/Android.mk |
| 420 | endif |
| 421 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 422 | ## VOILA!! |
David 'Digit' Turner | f59442f | 2010-10-08 16:22:10 +0200 | [diff] [blame] | 423 | |
Andrew Hsieh | ef0a233 | 2012-08-23 17:39:26 +0800 | [diff] [blame] | 424 | endif # BUILD_EMULATOR == true || BUILD_STANDALONE_EMULATOR == true |