# $Id: Makefile.in,v 1.15 1996/06/15 20:40:53 tom Exp $
################################################################################
# Copyright 1996 by Thomas E. Dickey <dickey@clark.net>                        #
# All Rights Reserved.                                                         #
#                                                                              #
# Permission to use, copy, modify, and distribute this software and its        #
# documentation for any purpose and without fee is hereby granted, provided    #
# that the above copyright notice appear in all copies and that both that      #
# copyright notice and this permission notice appear in supporting             #
# documentation, and that the name of the above listed copyright holder(s) not #
# be used in advertising or publicity pertaining to distribution of the        #
# software without specific, written prior permission. THE ABOVE LISTED        #
# COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
# SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
# PERFORMANCE OF THIS SOFTWARE.                                                #
################################################################################
# Makefile for ncurses source code.
#
# This makes the ncurses utility programs.
#
# The variable 'srcdir' refers to the source-distribution, and can be set with
# the configure script by "--srcdir=DIR".
#
# The rules are organized to produce the libraries for the configured models,
# and the programs with the configured default model.

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

SHELL		= /bin/sh
THIS		= Makefile

NC_MFLAGS 	= @nc_cv_makeflags@
@SET_MAKE@

MODEL		= ../@DFT_OBJ_SUBDIR@
INSTALL_PREFIX	= @INSTALL_PREFIX@
srcdir		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
includedir	= @includedir@
datadir		= @datadir@

ticdir		= $(datadir)/terminfo

INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@

AWK		= @AWK@

CC		= @CC@
CFLAGS		= @CFLAGS@

INCDIR		= $(srcdir)/../include
CPPFLAGS	= -I../progs -I$(srcdir) @CPPFLAGS@ \
		  -DHAVE_CONFIG_H -DTERMINFO=\"$(ticdir)\"

CCFLAGS		= $(CPPFLAGS) $(CFLAGS)

CFLAGS_NORMAL	= $(CCFLAGS)
CFLAGS_DEBUG	= $(CCFLAGS) @CC_G_OPT@ -DTRACE
CFLAGS_PROFILE	= $(CCFLAGS) -pg
CFLAGS_SHARED	= $(CCFLAGS) @CC_SHARED_OPTS@

CFLAGS_DEFAULT	= $(CFLAGS_@DFT_UPR_MODEL@)

LINK		= $(CC)
LDFLAGS		= @LDFLAGS@ @LD_MODEL@ @LIBS@ 

LINT		= @LINT@
LINT_OPTS	= @LINT_OPTS@
LINT_LIBS	= -lncurses @LIBS@

AUTO_SRC = \
	termsort.c

PROGS = tic toe infocmp clear tput tset

TESTPROGS = mvcur tctest hardscroll hashmap

# Default library, for linking applications
LIB_CURSES = ../lib/libncurses@DFT_DEP_SUFFIX@

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

install: install.progs 

# this line simplifies the configure-script
install.libs:

install.progs: $(PROGS) $(INSTALL_PREFIX)$(bindir)
	$(INSTALL_PROGRAM) tic     $(INSTALL_PREFIX)$(bindir)/tic
	$(INSTALL_PROGRAM) toe     $(INSTALL_PREFIX)$(bindir)/toe
	$(INSTALL_PROGRAM) infocmp $(INSTALL_PREFIX)$(bindir)/infocmp
	$(INSTALL_PROGRAM) clear   $(INSTALL_PREFIX)$(bindir)/clear
	$(INSTALL_PROGRAM) tput    $(INSTALL_PREFIX)$(bindir)/tput
	$(INSTALL_PROGRAM) tset    $(INSTALL_PREFIX)$(bindir)/tset
	@echo "linking captoinfo to tic"
	-@rm -f $(INSTALL_PREFIX)$(bindir)/captoinfo
	-@ln $(INSTALL_PREFIX)$(bindir)/tic $(INSTALL_PREFIX)$(bindir)/captoinfo
	@echo "linking reset to tset"
	-@rm -f $(INSTALL_PREFIX)$(bindir)/reset
	-@ln $(INSTALL_PREFIX)$(bindir)/tset $(INSTALL_PREFIX)$(bindir)/reset

$(INSTALL_PREFIX)$(bindir) :
	$(srcdir)/../mkinstalldirs $@

#
# Utilities normally built by make all start here
#

DEPS_TIC = \
	$(MODEL)/tic.o \
	$(MODEL)/dump_entry.o \
	$(LIB_CURSES)
tic: $(DEPS_TIC)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_TIC) $(LDFLAGS) -o $@

