#	@(#)Makefile	5.14 (Berkeley) 12/22/91
#	tset for linux -- fixes made by Juha.Virtanen@hut.fi 29th May 1995

CC =		gcc -m486
INSTALL = 	install

TSET =		tset
RESET =		reset
LIBS =		std stdcrt vt100 vt300
SRCS =		map.c misc.c set.c term.c tset.c ttytype.c wrterm.c
OBJS =		map.o misc.o set.o term.o tset.o ttytype.o wrterm.o

#CFLAGS =	-g -Wall #-DDEBUG
# a.out
#CFLAGS =	-O6 -Wall -fomit-frame-pointer -pipe
#LDFLAGS =	-s -N
# ELF
CFLAGS =	-O6 -Wall -pipe
LDFLAGS =	-s
LDADD =		-ltermcap

DESTDIR = 	/usr/local
BINDIR =	$(DESTDIR)/bin
MANDIR =	$(DESTDIR)/man
MAN1DIR =	$(MANDIR)/man1
MAN5DIR =	$(MANDIR)/man5
LIBDIR =	$(DESTDIR)/lib/tabset


all: $(TSET)

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

tset: .depend ${OBJS}
	${CC} -o ${TSET} ${OBJS} $(LDFLAGS) ${LDADD}

install: $(TSET)
	$(INSTALL) -m 555 $(TSET) $(BINDIR)
	ln -sf $(TSET) $(BINDIR)/$(RESET)
	$(INSTALL) -m 444 $(TSET).1 $(MAN1DIR)
	$(INSTALL) -m 444 $(RESET).1 $(MAN1DIR)
	$(INSTALL) -m 444 ttytype.5 $(MAN5DIR)
	$(INSTALL) -d $(LIBDIR)
	(cd tabset; for f in $(LIBS); do $(INSTALL) -m 444 $$f $(LIBDIR); done)

uninstall:
	rm -f $(BINDIR)/$(TSET) $(BINDIR)/$(RESET)
	rm -f $(MAN1DIR)/$(TSET).1 $(MAN1DIR)/$(RESET).1 $(MAN5DIR)/ttytype.5
	(cd $(LIBDIR); for f in $(LIBS); do rm -f $(LIBDIR)/$$f; done)

clobber:
	rm -f *.o core core.*

clean: clobber
	rm -f $(TSET) $(RESET)

realclean: clean
	rm -f *~ .depend

.depend dep:
	rm -f .depend
	$(CPP) -M *.c > .depend
	
#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
