1# Copyright (C) 2009 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# this script is included repeatedly by main.mk to add a new toolchain 17# definition to the NDK build system. 18# 19# '_config_mk' must be defined as the path of a toolchain 20# configuration file (config.mk) that will be included here. 21# 22$(call assert-defined, _config_mk) 23 24# The list of variables that must or may be defined 25# by the toolchain configuration file 26# 27NDK_TOOLCHAIN_VARS_REQUIRED := TOOLCHAIN_ABIS TOOLCHAIN_ARCH 28NDK_TOOLCHAIN_VARS_OPTIONAL := 29 30# Clear variables that are supposed to be defined by the config file 31$(call clear-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED)) 32$(call clear-vars,$(NDK_TOOLCHAIN_VARS_OPTIONAL)) 33 34# Include the config file 35include $(_config_mk) 36 37# Check that the proper variables were defined 38$(call check-required-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED),$(_config_mk)) 39 40# Check that the file didn't do something stupid 41$(call assert-defined, _config_mk) 42 43# Now record the toolchain-specific information 44_dir := $(patsubst %/,%,$(dir $(_config_mk))) 45_name := $(notdir $(_dir)) 46_arch := $(TOOLCHAIN_ARCH) 47_abis := $(TOOLCHAIN_ABIS) 48 49_toolchain := NDK_TOOLCHAIN.$(_name) 50 51# check that the toolchain name is unique 52$(if $(strip $($(_toolchain).defined)),\ 53 $(call __ndk_error,Toolchain $(_name) defined in $(_parent) is\ 54 already defined in $(NDK_TOOLCHAIN.$(_name).defined))) 55 56$(_toolchain).defined := $(_toolchain_config) 57$(_toolchain).arch := $(_arch) 58$(_toolchain).abis := $(_abis) 59$(_toolchain).setup := $(wildcard $(_dir)/setup.mk) 60 61$(if $(strip $($(_toolchain).setup)),,\ 62 $(call __ndk_error, Toolchain $(_name) lacks a setup.mk in $(_dir))) 63 64NDK_ALL_TOOLCHAINS += $(_name) 65NDK_ALL_ARCHS += $(_arch) 66NDK_ALL_ABIS += $(_abis) 67 68# NDK_ABI.<abi>.toolchains records the list of toolchains that support 69# a given ABI 70# 71$(foreach _abi,$(_abis),\ 72 $(eval NDK_ABI.$(_abi).toolchains += $(_name)) \ 73 $(eval NDK_ABI.$(_abi).arch := $(sort $(NDK_ABI.$(_abi).arch) $(_arch)))\ 74) 75 76NDK_ARCH.$(_arch).toolchains += $(_name) 77NDK_ARCH.$(_arch).abis := $(sort $(NDK_ARCH.$(_arch).abis) $(_abis)) 78 79# done 80