# Makefile.in -- Makefile for dict-wn
# Created: Sat Mar  8 15:41:40 1997 by faith@cs.unc.edu
# Revised: Sun Jul  5 19:48:20 1998 by faith@acm.org
# Copyright 1997, 1998 Rickard E. Faith (faith@acm.org)
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 1, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 675 Mass Ave, Cambridge, MA 02139, USA.
# 
# $Id: Makefile.in,v 1.8 1998/07/06 01:33:40 faith Exp $
#

VERSION=1.5
NAME=dict-misc

ifneq (,)
This makefile requires GNU Make.
endif

.SUFFIXES:	

srcdir=		@srcdir@
VPATH=		@srcdir@
prefix=		@prefix@
datadir=        @datadir@
dictdir=        $(datadir)/dict
subdirs=        @subdirs@
exec_prefix=	@exec_prefix@
man1_prefix=	$(prefix)/man/man1

SHELL=		/bin/sh

CC=		@CC@
CPP=		@CPP@
RANLIB=		@RANLIB@
INSTALL=	@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DATA=	@INSTALL_DATA@
LEX=		@LEX@
LEXLIB= 	@LEXLIB@
YACC=		@YACC@
DICTZIP=        @DICTZIP@

CFLAGS=		@CFLAGS@
LDFLAGS=        @LDFLAGS@
XTRACFLAGS=     @WCFLAGS@ @XTRACFLAGS@ @DEFS@ @CPPFLAGS@ -I.
XTRALDFLAGS=    @WLDFLAGS@ @XTRALDFLAGS@
LDLIBS=		@LIBS@

EXES=	 	dictfmt

HEADERS= 	./config.h @XTRAHEADERS@

DATABASES=       jargon.dict foldoc.dict elements.dict \
			easton.dict hitchcock.dict world95.dict
DATAINDICES=     jargon.index foldoc.index elements.index \
			easton.index hitchcock.index world95.dict

all::
	@for subdir in `echo $(subdirs)`; do \
		echo making in $$subdir; \
		(cd $$subdir && $(MAKE)) || exit 1; \
	done

all:: $(EXES)

db :: $(DATABASES)

easton.dict easton.index: dictfmt data/easton/easton-info.txt
	cat data/easton/easton-info.txt data/easton/T*.html \
		| sed 's,<A HREF=[^>]*>\([^<]*\).*</A>,{\1},g' \
		| sed 's,\([A-Z][A-Z]*\) .T000[0-9]*,{\1},g' \
		| ./dictfmt -e \
			-u ftp://ccel.wheaton.edu/ebooks/HTML/e/easton/ebd/ \
			-s "Easton's 1897 Bible Dictionary" easton
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip easton.dict; \
	fi

install.easton: easton.index
	install -m 755 -d $(dictdir)
	if [ -e easton.dict.dz ]; then \
		install -m 644 easton.dict.dz $(dictdir); \
	else \
		install -m 644 easton.dict $(dictdir); \
	fi
	install -m 644 easton.index $(dictdir)

hitchcock.dict hitchcock.index: dictfmt data/bible_names.txt
	./dictfmt -h \
	   -u ftp://ccel.wheaton.edu/ebooks/HTML/bible_names/bible_names.txt \
	   -s "Hitchcock's Bible Names Dictionary (late 1800's)" \
	   hitchcock < data/bible_names.txt
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip hitchcock.dict; \
	fi

install.hitchcock: hitchcock.index
	install -m 755 -d $(dictdir)
	if [ -e hitchcock.dict.dz ]; then \
		install -m 644 hitchcock.dict.dz $(dictdir); \
	else \
		install -m 644 hitchcock.dict $(dictdir); \
	fi
	install -m 644 hitchcock.index $(dictdir)

jargon.dict jargon.index: dictfmt data/jarg400.txt
	./dictfmt -j -u http://www.ccil.org/jargon \
		-s "Jargon File (4.0.0/24 July 1996)" \
		jargon < data/jarg400.txt
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip jargon.dict; \
	fi

install.jargon: jargon.index
	install -m 755 -d $(dictdir)
	if [ -e jargon.dict.dz ]; then \
		install -m 644 jargon.dict.dz $(dictdir); \
	else \
		install -m 644 jargon.dict $(dictdir); \
	fi
	install -m 644 jargon.index $(dictdir)

foldoc.dict foldoc.index: dictfmt data/Dictionary
	./dictfmt -f -u ftp://wombat.doc.ic.ac.uk/foldoc/Dictionary.gz \
		-s "The Free On-line Dictionary of Computing (15Feb98)" \
		foldoc < data/Dictionary
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip foldoc.dict; \
	fi

install.foldoc: foldoc.index
	install -m 755 -d $(dictdir)
	if [ -e foldoc.dict.dz ]; then \
		install -m 644 foldoc.dict.dz $(dictdir); \
	else \
		install -m 644 foldoc.dict $(dictdir); \
	fi
	install -m 644 foldoc.index $(dictdir)

elements.dict elements.index: dictfmt data/elements
	./dictfmt -p -u mailto:jkominek@xtn.net \
		-s "The Elements (22Oct97)" \
		elements < data/elements
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip elements.dict; \
	fi

