Merged revisions 220099 via svnmerge from
[asterisk/asterisk.git] / build_tools / mkpkgconfig
index bc04f75..522afba 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 PPATH=$1
 ## Make sure we were called from Makefile
 
@@ -13,13 +13,20 @@ 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
+    EXTREGEX="sed -r -e"
+else
+    EXTREGEX="perl -pe"
+fi
+
 ## Clean out CFLAGS for the spec file.
 
-LOCAL_CFLAGS=`echo $CFLAGS | sed -e 's/[[:space:]]*-pipe[[:space:]]*//g' | sed -e 's/-[Wmp][^[:space:]]*[[:space:]]*//g' | \
-  sed -e 's/-I\(include|\.\.\/include\) //g' | \
-  sed -e 's/-DINSTALL_PREFIX=[^[:space:]]* //g' | \
-  sed -e 's/-DASTERISK_VERSION=[^[:space:]]* //g' | \
-  sed -e 's/-DAST\(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR\)=[^[:space:]]* //g'`
+LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/\s*-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
+  ${EXTREGEX} 's/-I(include|\.\.\/include) //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'`
 
 
 cat <<EOF > $PPATH/asterisk.pc