# Makefile written by Paul Landes (landes@jove.acs.unt.edu)
# on: Sat 10/4/97 19:10:16

# Copyright (C) 1997 by Paul Landes. This code/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 2 of the License, or (at your option) 
# any later version. 

# Comment the next line to NOT compile with GNU readline
READLN	  = __READLN

# Un-omment the next line to use IBM character sets for
# row/column delemiters
#DOSPLAT   = -D_DOS_PLAT

# Binary and man page installation
BINDIR    = /usr/local/bin
MANDIR    = /usr/local/man/man1

CC        = g++
C         = gcc
DEF       = $(DOSPLAT)
LIB	  =

ifeq (__READLN, ${READLN})
LIB	 += -lreadline -lncurses -lhistory
DEF      += -D$(READLN)
endif

PROG      = trtab
OBJ       = stringn.o strmanip.o truth.o evalhelp.o \
            erralloc.o readln.o trfunc.o cmdop.o
INCD      = include
INC       = -I$(INCD)
CFLAGS    = -g -Wall $(DEF)

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

%.o : %.c
		$(C) $(CFLAGS) -c $(INC) $<

all:		$(PROG)

$(PROG):	$(PROG).o $(OBJ)
		$(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(PROG).o $(LIB)

$(PROG).o:	$(PROG).cc

strmanip.o:	strmanip.cc $(INCD)/strmanip.h
stringn.o:	stringn.cc $(INCD)/stringn.h
stack.o:	varlist.cc $(INCD)/varlist.h
truth.o:	truth.cc $(INCD)/truth.h
evalhelp.o:	evalhelp.cc $(INCD)/evalhelp.h
erralloc.o:	erralloc.cc $(INCD)/erralloc.h
readln.o:	readln.c $(INCD)/readln.h
trfunc.o:	trfunc.cc $(INCD)/trtab.h

.PHONY: go
go:
		$(PROG)

.PHONY:	install
install:
	@ echo "$(PROG) -> $(BINDIR)"
	install -m755 $(PROG) $(BINDIR)
	@ echo "$(PROG).1 -> $(MANDIR)"
	install -m644 $(PROG).1 $(MANDIR)

.PHONEY: clean
clean:
	rm -f *.o *~ core $(PROG)

