Home | History | Annotate | Download | only in core
      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 #
     39 NDK_LOG := $(strip $(NDK_LOG))
     40 ifeq ($(NDK_LOG),true)
     41     override NDK_LOG := 1
     42 endif
     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 #
     48 NDK_HOST_32BIT := $(strip $(NDK_HOST_32BIT))
     49 ifeq ($(NDK_HOST_32BIT),true)
     50     override NDK_HOST_32BIT := 1
     51 endif
     52 
     53 # Check that we have at least GNU Make 3.81
     54 # We do this by detecting whether 'lastword' is supported
     55 #
     56 MAKE_TEST := $(lastword a b c d e f)
     57 ifneq ($(MAKE_TEST),f)
     58     $(error Android NDK: GNU Make version $(MAKE_VERSION) is too low (should be >= 3.81))
     59 endif
     60 ifeq ($(NDK_LOG),1)
     61     $(info Android NDK: GNU Make version $(MAKE_VERSION) detected)
     62 endif
     63 
     64 # NDK_ROOT *must* be defined and point to the root of the NDK installation
     65 NDK_ROOT := $(strip $(NDK_ROOT))
     66 ifndef NDK_ROOT
     67     $(error ERROR while including init.mk: NDK_ROOT must be defined !)
     68 endif
     69 ifneq ($(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.)
     72 endif
     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 
     90 ifdef NDK_NO_WARNINGS
     91 __ndk_warning :=
     92 endif
     93 ifdef NDK_NO_ERRORS
     94 __ndk_error :=
     95 endif
     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 # -----------------------------------------------------------------------------
    103 ifeq ($(NDK_LOG),1)
    104 ndk_log = $(info $(__ndk_name): $1)
    105 else
    106 ndk_log :=
    107 endif
    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 # -----------------------------------------------------------------------------
    119 ifeq ($(NDK_HOST_32BIT),1)
    120 host-prebuilt-tag = $1/prebuilt/$(HOST_TAG)
    121 else
    122 host-prebuilt-tag = \
    123    $(if $(strip $(wildcard $1/prebuilt/$(HOST_TAG64))),$1/prebuilt/$(HOST_TAG64),$1/prebuilt/$(HOST_TAG))
    124 endif
    125 
    126 # ====================================================================
    127 #
    128 # Host system auto-detection.
    129 #
    130 # ====================================================================
    131 
    132 #
    133 # Determine host system and architecture from the environment
    134 #
    135 HOST_OS := $(strip $(HOST_OS))
    136 ifndef 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))
    164 else
    165     $(call ndk_log,Host OS from environment: $(HOST_OS))
    166 endif
    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 #
    183 HOST_OS_BASE := $(HOST_OS)
    184 
    185 ifeq ($(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
    206 endif
    207 
    208 ifneq ($(HOST_OS),$(HOST_OS_BASE))
    209     $(call ndk_log, Host operating system detected: $(HOST_OS), base OS: $(HOST_OS_BASE))
    210 else
    211     $(call ndk_log, Host operating system detected: $(HOST_OS))
    212 endif
    213 
    214 # Always use /usr/bin/file on Darwin to avoid relying on broken Ports
    215 # version. See http://b.android.com/53769 .
    216 HOST_FILE_PROGRAM := file
    217 ifeq ($(HOST_OS),darwin)
    218 HOST_FILE_PROGRAM := /usr/bin/file
    219 endif
    220 
    221 HOST_ARCH := $(strip $(HOST_ARCH))
    222 HOST_ARCH64 :=
    223 ifndef 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))
    251 else
    252     $(call ndk_log,Host CPU from environment: $(HOST_ARCH))
    253 endif
    254 
    255 ifeq (,$(HOST_ARCH64))
    256     HOST_ARCH64 := $(HOST_ARCH)
    257 endif
    258 
    259 HOST_TAG := $(HOST_OS_BASE)-$(HOST_ARCH)
    260 HOST_TAG64 := $(HOST_OS_BASE)-$(HOST_ARCH64)
    261 
    262 # The directory separator used on this host
    263 HOST_DIRSEP := :
    264 ifeq ($(HOST_OS),windows)
    265   HOST_DIRSEP := ;
    266 endif
    267 
    268 # The host executable extension
    269 HOST_EXEEXT :=
    270 ifeq ($(HOST_OS),windows)
    271   HOST_EXEEXT := .exe
    272 endif
    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 #
    278 ifeq ($(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
    291 endif
    292 
    293 $(call ndk_log,HOST_TAG set to $(HOST_TAG))
    294 
    295 # Check for NDK-specific versions of our host tools
    296 HOST_PREBUILT_ROOT := $(call host-prebuilt-tag, $(NDK_ROOT))
    297 HOST_PREBUILT := $(strip $(wildcard $(HOST_PREBUILT_ROOT)/bin))
    298 HOST_AWK := $(strip $(NDK_HOST_AWK))
    299 HOST_SED  := $(strip $(NDK_HOST_SED))
    300 HOST_MAKE := $(strip $(NDK_HOST_MAKE))
    301 HOST_PYTHON := $(strip $(NDK_HOST_PYTHON))
    302 ifdef 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
    320 else
    321     $(call ndk_log,Host tools prebuilt directory not found, using system tools)
    322 endif
    323 
    324 HOST_ECHO := $(strip $(NDK_HOST_ECHO))
    325 ifdef 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
    333 endif
    334 ifndef HOST_ECHO
    335     HOST_ECHO := echo
    336 endif
    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.
    340 ifeq ($(HOST_OS),windows)
    341   # Our custom toolbox echo binary supports -n.
    342   HOST_ECHO_N := $(HOST_ECHO) -n
    343 else
    344   # On Posix, just use bare printf.
    345   HOST_ECHO_N := printf %s
    346 endif
    347 $(call ndk_log,Host 'echo -n' tool: $(HOST_ECHO_N))
    348 
    349 HOST_CMP := $(strip $(NDK_HOST_CMP))
    350 ifdef HOST_PREBUILT
    351     ifndef HOST_CMP
    352         HOST_CMP := $(strip $(wildcard $(HOST_PREBUILT)/cmp$(HOST_EXEEXT)))
    353     endif
    354 endif
    355 ifndef HOST_CMP
    356     HOST_CMP := cmp
    357 endif
    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 #
    364 HOST_AWK := $(strip $(HOST_AWK))
    365 ifndef HOST_AWK
    366     HOST_AWK := awk
    367 endif
    368 $(call ndk_log,Host 'awk' tool: $(HOST_AWK))
    369 
    370 # Location of all awk scripts we use
    371 BUILD_AWK := $(NDK_ROOT)/build/awk
    372 
    373 AWK_TEST := $(shell $(HOST_AWK) -f $(BUILD_AWK)/check-awk.awk)
    374 $(call ndk_log,Host 'awk' test returned: $(AWK_TEST))
    375 ifneq ($(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.)
    378 endif
    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 #
    405 ifeq ($(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
    433 endif # HOST_OS == cygwin
    434 
    435 # The location of the build system files
    436 BUILD_SYSTEM := $(NDK_ROOT)/build/core
    437 
    438 # Include common definitions
    439 include $(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 #
    457 NDK_PLATFORMS_ROOT := $(strip $(NDK_PLATFORMS_ROOT))
    458 ifndef 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/build-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))
    475 endif
    476 ifeq ($(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)
    480 endif
    481 
    482 NDK_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
    491 NDK_ALL_PLATFORM_LEVELS := $(filter android-%,$(NDK_ALL_PLATFORMS))
    492 NDK_ALL_PLATFORM_LEVELS := $(patsubst android-%,%,$(NDK_ALL_PLATFORM_LEVELS))
    493 $(call ndk_log,Found stable platform levels: $(NDK_ALL_PLATFORM_LEVELS))
    494 
    495 NDK_MAX_PLATFORM_LEVEL := 3
    496 $(foreach level,$(NDK_ALL_PLATFORM_LEVELS),\
    497   $(eval NDK_MAX_PLATFORM_LEVEL := $$(call max,$$(NDK_MAX_PLATFORM_LEVEL),$$(level)))\
    498 )
    499 $(call ndk_log,Found max platform level: $(NDK_MAX_PLATFORM_LEVEL))
    500 
    501 # ====================================================================
    502 #
    503 # Read all toolchain-specific configuration files.
    504 #
    505 # Each toolchain must have a corresponding config.mk file located
    506 # in build/toolchains/<name>/ that will be included here.
    507 #
    508 # Each one of these files should define the following variables:
    509 #   TOOLCHAIN_NAME   toolchain name (e.g. arm-linux-androideabi-4.6)
    510 #   TOOLCHAIN_ABIS   list of target ABIs supported by the toolchain.
    511 #
    512 # Then, it should include $(ADD_TOOLCHAIN) which will perform
    513 # book-keeping for the build system.
    514 #
    515 # ====================================================================
    516 
    517 # the build script to include in each toolchain config.mk
    518 ADD_TOOLCHAIN := $(BUILD_SYSTEM)/add-toolchain.mk
    519 
    520 # the list of known values
    521 NDK_KNOWN_ABIS     := armeabi-v7a armeabi x86 mips
    522 NDK_KNOWN_ARCHS    := arm x86 mips
    523 _archs := $(sort $(strip $(notdir $(wildcard $(NDK_PLATFORMS_ROOT)/android-*/arch-*))))
    524 NDK_FOUND_ARCHS    := $(_archs:arch-%=%)
    525 
    526 # the list of all toolchains in this NDK
    527 NDK_ALL_TOOLCHAINS :=
    528 NDK_ALL_ABIS       :=
    529 NDK_ALL_ARCHS      :=
    530 
    531 TOOLCHAIN_CONFIGS := $(wildcard $(NDK_ROOT)/toolchains/*/config.mk)
    532 $(foreach _config_mk,$(TOOLCHAIN_CONFIGS),\
    533   $(eval include $(BUILD_SYSTEM)/add-toolchain.mk)\
    534 )
    535 
    536 NDK_ALL_TOOLCHAINS   := $(sort $(NDK_ALL_TOOLCHAINS))
    537 NDK_ALL_ABIS         := $(sort $(NDK_ALL_ABIS))
    538 NDK_ALL_ARCHS        := $(sort $(NDK_ALL_ARCHS))
    539 
    540 # Check that each ABI has a single architecture definition
    541 $(foreach _abi,$(strip $(NDK_ALL_ABIS)),\
    542   $(if $(filter-out 1,$(words $(NDK_ABI.$(_abi).arch))),\
    543     $(call __ndk_info,INTERNAL ERROR: The $(_abi) ABI should have exactly one architecture definitions. Found: '$(NDK_ABI.$(_abi).arch)')\
    544     $(call __ndk_error,Aborting...)\
    545   )\
    546 )
    547 
    548 # Allow the user to define NDK_TOOLCHAIN to a custom toolchain name.
    549 # This is normally used when the NDK release comes with several toolchains
    550 # for the same architecture (generally for backwards-compatibility).
    551 #
    552 NDK_TOOLCHAIN := $(strip $(NDK_TOOLCHAIN))
    553 ifdef NDK_TOOLCHAIN
    554     # check that the toolchain name is supported
    555     $(if $(filter-out $(NDK_ALL_TOOLCHAINS),$(NDK_TOOLCHAIN)),\
    556       $(call __ndk_info,NDK_TOOLCHAIN is defined to the unsupported value $(NDK_TOOLCHAIN)) \
    557       $(call __ndk_info,Please use one of the following values: $(NDK_ALL_TOOLCHAINS))\
    558       $(call __ndk_error,Aborting)\
    559     ,)
    560     $(call ndk_log, Using specific toolchain $(NDK_TOOLCHAIN))
    561 endif
    562 
    563 # Allow the user to define NDK_TOOLCHAIN_VERSION to override the toolchain
    564 # version number. Unlike NDK_TOOLCHAIN, this only changes the suffix of
    565 # the toolchain path we're using.
    566 #
    567 # For example, if GCC 4.6 is the default, defining NDK_TOOLCHAIN_VERSION=4.7
    568 # will ensure that ndk-build uses the following toolchains, depending on
    569 # the target architecture:
    570 #
    571 #    arm -> arm-linux-androideabi-4.7
    572 #    x86 -> x86-android-linux-4.7
    573 #    mips -> mipsel-linux-android-4.7
    574 #
    575 # This is used in setup-toolchain.mk
    576 #
    577 NDK_TOOLCHAIN_VERSION := $(strip $(NDK_TOOLCHAIN_VERSION))
    578 
    579 $(call ndk_log, This NDK supports the following target architectures and ABIS:)
    580 $(foreach arch,$(NDK_ALL_ARCHS),\
    581     $(call ndk_log, $(space)$(space)$(arch): $(NDK_ARCH.$(arch).abis))\
    582 )
    583 $(call ndk_log, This NDK supports the following toolchains and target ABIs:)
    584 $(foreach tc,$(NDK_ALL_TOOLCHAINS),\
    585     $(call ndk_log, $(space)$(space)$(tc):  $(NDK_TOOLCHAIN.$(tc).abis))\
    586 )
    587 
    588