# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # # Author: Hanno Meyer-Thurow # Purpose: Serve paths to boost libraries & headers # inherit flag-o-matic multilib # add_boost_library_path # # one paramater: boost version # # ex: add_boost_library_path 1_42 add_boost_library_path() { local path="$(check_boost_library_path ${*})" if [ "${path}" ] ; then append-ldflags "-L${path}" else die "path not found!" fi } # add_boost_include_path # # one paramater: boost version # # ex: add_boost_include_path 1_42 add_boost_include_path() { local path="$(check_boost_include_path ${*})" if [ "${path}" ] ; then append-cxxflags "-I${path}" else die "path not found!" fi } # add_boost_paths: convenient wrapper # # one parameter optionally: boost version # # ex: add_boost_paths # ex: add_boost_paths 139 # ex: add_boost_paths =139 # ex: add_boost_paths <139 # ex: add_boost_paths >139 add_boost_paths() { # required for analyse local BV # analyse _boost_analyse ${*} add_boost_include_path ${BV} add_boost_library_path ${BV} } # check_boost_library_path # # one paramater: boost version # # return value: library path to boost version # # ex: check_boost_library_path 1_42 check_boost_library_path() { [[ ${#} -eq 1 ]] || die "pass only one paramater!" local path="/usr/$(get_libdir)/boost-${1}" [ -d "${path}" ] && echo -n "${path}" } # check_boost_include_path # # one paramater: boost version # # return value: include path to boost version # # ex: check_boost_include_path 1_42 check_boost_include_path() { [[ ${#} -eq 1 ]] || die "pass only one paramater!" local path="/usr/include/boost-${1}" [ -d "${path}" ] && echo -n "${path}" } # check_boost_paths: convenient wrapper # # one parameter optionally: boost version # # ex: check_boost_paths # ex: check_boost_paths 139 # ex: check_boost_paths =139 # ex: check_boost_paths <139 # ex: check_boost_paths >139 check_boost_paths() { # required for analyse local BV # analyse _boost_analyse ${*} # check include path check_boost_include_path ${BV} >/dev/null [[ ${?} -eq 0 ]] || die "include path to boost version ${BV} not found!" # check library path check_boost_library_path ${BV} >/dev/null [[ ${?} -eq 0 ]] || die "library path to boost version ${BV} not found!" } # helper functions # return value is written to "global" variable 'BV'! _boost_analyse() { # type to compare local type= # boost version local boost_version=0 local final_version=0 [[ ${#} -gt 1 ]] && die "too many parameters given!" # analyse paramter if [[ ${#} -eq 1 ]] ; then if [[ ${#1} == 3 ]] ; then type='>' # this even converts characters to integer value # - guess the results then ;) (( boost_version = ${1} )) elif [[ ${#1} == 4 ]] ; then type=${1:0:1} (( boost_version = ${1:1} )) else die "bad parameter given!" fi fi for b in $(ls -d -1 /usr/include/boost-*) ; do # version local version="${b: -4:4}" # strip underscore local stripversion="${version/_}" # test local found= [[ ${type} == '>' ]] && found="$(_boost_gt ${stripversion} ${boost_version})" [[ ${type} == '=' ]] && found="$(_boost_eq ${stripversion} ${boost_version})" [[ ${type} == '<' ]] && found="$(_boost_lt ${stripversion} ${boost_version})" if [ "${found}" ] ; then boost_version=${stripversion} final_version=${version} fi done [[ ${boost_version} -eq 0 ]] && die "no boost found!" einfo "found boost version ${final_version}" # write return value into "global" variable BV="${final_version}" } _boost_gt() { [[ ${1} -gt ${2} ]] \ && echo -n 1 \ || echo -n 0 } _boost_eq() { [[ ${1} -eq ${2} ]] \ && echo -n 1 \ || echo -n 0 } _boost_lt() { [[ ${1} -lt ${2} ]] \ && echo -n 1 \ || echo -n 0 }