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_SED := $(strip $(NDK_HOST_SED)) 300HOST_MAKE := $(strip $(NDK_HOST_MAKE)) 301HOST_PYTHON := $(strip $(NDK_HOST_PYTHON)) 302ifdef HOST_PREBUILT 303 $(call ndk_log,Host tools prebuilt directory: $(HOST_PREBUILT)) 304 # The windows prebuilt binaries are for ndk-build.cmd 305 # On cygwin, we must use the Cygwin version of these tools instead. 306 ifneq ($(HOST_OS),cygwin) 307 ifndef HOST_AWK 308 HOST_AWK := $(wildcard $(HOST_PREBUILT)/awk$(HOST_EXEEXT)) 309 endif 310 ifndef HOST_SED 311 HOST_SED := $(wildcard $(HOST_PREBUILT)/sed$(HOST_EXEEXT)) 312 endif 313 ifndef HOST_MAKE 314 HOST_MAKE := $(wildcard $(HOST_PREBUILT)/make$(HOST_EXEEXT)) 315 endif 316 ifndef HOST_PYTHON 317 HOST_PYTHON := $(wildcard $(HOST_PREBUILT)/python$(HOST_EXEEXT)) 318 endif 319 endif 320else 321 $(call ndk_log,Host tools prebuilt directory not found, using system tools) 322endif 323 324HOST_ECHO := $(strip $(NDK_HOST_ECHO)) 325ifdef HOST_PREBUILT 326 ifndef HOST_ECHO 327 # Special case, on Cygwin, always use the host echo, not our prebuilt one 328 # which adds \r\n at the end of lines. 329 ifneq ($(HOST_OS),cygwin) 330 HOST_ECHO := $(strip $(wildcard $(HOST_PREBUILT)/echo$(HOST_EXEEXT))) 331 endif 332 endif 333endif 334ifndef HOST_ECHO 335 HOST_ECHO := echo 336endif 337$(call ndk_log,Host 'echo' tool: $(HOST_ECHO)) 338 339# Define HOST_ECHO_N to perform the equivalent of 'echo -n' on all platforms. 340ifeq ($(HOST_OS),windows) 341 # Our custom toolbox echo binary supports -n. 342 HOST_ECHO_N := $(HOST_ECHO) -n 343else 344 # On Posix, just use bare printf. 345 HOST_ECHO_N := printf %s 346endif 347$(call ndk_log,Host 'echo -n' tool: $(HOST_ECHO_N)) 348 349HOST_CMP := $(strip $(NDK_HOST_CMP)) 350ifdef HOST_PREBUILT 351 ifndef HOST_CMP 352 HOST_CMP := $(strip $(wildcard $(HOST_PREBUILT)/cmp$(HOST_EXEEXT))) 353 endif 354endif 355ifndef HOST_CMP 356 HOST_CMP := cmp 357endif 358$(call ndk_log,Host 'cmp' tool: $(HOST_CMP)) 359 360# 361# Verify that the 'awk' tool has the features we need. 362# Both Nawk and Gawk do. 363# 364HOST_AWK := $(strip $(HOST_AWK)) 365ifndef HOST_AWK 366 HOST_AWK := awk 367endif 368$(call ndk_log,Host 'awk' tool: $(HOST_AWK)) 369 370# Location of all awk scripts we use 371BUILD_AWK := $(NDK_ROOT)/build/awk 372 373AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk) 374$(call ndk_log,Host 'awk' test returned: $(AWK_TEST)) 375ifneq ($(AWK_TEST),Pass) 376 $(call __ndk_info,Host 'awk' tool is outdated. Please define NDK_HOST_AWK to point to Gawk or Nawk !) 377 $(call __ndk_error,Aborting.) 378endif 379 380# 381# On Cygwin/MSys, define the 'cygwin-to-host-path' function here depending on the 382# environment. The rules are the following: 383# 384# 1/ If NDK_USE_CYGPATH=1 and cygpath does exist in your path, cygwin-to-host-path 385# calls "cygpath -m" for each host path. Since invoking 'cygpath -m' from GNU 386# Make for each source file is _very_ slow, this is only a backup plan in 387# case our automatic substitution function (described below) doesn't work. 388# 389# 2/ Generate a Make function that performs the mapping from cygwin/msys to host 390# paths through simple substitutions. It's really a series of nested patsubst 391# calls, that loo like: 392# 393# cygwin-to-host-path = $(patsubst /cygdrive/c/%,c:/%,\ 394# $(patsusbt /cygdrive/d/%,d:/%, \ 395# $1) 396# or in MSys: 397# cygwin-to-host-path = $(patsubst /c/%,c:/%,\ 398# $(patsusbt /d/%,d:/%, \ 399# $1) 400# 401# except that the actual definition is built from the list of mounted 402# drives as reported by "mount" and deals with drive letter cases (i.e. 403# '/cygdrive/c' and '/cygdrive/C') 404# 405ifeq ($(HOST_OS),cygwin) 406 CYGPATH := $(strip $(HOST_CYGPATH)) 407 ifndef CYGPATH 408 $(call ndk_log, Probing for 'cygpath' program) 409 CYGPATH := $(strip $(shell which cygpath 2>/dev/null)) 410 ifndef CYGPATH 411 $(call ndk_log, 'cygpath' was *not* found in your path) 412 else 413 $(call ndk_log, 'cygpath' found as: $(CYGPATH)) 414 endif 415 endif 416 417 ifeq ($(NDK_USE_CYGPATH),1) 418 ifndef CYGPATH 419 $(call __ndk_info,No cygpath) 420 $(call __ndk_error,Aborting) 421 endif 422 $(call ndk_log, Forced usage of 'cygpath -m' through NDK_USE_CYGPATH=1) 423 cygwin-to-host-path = $(strip $(shell $(CYGPATH) -m $1)) 424 else 425 # Call an awk script to generate a Makefile fragment used to define a function 426 WINDOWS_HOST_PATH_FRAGMENT := $(shell mount | tr '\\' '/' | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk) 427 ifeq ($(NDK_LOG),1) 428 $(info Using cygwin substitution rules:) 429 $(eval $(shell mount | tr '\\' '/' | $(HOST_AWK) -f $(BUILD_AWK)/gen-windows-host-path.awk -vVERBOSE=1)) 430 endif 431 $(eval cygwin-to-host-path = $(WINDOWS_HOST_PATH_FRAGMENT)) 432 endif 433endif # HOST_OS == cygwin 434 435# The location of the build system files 436BUILD_SYSTEM := $(NDK_ROOT)/build/core 437 438# Include common definitions 439include $(BUILD_SYSTEM)/definitions.mk 440 441# ==================================================================== 442# 443# Read all platform-specific configuration files. 444# 445# Each platform must be located in build/platforms/android-<apilevel> 446# where <apilevel> corresponds to an API level number, with: 447# 3 -> Android 1.5 448# 4 -> next platform release 449# 450# ==================================================================== 451 452# The platform files were moved in the Android source tree from 453# $TOP/ndk/build/platforms to $TOP/development/ndk/platforms. However, 454# the official NDK release packages still place them under the old 455# location for now, so deal with this here 456# 457NDK_PLATFORMS_ROOT := $(strip $(NDK_PLATFORMS_ROOT)) 458ifndef NDK_PLATFORMS_ROOT 459 NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/platforms)) 460 ifndef NDK_PLATFORMS_ROOT 461 NDK_PLATFORMS_ROOT := $(strip $(wildcard $(NDK_ROOT)/build/platforms)) 462 endif 463 464 ifndef NDK_PLATFORMS_ROOT 465 $(call __ndk_info,Could not find platform files (headers and libraries)) 466 $(if $(strip $(wildcard $(NDK_ROOT)/RELEASE.TXT)),\ 467 $(call __ndk_info,Please define NDK_PLATFORMS_ROOT to point to a valid directory.)\ 468 ,\ 469 $(call __ndk_info,Please run build/tools/gen-platforms.sh to build the corresponding directory.)\ 470 ) 471 $(call __ndk_error,Aborting) 472 endif 473 474 $(call ndk_log,Found platform root directory: $(NDK_PLATFORMS_ROOT)) 475endif 476ifeq ($(strip $(wildcard $(NDK_PLATFORMS_ROOT)/android-*)),) 477 $(call __ndk_info,Your NDK_PLATFORMS_ROOT points to an invalid directory) 478 $(call __ndk_info,Current value: $(NDK_PLATFORMS_ROOT)) 479 $(call __ndk_error,Aborting) 480endif 481 482NDK_ALL_PLATFORMS := $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*))) 483$(call ndk_log,Found supported platforms: $(NDK_ALL_PLATFORMS)) 484 485$(foreach _platform,$(NDK_ALL_PLATFORMS),\ 486 $(eval include $(BUILD_SYSTEM)/add-platform.mk)\ 487) 488 489# we're going to find the maximum platform number of the form android-<number> 490# ignore others, which could correspond to special and experimental cases 491NDK_PREVIEW_LEVEL := L 492NDK_ALL_PLATFORM_LEVELS := $(filter android-%,$(NDK_ALL_PLATFORMS)) 493NDK_ALL_PLATFORM_LEVELS := $(patsubst android-%,%,$(NDK_ALL_PLATFORM_LEVELS)) 494$(call ndk_log,Found stable platform levels: $(NDK_ALL_PLATFORM_LEVELS)) 495 496# Hack to pull $(NDK_PREVIEW_LEVEL) ahead of all (numeric) level 497NDK_MAX_PLATFORM_LEVEL := 3 498_max_theoretical_api_level := 99 499$(foreach level,$(NDK_ALL_PLATFORM_LEVELS),\ 500 $(eval NDK_MAX_PLATFORM_LEVEL := $$(if $$(subst $$(NDK_PREVIEW_LEVEL),,$$(level)),$$(call max,$$(NDK_MAX_PLATFORM_LEVEL),$$(level)),$(_max_theoretical_api_level)))\ 501) 502ifeq ($(NDK_MAX_PLATFORM_LEVEL),$(_max_theoretical_api_level)) 503NDK_MAX_PLATFORM_LEVEL := $(NDK_PREVIEW_LEVEL) 504endif 505 506$(call ndk_log,Found max platform level: $(NDK_MAX_PLATFORM_LEVEL)) 507 508# ==================================================================== 509# 510# Read all toolchain-specific configuration files. 511# 512# Each toolchain must have a corresponding config.mk file located 513# in build/toolchains/<name>/ that will be included here. 514# 515# Each one of these files should define the following variables: 516# TOOLCHAIN_NAME toolchain name (e.g. arm-linux-androideabi-4.6) 517# TOOLCHAIN_ABIS list of target ABIs supported by the toolchain. 518# 519# Then, it should include $(ADD_TOOLCHAIN) which will perform 520# book-keeping for the build system. 521# 522# ==================================================================== 523 524# the build script to include in each toolchain config.mk 525ADD_TOOLCHAIN := $(BUILD_SYSTEM)/add-toolchain.mk 526 527# the list of known abis and archs 528NDK_KNOWN_DEVICE_ABI64S := arm64-v8a x86_64 mips64 529NDK_KNOWN_DEVICE_ABI32S := armeabi-v7a armeabi x86 mips 530NDK_KNOWN_DEVICE_ABIS := $(NDK_KNOWN_DEVICE_ABI64S) $(NDK_KNOWN_DEVICE_ABI32S) 531NDK_KNOWN_ABIS := armeabi-v7a-hard $(NDK_KNOWN_DEVICE_ABIS) 532NDK_KNOWN_ABI32S := armeabi-v7a-hard $(NDK_KNOWN_DEVICE_ABI32S) 533NDK_KNOWN_ARCHS := arm x86 mips arm64 x86_64 mips64 534_archs := $(sort $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*/arch-*)))) 535NDK_FOUND_ARCHS := $(_archs:arch-%=%) 536 537# the list of abis 'APP_ABI=all' is expanded to 538ifneq (,$(filter yes all all32 all64,$(_NDK_TESTING_ALL_))) 539NDK_APP_ABI_ALL_EXPANDED := $(NDK_KNOWN_ABIS) 540NDK_APP_ABI_ALL32_EXPANDED := $(NDK_KNOWN_ABI32S) 541else 542NDK_APP_ABI_ALL_EXPANDED := $(NDK_KNOWN_DEVICE_ABIS) 543NDK_APP_ABI_ALL32_EXPANDED := $(NDK_KNOWN_DEVICE_ABI32S) 544endif 545NDK_APP_ABI_ALL64_EXPANDED := $(NDK_KNOWN_DEVICE_ABI64S) 546 547# For testing purpose 548ifeq ($(_NDK_TESTING_ALL_),all32) 549NDK_APP_ABI_ALL_EXPANDED := $(NDK_APP_ABI_ALL32_EXPANDED) 550else 551ifeq ($(_NDK_TESTING_ALL_),all64) 552NDK_APP_ABI_ALL_EXPANDED := $(NDK_APP_ABI_ALL64_EXPANDED) 553endif 554endif 555 556# The first API level ndk-build enforces -fPIE for executable 557NDK_PIE_PLATFORM_LEVEL := 16 558 559# the list of all toolchains in this NDK 560NDK_ALL_TOOLCHAINS := 561NDK_ALL_ABIS := 562NDK_ALL_ARCHS := 563 564TOOLCHAIN_CONFIGS := $(wildcard $(NDK_ROOT)/toolchains/*/config.mk) 565$(foreach _config_mk,$(TOOLCHAIN_CONFIGS),\ 566 $(eval include $(BUILD_SYSTEM)/add-toolchain.mk)\ 567) 568 569NDK_ALL_TOOLCHAINS := $(sort $(NDK_ALL_TOOLCHAINS)) 570NDK_ALL_ABIS := $(sort $(NDK_ALL_ABIS)) 571NDK_ALL_ARCHS := $(sort $(NDK_ALL_ARCHS)) 572 573# Check that each ABI has a single architecture definition 574$(foreach _abi,$(strip $(NDK_ALL_ABIS)),\ 575 $(if $(filter-out 1,$(words $(NDK_ABI.$(_abi).arch))),\ 576 $(call __ndk_info,INTERNAL ERROR: The $(_abi) ABI should have exactly one architecture definitions. Found: '$(NDK_ABI.$(_abi).arch)')\ 577 $(call __ndk_error,Aborting...)\ 578 )\ 579) 580 581# Allow the user to define NDK_TOOLCHAIN to a custom toolchain name. 582# This is normally used when the NDK release comes with several toolchains 583# for the same architecture (generally for backwards-compatibility). 584# 585NDK_TOOLCHAIN := $(strip $(NDK_TOOLCHAIN)) 586ifdef NDK_TOOLCHAIN 587 # check that the toolchain name is supported 588 $(if $(filter-out $(NDK_ALL_TOOLCHAINS),$(NDK_TOOLCHAIN)),\ 589 $(call __ndk_info,NDK_TOOLCHAIN is defined to the unsupported value $(NDK_TOOLCHAIN)) \ 590 $(call __ndk_info,Please use one of the following values: $(NDK_ALL_TOOLCHAINS))\ 591 $(call __ndk_error,Aborting)\ 592 ,) 593 $(call ndk_log, Using specific toolchain $(NDK_TOOLCHAIN)) 594endif 595 596# Allow the user to define NDK_TOOLCHAIN_VERSION to override the toolchain 597# version number. Unlike NDK_TOOLCHAIN, this only changes the suffix of 598# the toolchain path we're using. 599# 600# For example, if GCC 4.6 is the default, defining NDK_TOOLCHAIN_VERSION=4.8 601# will ensure that ndk-build uses the following toolchains, depending on 602# the target architecture: 603# 604# arm -> arm-linux-androideabi-4.8 605# x86 -> x86-android-linux-4.8 606# mips -> mipsel-linux-android-4.8 607# 608# This is used in setup-toolchain.mk 609# 610NDK_TOOLCHAIN_VERSION := $(strip $(NDK_TOOLCHAIN_VERSION)) 611 612$(call ndk_log, This NDK supports the following target architectures and ABIS:) 613$(foreach arch,$(NDK_ALL_ARCHS),\ 614 $(call ndk_log, $(space)$(space)$(arch): $(NDK_ARCH.$(arch).abis))\ 615) 616$(call ndk_log, This NDK supports the following toolchains and target ABIs:) 617$(foreach tc,$(NDK_ALL_TOOLCHAINS),\ 618 $(call ndk_log, $(space)$(space)$(tc): $(NDK_TOOLCHAIN.$(tc).abis))\ 619) 620 621