#!/bin/sh -
#
# /usr/bin/wx-config
#
#  a lame wx-config wrapper (bugs to wxwidgets@gentoo.org)

EPREFIX=''
LIBDIR="lib64"

_wxerror() {
	cat >&2 <<- EOF
		An error occurred while calling wx-config:
		
		${1}

		Please use \`eselect wxwidgets\` to select an available profile and try again.
	EOF
	exit 1
}

if [ -n "${WX_ECLASS_CONFIG}" ]; then
	exec "${WX_ECLASS_CONFIG}" "$@"
else
	if [ -e "${EPREFIX}"/var/lib/wxwidgets/current ]; then
		. "${EPREFIX}"/var/lib/wxwidgets/current
	else
		_wxerror "Cannot find the wxWidgets profile configuration ( ${EPREFIX}/var/lib/wxwidgets/current )"
	fi

	if [ -z "${WXCONFIG}" ] || [ "${WXCONFIG}" = none ]; then
		_wxerror "No profile currently selected"
	fi

	if [ -x "${EPREFIX}/usr/${LIBDIR}/wx/config/${WXCONFIG}" ]; then
		exec "${EPREFIX}/usr/${LIBDIR}/wx/config/${WXCONFIG}" "$@"
	else
		_wxerror "Cannot find wxWidgets profile ( ${WXCONFIG} )"
	fi
fi
