use a macro instead of an inline function, so that backtraces will report the caller...
[asterisk-bristuff.git] / build_tools / mkpkgconfig
blobceea7ebc01d3854a5ae49424b546553cdfbd07cf
1 #!/bin/bash
2 PPATH=$1
3 ## Make sure we were called from Makefile
5 if [ "x$ASTERISKVERSIONNUM" = "x" ]; then
6 echo " ** Do not call this script directly"
7 exit
8 fi
10 ## Create a pkgconfig spec file for 3rd party modules (pkg-config asterisk --cflags)
12 if [ ! -d $PPATH ]; then
13 exit
16 #Solaris (and some others) don't have sed -r. perl -p is equivalent
17 if [[ `echo "xxx" | sed -r 's/x/y/g' 2>/dev/null | ${GREP} -c "yyy"` != 0 ]]; then
18 EXTREGEX="sed -r -e"
19 else
20 EXTREGEX="perl -pe"
23 ## Clean out CFLAGS for the spec file.
25 LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/\s*-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
26 ${EXTREGEX} 's/-I(include|\.\.\/include) //g' | \
27 ${EXTREGEX} 's/-DINSTALL_PREFIX=\S* //g' | \
28 ${EXTREGEX} 's/-DASTERISK_VERSION=\S* //g' | \
29 ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'`
32 cat <<EOF > $PPATH/asterisk.pc
33 install_prefix=$INSTALL_PREFIX
34 version_number=$ASTERISKVERSIONNUM
35 etcdir=$ASTETCDIR
36 libdir=$ASTLIBDIR
37 varlibdir=$ASTVARLIBDIR
38 varrundir=$ASTVARRUNDIR
39 spooldir=$ASTSPOOLDIR
40 logdir=$ASTLOGDIR
41 confpath=$ASTCONFPATH
42 moddir=$MODULES_DIR
43 agidir=$AGI_DIR
45 Name: asterisk
46 Description: Open Source PBX and telephony toolkit
47 Version: $ASTERISKVERSION
48 Libs: $LIBS
49 Cflags: $LOCAL_CFLAGS
50 EOF