175af46c2Stedu#!/bin/sh 275af46c2Stedu# 3*5cbc9e81Sjasper# $OpenBSD: generate_pkgconfig.sh,v 1.2 2013/06/15 11:40:56 jasper Exp $ 475af46c2Stedu# 575af46c2Stedu# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <jasper@openbsd.org> 675af46c2Stedu# 775af46c2Stedu# Permission to use, copy, modify, and distribute this software for any 875af46c2Stedu# purpose with or without fee is hereby granted, provided that the above 975af46c2Stedu# copyright notice and this permission notice appear in all copies. 1075af46c2Stedu# 1175af46c2Stedu# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1275af46c2Stedu# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1375af46c2Stedu# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1475af46c2Stedu# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1575af46c2Stedu# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1675af46c2Stedu# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1775af46c2Stedu# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1875af46c2Stedu# 19*5cbc9e81Sjasper# Generate pkg-config file for fuse 2075af46c2Stedu 2175af46c2Steduusage() { 2275af46c2Stedu echo "usage: ${0##*/} -c current_directory -o obj_directory" 2375af46c2Stedu exit 1 2475af46c2Stedu} 2575af46c2Stedu 2675af46c2Steducurdir= 2775af46c2Steduobjdir= 2875af46c2Steduwhile getopts "c:o:" flag; do 2975af46c2Stedu case "$flag" in 3075af46c2Stedu c) 3175af46c2Stedu curdir=$OPTARG 3275af46c2Stedu ;; 3375af46c2Stedu o) 3475af46c2Stedu objdir=$OPTARG 3575af46c2Stedu ;; 3675af46c2Stedu *) 3775af46c2Stedu usage 3875af46c2Stedu ;; 3975af46c2Stedu esac 4075af46c2Stedudone 4175af46c2Stedu 4275af46c2Stedu[ -n "${curdir}" ] || usage 4375af46c2Steduif [ ! -d "${curdir}" ]; then 4475af46c2Stedu echo "${0##*/}: ${curdir}: not found" 4575af46c2Stedu exit 1 4675af46c2Stedufi 4775af46c2Stedu[ -n "${objdir}" ] || usage 4875af46c2Steduif [ ! -w "${objdir}" ]; then 4975af46c2Stedu echo "${0##*/}: ${objdir}: not found or not writable" 5075af46c2Stedu exit 1 5175af46c2Stedufi 5275af46c2Stedu 5375af46c2Steduversion_re="s/^#define[[:blank:]]+FUSE_VERSION_PKG_INFO[[:blank:]]+\"(.*)\".*/\1/p" 5475af46c2Steduversion_file=${curdir}/fuse_private.h 5575af46c2Stedulib_version=$(sed -nE ${version_re} ${version_file}) 5675af46c2Stedu 5775af46c2Stedupc_file="${objdir}/fuse.pc" 5875af46c2Steducat > ${pc_file} << __EOF__ 5975af46c2Steduprefix=/usr 6075af46c2Steduexec_prefix=\${prefix} 6175af46c2Stedulibdir=\${exec_prefix}/lib 6275af46c2Steduincludedir=\${prefix}/include 6375af46c2Stedu 6475af46c2SteduName: fuse 6575af46c2SteduDescription: fuse filesystem library 6675af46c2SteduVersion: ${lib_version} 6775af46c2SteduRequires: 6875af46c2SteduLibs: -L\${libdir} -lfuse 6975af46c2SteduCflags: -I\${includedir} 7075af46c2Stedu__EOF__ 71