/* 
 * -*- Mode: Text -*-
 *
 * Look over config.X before building.
 *
 * You may want to edit BINDIR, LIBDIR, DEFHASH, DEFDICT, MANDIR, and
 * MANEXT below; the Makefile will update all other files to match.
 *
 * On USG systems, add -DUSG to CFLAGS.
 *
 * The ifdef NO8BIT may be used if 8 bit extended text characters
 * cause problems, or you simply don't wish to allow the feature.
 *
 * the argument syntax for buildhash to make alternate dictionary files
 * is simply:
 *
 *   buildhash <infile> <outfile>
*/

LIBDIR = /usr/athena/lib/ispell
DEFHASH = ispell.hash
DEFDICT = dict.191
SHELL = /bin/sh

TERMLIB = -ltermcap

#if defined(_AUX_SOURCE)
DEFINES= -DUSG
#endif

all:: configure ispell.hash munchlist

OBJS=ispell.o term.o good.o lookup.o hash.o tree.o
SRCS=ispell.c term.c good.c lookup.c hash.c tree.c

build_program(buildhash,buildhash.o hash.o,,)
SimpleProgram(icombine,icombine.c,,$(LIBDIR))
SimpleProgram(ispell,$(OBJS),$(TERMLIB),$(ATHBINDIR))

ispell.hash: buildhash $(DEFDICT)
	./buildhash $(DEFDICT) $(DEFHASH)

/* install */
create_dir($(ATHBINDIR))
create_dir($(LIBDIR))

install_file(ispell.hash,$(LIBDIR)/$(DEFHASH))
install_file(expand1.sed,$(LIBDIR))
install_file(expand2.sed,$(LIBDIR))
install_man(ispell.1,ispell.1)

install::
	$(INSTALL) -m 755 munchlist $(DESTDIR)$(ATHBINDIR)/munchlist


$(OBJS) buildhash.o: config.h

configure: Makefile config.X munchlist.X
	-mv -f config.h config.h.old
	sed -e 's@!!LIBDIR!!@$(LIBDIR)@' -e 's@!!DEFDICT!!@$(DEFDICT)@' \
	    -e 's@!!DEFHASH!!@$(DEFHASH)@' <config.X >config.h
	-cmp -s config.h.old config.h && mv -f config.h.old config.h
	-mv -f munchlist munchlist.old
	sed -e 's@!!LIBDIR!!@$(LIBDIR)@' -e 's@!!DEFDICT!!@$(DEFDICT)@' \
		<munchlist.X >munchlist
	chmod +x munchlist
	-cmp -s munchlist.old munchlist && mv -f munchlist.old munchlist
	touch configure


clean::
	$(RM) hash.out 	*.stat *.cnt munchlist config.h ispell.hash configure

#if 0
depend:
	makedepend ${CFLAGS} ${SRCS}
#endif
	
