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