# Generated automatically from Makefile.in by configure.
# 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 	= $(MFLAGS)


MODEL		= ../objects
srcdir		= .
prefix		= /usr
exec_prefix	= ${prefix}
bindir		= $(exec_prefix)/bin
includedir	= $(prefix)/include/ncurses

# We'd put terminfo in /usr/share/terminfo, but that's not the convention...
ticdir		= $(exec_prefix)/lib/terminfo

INSTALL		= /usr/bin/install -c
INSTALL_PROGRAM	= ${INSTALL}

AWK		= gawk

CC		= gcc
CFLAGS		=  -O -DNDEBUG

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

CCFLAGS		= $(CPPFLAGS) $(CFLAGS)

CFLAGS_NORMAL	= $(CCFLAGS)
CFLAGS_DEBUG	= $(CCFLAGS) -g -DTRACE
CFLAGS_PROFILE	= $(CCFLAGS) -pg
CFLAGS_SHARED	= $(CCFLAGS) -fPIC

CFLAGS_DEFAULT	= $(CFLAGS_NORMAL)

LINK		= $(CC)
LDFLAGS		=   -lbsd  

AUTO_SRC = \
	termsort.c

PROGS = tic infocmp clear tput tset

TESTPROGS = mvcur tctest hardscroll

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

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

install: install.progs 

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

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

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

#
# Utilities normally built by make all start here
#

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

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

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

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

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

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

#
# 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)
	 $(LINK) $(CCFLAGS) -DTRACE -DMAIN $(MVFLAGS) $(DEPS_MVCUR) $(LDFLAGS) -o $@

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

# Demonstrator/tester for hardware-scrolling algorithm.
hardscroll: \
		$(srcdir)/../ncurses/hardscroll.c
	 $(LINK) $(CCFLAGS) -DMAINDEBUG $(srcdir)/../ncurses/hardscroll.c $(LDFLAGS) -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 \
../include/Caps.filtered :
	cd ../include; $(MAKE) $(NC_MFLAGS)
$(LIB_CURSES) :
	cd ../ncurses; $(MAKE) $(NC_MFLAGS)

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

NORMAL_OBJS = \
	../objects/clear.o \
	../objects/comp_main.o \
	../objects/dump_entry.o \
	../objects/infocmp.o \
	../objects/tput.o \
	../objects/tset.o \
	../objects/write_entry.o

clean ::
	rm -f $(NORMAL_OBJS)

# Program modules (some are in ncurses lib!)

../objects/clear.o :	$(srcdir)/clear.c \
			../include/term.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/clear.c

../objects/comp_main.o :	$(srcdir)/comp_main.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/comp_main.c

../objects/dump_entry.o :	$(srcdir)/dump_entry.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h \
			../include/parametrized.h \
			termsort.c
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/dump_entry.c

../objects/infocmp.o :	$(srcdir)/infocmp.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/infocmp.c

../objects/tput.o :	$(srcdir)/tput.c \
			../include/term.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/tput.c

../objects/tset.o :	$(srcdir)/tset.c \
			../include/term.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/tset.c

../objects/write_entry.o :	$(srcdir)/write_entry.c \
			../include/term.h \
			$(INCDIR)/tic.h
	cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../progs/write_entry.c


DEBUG_OBJS = \
	../obj_g/clear.o \
	../obj_g/comp_main.o \
	../obj_g/dump_entry.o \
	../obj_g/infocmp.o \
	../obj_g/tput.o \
	../obj_g/tset.o \
	../obj_g/write_entry.o

clean ::
	rm -f $(DEBUG_OBJS)

# Program modules (some are in ncurses lib!)

../obj_g/clear.o :	$(srcdir)/clear.c \
			../include/term.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/clear.c

../obj_g/comp_main.o :	$(srcdir)/comp_main.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/comp_main.c

../obj_g/dump_entry.o :	$(srcdir)/dump_entry.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h \
			../include/parametrized.h \
			termsort.c
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/dump_entry.c

../obj_g/infocmp.o :	$(srcdir)/infocmp.c \
			../include/term.h \
			$(INCDIR)/tic.h \
			$(srcdir)/dump_entry.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/infocmp.c

../obj_g/tput.o :	$(srcdir)/tput.c \
			../include/term.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/tput.c

../obj_g/tset.o :	$(srcdir)/tset.c \
			../include/term.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/tset.c

../obj_g/write_entry.o :	$(srcdir)/write_entry.c \
			../include/term.h \
			$(INCDIR)/tic.h
	cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../progs/write_entry.c

