Merge "pjproject: Add cache_pools debugging option."
[asterisk/asterisk.git] / build_tools / mkpkgconfig
index ceea7eb..9d29b9e 100755 (executable)
@@ -1,5 +1,6 @@
-#!/bin/bash
-PPATH=$1
+#!/bin/sh
+PPATH="$1"
+GREP=${GREP:-grep}
 ## Make sure we were called from Makefile
 
 if [ "x$ASTERISKVERSIONNUM" = "x" ]; then
@@ -9,27 +10,26 @@ fi
 
 ## Create a pkgconfig spec file for 3rd party modules (pkg-config asterisk --cflags)
 
-if [ ! -d $PPATH ]; then
+if [ ! -d "$PPATH" ]; then
   exit
 fi
 
 #Solaris (and some others) don't have sed -r.  perl -p is equivalent
-if [[ `echo "xxx" | sed -r 's/x/y/g' 2>/dev/null | ${GREP} -c "yyy"` != 0 ]]; then
+if [ `echo "xxx" | sed -r 's/x/y/g' 2>/dev/null | ${GREP} -c "yyy"` != 0 ]; then
     EXTREGEX="sed -r -e"
 else
     EXTREGEX="perl -pe"
 fi
 
 ## Clean out CFLAGS for the spec file.
-
-LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/\s*-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
-  ${EXTREGEX} 's/-I(include|\.\.\/include) //g' | \
+LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
+  ${EXTREGEX} 's/\s+-I(include|\.\.\/include)\s+/ /g' | \
   ${EXTREGEX} 's/-DINSTALL_PREFIX=\S* //g' | \
   ${EXTREGEX} 's/-DASTERISK_VERSION=\S* //g' | \
-  ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'`
-
+  ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g' | \
+  ${EXTREGEX} 's/^\s|\s$//g'`
 
-cat <<EOF > $PPATH/asterisk.pc
+cat <<EOF > "$PPATH/asterisk.pc"
 install_prefix=$INSTALL_PREFIX
 version_number=$ASTERISKVERSIONNUM
 etcdir=$ASTETCDIR
@@ -39,7 +39,7 @@ varrundir=$ASTVARRUNDIR
 spooldir=$ASTSPOOLDIR
 logdir=$ASTLOGDIR
 confpath=$ASTCONFPATH
-moddir=$MODULES_DIR
+moddir=$ASTMODDIR
 agidir=$AGI_DIR
 
 Name: asterisk