# # $Id: convert.subr.in,v 1.14 2004/05/08 12:41:27 jmmv Exp $ # Convert type specification. # # buildtool # Copyright (c) 2003, 2004 Julio M. Merino Vidal. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of the author nor the names of contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # BT_TARGET_DEFS+=BT_CONVERT_FUNC BT_TARGET_DEFS+="BT_FROM_NAME BT_TO_NAME" BT_TARGET_DEFS+="BT_FROM_SUFFIX BT_TO_SUFFIX" BT_CONVERT_SUFFIXES+=".c .cc .cpp .o .po" convert_defs() { local target="${1}" local sfx tmp if [ -z "${BT_TO_SUFFIX}" ]; then for sfx in ${BT_CONVERT_SUFFIXES}; do if [ ${target%%${sfx}} '<' ${target} ]; then BT_TO_NAME=${target} BT_TO_SUFFIX=${sfx} break fi done [ -n "${BT_TO_SUFFIX}" ] || \ btcmn_err "cannot determine \`to' suffix of \`${target}'" fi if [ -z "${BT_FROM_SUFFIX}" ]; then tmp=${target%%${BT_TO_SUFFIX}} for sfx in ${BT_CONVERT_SUFFIXES}; do if [ -f ${BT_SRCDIR}/${tmp}${sfx} ]; then BT_FROM_NAME=${BT_SRCDIR}/${tmp}${sfx} BT_FROM_SUFFIX=${sfx} break fi done [ -n "${BT_FROM_SUFFIX}" ] || \ btcmn_err "cannot determine \`from' suffix of \`${target}'" \ "(maybe the source file is missing?)" fi BT_CONVERT_FUNC="convert_${BT_FROM_SUFFIX}_${BT_TO_SUFFIX}" if ! isfunc ${BT_CONVERT_FUNC}; then btcmn_warn "no function to convert from \`${BT_FROM_SUFFIX}' to \`${BT_TO_SUFFIX}'" # NOLINT fi } convert_build() { ${BT_CONVERT_FUNC} ${BT_FROM_NAME} ${BT_TO_NAME} } convert_.c_.o() { bt_compile_c ${BT_FLAGS_CPP} ${BT_FLAGS_CC} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_.cc_.o() { bt_compile_cxx ${BT_FLAGS_CPP} ${BT_FLAGS_CXX} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_.cpp_.o() { bt_compile_cxx ${BT_FLAGS_CPP} ${BT_FLAGS_CXX} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_.c_.po() { bt_compile_c ${BT_FLAGS_CPP} ${BT_FLAGS_CC} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_.cc_.po() { bt_compile_cxx ${BT_FLAGS_CPP} ${BT_FLAGS_CXX} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_.cpp_.po() { bt_compile_cxx ${BT_FLAGS_CPP} ${BT_FLAGS_CXX} -c ${BT_FROM_NAME} \ -o ${BT_TO_NAME} } convert_clean() { bt_remove ${BT_TO_NAME} } # Local Variables: *** # mode: shell-script *** # End: *** # vim: syntax=sh