# New ports collection makefile for:		estic-1.60
# Controller for ISDN TK-Anlage (PBX, Private Branch Exchange) made by Istec
# Date created: 				21 Sep 1996
# Whom: 					Julian H. Stacey <jhs@

PORTNAME=		estic
PORTVERSION=		1.60
PORTREVISION=   	1
CATEGORIES=		misc
DISTNAME=		estic-1.60-sources
PATCHFILES=             estic-1.61-patch-from-1.60.zip
MASTER_SITES=		ftp://ftp.gwdg.de/pub/misc/isdn/linux/estic/
USE_ZIP=		YES
# seen 2000.12.01: http://linux01.gwdg.de/pub/isdn/estic/estic-1.60-sources.zip
# seen 2000.12.01: http://linux01.gwdg.de/pub/isdn/estic/estic-1.61-patch-from-1.60.zip

MAINTAINER=		"Julian H. Stacey" <jhs@

BUILD_DEPENDS=		unzip:${PORTSDIR}/archivers/unzip

EXTRACT_CMD=		unzip
EXTRACT_BEFORE_ARGS=#	-q
NO_WRKSUBDIR=		yes

# BUILD_DEPENDS+=	 ${X11BASE}/lib/libX11.a
#			There are 2 versions, estic & xestic,
#			maybe one of them depends on the vga font from pcemu ?
X_OR_NOT=-x#		With X Window System,		Runs OK
#X_OR_NOT=#		Without X Window System,	Compile fails
AUTHOR= 		"Ullrich von Bassewitz" <uz_ERASE@ibb.schwaben.com>

# Where to install.
PBX_VAR=${PREFIX}/var/log/pbx
PBX_ETC=${PREFIX}/etc/pbx
PBX_MAN=${PREFIX}/man/man1
PBX_BIN=${PREFIX}/bin
PBX_DOC=${PREFIX}/share/doc/estic
SPUNK=${WRKSRC}/spunk		      
AREACODE=${WRKSRC}/areacode
ESTIC=${WRKSRC}/estic
MAKE_1=make X11BASE=${X11BASE} -f make/freebsd
MAKE_2=${MAKE_1}${X_OR_NOT}.mak       

do-configure:
	cd ${SPUNK}	; ${MAKE_2}	dep
	cd ${AREACODE} ; ${MAKE_1}.mak	dep
	cd ${ESTIC}	; ${MAKE_2}	dep

MAKE_E= make X11BASE=${X11BASE} -f make/freebsd${X_OR_NOT}.mak
do-build:
	@# If you don't want ResourceEditor you can `cd spunk ; ${MAKE_E} lib` 
	cd ${SPUNK}	; ${MAKE_2}   
	cd ${AREACODE}	; ${MAKE_1}.mak  areacode.o
	cd ${ESTIC}	; ${MAKE_2}   

do-install:
	${INSTALL_PROGRAM} ${ESTIC}/xestic ${PBX_BIN}/
	${INSTALL_DATA} ${ESTIC}/estic.res ${PBX_BIN}/
	@# estic doc says estic.res must be in bin path or current directory
	@${MKDIR} ${PBX_DOC}
	${INSTALL_MAN} ${ESTIC}/estic.doc ${PBX_DOC}
	@# estic.doc is not nroff format, & is in German, volunteers to create
	@# _and maintain_ nroff formatted English should contact ${AUTHOR}
	${INSTALL_MAN} ${FILESDIR}/README ${PBX_DOC}
	@# files/README is not in nroff, but is a temporary document.
	@${MKDIR} ${PBX_ETC} ${PBX_VAR}
	${INSTALL_DATA} ${ESTIC}/samples/estic.ini ${PBX_ETC}/estic.ini.generic_example
	${INSTALL_DATA} files/estic.ini ${PBX_ETC}/estic.ini.freebsd_example
	${INSTALL_DATA} ${ESTIC}/samples/alias.dat ${PBX_ETC}/aliases.example
	@# create config & debug so we can change mode to private
	@touch ${PBX_ETC}/config ${PBX_VAR}/debug
	chmod 600 ${PBX_VAR}/debug ${PBX_ETC}/config
	chmod 700 ${PBX_VAR} # estic will create ./1996.11 etc

post-extract:
	cp files/areacode-freebsd.mak ${WRKDIR}/areacode/make/freebsd.mak

post-install:
	@echo ""
	@echo " Suggestion, try:	make demo"

demo:
	@echo "If you want to try this under X-Windows, do this:"
	@echo " setenv SPUNK_LANGUAGE 001"
	@echo " setenv SPUNK_XFONT 8x13"
	@echo " cd ${PBX_ETC}"
	@echo " vi estic.ini"
	@echo " chmod 666 /dev/cuaaX, or su"
	@echo " ${ESTIC}/xestic -display :0"
	@echo " (If you have no Istec 100[38] connected, append -n )"
	@echo " A BUGS & PROBLEMS section exists in files/README == man estic_freebsd"

# Ref. NO_CDROM= & NO_PACKAGE=
# It is not necessary to prevent inclusion of source or binary on FreeBSD
# CDROMs, # (despite the original German phraseology) as I (<jhs@
# have obtained a waiver.  See files/README for explanation.

.include <bsd.port.mk>
