#!/bin/sh
# ====================================================================
# Copyright (c) 2000-2004 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================

# SVN script designed to allow easy command line access to SVN
# configuration parameters.

prefix="/usr"
exec_prefix="/usr"
bindir="/usr/bin"
libdir="/usr/lib"
includedir="/usr/include"

LIBS="-lneon -lz -lssl -lcrypto -ldl -lxml2 -lz -lpthread -lm  -L/usr/lib -laprutil-0   -lgdbm -ldb -lexpat  -L/usr/lib -lapr-0 -lrt -lm -lcrypt -lnsl  -ldl @SVN_DB_LIBS@ "
CFLAGS="-O2 -fomit-frame-pointer -pipe -march=i586 -mcpu=pentiumpro    -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread  -DNEON_ZLIB -DNEON_SSL"
CPPFLAGS="  -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE"
INCLUDES="-I/usr/include/neon   @SVN_DB_INCLUDES@  -I/usr/include/apache2   -I/usr/include/apache2 "
LDFLAGS="    -L/usr/lib"

SVN_SOURCE_DIR="/home/ben/rpm/BUILD/subversion-1.0.1"
SVN_BUILD_DIR="/home/ben/rpm/BUILD/subversion-1.0.1"

show_usage()
{
    cat << EOF
Usage: svn-config [OPTION]

Known values for OPTION are:
  --prefix[=DIR]    change prefix to DIR
  --cflags          print C compiler flags
  --cppflags        print cpp flags
  --includes        print include information
  --ldflags         print linker flags
  --libs            print library information
  --srcdir          print SVN source directory
  --link-ld         [NOT IMPL] print link switch(es) for linking to SVN
  --link-libtool    [NOT IMPL] print the libtool inputs for linking to SVN
  --help            print this help

When linking with libtool, an application should do something like:
  SVN_LIBS="\`svn-config --link-libtool --libs\`"
or when linking directly:
  SVN_LIBS="\`svn-config --link-ld --libs\`"

An application should use the results of --cflags, --cppflags, --includes,
and --ldflags in their build process.
EOF
}

if test $# -eq 0; then
    show_usage
    exit 1
fi

thisdir="`dirname $0`"
thisdir="`cd $thisdir && pwd`"
if test -d $bindir; then
  tmpbindir="`cd $bindir && pwd`"
else
  tmpbindir=""
fi
if test "$tmpbindir" = "$thisdir"; then
  location=installed
elif test "$SVN_SOURCE_DIR" = "$thisdir"; then
  location=source
else
  location=build
fi

flags=""

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

    case "$1" in
    # It is possible for the user to override our prefix.
    --prefix=*)
    prefix=$optarg
    ;;
    --prefix)
    echo $prefix
    exit 0
    ;;
    --cflags)
    flags="$flags $CFLAGS"
    ;;
    --cppflags)
    flags="$flags $CPPFLAGS"
    ;;
    --libs)
    flags="$flags $LIBS"
    ;;
    --includes)
    if test "$location" = "installed"; then
        flags="$flags -I$includedir/subversion-1 $INCLUDES"
    elif test "$location" = "source"; then
        flags="$flags -I$SVN_SOURCE_DIR/include $INCLUDES"
    else
        flags="$flags -I$thisdir/include -I$SVN_SOURCE_DIR/include $INCLUDES"
    fi
    ;;
    --ldflags)
    flags="$flags $LDFLAGS"
    ;;
    --srcdir)
    echo $SVN_SOURCE_DIR
    exit 0
    ;;
    --help)
    show_usage
    exit 0
    ;;
    *)
    show_usage
    exit 1
    ;;
    esac

    # Next please.
    shift
done

if test -n "$flags"; then
  echo "$flags"
fi

exit 0
