# Makefile for ncurses source code.
#
# This makes/installs ncurses include-files
#
# The variable 'srcdir' refers to the source-distribution, and can be set with
# the configure script by "--srcdir=DIR".

# turn off _all_ suffix rules; we'll generate our own
.SUFFIXES:

SHELL		= /bin/sh
THIS		= Makefile

srcdir		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
includedir	= @includedir@

INSTALL		= @INSTALL@
INSTALL_DATA	= @INSTALL_DATA@

AWK		= @AWK@

VERSION		= @nc_cv_rel_version@
BUILTIN_BOOL	= @nc_cv_builtin_bool@
TYPE_OF_BOOL	= @nc_cv_sizeof_bool@

AUTO_SRC = \
	MKterm.h.awk \
	curses.h \
	termcap.h \
	Caps.filtered \
	hashsize.h \
	parametrized.h \
	unctrl.h \
	term.h

################################################################################
all ::	$(AUTO_SRC)

install \
install.libs \
install.includes : term.h $(includedir)
	$(INSTALL_DATA) term.h $(includedir)/term.h
	$(INSTALL_DATA) curses.h $(includedir)/curses.h
	$(INSTALL_DATA) unctrl.h $(includedir)/unctrl.h
	$(INSTALL_DATA) termcap.h $(includedir)/termcap.h
	@echo "Make sure you delete any old header files!"

$(includedir) :
	$(srcdir)/../mkinstalldirs $@

# These productions arrange for the files with embedded version numbers to be
# rebuilt whenever the source tree is re-configured (which will make Makefile
# newer than their ancestors). 
MKterm.h.awk: $(srcdir)/MKterm.h.awk.in Makefile
	-@rm -f $@
	sed <$(srcdir)/$@.in >$@ -e "/@VERSION@/s//$(VERSION)/"

curses.h: $(srcdir)/MKcurses.sh $(srcdir)/curses.h.in Makefile
	-@rm -f $@
	sh $(srcdir)/MKcurses.sh $(VERSION) $(BUILTIN_BOOL) $(TYPE_OF_BOOL) $(srcdir)

termcap.h: $(srcdir)/termcap.h.in Makefile
	-@rm -f $@
	sed <$(srcdir)/$@.in >$@ -e "/@VERSION@/s//$(VERSION)/"

unctrl.h: $(srcdir)/unctrl.h.in Makefile
	-@rm -f $@
	sed <$(srcdir)/$@.in >$@ -e "/@VERSION@/s//$(VERSION)/"

# For binary compatibility with SVr4, use GETMEXCLUDE=bool.  For strict
# conformance with the gratuitous and stupid change made in the XSI Curses
# standard, use GETMEXCLUDE=str
GETMEXCLUDE=bool

Caps.filtered: ${srcdir}/Caps
	grep -v 'getm	*$(GETMEXCLUDE)' ${srcdir}/Caps >$@

term.h: Caps.filtered MKterm.h.awk
	$(AWK) -f MKterm.h.awk Caps.filtered > $@
	sh $(srcdir)/edit_cfg.sh ../include/config.h $@

hashsize.h: Caps.filtered $(srcdir)/MKhashsize.sh
	sh $(srcdir)/MKhashsize.sh >$@

parametrized.h: Caps.filtered $(srcdir)/MKparametrized.sh
	sh $(srcdir)/MKparametrized.sh >$@

tags:
	ctags *.[ch]

TAGS:
	etags *.[ch]

clean ::
	-rm -f tags TAGS *~
	-rm -f $(AUTO_SRC)

distclean: clean
	-rm -f Makefile \
	`if test X"${srcdir}" != X".";then echo curses.h;fi`

mostlyclean: clean

realclean: distclean

###############################################################################
# The remainder of this file is automatically generated during configuration
###############################################################################
