#! /bin/sh
##
## sipxportlib-config
##
## Copyright (C) 2004 SIPfoundry Inc.
## Licensed by SIPfoundry under the LGPL license.
## 
## Copyright (C) 2004, 2005 Pingtel Corp.
## 
## 

Action=PRINT
Info=""

prefix=/usr/local
exec_prefix=@exec_prefix@
includedir=@includedir@
libdir=/usr/local/lib

while [ $# -ne 0 ]
do
    case ${1} in
        --bin)
            Info="${Info} /usr/local/bin"
            ;;

        --include)
            Info="${Info} /usr/local/include"
            ;;

        --lib)
            Info="${Info} /usr/local/lib"
            ;;

        --host)
            Info="${Info} i386-portbld-freebsd6.4"
            ;;

        --version)
            Info="${Info} 3.6.0"
            ;;

        --build)
            Info="${Info} 008527 2008-09-15T20:44:53 freebsd.org"
            ;;

        --conf)
            Info="${Info} /usr/local/etc/sipxpbx"
            ;;

        --data)
            Info="${Info} /usr/local/share/sipxpbx"
            ;;

        --log)
            Info="${Info} /var/log/sipxpbx"
            ;;

        --run)
            Info="${Info} /var/run/sipxpbx"
            ;;

        --db)
            Info="${Info} /var/sipxdata/sipdb"
            ;;

        --all)
            Action=ALL
            break
            ;;

        --configopts)
            Info="${Info}  --enable-sip-tls --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd6.4"
            ;;

        --help)
            Action=USAGE
            break
            ;;

        ##
        ## handle an unknown switch
        ##
        -*)
            echo "Unknown switch '${1}'" 1>&2
            Action=USAGE
            ;;
    esac           

    shift # always consume 1
done

if [ "${Action}" = "PRINT" -a "${Info}" = "" ]
then
    Action=USAGE
fi

case ${Action} in

    USAGE)
        cat <<EOF
Usage: sipxportlib-config [OPTIONS]
 
     Option:      Displays:

    --bin         executable installation directory
    --include     header file installation directory
    --lib         object-code installation directory
    --conf        configuration directory
    --data        run time data directory
    --log         log directory
    --run         pid directory
    --db          database directory
    --host        host information
    --version     version information
    --build       build information

    --all         all of the above, with labels
    --configopts  options passed to the configure script when this was built

    --help        this message
EOF
        exit
        ;;

    PRINT)
        echo ${Info}
        ;;

    ALL)
        cat <<EOF
sipxportlib version  3.6.0
sipxportlib build    008527 2008-09-15T20:44:53 freebsd.org
sipxportlib bin      /usr/local/bin
sipxportlib include  /usr/local/include
sipxportlib lib      /usr/local/lib
sipxportlib host     i386-portbld-freebsd6.4
sipxportlib conf     /usr/local/etc/sipxpbx
sipxportlib data     /usr/local/share/sipxpbx
sipxportlib log      /var/log/sipxpbx
sipxportlib run      /var/run/sipxpbx
sipxportlib db       /var/sipxdata/sipdb
sipxportlib cfgopts   --enable-sip-tls --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd6.4
EOF
        ;;

esac

exit
