# Makefile for GNU termcap library.
# Copyright (C) 1992 Free Software Foundation, Inc.

# This 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, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = @srcdir@
@VPATH@

CC = @CC@

# If you don't have a BSD or GNU install program, use cp.
INSTALL = @INSTALL@
INSTALLDATA = @INSTALLDATA@

# Things you might add to DEFS:
# -DUSG			If you have memcpy instead of bcopy.
# -DNO_ARG_ARRAY	If you can't take the address of the first of
#			a group of arguments and treat it as an array.

DEFS = @DEFS@

CDEBUG = -g
CFLAGS = $(CDEBUG) $(DEFS)

prefix = /usr/local

# Directory in which to install libtermcap.a.
libdir = $(prefix)/lib

# Directory in which to install termcap.h.
includedir = $(prefix)/include

# Directory in which to optionally also install termcap.h,
# so compilers besides gcc can find it by default.
# If it is empty or not defined, termcap.h will only be installed in
# includedir. 
oldincludedir = /usr/include

# Directory in which to install the documentation info files.
infodir = $(prefix)/info

#### End of system configuration section. ####

# Version of libtermcap distribution.
VERSION = 1.0

SRCS = termcap.c tparam.c
OBJS = termcap.o tparam.o
HDRS = termcap.h
DISTFILES = $(SRCS) $(HDRS) COPYING README termcap.texinfo termcap.info* \
texinfo.tex Makefile.in configure configure.in

all:	libtermcap.a termcap.info
.PHONY: all

install: all
	$(INSTALLDATA) libtermcap.a $(libdir)/libtermcap.a
	-ranlib $(libdir)/libtermcap.a
	cd $(srcdir); $(INSTALLDATA) termcap.h $(includedir)/termcap.h
	cd $(srcdir); test -n "$(oldincludedir)" && \
	  $(INSTALLDATA) termcap.h $(oldincludedir)/termcap.h
	cd $(srcdir); $(INSTALLDATA) termcap.info* $(infodir)
.PHONY: install

libtermcap.a: $(OBJS)
	ar rc $@ $(OBJS)
	-ranlib $@

termcap.info: termcap.texinfo
	makeinfo $termcap.texinfo< --output=$(srcdir)/$@

tags:	$(SRCS)
	ctags $(SRCS)

TAGS:	$(SRCS)
	etags $(SRCS)

clean:
	rm -f *.a *.o core
.PHONY: clean

mostlyclean: clean
.PHONY: mostlyclean

distclean: clean
	rm -f Makefile config.status
.PHONY: distclean

realclean: distclean
	rm -f TAGS tags *.info*
.PHONY: realclean

dist: $(DISTFILES)
	echo termcap-$(VERSION) > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(DISTFILES) `cat .fname`
	tar chZf `cat .fname`.tar.Z `cat .fname`
	rm -rf `cat .fname` .fname
.PHONY: dist
