#
# Copyright (C) 1996 Ken MacLeod
# See the file COPYING for distribution terms.
#
# $Id: Makefile.in,v 1.2 2001/11/30 23:41:44 sano Exp $
#

SHELL = /bin/sh

PACKAGE=@PACKAGE@
VERSION=@VERSION@

prefix=@prefix@
exec_prefix=@exec_prefix@

libdir=@libdir@
datadir=@datadir@
docdir=@docdir@
perl5libdir=@perl5libdir@
textmoddir=@textmoddir@
entitymapdir=@entitymapdir@
localentitymapdir=@localentitymapdir@

mandir=@mandir@
manext=.3
man3dir=${mandir}/man3

srcdir=@srcdir@
VPATH=@srcdir@

@SET_MAKE@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
SED=@SED@
PERL5=@PERL5@

DOCS = \
  COPYING \
  README
  

.SUFFIXES:
.SUFFIXES: .pl .sgml

all: EntityMap.pm

EntityMap.pm: EntityMap.pm.in Makefile
	${RM} EntityMap.pm
	sed <EntityMap.pm.in >EntityMap.pm \
	  -e 's|[@]localentitymapdir@|${localentitymapdir}|g' \
	  -e 's|[@]entitymapdir@|${entitymapdir}|g'

install: all installdirs
	${INSTALL_DATA} EntityMap.pm ${textmoddir}/EntityMap.pm
	cd sdata; $(MAKE) LIBDIR=${entitymapdir} \
	  PERM_D=755 PERM_F=644 MKDIR="../config/install-sh -d" CP=cp install

installdirs:
	for ii in ${prefix} ${perl5libdir} ${textmoddir} \
	  ${localentitymapdir} ${entitymapdir}; do \
	  ./config/install-sh -d $$ii; \
	done

installdoc:
	./config/install-sh -d ${docdir}
	for ii in ${DOCS}; do \
	  ${INSTALL_DATA} $$ii ${docdir}/$$ii; \
	done

Makefile: Makefile.in configure
	./configure

configure: configure.in
	autoconf

check: test-links
	perl test-entitymap.pl

test-links:
	ln -s . Text

clean:
	(cd sdata; $(MAKE) clean)
	${RM} make-dist MANIFEST.bak
	${RM} Text
	${RM} EntityMap.pm
	${RM} *~

realclean: clean

distclean: clean
	${RM} config.cache config.log config.status

maintainerclean: distclean
	${RM} Makefile configure

dist: distclean make-dist
	cd ${srcdir}; ./make-dist

SEDPL= \
  -e's;\@PACKAGE\@;${PACKAGE};' \
  -e's;\@VERSION\@;${VERSION};' \
  -e's;\@PERL5\@;${PERL5};'

.pl:
	${RM} $@
	${SED} ${SEDPL} <$< >$@ || (${RM} $@; exit 1)
	chmod +x $@
