#!/bin/sh
# Generated automatically from beepcore-c-config.in by configure.
#
# Copyright (c) 2002 Invisible Worlds, Inc.  All rights reserved.
# 
# The contents of this file are subject to the Blocks Public License (the
# "License"); You may not use this file except in compliance with the License.
# 
# You may obtain a copy of the License at http://www.invisible.net/
# 
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
# for the specific language governing rights and limitations under the
# License.
#
# $Id: beepcore-c-config.in,v 1.1 2002/08/02 01:45:09 cphmit Exp $

set -e

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

PROGRAM_VERSION="0.3"
TARGET_LIBS="-lrt -lpthread -ldl -lnsl -lc"
TARGET_DEFINES="-DLINUX"
SSL_LIBS=""
SSL_INCLUDES=""
CYRUS_LIBS="-lsasl2"
CYRUS_DEFINES="-DCYRUS_SASL"
CYRUS_INCLUDES=""

ECHO_CFLAGS=
ECHO_TLS_CFLAGS=
ECHO_CYRUS_CFLAGS=
ECHO_LIBS=
ECHO_TLS_LIBS=
ECHO_CYRUS_LIBS=

usage ()
{
    cat 1>&2 <<EOF
Usage: beepcore-c-config [OPTIONS]
Options:
    [--version]      print beepcore-c version
    [--cflags]       print flags for compiling against beepcore-c
    [--tls-cflags]   print flags for compiling against TLS profile
    [--cyrus-cflags] print flags for compiling against Cyrus SASLv2 profiles
    [--libs]         print flags for linking to beepcore-c
    [--tls-libs]     print flags for linking to TLS profile
    [--cyrus-libs]   print flags for linking to Cyrus SASLv2 profiles
EOF
    exit 1
}

[ $# -gt 0 ] || usage
while [ $# -gt 0 ]; do
    case "${1}" in
	(--version)
	    echo "${PROGRAM_VERSION}"
	    exit 0
	    ;;
	(--cflags)
	    ECHO_CFLAGS=yes
	    ;;
	(--tls-cflags)
	    ECHO_TLS_CFLAGS=yes
	    ECHO_CFLAGS=yes
	    ;;
	(--cyrus-cflags)
	    ECHO_CYRUS_CFLAGS=yes
	    ECHO_CFLAGS=yes
	    ;;
	(--libs)
	    ECHO_LIBS=yes
	    ;;
	(--tls-libs)
	    ECHO_TLS_LIBS=yes
	    ECHO_LIBS=yes
	    ;;
	(--cyrus-libs)
	    ECHO_CYRUS_LIBS=yes
	    ECHO_LIBS=yes
	    ;;
	(*)
	    usage
	    ;;
    esac
    shift
done

if [ "${ECHO_CFLAGS}" ]; then
    add_cflags ()
    {
	if [ "${1}" ]; then
	    if [ "${CFLAGS_STRING}" ]; then
		CFLAGS_STRING="${CFLAGS_STRING} ${1}"
	    else
		CFLAGS_STRING="${1}"
	    fi
	fi
    }

    CFLAGS_STRING=""
    if [ "${ECHO_TLS_CFLAGS}" ]; then
	add_cflags "${SSL_INCLUDES}"
    fi
    if [ "${ECHO_CYRUS_CFLAGS}" ]; then
	add_cflags "${CYRUS_DEFINES}"
	add_cflags "${CYRUS_INCLUDES}"
    fi
    add_cflags "${TARGET_DEFINES}"

    if [ "${includedir}" != "/usr/include" ]; then
	CFLAGS_STRING="-I${includedir} ${CFLAGS_STRING}"
    fi

    echo "${CFLAGS_STRING}"
fi

if [ "${ECHO_LIBS}" ]; then
    add_libs ()
    {
	if [ "${1}" ]; then
	    if [ "${LIBS_STRING}" ]; then
		LIBS_STRING="${LIBS_STRING} ${1}"
	    else
		LIBS_STRING="${1}"
	    fi
	fi
    }

    LIBS_STRING=""
    if [ "${ECHO_TLS_LIBS}" ]; then
	add_libs "-ltls-profile"
	add_libs "${SSL_LIBS}"
	add_libs "-lssl"
	add_libs "-lcrypto"
    fi
    if [ "${ECHO_CYRUS_LIBS}" ]; then
	add_libs "-lcyrus-profiles"
	add_libs "${CYRUS_LIBS}"
    fi
    add_libs "-lbeepcore-c"
    add_libs "${TARGET_LIBS}"

    if [ "${libdir}" != "/usr/lib" ]; then
	LIBS_STRING="-L${libdir} ${LIBS_STRING}"
    fi

    echo "${LIBS_STRING}"
fi

exit 0
