## -*- text -*- ####################################################
#								   #
# Makefile for termcap replacement libbrary.			   #
#								   #
####################################################################

O_SUFFIX=obj
A_SUFFIX=olb

# Here is a rule for making .$(O_SUFFIX) files from .c files that doesn't force
# the type of the machine (like -sun3) into the flags.
.c.$(O_SUFFIX):
	$(CC) -c $(CFLAGS) $(LOCAL_INCLUDES) $(CPPFLAGS) $*.c

# Destination installation directory.  The libraries are copied to DESTDIR
# when you do a `make install'.
DESTDIR = /usr/local/lib

DEBUG_FLAGS = -g
#OPTIMIZE_FLAGS = -O
LDFLAGS = $(DEBUG_FLAGS) 
CFLAGS = $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS)

SHELL = /bin/sh

# A good alternative is gcc -traditional.
#CC = gcc -traditional
CC = cc
RANLIB = ranlib
AR = ar
RM = rm
CP = cp

CSOURCES = termcap.c tparam.c

SOURCES  = $(CSOURCES)

OBJECTS = termcap.$(O_SUFFIX) tparam.$(O_SUFFIX)

DOCUMENTATION = termcap.texinfo

THINGS_TO_TAR = $(SOURCES) $(DOCUMENTATION)

##########################################################################

all: libtermcap.$(A_SUFFIX)

libtermcap.$(A_SUFFIX):	$(OBJECTS)
		$(RM) -f $@
		$(AR) clq $@ $(OBJECTS)
		-[ -n "$(RANLIB)" ] && $(RANLIB) $@

termcap.tar:	$(THINGS_TO_TAR)
		tar -cf $@ $(THINGS_TO_TAR)

termcap.tar.Z:	termcap.tar
		compress -f termcap.tar

install:	$(DESTDIR)/libtermcap.$(A_SUFFIX)

clean:
		rm -f *.$(O_SUFFIX) *.$(A_SUFFIX) *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc

maintainer-clean realclean mostlyclean distclean: clean


$(DESTDIR)/libtermcap.a: libtermcap.a
		-mv $(DESTDIR)/libtermcap.a $(DESTDIR)/libtermcap.old
		cp libtermcap.a $@
		-[ -n "$(RANLIB) ] && $(RANLIB) -t $@
