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 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 11 | # determine the location of platform-specific directories |
| 12 | # |
| 13 | CONFIG_DIRS := \ |
David 'Digit' Turner | 34d1651 | 2010-05-18 17:02:33 -0700 | [diff] [blame] | 14 | $(LOCAL_PATH)/android/config/$(QEMU_HOST_TAG) |
| 15 | |
| 16 | ifeq ($(BUILD_STANDALONE_EMULATOR),true) |
| 17 | CONFIG_DIRS := $(LOCAL_PATH)/objs $(CONFIG_DIRS) |
| 18 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 19 | |
| 20 | CONFIG_INCLUDES := $(CONFIG_DIRS:%=-I%) |
| 21 | |
David 'Digit' Turner | 0a349b8 | 2011-03-02 12:49:26 +0100 | [diff] [blame] | 22 | MY_CC := $(HOST_CC) |
| 23 | MY_CXX := $(HOST_CXX) |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 24 | MY_LD := $(HOST_LD) |
David 'Digit' Turner | 0a349b8 | 2011-03-02 12:49:26 +0100 | [diff] [blame] | 25 | MY_AR := $(HOST_AR) |
Kenny Root | 095cd0f | 2009-09-19 18:32:44 -0500 | [diff] [blame] | 26 | |
Lars Poeschel | 33da99a | 2012-08-22 09:42:42 +0200 | [diff] [blame] | 27 | MY_CFLAGS := $(CONFIG_INCLUDES) -O2 -g -fno-PIC -falign-functions=0 -fomit-frame-pointer |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 28 | |
David 'Digit' Turner | 466f548 | 2009-07-30 15:50:19 +0200 | [diff] [blame] | 29 | # Overwrite configuration for debug builds. |
| 30 | # |
| 31 | ifeq ($(BUILD_DEBUG_EMULATOR),true) |
Iliyan Malchev | d00f7c4 | 2012-03-30 10:54:20 -0700 | [diff] [blame] | 32 | MY_CFLAGS := $(CONFIG_INCLUDES) |
| 33 | MY_CFLAGS += -O0 -g |
| 34 | MY_CFLAGS += -fno-PIC -falign-functions=0 |
David 'Digit' Turner | 466f548 | 2009-07-30 15:50:19 +0200 | [diff] [blame] | 35 | endif |
| 36 | |
David 'Digit' Turner | b95f892 | 2009-08-21 23:10:16 -0700 | [diff] [blame] | 37 | MY_LDLIBS := |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 38 | MY_LDFLAGS := |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 39 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 40 | ifeq ($(HOST_OS),freebsd) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 41 | MY_CFLAGS += -I /usr/local/include |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 42 | endif |
| 43 | |
| 44 | ifeq ($(HOST_OS),windows) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 45 | # 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] | 46 | MY_CFLAGS += -DWINVER=0x501 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 47 | MY_CFLAGS += -D_WIN32 |
Hadi Muliawan | 3d0cbda | 2013-07-22 11:50:57 -0700 | [diff] [blame] | 48 | # LARGEADDRESSAWARE gives more address space to 32-bit process |
| 49 | MY_LDLIBS += -Xlinker --large-address-aware |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame^] | 50 | ifneq ($(HOST_IS_64_BIT),) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 51 | # Microsoft 64-bit compiler define both _WIN32 and _WIN64 |
| 52 | MY_CFLAGS += -D_WIN64 |
| 53 | # amd64-mingw32msvc- toolchain still name it vfw32. May change it once amd64-mingw32msvc- |
| 54 | # is stabilized |
| 55 | MY_LDLIBS += -lvfw32 |
| 56 | else |
| 57 | MY_LDLIBS += -lvfw32 |
| 58 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 59 | endif |
| 60 | |
| 61 | ifeq ($(HOST_ARCH),ppc) |
| 62 | MY_CFLAGS += -D__powerpc__ |
| 63 | endif |
| 64 | |
| 65 | ifeq ($(HOST_OS),darwin) |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 66 | MY_CFLAGS += -D_DARWIN_C_SOURCE=1 |
Andrew Hsieh | a5d8f65 | 2012-11-09 21:18:22 -0800 | [diff] [blame] | 67 | ifneq ($(host_toolchain_header),) |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 68 | MY_CFLAGS += -mdynamic-no-pic |
Andrew Hsieh | a5d8f65 | 2012-11-09 21:18:22 -0800 | [diff] [blame] | 69 | MY_CFLAGS += -isystem $(host_toolchain_header) |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 70 | else |
| 71 | ifneq (,$(mac_sdk_root)) |
| 72 | MY_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) |
| 73 | 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] | 74 | |
David 'Digit' Turner | a07421f | 2014-01-18 14:26:43 +0100 | [diff] [blame] | 75 | # Clang complains about this flag being not useful anymore. |
| 76 | MY_CFLAGS := $(filter-out -falign-functions=0,$(MY_CFLAGS)) |
| 77 | endif |
| 78 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 79 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 80 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 81 | # NOTE: The following definitions are only used by the standalone build. |
| 82 | MY_EXEEXT := |
| 83 | MY_DLLEXT := .so |
| 84 | ifeq ($(HOST_OS),windows) |
| 85 | MY_EXEEXT := .exe |
| 86 | MY_DLLEXT := .dll |
| 87 | endif |
| 88 | ifeq ($(HOST_OS),darwin) |
| 89 | MY_DLLEXT := .dylib |
| 90 | endif |
| 91 | |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 92 | # Some CFLAGS below use -Wno-missing-field-initializers but this is not |
| 93 | # supported on GCC 3.x which is still present under Cygwin. |
| 94 | # Find out by probing GCC for support of this flag. Note that the test |
| 95 | # itself only works on GCC 4.x anyway. |
| 96 | GCC_W_NO_MISSING_FIELD_INITIALIZERS := -Wno-missing-field-initializers |
| 97 | ifeq ($(HOST_OS),windows) |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 98 | ifeq (,$(shell gcc -Q --help=warnings 2>/dev/null | grep missing-field-initializers)) |
| 99 | $(info emulator: Ignoring unsupported GCC flag $(GCC_W_NO_MISSING_FIELD_INITIALIZERS)) |
| 100 | GCC_W_NO_MISSING_FIELD_INITIALIZERS := |
| 101 | endif |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 102 | endif |
| 103 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 104 | # BUILD_STANDALONE_EMULATOR is only defined when building with |
| 105 | # the android-rebuild.sh script. The script will also provide |
| 106 | # adequate values for HOST_CC |
| 107 | # |
| 108 | ifneq ($(BUILD_STANDALONE_EMULATOR),true) |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame^] | 109 | # 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] | 110 | # which contains the relevant headers and 32-bit libraries for audio (The host 64-bit |
| 111 | # Lucid doesn't provide these anymore, only their 64-bit versions). |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 112 | ifeq ($(HOST_OS),linux) |
Andrew Hsieh | 7db680c | 2014-03-13 04:18:13 -0700 | [diff] [blame] | 113 | HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux- |
| 114 | ifeq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)gcc))) |
| 115 | # fallback to the previous host toolchain if new one isn't available |
| 116 | HOST_SDK_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk/ |
| 117 | endif |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 118 | # Don't do anything if the toolchain is not there |
Andrew Hsieh | 7db680c | 2014-03-13 04:18:13 -0700 | [diff] [blame] | 119 | ifneq (,$(strip $(wildcard $(HOST_SDK_TOOLCHAIN_PREFIX)gcc))) |
| 120 | MY_CC := $(HOST_SDK_TOOLCHAIN_PREFIX)gcc |
| 121 | MY_CXX := $(HOST_SDK_TOOLCHAIN_PREFIX)g++ |
| 122 | MY_AR := $(HOST_SDK_TOOLCHAIN_PREFIX)ar |
| 123 | endif # $(HOST_SDK_TOOLCHAIN_PREFIX)gcc exists |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 124 | endif # HOST_OS == linux |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 125 | |
| 126 | ifneq ($(USE_CCACHE),) |
Ying Wang | 762d5de | 2012-01-09 11:53:58 -0800 | [diff] [blame] | 127 | ccache := prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache |
David 'Digit' Turner | 4ed818f | 2011-03-12 13:05:15 +0100 | [diff] [blame] | 128 | ccache := $(strip $(wildcard $(ccache))) |
Ying Wang | 7bf9d7f | 2010-10-07 15:12:11 -0700 | [diff] [blame] | 129 | ifneq ($(ccache),$(firstword $(MY_CC))) |
| 130 | MY_CC := $(ccache) $(MY_CC) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 131 | MY_CXX := $(ccache) $(MY_CXX) |
Ying Wang | 7bf9d7f | 2010-10-07 15:12:11 -0700 | [diff] [blame] | 132 | endif |
| 133 | ccache := |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 134 | endif |
| 135 | endif |
| 136 | |
| 137 | |
| 138 | ifneq ($(combo_target)$(TARGET_SIMULATOR),HOST_true) |
Ying Wang | 52e9ecf | 2014-04-23 18:24:30 -0700 | [diff] [blame^] | 139 | ifneq ($(HOST_IS_64_BIT),) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 140 | MY_CFLAGS += -m64 |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 141 | MY_LDFLAGS += -m64 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 142 | else |
| 143 | ifneq ($(HOST_ARCH),x86_64) |
| 144 | MY_CFLAGS += -m32 |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 145 | MY_LDFLAGS += -m32 |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 146 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 147 | endif |
Andrew Hsieh | 632a0e1 | 2012-04-28 00:48:53 +0800 | [diff] [blame] | 148 | |
| 149 | ifneq ($(BUILD_HOST_static),) |
| 150 | MY_LDLIBS += -static |
| 151 | endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 152 | endif |
| 153 | |
David 'Digit' Turner | 7891dd3 | 2014-04-28 10:59:47 +0200 | [diff] [blame] | 154 | ifeq ($(HOST_OS)-$(BUILD_STANDALONE_EMULATOR),windows-true) |
| 155 | # Ensure that printf() et al use GNU printf format specifiers as required |
| 156 | # by QEMU. This is important when using the newer Mingw64 cross-toolchain. |
| 157 | # See http://sourceforge.net/apps/trac/mingw-w64/wiki/gnu%20printf |
| 158 | MY_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 |
| 159 | endif |
| 160 | |
David 'Digit' Turner | 4e024bb | 2010-09-22 14:19:28 +0200 | [diff] [blame] | 161 | # Enable warning, except those related to missing field initializers |
| 162 | # (the QEMU coding style loves using these). |
| 163 | # |
Raphael Moll | 9e319a9 | 2012-11-28 13:48:25 -0800 | [diff] [blame] | 164 | MY_CFLAGS += -Wall $(GCC_W_NO_MISSING_FIELD_INITIALIZERS) |
David 'Digit' Turner | 4e024bb | 2010-09-22 14:19:28 +0200 | [diff] [blame] | 165 | |
David 'Digit' Turner | e228840 | 2014-01-09 18:35:14 +0100 | [diff] [blame] | 166 | # Needed to build block.c on Linux/x86_64. |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 167 | MY_CFLAGS += -D_GNU_SOURCE=1 |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 168 | |
David 'Digit' Turner | 6e9d1d4 | 2013-12-13 17:29:58 +0100 | [diff] [blame] | 169 | MY_CFLAGS += -I$(LOCAL_PATH)/include |
| 170 | |
David 'Digit' Turner | 910aea9 | 2014-01-15 16:53:38 +0100 | [diff] [blame] | 171 | # Need to include "qapi-types.h" and other auto-generated files from |
| 172 | # android-configure.sh |
| 173 | MY_CFLAGS += -I$(LOCAL_PATH)/qapi-auto-generated |
| 174 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 175 | ifneq (true,$(BUILD_STANDALONE_EMULATOR)) |
| 176 | my-host-tool = $(MY_$1) |
| 177 | else |
| 178 | my-host-tool = $(if $(strip $(LOCAL_HOST_BUILD)),$(BUILD_$1),$(MY_$1)) |
| 179 | endif |
| 180 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 181 | # A useful function that can be used to start the declaration of a host |
| 182 | # module. Avoids repeating the same stuff again and again. |
| 183 | # Usage: |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 184 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 185 | # $(call start-emulator-library, <module-name>) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 186 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 187 | # ... declarations |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 188 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 189 | # $(call end-emulator-library) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 190 | # |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 191 | start-emulator-library = \ |
| 192 | $(eval include $(CLEAR_VARS)) \ |
| 193 | $(eval LOCAL_NO_DEFAULT_COMPILER_FLAGS := true) \ |
David 'Digit' Turner | 317c9d5 | 2011-05-10 06:38:21 +0200 | [diff] [blame] | 194 | $(eval LOCAL_MODULE := $1) \ |
David 'Digit' Turner | 42fc449 | 2011-06-29 13:16:16 +0200 | [diff] [blame] | 195 | $(eval LOCAL_MODULE_CLASS := STATIC_LIBRARIES) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 196 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 197 | # Used with start-emulator-library |
| 198 | end-emulator-library = \ |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 199 | $(eval $(end-emulator-module-ev)) \ |
David 'Digit' Turner | 42fc449 | 2011-06-29 13:16:16 +0200 | [diff] [blame] | 200 | $(eval include $(BUILD_HOST_STATIC_LIBRARY)) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 201 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 202 | # A variant of start-emulator-library to start the definition of a host |
| 203 | # program instead. Use with end-emulator-program |
David 'Digit' Turner | 088edf8 | 2011-05-09 15:59:28 +0200 | [diff] [blame] | 204 | start-emulator-program = \ |
| 205 | $(call start-emulator-library,$1) \ |
David 'Digit' Turner | 42fc449 | 2011-06-29 13:16:16 +0200 | [diff] [blame] | 206 | $(eval LOCAL_MODULE_CLASS := EXECUTABLES) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 207 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 208 | # A varient of end-emulator-library for host programs instead |
| 209 | end-emulator-program = \ |
| 210 | $(eval LOCAL_LDLIBS += $(QEMU_SYSTEM_LDLIBS)) \ |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 211 | $(eval $(end-emulator-module-ev)) \ |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 212 | $(eval include $(BUILD_HOST_EXECUTABLE)) |
Xavier Ducrohet | fc8ed80 | 2011-02-09 18:04:23 -0800 | [diff] [blame] | 213 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 214 | define end-emulator-module-ev |
| 215 | LOCAL_CC := $$(call my-host-tool,CC) |
| 216 | LOCAL_CXX := $$(call my-host-tool,CXX) |
| 217 | LOCAL_AR := $$(call my-host-tool,AR) |
| 218 | LOCAL_LD := $$(call my-host-tool,LD) |
| 219 | LOCAL_CFLAGS := $$(call my-host-tool,CFLAGS) $$(LOCAL_CFLAGS) |
| 220 | LOCAL_LDFLAGS := $$(call my-host-tool,LDFLAGS) $$(LOCAL_LDFLAGS) |
| 221 | LOCAL_LDLIBS := $$(LOCAL_LDLIBS) $$(call my-host-tool,LDLIBS) |
| 222 | endef |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 223 | |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 224 | # The common libraries |
| 225 | # |
| 226 | QEMU_SYSTEM_LDLIBS := -lm |
| 227 | ifeq ($(HOST_OS),windows) |
David 'Digit' Turner | 7891dd3 | 2014-04-28 10:59:47 +0200 | [diff] [blame] | 228 | QEMU_SYSTEM_LDLIBS += -mwindows -mconsole |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 229 | endif |
| 230 | |
| 231 | ifeq ($(HOST_OS),freebsd) |
| 232 | QEMU_SYSTEM_LDLIBS += -L/usr/local/lib -lpthread -lX11 -lutil |
| 233 | endif |
| 234 | |
| 235 | ifeq ($(HOST_OS),linux) |
| 236 | QEMU_SYSTEM_LDLIBS += -lutil -lrt |
| 237 | endif |
| 238 | |
| 239 | ifeq ($(HOST_OS),windows) |
Andrew Hsieh | c7389bd | 2012-03-13 02:13:40 -0700 | [diff] [blame] | 240 | # amd64-mingw32msvc- toolchain still name it ws2_32. May change it once amd64-mingw32msvc- |
| 241 | # is stabilized |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 242 | QEMU_SYSTEM_LDLIBS += -lwinmm -lws2_32 -liphlpapi |
| 243 | else |
| 244 | QEMU_SYSTEM_LDLIBS += -lpthread |
| 245 | endif |
| 246 | |
David 'Digit' Turner | 393c0f1 | 2010-07-28 12:20:56 -0700 | [diff] [blame] | 247 | ifeq ($(HOST_OS),darwin) |
Vladimir Chtchetkine | 955a997 | 2011-10-12 15:40:17 -0700 | [diff] [blame] | 248 | QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa,-framework,QTKit,-framework,CoreVideo |
Andrew Hsieh | c2f0b96 | 2012-08-09 18:21:33 +0800 | [diff] [blame] | 249 | |
| 250 | # SDK 10.6+ doesn't have __dyld_func_lookup anymore. Dynamic library lookup symbols |
| 251 | # are instead resolved at runtime |
| 252 | OSX_VERSION_MAJOR := $(shell echo $(mac_sdk_version) | cut -d . -f 2) |
| 253 | OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6 := $(shell [ $(OSX_VERSION_MAJOR) -ge 6 ] && echo true) |
| 254 | ifeq ($(OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6),true) |
Al Sutton | 49dd3f3 | 2012-01-04 15:19:05 -0800 | [diff] [blame] | 255 | QEMU_SYSTEM_LDLIBS += -undefined dynamic_lookup |
Al Sutton | c3c9c6f | 2011-12-21 13:16:22 -0800 | [diff] [blame] | 256 | endif |
David 'Digit' Turner | 393c0f1 | 2010-07-28 12:20:56 -0700 | [diff] [blame] | 257 | endif |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 258 | |
David 'Digit' Turner | af061c5 | 2014-02-28 23:33:54 +0100 | [diff] [blame] | 259 | # This defines EMULATOR_BUILD_64BITS to indicate that 64-bit binaries |
| 260 | # must be generated by the build system. For now, only do it for |
| 261 | # Linux and Darwin, since we the sources do not compile with Mingw-w64 |
| 262 | # yet due to differing procedure call ABI conventions. |
| 263 | EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin,$(HOST_OS))) |
| 264 | |
David 'Digit' Turner | 18c664d | 2014-05-05 20:32:09 +0200 | [diff] [blame] | 265 | # Disable 64-bit build for Darwin platform builds. |
| 266 | ifeq ($(HOST_OS),darwin) |
| 267 | ifneq (true,$(BUILD_STANDALONE_EMULATOR)) |
| 268 | EMULATOR_BUILD_64BITS := $(strip $(empty)) |
| 269 | endif # BUILD_STANDALONE_EMULATOR != true |
| 270 | endif # HOST_OS == darwin |
| 271 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 272 | include $(LOCAL_PATH)/Makefile.common |
| 273 | |
Raphael Moll | cdbea23 | 2012-05-04 15:04:27 -0700 | [diff] [blame] | 274 | ifeq ($(HOST_OS),windows) |
| 275 | # on Windows, link the icon file as well into the executable |
| 276 | # unfortunately, our build system doesn't help us much, so we need |
| 277 | # to use some weird pathnames to make this work... |
| 278 | |
| 279 | # Locate windres executable |
| 280 | WINDRES := windres |
| 281 | ifneq ($(USE_MINGW),) |
| 282 | # When building the Windows emulator under Linux, use the MinGW one |
| 283 | WINDRES := i586-mingw32msvc-windres |
| 284 | endif |
| 285 | |
| 286 | # Usage: $(eval $(call insert-windows-icon)) |
| 287 | define insert-windows-icon |
| 288 | LOCAL_PREBUILT_OBJ_FILES += images/emulator_icon.o |
| 289 | endef |
| 290 | |
| 291 | # This seems to be the only way to add an object file that was not generated from |
| 292 | # a C/C++/Java source file to our build system. and very unfortunately, |
| 293 | # $(TOPDIR)/$(LOCALPATH) will always be prepended to this value, which forces |
| 294 | # us to put the object file in the source directory. |
| 295 | $(LOCAL_PATH)/images/emulator_icon.o: $(LOCAL_PATH)/images/android_icon.rc |
| 296 | $(WINDRES) $< -I $(LOCAL_PATH)/images -o $@ |
| 297 | endif |
| 298 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 299 | # We want to build all variants of the emulator binaries. This makes |
| 300 | # it easier to catch target-specific regressions during emulator development. |
| 301 | EMULATOR_TARGET_ARCH := arm |
| 302 | include $(LOCAL_PATH)/Makefile.target |
| 303 | |
David 'Digit' Turner | dc78122 | 2014-03-07 16:53:45 +0100 | [diff] [blame] | 304 | # Note: the same binary handles x86 and x86_64 |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 305 | EMULATOR_TARGET_ARCH := x86 |
| 306 | include $(LOCAL_PATH)/Makefile.target |
Vladimir Chtchetkine | ba1f57f | 2010-07-27 14:14:15 -0700 | [diff] [blame] | 307 | |
Bhanu Chetlapalli | 741dc13 | 2012-05-08 17:16:03 -0700 | [diff] [blame] | 308 | EMULATOR_TARGET_ARCH := mips |
| 309 | include $(LOCAL_PATH)/Makefile.target |
| 310 | |
Xavier Ducrohet | fc8ed80 | 2011-02-09 18:04:23 -0800 | [diff] [blame] | 311 | ############################################################################## |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 312 | ############################################################################## |
| 313 | ### |
David 'Digit' Turner | 2d238fd | 2011-03-25 10:34:47 +0100 | [diff] [blame] | 314 | ### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR |
| 315 | ### |
| 316 | ### |
| 317 | $(call start-emulator-program, emulator) |
| 318 | |
| 319 | LOCAL_SRC_FILES := android/main-emulator.c |
| 320 | LOCAL_STATIC_LIBRARIES := emulator-common |
| 321 | |
Raphael Moll | cdbea23 | 2012-05-04 15:04:27 -0700 | [diff] [blame] | 322 | ifeq ($(HOST_OS),windows) |
| 323 | $(eval $(call insert-windows-icon)) |
| 324 | endif |
| 325 | |
David 'Digit' Turner | 2d238fd | 2011-03-25 10:34:47 +0100 | [diff] [blame] | 326 | $(call end-emulator-program) |
| 327 | |
David 'Digit' Turner | 57deae3 | 2014-01-21 03:30:13 +0100 | [diff] [blame] | 328 | include $(LOCAL_PATH)/Makefile.tests |
| 329 | |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 330 | ############################################################################## |
| 331 | ############################################################################## |
| 332 | ### |
| 333 | ### GPU emulation libraries |
| 334 | ### |
| 335 | ### Build directly from sources when using the standalone build. |
| 336 | ### |
| 337 | ifeq (true,$(BUILD_STANDALONE_EMULATOR)) |
| 338 | ifeq (,$(strip $(wildcard $(EMULATOR_EMUGL_SOURCES_DIR)))) |
| 339 | $(error Cannot find GPU emulation sources directory: $(EMULATOR_EMUGL_SOURCES_DIR)) |
| 340 | endif |
| 341 | |
David 'Digit' Turner | 1bf3443 | 2014-05-11 11:03:28 +0200 | [diff] [blame] | 342 | # TODO(digit): Remove the line below. |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 343 | BUILD_EMULATOR_OPENGL := true |
David 'Digit' Turner | 1bf3443 | 2014-05-11 11:03:28 +0200 | [diff] [blame] | 344 | BUILD_EMULATOR_HOST_OPENGL := true |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 345 | include $(EMULATOR_EMUGL_SOURCES_DIR)/Android.mk |
| 346 | endif |
| 347 | |
David 'Digit' Turner | aff94b8 | 2011-02-07 18:10:54 +0100 | [diff] [blame] | 348 | ## VOILA!! |
David 'Digit' Turner | f59442f | 2010-10-08 16:22:10 +0200 | [diff] [blame] | 349 | |
Andrew Hsieh | ef0a233 | 2012-08-23 17:39:26 +0800 | [diff] [blame] | 350 | endif # BUILD_EMULATOR == true || BUILD_STANDALONE_EMULATOR == true |