# Makefile for lgrind, a LaTeX prettyprinter

# $Id: Makefile,v 2.0 96/02/19 23:54:15 gvr Exp $

# You will almost certainly want to change these
BASEDIR=/usr/TeX
DESTDIR=${BASEDIR}/bin
DEFSFILE=${BASEDIR}/texmf/tex/latex/lgrind/lgrindef
TEXINPUTS=${BASEDIR}/texmf/tex/latex/lgrind
DOC=${BASEDIR}/texmf/doc/latex/lgrind
MAN=${BASEDIR}/man

CC=gcc
INSTALL=install
SOURCES=lgrind.c regexp.c regexp.h lgrindef.c lgrindef.h retest.c v2lg.c
TEXFILES=lgrind.dtx lgrind.sty lgrind.ins
MANPAGES=lgrind.1 lgrindef.5
EXAMPLES=doc-lgrind.lg
CMDS=lgrind
OBJS=lgrind.o regexp.o retest.o lgrindef.o v2lg.o

HELPOPTION=--help
CFLAGS=-O2
# CFLAGS=-Dpopen=fopen -Dpclose=fclose
# There are operating systems and compilers without these...

all:	$(CMDS)

lgrind: lgrind.o lgrindef.o regexp.o
	$(CC) $(CFLAGS) -o lgrind lgrind.o lgrindef.o regexp.o

lgrind.o: lgrind.c
	$(CC) $(CFLAGS) -DDEFSFILE=\"${DEFSFILE}\" -DHELPOPTION=\"${HELPOPTION}\" \
	                   -c lgrind.c
#	$(CC) $(CFLAGS) -DDEFSFILE=\"${DEFSFILE}\" -DHELPOPTION=\"${HELPOPTION}\" \
#	                   -DNO_PERM_D -c lgrind.c

v2lg:	v2lg.o
	$(CC) $(CFLAGS) -o v2lg v2lg.o

tar:
	tar cvf /tmp/lgrind.tar \
	   Makefile ${MANPAGES} lgrindef ${SOURCES} ${TEXFILES} ${EXAMPLES}
	compress /tmp/lgrind.tar

shar:
	shar Makefile ${MANPAGES} lgrindef ${SOURCES} ${TEXFILES} ${EXAMPLES}
		> lgrind.shar

retest: retest.o regexp.o
	$(CC) $(CFLAGS) -o retest retest.o regexp.o

install: all
	$(INSTALL) -s lgrind ${DESTDIR}/lgrind
	$(INSTALL) -c -m 644 ../lgrindef ${DEFSFILE}
	$(INSTALL) -c -m 644 ../lgrind.dvi ${DOC}/lgrind.dvi
	$(INSTALL) -c -m 644 ../lgrind.sty ${TEXINPUTS}/lgrind.sty
	$(INSTALL) -c -m 644 lgrind.1 ${MAN}/man1/lgrind.1
	$(INSTALL) -c -m 644 lgrindef.5 ${MAN}/man5/lgrindef.5

clean:
	/bin/rm -f $(CMDS) $(OBJS) retest v2lg