DEPS_TOE = \
	$(MODEL)/toe.o \
	$(MODEL)/dump_entry.o \
	$(LIB_CURSES)
toe: $(DEPS_TOE)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_TOE) $(LDFLAGS) -o $@

DEPS_CLEAR = \
	$(MODEL)/clear.o \
	$(LIB_CURSES)
clear: $(DEPS_CLEAR)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_CLEAR) $(LDFLAGS) -o $@

DEPS_TPUT = \
	$(MODEL)/tput.o \
	$(LIB_CURSES)
tput: $(DEPS_TPUT)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_TPUT) $(LDFLAGS) -o $@

DEPS_INFOCMP = \
	$(MODEL)/infocmp.o \
	$(MODEL)/dump_entry.o \
	$(LIB_CURSES)
infocmp: $(DEPS_INFOCMP)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_INFOCMP) $(LDFLAGS) -o $@

DEPS_TSET = \
	$(MODEL)/tset.o \
	$(MODEL)/dump_entry.o \
	$(LIB_CURSES)
tset: $(DEPS_TSET)
	@ECHO_LINK@ $(LINK) $(CFLAGS_DEFAULT) $(DEPS_TSET) $(LDFLAGS) -o $@

termsort.c: $(srcdir)/MKtermsort.sh
	sh -c "$(srcdir)/MKtermsort.sh $(AWK) $(srcdir)/../include/Caps" >$@

#
# Test programs (not normally built by make all) start here.
#

# Cursor movement optimization tester. Use -g for debugging but -O if you're
# profiling with intent to determine COMPUTE_OVERHEAD
MVFLAGS = -O
DEPS_MVCUR = \
	$(srcdir)/../ncurses/lib_mvcur.c \
	$(MODEL)/dump_entry.o \
	$(LIB_CURSES)
mvcur: $(DEPS_MVCUR)
	@ECHO_LINK@ $(LINK) $(CCFLAGS) -DTRACE -DMAIN $(MVFLAGS) $(DEPS_MVCUR) $(LDFLAGS) -o $@

# Termcap-conversion tester
DEPS_TCTEST = \
	$(srcdir)/../ncurses/captoinfo.c \
	$(LIB_CURSES)
tctest: $(DEPS_TCTEST)
	@ECHO_LINK@ $(LINK) $(CCFLAGS) -DTRACE -DMAIN $(DEPS_TCTEST) $(LDFLAGS) -o $@

# Demonstrator/tester for hardware-scrolling algorithm.
DEPS_HARDSCROLL = \
	$(srcdir)/../ncurses/hardscroll.c \
	$(MODEL)/lib_trace.o	
hardscroll: 
	@ECHO_LINK@ $(LINK) $(CCFLAGS) -I$(srcdir)/../ncurses -DTRACE -DSCROLLDEBUG $(DEPS_HARDSCROLL) $(LDFLAGS) -o $@

# Demonstrator-tester for enhanced hardware-scrolling code with hash mapping
DEPS_HASHMAP = \
	$(srcdir)/../ncurses/hashmap.c \
	$(srcdir)/../ncurses/hardscroll.c \
	$(MODEL)/lib_trace.o	
hashmap: $(DEPS_HASHMAP)
	@ECHO_LINK@ $(LINK) $(CCFLAGS) -I$(srcdir)/../ncurses -DTRACE  -DHASHDEBUG $(DEPS_HASHMAP) -o $@

#
# Utility productions start here
#

tags:
	ctags *.[ch]

TAGS:
	etags *.[ch]

clean ::
	-rm -f tags TAGS do.tic *~
	-rm -f $(AUTO_SRC) $(TESTPROGS)
	-rm -f $(PROGS)

distclean :: clean
	-rm -f Makefile

mostlyclean :: clean

realclean :: distclean

# These rules are used to allow "make -n" to work on a clean directory-tree
../include/hashsize.h \
../include/parametrized.h \
../include/term.h :
	cd ../include; $(MAKE) $(NC_MFLAGS)
$(LIB_CURSES) :
	cd ../ncurses; $(MAKE) $(NC_MFLAGS)

lint:
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/clear.c                          $(LINT_LIBS)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/infocmp.c $(srcdir)/dump_entry.c $(LINT_LIBS)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tic.c     $(srcdir)/dump_entry.c $(LINT_LIBS)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/toe.c     $(srcdir)/dump_entry.c $(LINT_LIBS)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tput.c                           $(LINT_LIBS)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(srcdir)/tset.c    $(srcdir)/dump_entry.c $(LINT_LIBS)

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