1# Copyright (C) 2009-2010 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15 16# Initialization of the NDK build system. This file is included by 17# several build scripts. 18# 19 20# Disable GNU Make implicit rules 21 22# this turns off the suffix rules built into make 23.SUFFIXES: 24 25# this turns off the RCS / SCCS implicit rules of GNU Make 26% : RCS/%,v 27% : RCS/% 28% : %,v 29% : s.% 30% : SCCS/s.% 31 32# If a rule fails, delete $@. 33.DELETE_ON_ERROR: 34 35 36# Define NDK_LOG=1 in your environment to display log traces when 37# using the build scripts. See also the definition of ndk_log below. 38# 39NDK_LOG := $(strip $(NDK_LOG)) 40ifeq ($(NDK_LOG),true) 41 override NDK_LOG := 1 42endif 43 44# Define NDK_HOST_32BIT=1 in your environment to always use toolchain in 32-bit 45# even if 64-bit is present. Note that toolchains in 64-bit still produce 46# 32-bit binaries for Android 47# 48NDK_HOST_32BIT := $(strip $(NDK_HOST_32BIT)) 49ifeq ($(NDK_HOST_32BIT),true) 50 override NDK_HOST_32BIT := 1 51endif 52 53# Check that we have at least GNU Make 3.81 54# We do this by detecting whether 'lastword' is supported 55# 56MAKE_TEST := $(lastword a b c d e f) 57ifneq ($(MAKE_TEST),f) 58 $(error Android NDK: GNU Make version $(MAKE_VERSION) is too low (should be >= 3.81)) 59endif 60ifeq ($(NDK_LOG),1) 61 $(info Android NDK: GNU Make version $(MAKE_VERSION) detected) 62endif 63 64# NDK_ROOT *must* be defined and point to the root of the NDK installation 65NDK_ROOT := $(strip $(NDK_ROOT)) 66ifndef NDK_ROOT 67 $(error ERROR while including init.mk: NDK_ROOT must be defined !) 68endif 69ifneq ($(words $(NDK_ROOT)),1) 70 $(info,The Android NDK installation path contains spaces: '$(NDK_ROOT)') 71 $(error,Please fix the problem by reinstalling to a different location.) 72endif 73 74# ==================================================================== 75# 76# Define a few useful variables and functions. 77# More stuff will follow in definitions.mk. 78# 79# ==================================================================== 80 81# Used to output warnings and error from the library, it's possible to 82# disable any warnings or errors by overriding these definitions 83# manually or by setting NDK_NO_WARNINGS or NDK_NO_ERRORS 84 85__ndk_name := Android NDK 86__ndk_info = $(info $(__ndk_name): $1 $2 $3 $4 $5) 87__ndk_warning = $(warning $(__ndk_name): $1 $2 $3 $4 $5) 88__ndk_error = $(error $(__ndk_name): $1 $2 $3 $4 $5) 89 90ifdef NDK_NO_WARNINGS 91__ndk_warning := 92endif 93ifdef NDK_NO_ERRORS 94__ndk_error := 95endif 96 97# ----------------------------------------------------------------------------- 98# Function : ndk_log 99# Arguments: 1: text to print when NDK_LOG is defined to 1 100# Returns : None 101# Usage : $(call ndk_log,<some text>) 102# ----------------------------------------------------------------------------- 103ifeq ($(NDK_LOG),1) 104ndk_log = $(info $(__ndk_name): $1) 105else 106ndk_log := 107endif 108 109# ----------------------------------------------------------------------------- 110# Function : host-prebuilt-tag 111# Arguments: 1: parent path of "prebuilt" 112# Returns : path $1/prebuilt/(HOST_TAG64) exists and NDK_HOST_32BIT isn't defined to 1, 113# or $1/prebuilt/(HOST_TAG) 114# Usage : $(call host-prebuilt-tag, <path>) 115# Rationale: This function is used to proble available 64-bit toolchain or 116# return 32-bit one as default. Note that HOST_TAG64==HOST_TAG for 117# 32-bit system (or 32-bit userland in 64-bit system) 118# ----------------------------------------------------------------------------- 119ifeq ($(NDK_HOST_32BIT),1) 120host-prebuilt-tag = $1/prebuilt/$(HOST_TAG) 121else 122host-prebuilt-tag = \ 123 $(if $(strip $(wildcard $1/prebuilt/$(HOST_TAG64))),$1/prebuilt/$(HOST_TAG64),$1/prebuilt/$(HOST_TAG)) 124endif 125 126# ==================================================================== 127# 128# Host system auto-detection. 129# 130# ==================================================================== 131 132# 133# Determine host system and architecture from the environment 134# 135HOST_OS := $(strip $(HOST_OS)) 136ifndef HOST_OS 137 # On all modern variants of Windows (including Cygwin and Wine) 138 # the OS environment variable is defined to 'Windows_NT' 139 # 140 # The value of PROCESSOR_ARCHITECTURE will be x86 or AMD64 141 # 142 ifeq ($(OS),Windows_NT) 143 HOST_OS := windows 144 else 145 # For other systems, use the `uname` output 146 UNAME := $(shell uname -s) 147 ifneq (,$(findstring Linux,$(UNAME))) 148 HOST_OS := linux 149 endif 150 ifneq (,$(findstring Darwin,$(UNAME))) 151 HOST_OS := darwin 152 endif 153 # We should not be there, but just in case ! 154 ifneq (,$(findstring CYGWIN,$(UNAME))) 155 HOST_OS := windows 156 endif 157 ifeq ($(HOST_OS),) 158 $(call __ndk_info,Unable to determine HOST_OS from uname -s: $(UNAME)) 159 $(call __ndk_info,Please define HOST_OS in your environment.) 160 $(call __ndk_error,Aborting.) 161 endif 162 endif 163 $(call ndk_log,Host OS was auto-detected: $(HOST_OS)) 164else 165 $(call ndk_log,Host OS from environment: $(HOST_OS)) 166endif 167 168# For all systems, we will have HOST_OS_BASE defined as 169# $(HOST_OS), except on Cygwin where we will have: 170# 171# HOST_OS == cygwin 172# HOST_OS_BASE == windows 173# 174# Trying to detect that we're running from Cygwin is tricky 175# because we can't use $(OSTYPE): It's a Bash shell variable 176# that is not exported to sub-processes, and isn't defined by 177# other shells (for those with really weird setups). 178# 179# Instead, we assume that a program named /bin/uname.exe 180# that can be invoked and returns a valid value corresponds 181# to a Cygwin installation. 182# 183HOST_OS_BASE := $(HOST_OS) 184 185ifeq ($(HOST_OS),windows) 186 ifneq (,$(strip $(wildcard /bin/uname.exe))) 187 $(call ndk_log,Found /bin/uname.exe on Windows host, checking for Cygwin) 188 # NOTE: The 2>NUL here is for the case where we're running inside the 189 # native Windows shell. On cygwin, this will create an empty NUL file 190 # that we're going to remove later (see below). 191 UNAME := $(shell /bin/uname.exe -s 2>NUL) 192 $(call ndk_log,uname -s returned: $(UNAME)) 193 ifneq (,$(filter CYGWIN%,$(UNAME))) 194 $(call ndk_log,Cygwin detected: $(shell uname -a)) 195 HOST_OS := cygwin 196 DUMMY := $(shell rm -f NUL) # Cleaning up 197 else 198 ifneq (,$(filter MINGW32%,$(UNAME))) 199 $(call ndk_log,MSys detected: $(shell uname -a)) 200 HOST_OS := cygwin 201 else 202 $(call ndk_log,Cygwin *not* detected!) 203 endif 204 endif 205 endif 206endif 207 208ifneq ($(HOST_OS),$(HOST_OS_BASE)) 209 $(call ndk_log, Host operating system detected: $(HOST_OS), base OS: $(HOST_OS_BASE)) 210else 211 $(call ndk_log, Host operating system detected: $(HOST_OS)) 212endif 213 214# Always use /usr/bin/file on Darwin to avoid relying on broken Ports 215# version. See http://b.android.com/53769 . 216HOST_FILE_PROGRAM := file 217ifeq ($(HOST_OS),darwin) 218HOST_FILE_PROGRAM := /usr/bin/file 219endif 220 221HOST_ARCH := $(strip $(HOST_ARCH)) 222HOST_ARCH64 := 223ifndef HOST_ARCH 224 ifeq ($(HOST_OS_BASE),windows) 225 HOST_ARCH := $(PROCESSOR_ARCHITECTURE) 226 ifeq ($(HOST_ARCH),AMD64) 227 HOST_ARCH := x86 228 endif 229 # Windows is 64-bit if either ProgramW6432 or ProgramFiles(x86) is set 230 ifneq ("/",$(shell echo "%ProgramW6432%/%ProgramFiles(x86)%")) 231 HOST_ARCH64 := x86_64 232 endif 233 else # HOST_OS_BASE != windows 234 UNAME := $(shell uname -m) 235 ifneq (,$(findstring 86,$(UNAME))) 236 HOST_ARCH := x86 237 ifneq (,$(shell $(HOST_FILE_PROGRAM) -L $(SHELL) | grep 'x86[_-]64')) 238 HOST_ARCH64 := x86_64 239 endif 240 endif 241 # We should probably should not care at all 242 ifneq (,$(findstring Power,$(UNAME))) 243 HOST_ARCH := ppc 244 endif 245 ifeq ($(HOST_ARCH),) 246 $(call __ndk_info,Unsupported host architecture: $(UNAME)) 247 $(call __ndk_error,Aborting) 248 endif 249 endif # HOST_OS_BASE != windows 250 $(call ndk_log,Host CPU was auto-detected: $(HOST_ARCH)) 251else 252 $(call ndk_log,Host CPU from environment: $(HOST_ARCH)) 253endif 254 255ifeq (,$(HOST_ARCH64)) 256 HOST_ARCH64 := $(HOST_ARCH) 257endif 258 259HOST_TAG := $(HOST_OS_BASE)-$(HOST_ARCH) 260HOST_TAG64 := $(HOST_OS_BASE)-$(HOST_ARCH64) 261 262# The directory separator used on this host 263HOST_DIRSEP := : 264ifeq ($(HOST_OS),windows) 265 HOST_DIRSEP := ; 266endif 267 268# The host executable extension 269HOST_EXEEXT := 270ifeq ($(HOST_OS),windows) 271 HOST_EXEEXT := .exe 272endif 273 274# If we are on Windows, we need to check that we are not running 275# Cygwin 1.5, which is deprecated and won't run our toolchain 276# binaries properly. 277# 278ifeq ($(HOST_TAG),windows-x86) 279 ifeq ($(HOST_OS),cygwin) 280 # On cygwin, 'uname -r' returns something like 1.5.23(0.225/5/3) 281 # We recognize 1.5. as the prefix to look for then. 282 CYGWIN_VERSION := $(shell uname -r) 283 ifneq ($(filter XX1.5.%,XX$(CYGWIN_VERSION)),) 284 $(call __ndk_info,You seem to be running Cygwin 1.5, which is not supported.) 285 $(call __ndk_info,Please upgrade to Cygwin 1.7 or higher.) 286 $(call __ndk_error,Aborting.) 287 endif 288 endif 289 # special-case the host-tag 290 HOST_TAG := windows 291endif 292 293$(call ndk_log,HOST_TAG set to $(HOST_TAG)) 294 295# Check for NDK-specific versions of our host tools 296HOST_PREBUILT_ROOT := $(call host-prebuilt-tag, $(NDK_ROOT)) 297HOST_PREBUILT := $(strip $(wildcard $(HOST_PREBUILT_ROOT)/bin)) 298HOST_AWK := $(strip $(NDK_HOST_AWK)) 299HOST_MAKE := $(strip $(NDK_HOST_MAKE)) 300HOST_PYTHON := $(strip $(NDK_HOST_PYTHON)) 301ifdef HOST_PREBUILT 302 $(call ndk_log,Host tools prebuilt directory: $(HOST_PREBUILT)) 303 # The windows prebuilt binaries are for ndk-build.cmd 304 # On cygwin, we must use the Cygwin version of these tools instead. 305 ifneq ($(HOST_OS),cygwin) 306 ifndef HOST_AWK 307 HOST_AWK := $(wildcard $(HOST_PREBUILT)/awk$(HOST_EXEEXT)) 308 endif 309 ifndef HOST_MAKE 310 HOST_MAKE := $(wildcard $(HOST_PREBUILT)/make$(HOST_EXEEXT)) 311 endif 312 ifndef HOST_PYTHON 313 HOST_PYTHON := $(wildcard $(HOST_PREBUILT)/python$(HOST_EXEEXT)) 314 endif 315 endif 316else 317 $(call ndk_log,Host tools prebuilt directory not found, using system tools) 318endif 319 320HOST_ECHO := $(strip $(NDK_HOST_ECHO)) 321ifdef HOST_PREBUILT 322 ifndef HOST_ECHO 323 # Special case, on Cygwin, always use the host echo, not our prebuilt one 324 # which adds \r\n at the end of lines. 325 ifneq ($(HOST_OS),cygwin) 326 HOST_ECHO := $(strip $(wildcard $(HOST_PREBUILT)/echo$(HOST_EXEEXT))) 327 endif 328 endif 329endif 330ifndef HOST_ECHO 331 HOST_ECHO := echo 332endif 333$(call ndk_log,Host 'echo' tool: $(HOST_ECHO)) 334 335# Define HOST_ECHO_N to perform the equivalent of 'echo -n' on all platforms. 336ifeq ($(HOST_OS),windows) 337 # Our custom toolbox echo binary supports -n. 338 HOST_ECHO_N := $(HOST_ECHO) -n 339else 340 # On Posix, just use bare printf. 341 HOST_ECHO_N := printf %s 342endif 343$(call ndk_log,Host 'echo -n' tool: $(HOST_ECHO_N)) 344 345HOST_CMP := $(strip $(NDK_HOST_CMP)) 346ifdef HOST_PREBUILT 347 ifndef HOST_CMP 348 HOST_CMP := $(strip $(wildcard $(HOST_PREBUILT)/cmp$(HOST_EXEEXT))) 349 endif 350endif 351ifndef HOST_CMP 352 HOST_CMP := cmp 353endif 354$(call ndk_log,Host 'cmp' tool: $(HOST_CMP)) 355 356# 357# Verify that the 'awk' tool has the features we need. 358# Both Nawk and Gawk do. 359# 360HOST_AWK := $(strip $(HOST_AWK)) 361ifndef HOST_AWK 362 HOST_AWK := awk 363endif 364$(call ndk_log,Host 'awk' tool: $(HOST_AWK)) 365 366# Location of all awk scripts we use 367BUILD_AWK := $(NDK_ROOT)/build/awk 368 369AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk) 370$(call ndk_log,Host 'awk' test returned: $(AWK_TEST)) 371ifneq ($(AWK_TEST),Pass) 372 $(call __ndk_info,Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !) 373 $(call __ndk_error,Aborting.) 374endif 375 376# 377# On Cygwin/MSys, define the 'cygwin-to-host-path' function here depending on the 378# environment. The rules are the following: 379# 380# 1/ If NDK_USE_CYGPATH=1 and cygpath does exist in your path, cygwin-to-host-path 381# calls "cygpath -m" for each host path. Since invoking 'cygpath -m' from GNU 382# Make for each source file is _very_ slow, this is only a backup plan in 383# case our automatic substitution function (described below) doesn't work. 384# 385# 2/ Generate a Make function that performs the mapping from cygwin/msys to host 386# paths through simple substitutions. It's really a series of nested patsubst 387# calls, that loo like: 388# 389# cygwin-to-host-path = $(patsubst /cygdrive/c/%,c:/%,\ 390# $(patsusbt /cygdrive/d/%,d:/%, \ 391# $1) 392# or in MSys: 393# cygwin-to-host-path = $(patsubst /c/%,c:/%,\ 394# $(patsusbt /d/%,d:/%, \ 395# $1) 396# 397# except that the actual definition is built from the list of mounted 398# drives as reported by "mount" and deals with drive letter cases (i.e. 399# '/cygdrive/c' and '/cygdrive/C') 400# 401ifeq ($(HOST_OS),cygwin) 402 CYGPATH := $(strip $(HOST_CYGPATH)) 403 ifndef CYGPATH 404 $(call ndk_log, Probing for 'cygpath' program) 405 CYGPATH := $(strip $(shell which cygpath 2>/dev/null)) 406 ifndef CYGPATH 407 $(call ndk_log, 'cygpath' was *not* found in your path) 408 else 409 $(call ndk_log, 'cygpath' found as: $(CYGPATH)) 410 endif 411 endif 412 413 ifeq ($(NDK_USE_CYGPATH),1) 414 ifndef CYGPATH 415 $(call __ndk_info,No cygpath) 416 $(call __ndk_error,Aborting) 417 endif 418 $(call ndk_log, Forced usage of 'cygpath -m' through NDK_USE_CYGPATH=1) 419 cygwin-to-host-path = $(strip $(shell $(CYGPATH) -m $1)) 420 else 421 # Call an awk script to generate a Makefile fragment used to define a function 422 WINDOWS_HOST_PATH_FRAGMENT := $(shell mount | tr '\\' '/' | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk) 423 ifeq ($(NDK_LOG),1) 424 $(info Using cygwin substitution rules:) 425 $(eval $(shell mount | tr '\\' '/' | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk -vVERBOSE=1)) 426 endif 427 $(eval cygwin-to-host-path = $(WINDOWS_HOST_PATH_FRAGMENT)) 428 endif 429endif # HOST_OS == cygwin 430 431# The location of the build system files 432BUILD_SYSTEM := $(NDK_ROOT)/build/core 433 434# Include common definitions 435include $(BUILD_SYSTEM)/definitions.mk 436 437# ==================================================================== 438# 439# Read all platform-specific configuration files. 440# 441# Each platform must be located in build/platforms/android-<apilevel> 442# where <apilevel> corresponds to an API level number, with: 443# 3 -> Android 1.5 444# 4 -> next platform release 445# 446# ==================================================================== 447 448# The platform files were moved in the Android source tree from 449# $TOP/ndk/build/platforms to $TOP/development/ndk/platforms. However, 450# the official NDK release packages still place them under the old 451# location for now, so deal with this here 452# 453NDK_PLATFORMS_ROOT := $(strip $(NDK_PLATFORMS_ROOT)) 454ifndef NDK_PLATFORMS_ROOT 455 NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/platforms)) 456 ifndef NDK_PLATFORMS_ROOT 457 NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/build/platforms)) 458 endif 459 460 ifndef NDK_PLATFORMS_ROOT 461 $(call __ndk_info,Could not find platform files (headers and libraries)) 462 $(if $(strip $(wildcard $(NDK_ROOT)/RELEASE.TXT)),\ 463 $(call __ndk_info,Please define NDK_PLATFORMS_ROOT to point to a valid directory.)\ 464 ,\ 465 $(call __ndk_info,Please run build/tools/gen-platforms.sh to build the corresponding directory.)\ 466 ) 467 $(call __ndk_error,Aborting) 468 endif 469 470 $(call ndk_log,Found platform root directory: $(NDK_PLATFORMS_ROOT)) 471endif 472ifeq ($(strip $(wildcard $(NDK_PLATFORMS_ROOT)/android-*)),) 473 $(call __ndk_info,Your NDK_PLATFORMS_ROOT points to an invalid directory) 474 $(call __ndk_info,Current value: $(NDK_PLATFORMS_ROOT)) 475 $(call __ndk_error,Aborting) 476endif 477 478NDK_ALL_PLATFORMS := $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*))) 479$(call ndk_log,Found supported platforms: $(NDK_ALL_PLATFORMS)) 480 481$(foreach _platform,$(NDK_ALL_PLATFORMS),\ 482 $(eval include $(BUILD_SYSTEM)/add-platform.mk)\ 483) 484 485# we're going to find the maximum platform number of the form android-<number> 486# ignore others, which could correspond to special and experimental cases 487NDK_PREVIEW_LEVEL := L 488NDK_ALL_PLATFORM_LEVELS := $(filter android-%,$(NDK_ALL_PLATFORMS)) 489NDK_ALL_PLATFORM_LEVELS := $(patsubst android-%,%,$(NDK_ALL_PLATFORM_LEVELS)) 490ifneq (,$(filter $(NDK_PREVIEW_LEVEL),$(NDK_ALL_PLATFORM_LEVELS))) 491 $(call __ndk_info,Please remove stale preview platforms/android-$(NDK_PREVIEW_LEVEL)) 492 $(call __ndk_info,API level android-L is renamed as android-21.) 493 $(call __ndk_error,Aborting) 494endif 495$(call ndk_log,Found stable platform levels: $(NDK_ALL_PLATFORM_LEVELS)) 496 497NDK_MAX_PLATFORM_LEVEL := 3 498$(foreach level,$(NDK_ALL_PLATFORM_LEVELS),\ 499 $(eval NDK_MAX_PLATFORM_LEVEL := $$(call max,$$(NDK_MAX_PLATFORM_LEVEL),$$(level)))\ 500) 501 502$(call ndk_log,Found max platform level: $(NDK_MAX_PLATFORM_LEVEL)) 503 504# ==================================================================== 505# 506# Read all toolchain-specific configuration files. 507# 508# Each toolchain must have a corresponding config.mk file located 509# in build/toolchains/<name>/ that will be included here. 510# 511# Each one of these files should define the following variables: 512# TOOLCHAIN_NAME toolchain name (e.g. arm-linux-androideabi-4.9) 513# TOOLCHAIN_ABIS list of target ABIs supported by the toolchain. 514# 515# Then, it should include $(ADD_TOOLCHAIN) which will perform 516# book-keeping for the build system. 517# 518# ==================================================================== 519 520# the build script to include in each toolchain config.mk 521ADD_TOOLCHAIN := $(BUILD_SYSTEM)/add-toolchain.mk 522 523# the list of known abis and archs 524NDK_KNOWN_DEVICE_ABI64S := arm64-v8a x86_64 mips64 525NDK_KNOWN_DEVICE_ABI32S := armeabi-v7a armeabi x86 mips 526NDK_KNOWN_DEVICE_ABIS := $(NDK_KNOWN_DEVICE_ABI64S) $(NDK_KNOWN_DEVICE_ABI32S) 527NDK_KNOWN_ABIS := armeabi-v7a-hard $(NDK_KNOWN_DEVICE_ABIS) 528NDK_KNOWN_ABI32S := armeabi-v7a-hard $(NDK_KNOWN_DEVICE_ABI32S) 529NDK_KNOWN_ARCHS := arm x86 mips arm64 x86_64 mips64 530_archs := $(sort $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*/arch-*)))) 531NDK_FOUND_ARCHS := $(_archs:arch-%=%) 532 533# the list of abis 'APP_ABI=all' is expanded to 534ifneq (,$(filter yes all all32 all64,$(_NDK_TESTING_ALL_))) 535NDK_APP_ABI_ALL_EXPANDED := $(NDK_KNOWN_ABIS) 536NDK_APP_ABI_ALL32_EXPANDED := $(NDK_KNOWN_ABI32S) 537else 538NDK_APP_ABI_ALL_EXPANDED := $(NDK_KNOWN_DEVICE_ABIS) 539NDK_APP_ABI_ALL32_EXPANDED := $(NDK_KNOWN_DEVICE_ABI32S) 540endif 541NDK_APP_ABI_ALL64_EXPANDED := $(NDK_KNOWN_DEVICE_ABI64S) 542 543# For testing purpose 544ifeq ($(_NDK_TESTING_ALL_),all32) 545NDK_APP_ABI_ALL_EXPANDED := $(NDK_APP_ABI_ALL32_EXPANDED) 546else 547ifeq ($(_NDK_TESTING_ALL_),all64) 548NDK_APP_ABI_ALL_EXPANDED := $(NDK_APP_ABI_ALL64_EXPANDED) 549endif 550endif 551 552# The first API level ndk-build enforces -fPIE for executable 553NDK_FIRST_PIE_PLATFORM_LEVEL := 16 554 555# the list of all toolchains in this NDK 556NDK_ALL_TOOLCHAINS := 557NDK_ALL_ABIS := 558NDK_ALL_ARCHS := 559 560TOOLCHAIN_CONFIGS := $(wildcard $(NDK_ROOT)/toolchains/*/config.mk) 561$(foreach _config_mk,$(TOOLCHAIN_CONFIGS),\ 562 $(eval include $(BUILD_SYSTEM)/add-toolchain.mk)\ 563) 564 565NDK_ALL_TOOLCHAINS := $(sort $(NDK_ALL_TOOLCHAINS)) 566NDK_ALL_ABIS := $(sort $(NDK_ALL_ABIS)) 567NDK_ALL_ARCHS := $(sort $(NDK_ALL_ARCHS)) 568 569# Check that each ABI has a single architecture definition 570$(foreach _abi,$(strip $(NDK_ALL_ABIS)),\ 571 $(if $(filter-out 1,$(words $(NDK_ABI.$(_abi).arch))),\ 572 $(call __ndk_info,INTERNAL ERROR: The $(_abi) ABI should have exactly one architecture definitions. Found: '$(NDK_ABI.$(_abi).arch)')\ 573 $(call __ndk_error,Aborting...)\ 574 )\ 575) 576 577# Allow the user to define NDK_TOOLCHAIN to a custom toolchain name. 578# This is normally used when the NDK release comes with several toolchains 579# for the same architecture (generally for backwards-compatibility). 580# 581NDK_TOOLCHAIN := $(strip $(NDK_TOOLCHAIN)) 582ifdef NDK_TOOLCHAIN 583 # check that the toolchain name is supported 584 $(if $(filter-out $(NDK_ALL_TOOLCHAINS),$(NDK_TOOLCHAIN)),\ 585 $(call __ndk_info,NDK_TOOLCHAIN is defined to the unsupported value $(NDK_TOOLCHAIN)) \ 586 $(call __ndk_info,Please use one of the following values: $(NDK_ALL_TOOLCHAINS))\ 587 $(call __ndk_error,Aborting)\ 588 ,) 589 $(call ndk_log, Using specific toolchain $(NDK_TOOLCHAIN)) 590endif 591 592# Allow the user to define NDK_TOOLCHAIN_VERSION to override the toolchain 593# version number. Unlike NDK_TOOLCHAIN, this only changes the suffix of 594# the toolchain path we're using. 595# 596# For example, if GCC 4.8 is the default, defining NDK_TOOLCHAIN_VERSION=4.9 597# will ensure that ndk-build uses the following toolchains, depending on 598# the target architecture: 599# 600# arm -> arm-linux-androideabi-4.9 601# x86 -> x86-android-linux-4.9 602# mips -> mipsel-linux-android-4.9 603# 604# This is used in setup-toolchain.mk 605# 606NDK_TOOLCHAIN_VERSION := $(strip $(NDK_TOOLCHAIN_VERSION)) 607 608$(call ndk_log, This NDK supports the following target architectures and ABIS:) 609$(foreach arch,$(NDK_ALL_ARCHS),\ 610 $(call ndk_log, $(space)$(space)$(arch): $(NDK_ARCH.$(arch).abis))\ 611) 612$(call ndk_log, This NDK supports the following toolchains and target ABIs:) 613$(foreach tc,$(NDK_ALL_TOOLCHAINS),\ 614 $(call ndk_log, $(space)$(space)$(tc): $(NDK_TOOLCHAIN.$(tc).abis))\ 615) 616 617