# # $Id: pkgconfig.in,v 1.2 2003/10/04 15:07:59 jmmv Exp $ # Handle pkgconfig files. # # buildtool # Copyright (c) 2003 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. # global PKG_CONFIG_PATH global pc_file global pc_cflags pc_descr pc_libs pc_name pc_version pkgconfig_open() { local pkgname=$1 local d dirs [ -n "${pc_file}" ] && btcmn_err "pkgconfig file already opened" pc_file= pc_cflags= pc_descr= pc_libs= pc_name= pc_version= dirs=$(echo ${PKG_CONFIG_PATH}:@DIR_PKGCONFIG@ | tr : ' ') for d in ${dirs}; do if [ -f ${d}/${pkgname}.pc ]; then pc_file=${d}/${pkgname}.pc pc_name=${pkgname} pkgconfig_cnvt_read return 0 fi done return 1 } pkgconfig_cnvt_read() { local tmp=/tmp/bt_pkgflags-pc.$$ local Cflags= Description= Libs= Name= Version= local Requires= egrep -v '^$' ${pc_file} | sed -e 's|=|="|' -e 's|: |="|' -e 's|:$|="|' \ -e 's|$|"|' > ${tmp} set +w . ${tmp} set -w rm -f ${tmp} pc_cflags=${Cflags} pc_descr=${Description} pc_libs=${Libs} pc_name=${Name} pc_version=${Version} } pkgconfig_close() { [ -z "${pc_file}" ] && btcmn_err "no pkgconfig file currently opened" pc_file= } pkgconfig_get_cflags() { echo ${pc_cflags} } pkgconfig_get_libs() { echo ${pc_libs} } pkgconfig_get_name() { echo ${pc_name} } pkgconfig_get_version() { echo ${pc_version} } # Local Variables: *** # mode: shell-script *** # End: *** # vim: syntax=sh