#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# Filename: package/.../heimdal/parse-config
# Copyright (C) 2006 The OpenSDE Project
# Copyright (C) 2004 - 2006 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# 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; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

if pkginstalled -f heimdal; then

	pkgprefix -t heimdal
	KRB5PREFIX=$root/$( pkgprefix heimdal )
	KRB5INC=$root$( pkgprefix includedir heimdal )
	KRB5LIB=$root$( pkgprefix libdir heimdal )

	# Set up an environment variable to point to the package
	# config file.
	KRB5_CONFIG=$root$( pkgprefix bindir heimdal )/krb5-config
	export KRB5_CONFIG

	# config tweaks
	case "$pkg" in
		postgresql)
			# packages 'sensitive' to the massive enabling
			var_append extraconfopt " " "--with-krb5"	;;
		*)	# massive enabling of heimdal support

			# prefix-less
			var_append extraconfopt " " "--with-kerberos"	#This usually supports 4 only
			#var_append extraconfopt " " "--with-krb4"	#4 Only and not recommended
			var_append extraconfopt " " "--with-gss"	#From mutt

			# prefix-based
			var_append extraconfopt " " "--with-krb5${KRB5PREFIX:+=$KRB5PREFIX}"		#From nfs-utils
			var_append extraconfopt " " "--with-kerberos5${KRB5PREFIX:+=$KRB5PREFIX}"	#From openssh and fetchmail
			var_append extraconfopt " " "--enable-gssapi${KRB5PREFIX:+=$KRB5PREFIX}"	#From cyrus-sasl2

			var_append extraconfopt " " "--with-krb5-includes${KRB5INC:+=$KRB5INC}" 	#From evolution-data-server
			var_append extraconfopt " " "--with-krb5-libs${KRB5LIB:+=$KRB5LIB}"		#From evolution-data-server

			var_append extraconfopt " " "--with-gssapi-includes${KRB5INC:+=$KRB5INC}"	#From curl
			var_append extraconfopt " " "--with-gssapi-libs${KRB5LIB:+=$KRB5LIB}"		#From curl

			# and well known mandatory dependencies
			var_append extraconfopt " " "--with-ssl"        #from ethereal 

			;;
	esac

	# make tweaks
	case "$pkg" in
		emacs)
			var_append GCC_WRAPPER_APPEND " " "-I$KRB5INC"
			var_append GCC_WRAPPER_APPEND " " "-L$KRB5LIB"
			;;
		cvs|curl|openssh|postgresql)
			KRB5LIBS="`krb5-config --libs gssapi` -lhdb -lkadm5clnt -lkadm5srv"
			KRB5CFLAGS=`krb5-config --cflags gssapi`

			var_append CPP_wRAPPER_APPEND ' ' "$KRB5CFLAGS"

			for x in CXX GCC; do
				var_append ${x}_WRAPPER_APPEND ' ' "$KRB5CFLAGS"
				var_append ${x}_WRAPPER_APPEND ' ' "$KRB5LIBS"
			done

			unset KRB5LIBS KRB5CFLAGS
		;;
	esac

	# and clean the enviroment
	unset KRB5PREFIX KRB5INC KRB5LIB
fi