#!/bin/sh # Defaults output=sconfig.mk conf=sconfig.conf me=`basename $0` prev= for option; do if test -n "$prev"; then eval "$prev=\$option" prev= continue fi optarg=`expr "x$option" : 'x[^=]*=\(.*\)'` optsub=`expr substr "$option" 3 length "$option"` case $option in --conf | -c) prev=conf ;; --conf=*) conf=$optarg ;; -c*) conf=$optsub ;; --output | -o) prev=output ;; --output=*) output=$optarg ;; -o*) output=$optsub ;; --help) echo "This file should be called from a makefile." exit 0 ;; -*) echo "$me: error: unrecognized option: $option Try \`$0 --help' for more information." >&2 exit 1 ;; esac done cppflags="$CPPFLAGS" ldflags="$LDFLAGS" function error() { msg=$1; code=3; if test $# -ge 2; then code=$2 fi echo $msg >&2 exit $code } function usepkg() { cppflags="$cppflags `pkg-config --cflags $1`" test $? -gt 0 && error "Could not find package: '$1'" ldflags="$ldflags `pkg-config --libs $1`" } includes='/usr/include /usr/local/include' function uselib() { lib=$1 header=$1.h if test $# -ge 2; then header=$2 fi newcppflags= for dir in $includes; do if test -f $dir/$header; then newcppflags="-I$dir" break fi done if test -z "$newcppflags"; then error "Could not find library: '$lib'" fi if test "$newcppflags" != '-I/usr/include'; then cppflags="$cppflags $newcppflags" fi ldflags="$ldflags -l$lib" } source $conf rm -rf $output cat >$output <