# New ports collection makefile for:	X-Emacs
# Date created:		27 September 1994
# Whom:			Michael Elbel (me)
#
# $FreeBSD: ports/editors/xemacs/Makefile,v 1.57 2000/10/24 12:09:16 knu Exp $
#

PORTNAME=	xemacs
PORTVERSION=	19.16
CATEGORIES=	editors
MASTER_SITES=	${MASTER_SITE_XEMACS}
MASTER_SITE_SUBDIR=	${DISTNAME}

MAINTAINER=	gj@FreeBSD.org

LIB_DEPENDS=	jpeg.9:${PORTSDIR}/graphics/jpeg \
		png.4:${PORTSDIR}/graphics/png

NO_LATEST_LINK=	yes
USE_XPM=	yes
USE_GMAKE=	yes
STRIP=
HAS_CONFIGURE=	yes
CONFIGURE_ARGS=	i386--freebsd --prefix=${PREFIX} \
		--lockdir=/var/run/emacs/lock \
		--with-sound=native \
		--site-includes=${PREFIX}/include \
		--site-libraries=${PREFIX}/lib \
		--sitelispdir="${PREFIX}/lib/xemacs/site-lisp ${PREFIX}/share/emacs/site-lisp" \
		${WITH_DIALOGS} ${WITH_XFACE} ${WITH_OFFIX}
MAN1=		ctags.1 etags.1 gnuattach.1 gnuclient.1 gnudoit.1 \
		gnuserv.1 xemacs.1

# hack to avoid shipping binaries linked with Motif
.if defined(MOTIF_STATIC)
WITH_DIALOGS=	--with-dialogs=athena
.endif

# Drop faces (libcompface) and offix (libDnd) if building package,
# autodetect otherwise
.if defined(PACKAGE_BUILDING)
WITH_XFACE?=	--with-xface=no
WITH_OFFIX?=	--with-offix=no
.endif

pre-configure:
.if defined(HAVE_MOTIF)
	@${ECHO_MSG} ""
	@${ECHO_MSG} "If your MOTIF library is actually lesstif, you might occasionally"
	@${ECHO_MSG} "experience locked-up frames."
	@${ECHO_MSG} "In this case, set the environment variable MOTIF_STATIC and recompile, "
	@${ECHO_MSG} "which will force the use of athena widgets for dialogs."
.endif

post-install:
.for file in b2m ctags etags emacsclient gnuattach gnuclient \
	gnudoit ${DISTNAME}
	strip ${PREFIX}/bin/${file}
.endfor
# byte compile the new x-win-xfree86.el
	${PREFIX}/bin/xemacs -batch -eval '(byte-compile-file "${PREFIX}/lib/${DISTNAME}/lisp/x11/x-win-xfree86.el" nil)'
# also silently delete x-win-xfree86.el.orig
	@${RM} -f ${PREFIX}/lib/${DISTNAME}/lisp/x11/x-win-xfree86.el.orig
# ``make install'' does not set the permissions like pkg_add does.
	${CHMOD} 1777 /var/run/emacs/lock
	${CHMOD} 755 ${PREFIX}/lib/xemacs/site-lisp
	${CHMOD} 755 ${PREFIX}/share/emacs/site-lisp
# install xemacs.sh into ${PREFIX}/etc/rc.d
	@if [ ! -d ${PREFIX}/etc/rc.d ]; then ${MKDIR} ${PREFIX}/etc/rc.d; fi
	${INSTALL_SCRIPT} ${FILESDIR}/xemacs.sh ${PREFIX}/etc/rc.d
 
.include <bsd.port.mk>
