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# Plug in the undefined 38ifeq ($(TOOLCHAIN_ABIS)$(TOOLCHAIN_ARCH),) 39ifeq (1,$(words $(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)))) 40TOOLCHAIN_ARCH := $(filter-out $(NDK_KNOWN_ARCHS),$(NDK_FOUND_ARCHS)) 41TOOLCHAIN_ABIS := $(TOOLCHAIN_ARCH) $(NDK_KNOWN_ABIS:%=$(TOOLCHAIN_ARCH)%) $(NDK_KNOWN_ABIS:%=$(TOOLCHAIN_ARCH)bc%) 42endif 43endif 44 45ifeq ($(TOOLCHAIN_ABIS)$(TOOLCHAIN_ARCH),) 46# Ignore if both TOOLCHAIN_ABIS and TOOLCHAIN_ARCH are not defined 47else 48 49# Check that the proper variables were defined 50$(call check-required-vars,$(NDK_TOOLCHAIN_VARS_REQUIRED),$(_config_mk)) 51 52# Check that the file didn't do something stupid 53$(call assert-defined, _config_mk) 54 55# Now record the toolchain-specific information 56_dir := $(patsubst %/,%,$(dir $(_config_mk))) 57_name := $(notdir $(_dir)) 58_arch := $(TOOLCHAIN_ARCH) 59_abis := $(TOOLCHAIN_ABIS) 60 61_toolchain := NDK_TOOLCHAIN.$(_name) 62 63# check that the toolchain name is unique 64$(if $(strip $($(_toolchain).defined)),\ 65 $(call __ndk_error,Toolchain $(_name) defined in $(_parent) is\ 66 already defined in $(NDK_TOOLCHAIN.$(_name).defined))) 67 68$(_toolchain).defined := $(_toolchain_config) 69$(_toolchain).arch := $(_arch) 70$(_toolchain).abis := $(_abis) 71$(_toolchain).setup := $(wildcard $(_dir)/setup.mk) 72 73$(if $(strip $($(_toolchain).setup)),,\ 74 $(call __ndk_error, Toolchain $(_name) lacks a setup.mk in $(_dir))) 75 76NDK_ALL_TOOLCHAINS += $(_name) 77NDK_ALL_ARCHS += $(_arch) 78NDK_ALL_ABIS += $(_abis) 79 80# NDK_ABI.<abi>.toolchains records the list of toolchains that support 81# a given ABI 82# 83$(foreach _abi,$(_abis),\ 84 $(eval NDK_ABI.$(_abi).toolchains += $(_name)) \ 85 $(eval NDK_ABI.$(_abi).arch := $(sort $(NDK_ABI.$(_abi).arch) $(_arch)))\ 86) 87 88NDK_ARCH.$(_arch).toolchains += $(_name) 89NDK_ARCH.$(_arch).abis := $(sort $(NDK_ARCH.$(_arch).abis) $(_abis)) 90 91endif 92 93# done 94