# Generic installation directories.
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
scriptdir = $(bindir)
libdir = $(exec_prefix)/lib
datadir = $(prefix)/lib
infodir = $(prefix)/info
includedir = $(prefix)/include
manext = 1
mandir = $(prefix)/man/man$(manext)

srcdir = .

CC=gcc
CFLAGS = -g -O2
LINTFLAGS = -abchnpux
CSUBS = Expand.c Match.c subs.c
OSUBS = Expand.o Match.o subs.o
B =
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644

install_programs = texexpand detex texeqn texmatch texspell
install_manpages = texexpand.1 detex.1 texeqn.1 texmatch.1 texspell.1

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

default: all

all: texexpand detex texeqn texmatch

texexpand: texexpand.o $(OSUBS)
	$(CC) $(CFLAGS) -o $(B)texexpand texexpand.o $(OSUBS)

detex: detex.o DeTeX.o $(OSUBS)
	$(CC) $(CFLAGS) -o $(B)detex detex.o DeTeX.o $(OSUBS)

texeqn: texeqn.o Eqn.o $(OSUBS)
	$(CC) $(CFLAGS) -o $(B)texeqn texeqn.o Eqn.o $(OSUBS)

texmatch: texmatch.o $(OSUBS)
	$(CC) $(CFLAGS) -o $(B)texmatch texmatch.o $(OSUBS)

lint:
	lint $(LINTFLAGS) texexpand.c $(CSUBS) > texexpand.lnt
	lint $(LINTFLAGS) detex.c DeTeX.c $(CSUBS) > detex.lnt
	lint $(LINTFLAGS) texeqn.c Eqn.c $(CSUBS) > texeqn.lnt
	lint $(LINTFLAGS) texmatch.c $(CSUBS) > texmatch.lnt
	
install: all
	for p in $(install_programs); do \
          $(INSTALL_PROGRAM) $$p $(bindir)/$$p; done
# Man pages.
	$(INSTALL_DATA) $(srcdir)/detex.1 $(mandir)/detex.$(manext)
	$(INSTALL_DATA) $(srcdir)/texexpand.1 $(mandir)/texexpand.$(manext)
	$(INSTALL_DATA) $(srcdir)/texmatch.1 $(mandir)/texmatch.$(manext)
	$(INSTALL_DATA) $(srcdir)/texeqn.1 $(mandir)/texeqn.$(manext)
	$(INSTALL_DATA) $(srcdir)/texspell.1 $(mandir)/texspell.$(manext)


clean:
	/bin/rm -f *.o texexpand detex texeqn texmatch core *junk* *~ \#*\#

# DO NOT DELETE THIS LINE -- make depend depends on it.

setups.h: /usr/include/stdio.h /usr/include/unistd.h /usr/include/stdlib.h
setups.h: /usr/include/sys/types.h /usr/include/stddef.h
setups.h: /usr/include/limits.h /usr/include/string.h
setups.h: /usr/include/sys/ioctl.h
DeTeX.o: setups.h
Eqn.o: setups.h
Expand.o: setups.h
Match.o: setups.h
detex.o: setups.h
subs.o: setups.h
texeqn.o: setups.h
texexpand.o: setups.h
texmatch.o: setups.h 

