#!/bin/sh
## This file has been generated by Autoconf from libocc-config.in
## and is part of @PACKAGE@-@VERSION@

TOOLNAME=libocc-config
LIBOCC_LA=libocc.la
prefix=@prefix@			# exec_prefix may need it
exec_prefix=@exec_prefix@	# libdir may need it
libdir=@libdir@
includeddir=@includedir@

SHOW_LIBS=false
SHOW_CFLAGS=false

#
# :WARNING: currently this script should run under any sh(1);
#     thus the '=' sigs in the names of directories passed
#     through options (`--libdir' et. al.) get converted to spaces;
#     There is no easy workaround (although it is trivial in bash(1))
#

help() {
cat << END
Usage: $TOOLNAME [OPTION]...

  --help                  print this message
  --version               print the version of OpenC++ library
  --libs                  print the linker flags that are necessary to link
                          with libocc.a
  --cflags                print C flags that are necessary when including
                          OpenC++ headers
  --prefix=PREFIX         use PREFIX instead of the installation prefix 
                          when computing the output for --libs
  --exec-prefix=EPREFIX   use EPREFIX instead of the installation exec-prefix 
                          when computing the output for --libs
  --libdir=DIR            use DIR instead of the installation libdir 
                          of OpenC++ build when computing the output 
                          for --libs

Instead of using \`$TOOLNAME' you may want to use GNU Libtool to link
with OpenC++ library. Libtool abstracts away from the details of 
linker switches, it also takes care of library dependencies and building 
shared libraries on many architectures.
END
}

if test :$1: = ::; then 
    help
    exit
fi

while test :$1: != ::; do
    case $1 in
        --help)
            help
            exit
            ;;
        
        --version)
            echo @VERSION@
            exit
        ;;

        --prefix=*)
	    prefix="`echo $1 | (IFS='='; read SWITCH ARG; echo $ARG)`"
	    libdir=$prefix/lib
	    includedir=$prefix/include
            ;;
        	
        --exec-prefix=*)
            prefix="`echo $1 | (IFS='='; read SWITCH ARG; echo $ARG)`"/lib
	    libdir=$prefix/lib
            ;;
        	
        --libdir=*)
            libdir="`echo $1 | (IFS='='; read SWITCH ARG; echo $ARG)`"
            ;;

        --includedir=*)
            includedir="`echo $1 | (IFS='='; read SWITCH ARG; echo $ARG)`"
            ;;

        --libs)
            SHOW_LIBS=true
        ;;

        --cflags)
            SHOW_CFLAGS=true
        ;;

        *)
            help
            exit 1
        ;;
    esac
    shift
done

if test "$SHOW_LIBS" = true; then
    QUALIFIED_LIBOCC_LA=$libdir/$LIBOCC_LA
    if test -f "$QUALIFIED_LIBOCC_LA"; then
        echo -L$libdir -locc `. "$QUALIFIED_LIBOCC_LA"; echo $dependency_libs` 
    else
        echo "$TOOLNAME: cannot find $LIBOCC_LA in $libdir"
        echo "$TOOLNAME: fix paths, reinstall or use \`--libdir'"
        exit 1
    fi
fi

if test "$SHOW_CFLAGS" = true; then
    echo -I$includeddir/opencxx
fi
