#!/bin/sh

# this is shamelessly stolen from gnome-config
# and now restolen from gtkmm-config for libicq2000-config
# stealing is wrong, I'm just borrowing it

prefix=/usr/local
exec_prefix=${prefix}

libdir=${exec_prefix}/lib
includedir=${prefix}/include


bindir=${exec_prefix}/bin
pkglibdir=${libdir}/libicq2000
pkgincludedir=${includedir}/libicq2000

CFLAGS="-I${pkgincludedir}"
LIBDIRS="-L${libdir}"

libicq2000_libs="$LIBDIRS -licq2000 -L/usr/local/lib -lsigc -lpthread"
libicq2000_cflags="$CFLAGS -I/usr/local/lib/sigc++-1.0/include -I/usr/local/include/sigc++-1.0"

usage()
{
    cat <<EOF
Usage: libicq2000-config [OPTION]...

Generic options
  --version     output libicq2000 version information
  --help        display this help and exit

Compilation support options
  --cflags      print pre-processor and compiler flags
  --libs        print library linking information
  --libs-only-L only print the -L/-R part of --libs
  --libs-only-l only print the -l part of --libs

EOF

    exit $1
}

if test $# -eq 0; then
    usage 1
fi

cflags=false
libs_L=false
libs_l=false

any=no

while test $# -gt 0; do
    case "$1" in
    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
    *) optarg= ;;
    esac

    case $1 in
    --version)
        echo 0.3.2
        exit 0
        ;;
    --help)
        usage 0
        ;;
    --cflags)
        cflags=true
        ;;
    --libs)
        libs_L=true
        libs_l=true
        ;;
    --libs-only-L)
        libs_L=true
        ;;
    --libs-only-l)
        libs_l=true
        ;;
    *)
        usage 1
        ;;
    esac
    shift
done

output=""

if $cflags; then
    output="$output $libicq2000_cflags"
fi

for i in $libicq2000_libs; do
    case "$i" in
    -l*)
        if $libs | $libs_l; then
	    output="$output $i"
	fi ;;
    -L*|-R*)
        if $libs | $libs_L; then
	    output="$output $i"
	fi ;;
    *)
        output="$output $i" ;;
    esac
done

echo $output

exit 0