install.elements: elements.index
	install -m 755 -d $(dictdir)
	if [ -e elements.dict.dz ]; then \
		install -m 644 elements.dict.dz $(dictdir); \
	else \
		install -m 644 elements.dict $(dictdir); \
	fi
	install -m 644 elements.index $(dictdir)

world95.dict world95.index: dictfmt data/world95.txt
	./dictfmt -c5 \
-u ftp://uiarchive.cso.uiuc.edu/pub/etext/gutenberg/etext96/world95.zip \
		-s "The CIA World Factbook (1995)" \
		world95 < data/world95.txt
	if [ "$(DICTZIP)" != "cat" ]; then \
		dictzip world95.dict; \
	fi

install.world95: world95.index
	install -m 755 -d $(dictdir)
	if [ -e world95.dict.dz ]; then \
		install -m 644 world95.dict.dz $(dictdir); \
	else \
		install -m 644 world95.dict $(dictdir); \
	fi
	install -m 644 world95.index $(dictdir)


install: install.jargon install.foldoc install.elements \
	install.easton install.hitchcock install.world95

pack: $(DATAINDICES)
	tar cvf /tmp/$(NAME)-$(VERSION)-pre.tar \
		jargon.dict.dz jargon.index \
		foldoc.dict.dz foldoc.index \
		elements.dict.dz elements.index \
		easton.dict.dz easton.index \
		hitchcock.dict.dz hitchcock.index \
		world95.dict.dz world95.index
	gzip -f9 /tmp/$(NAME)-$(VERSION)-pre.tar

%.o: %.c
	$(CC) -c $(XTRACFLAGS) $(CFLAGS) $<

ALLFLAGS=$(XTRACFLAGS) $(CFLAGS) $(XTRALDFLAGS) $(LDFLAGS)
%: %.c
	$(CC) $(ALLFLAGS) -o $@ $< $(OBJS) $(LDLIBS)

$(OBJS):  $(HEADERS)

dictfmt: dictfmt.c $(HEADERS) $(OBJS)
	$(CC) $(ALLFLAGS) -o $@ $< $(OBJS) $(LDLIBS)

.PHONY: ChangeLog
ChangeLog:
	@(echo "***** Making new ChangeLog..."; \
	rm -f ChangeLog; \
	AWK=gawk rcs2log -i 2 > ChangeLog)

dist: ChangeLog
	@(NAME=$(NAME); \
	export NAME; \
	CVSROOT=`cat CVS/Root`; \
	export CVSROOT; \
	VERSION=$(VERSION); \
	export VERSION; \
	echo "***** Copying ChangeLog for $${NAME}-$${VERSION}..."; \
	cp ChangeLog /tmp; \
	echo "***** Exporting files for $${NAME}-$${VERSION}..."; \
	cd /tmp; \
	rm -rf /tmp/$${NAME}-$${VERSION} /tmp/$${NAME}-$${VERSION}.tar.gz; \
	cvs export -fNd $${NAME}-$${VERSION} -r HEAD $${NAME}; \
	cd $${NAME}-$${VERSION}; \
	make -f Makefile.conf; \
	mv ../ChangeLog .; \
	cd ..; \
	echo "***** Taring and zipping $${NAME}-$${VERSION}.tar.gz..."; \
	tar cvvf $${NAME}-$${VERSION}.tar $${NAME}-$${VERSION}; \
	gzip -9 $${NAME}-$${VERSION}.tar; \
	echo "***** Done making /tmp/$${NAME}-$${VERSION}.tar.gz")

.PHONY: clean distclean tags
clean:
	-rm -f *.o *.s *~ core a.out config.log $(EXES) $(TMPS)
	-rm -f *.log *.aux *.toc *.dvi *.ps
	-rm -f *.cfg *.dtk .inslog tca.map
	-rm -f *.dct *.idx y.output

recursive-clean: clean
	@for subdir in `echo $(subdirs)`; do \
		echo making clean in $$subdir; \
		(cd $$subdir && $(MAKE) clean) || exit 1; \
	done

distclean: clean
	@for subdir in `echo $(subdirs)`; do \
	 	if [ "$subdir" != "zlib" ]; then \
			echo making $@ in $$subdir; \
			(cd $$subdir && $(MAKE) $@) || exit 1; \
		fi \
	done
	-rm -f config.h config.cache config.status stamp-h.in stamp-h
	-rm -f configure Makefile
	-rm -f $(DATABASES) *.dict.dz $(DATAINDICES)

tags:
	etags *.[ch]


# The following is based on the "Automatic Remaking" node in the GNU
# Autoconf documentation:

$(srcdir)/configure: configure.in
	cd $(srcdir) && autoconf

# autoheader might not change config.h.in, so touch a stamp file.
${srcdir}/config.h.in: stamp-h.in
${srcdir}/stamp-h.in: configure.in
	cd ${srcdir} && autoheader
	date > ${srcdir}/stamp-h.in

config.h: stamp-h
stamp-h: config.h.in config.status
	./config.status

Makefile: Makefile.in config.status
	./config.status

config.status: configure
	./config.status --recheck

