#!/bin/sh
#
# $NetBSD: INSTALL,v 1.3 2003/08/30 20:23:08 jlam Exp $

PKGNAME=$1
STAGE=$2

LOCALBASE="@LOCALBASE@"

CP="@CP@"
ECHO="@ECHO@"
GREP="@GREP@"
LN="@LN@"
MV="@MV@"
RM="@RM@"

LOCALBASE=@LOCALBASE@
X11BASE=@X11BASE@
X11_HOSTDEF=${X11BASE}/lib/X11/config/host.def
HOSTDEF=${PKG_PREFIX}/lib/X11/config/host.def

case ${STAGE} in
POST-INSTALL)
	if [ ${PKG_PREFIX} = ${X11BASE} -o -f ${HOSTDEF} ]
	then
		${ECHO} -n "Updating ${HOSTDEF}..."
		${CP} -f ${HOSTDEF} ${HOSTDEF}.bak
	else
		${ECHO} -n "Creating ${HOSTDEF}..."
		if [ -f ${X11_HOSTDEF} ]
		then
			${CP} -f ${X11_HOSTDEF} ${HOSTDEF}.bak
		else
			${CP} -f /dev/null ${HOSTDEF}.bak
		fi
	fi
	( ${GREP} -v LessTif ${HOSTDEF}.bak;				\
	  ${ECHO} '#include <LessTif.def>';				\
	) > ${HOSTDEF}
	${RM} -f ${HOSTDEF}.bak
	${ECHO} "done."

	if [ ${PKG_PREFIX} != ${LOCALBASE} ]
	then
		${LN} -fs ${PKG_PREFIX}/share/aclocal/ac_find_motif.m4	\
			${LOCALBASE}/share/aclocal/ac_find_motif.m4
	fi
	;;
esac
exit 0
