#!/bin/sh
#
#   A script for retrieving the latest kvirc build configuration
#   Mainly used for building plugins out of the source tree
#   The idea is "stolen" from the gtk-config and xmms-config scripts :)
#
#
#   09-04-2000 Szymon Stefanek (Initial release)
#   31-01-2002 Szymon Stefanek (Revised for KVIrc 3.0.0)
#   27-07-2002 Szymon Stefanek (Revised again for KVIrc 3.0.0)
#   01-06-2007 Szymon Stefanek (Revised for SST)
#   ??-10-2007 Szymon Stefanek (Revised for Humor)
#   14-04-2008 CtrlAltCa (adapted to cmake branch)
#
#   This program is FREE software. You can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your opinion) any later version.
#
#   This program is distributed in the HOPE that it will be USEFUL,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#   See the GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program. If not, write to the Free Software Foundation,
#   Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

set -e

print_syntax()
{
	echo "kvirc4-config (KVIrc 4.0.0)"
	echo "	A script for retrieving the latest KVIrc build configuration"
	echo ""
	echo "Syntax : kvirc4-config [OPTIONS]"
	echo "  options:"
	echo "    --version         : Version of the KVIrc toolkit."
	echo "    --prefix          : The prefix where KVIrc was installed."
	echo "    --includedirs     : The include directories you should use to compile stuff with KVIrc."
	echo "    --includeflags    : The include directories above with -I prepended."
	echo "    --librarydirs     : The library directories you should use to compile stuff with KVIrc."
	echo "    --libraries       : The libraries you should use to compile stuff with KVIrc."
	echo "    --libraryflags    : The library directories above with -L prepended "
	echo "                        and the libraries above with -l prepended."
	exit 0
}

if test $# -eq 0; then
	print_syntax 1 1>&2
fi

KVIRC_STUFF_TO_ECHO=""

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

	LIBS="-lpthread;/usr/lib64/libz.so;optimized;/usr/lib64/libQtWebKit.so;debug;/usr/lib64/libQtWebKit.so;optimized;/usr/lib64/libQtGui.so;debug;/usr/lib64/libQtGui.so;/usr/lib64/libpng.so;/usr/lib64/libSM.so;/usr/lib64/libICE.so;/usr/lib64/libXrender.so;/usr/lib64/libfreetype.so;/usr/lib64/libfontconfig.so;/usr/lib64/libXext.so;/usr/lib64/libX11.so;/usr/lib64/libm.so;optimized;/usr/lib64/libQtDBus.so;debug;/usr/lib64/libQtDBus.so;/usr/lib64/libdbus-1.so;optimized;/usr/lib64/libQtXml.so;debug;/usr/lib64/libQtXml.so;optimized;/usr/lib64/libQtSql.so;debug;/usr/lib64/libQtSql.so;optimized;/usr/lib64/libQtNetwork.so;debug;/usr/lib64/libQtNetwork.so;/usr/lib64/libssl.so;optimized;/usr/lib64/libQtCore.so;debug;/usr/lib64/libQtCore.so;/usr/lib64/libz.so;/usr/lib64/libgthread-2.0.so;/usr/lib64/libglib-2.0.so;/usr/lib64/librt.so;-lpthread;-ldl;/usr/lib64/libSM.so;/usr/lib64/libICE.so;/usr/lib64/libX11.so;/usr/lib64/libXext.so;/usr/lib64/libphonon.so;KDE4__kdecore;KDE4__kdeui;KDE4__kparts;KDE4__kfile;KDE4__kio;/usr/lib64/libssl.so;-lcrypto"
	LIBS="${LIBS//;/ }"

	case $1 in
		--version)
		KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO 4.0.0"
		;;
		--prefix)
		KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO "
		;;
		--includedirs)
		KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO "
		;;
		--includeflags)
		for d in ; do
			KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO -I$d"
		done
		;;
		--librarydirs)
		KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO "
		;;
		--libraries)
		KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO ${LIBS}"
		;;
		--libraryflags)
		for d in ; do
			KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO -L$d"
		done
		for d in ${LIBS}; do
			KVIRC_STUFF_TO_ECHO="$KVIRC_STUFF_TO_ECHO -l$d"
		done
		;;
		*)
		print_syntax 1 1>&2
		;;
	esac
	shift
done

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