#*********************************************************************
#                         COPYRIGHT NOTICE                           *
#*********************************************************************
#        This software is copyright (C) 1982 by Pavel Curtis         *
#                                                                    *
#        Permission is granted to reproduce and distribute           *
#        this file by any means so long as no fee is charged         *
#        above a nominal handling fee and so long as this            *
#        notice is always included in the copies.                    *
#                                                                    *
#        Other rights are reserved except as explicitly granted      *
#        by written permission of the author.                        *
#                Pavel Curtis                                        *
#                Computer Science Dept.                              *
#                405 Upson Hall                                      *
#                Cornell University                                  *
#                Ithaca, NY 14853                                    *
#                                                                    *
#                Ph- (607) 256-4934                                  *
#                                                                    *
#                Pavel.Cornell@Udel-Relay   (ARPAnet)                *
#                decvax!cornell!pavel       (UUCPnet)                *
#********************************************************************/

# RCSid: $Header:   RCS/Makefile.v  Revision 2.2  82/10/25  15:28:23  pavel  Exp$

SRCDIR= /etc/term
CFLAGS= -O -DSRCDIR='"$(SRCDIR)"'
DFLAGS= -g -DTRACE -DSRCDIR='"$(SRCDIR)"'

SRCS=	comp_main.c comp_hash.c comp_captab.c comp_scan.c comp_error.c \
	comp_parse.c read_entry.c \
	dump.c dump_names.c  \
	lib_setup.c lib_fixterm.c lib_tparm.c lib_tputs.c \
	lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_data.c \
	lib_beep.c lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c \
	lib_addch.c lib_addstr.c lib_scroll.c lib_clreol.c lib_touchwin.c \
	lib_mvcur.c lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c \
	lib_printw.c lib_scanw.c lib_erase.c lib_getch.c lib_options.c \
	lib_box.c lib_clear.c lib_delch.c lib_deleteln.c lib_insch.c \
	lib_insertln.c lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
	lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c

#
# Normal, optimised object files
#
LIBOBJS= lib_setup.o lib_fixterm.o lib_tparm.o read_entry.o lib_tputs.o \
	lib_unctrl.o lib_raw.o lib_vidattr.o lib_trace.o lib_data.o lib_beep.o \
	lib_doupdate.o lib_refresh.o lib_initscr.o lib_newwin.o lib_addch.o \
	lib_addstr.o lib_scroll.o lib_clreol.o lib_touchwin.o lib_mvcur.o \
	lib_delwin.o lib_endwin.o lib_clrbot.o lib_move.o lib_printw.o \
	lib_scanw.o lib_erase.o lib_getch.o lib_options.o \
	lib_box.o lib_clear.o lib_delch.o lib_deleteln.o lib_insch.o \
	lib_insertln.o lib_getstr.o lib_mvwin.o lib_longname.o lib_tstp.o \
	lib_newterm.o lib_set_term.o lib_overlay.o lib_scrreg.o

#
# Debugging (tracing) object files
#
DLIBOBJS= lib_setup.d lib_fixterm.d lib_tparm.d read_entry.d lib_tputs.d \
	lib_unctrl.d lib_raw.d lib_vidattr.d lib_trace.d lib_data.d lib_beep.d \
	lib_doupdate.d lib_refresh.d lib_initscr.d lib_newwin.d lib_addch.d \
	lib_addstr.d lib_scroll.d lib_clreol.d lib_touchwin.d lib_mvcur.d \
	lib_delwin.d lib_endwin.d lib_clrbot.d lib_move.d lib_printw.d \
	lib_scanw.d lib_erase.d lib_getch.d lib_options.d \
	lib_box.d lib_clear.d lib_delch.d lib_deleteln.d lib_insch.d \
	lib_insertln.d lib_getstr.d lib_mvwin.d lib_longname.d lib_tstp.d \
	lib_newterm.d lib_set_term.d lib_overlay.d lib_scrreg.d

#
# Profiled Optimised object files
#
PLIBOBJS= lib_setup.p lib_fixterm.p lib_tparm.p read_entry.p lib_tputs.p \
	lib_unctrl.p lib_raw.p lib_vidattr.p lib_trace.p lib_data.p lib_beep.p \
	lib_doupdate.p lib_refresh.p lib_initscr.p lib_newwin.p lib_addch.p \
	lib_addstr.p lib_scroll.p lib_clreol.p lib_touchwin.p lib_mvcur.p \
	lib_delwin.p lib_endwin.p lib_clrbot.p lib_move.p lib_printw.p \
	lib_scanw.p lib_erase.p lib_getch.p lib_options.p \
	lib_box.p lib_clear.p lib_delch.p lib_deleteln.p lib_insch.p \
	lib_insertln.p lib_getstr.p lib_mvwin.p lib_longname.p lib_tstp.p \
	lib_newterm.p lib_set_term.p lib_overlay.p lib_scrreg.p

COMPOBJS= comp_main.o comp_hash.o comp_captab.o comp_scan.o comp_error.o \
	comp_parse.o read_entry.o

.SUFFIXES: .d .p

.c.d:
	-mv $*.o $*.O
	cc -c $(DFLAGS) $*.c
	mv $*.o $*.d
	-mv $*.O $*.o

.c.p:
	-mv $*.o $*.O
	cc -pg -c $(CFLAGS) $*.c
	mv $*.o $*.p
	-mv $*.O $*.o

all:	compile dump lib dlib

install: all
	sed -e 's/clude *"curses.h" *$$/clude <ncurses.h>/' term.h > /usr/include/term.h
	sed -e 's/^#include *"terminfo.h" *$$/#include <terminfo.h>/' curses.h > /usr/include/ncurses.h
	cp terminfo.h /usr/include/terminfo.h
	cp unctrl.h /usr/include/unctrl.h
	cp compile $(SRCDIR)/compile
	cp dump $(SRCDIR)/dump
	cp libcurses.a /usr/lib/libncurses.a
	cp libdcurses.a /usr/lib/libdcurses.a
	ranlib /usr/lib/libncurses.a
	ranlib /usr/lib/libdcurses.a

lib:	libcurses.a	
libcurses.a:	${LIBOBJS}
	ar rv libcurses.a ${LIBOBJS}
	ranlib libcurses.a

dlib:	libdcurses.a	
libdcurses.a:	${DLIBOBJS}
	ar rv libdcurses.a ${DLIBOBJS}
	ranlib libdcurses.a

plib:	libpcurses.a	
libpcurses.a:	${PLIBOBJS}
	ar rv libpcurses.a ${PLIBOBJS}
	ranlib libpcurses.a

compile: ${COMPOBJS}
	cc -o compile ${COMPOBJS}

dump: dump.o dump_names.o read_entry.o
	cc -o dump dump.o dump_names.o read_entry.o

lint: ${SRCS}
	lint ${DFLAGS} ${SRCS} > lint.out

term.h: Caps MKterm.h.awk
	awk -f MKterm.h.awk Caps > term.h

comp_captab.c: Caps MKcaptab.awk
	awk -f MKcaptab.awk Caps > comp_captab.c

dump.o: dump.c term.h compiler.h

dump_names.c: Caps MKnames.awk
	awk -f MKnames.awk Caps
	cat boolnames numnames strnames > dump_names.c
	-rm -f boolnames numnames strnames

clean:
	-rm -f *.[od] term.h comp_captab.c tags dump_names.c

tags:	*.c *.h
	ctags *.c *.h

depend:	${SRCS}
	grep "^#include" ${SRCS} \
		| sed 's/\([^:]*\).c:[^"]*"\([^"]*\)".*/\1.o: \2/' \
		| sed '/#include/d' > makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' > eddep
	echo '$$r makedep' >> eddep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$s/\.o/.d/' >> eddep
	echo '$$r makedep' >> eddep
	echo 'w' >> eddep
	cp Makefile Makefile.bak
	ex - Makefile < eddep
	rm makedep eddep
	echo >> Makefile
	echo "# DEPENDENCIES MUST END AT END OF FILE" >> Makefile
	echo "# IF YOU PUT STUFF HERE, IT WILL GO AWAY" >> Makefile
	echo "# See make depend, above" >> Makefile

# DO NOT DELETE THIS LINE - make depend needs it

comp_main.d: compiler.h
comp_hash.d: compiler.h
comp_hash.d: term.h
comp_captab.d: compiler.h
comp_captab.d: term.h
comp_scan.d: compiler.h
comp_error.d: compiler.h
comp_parse.d: compiler.h
comp_parse.d: term.h
comp_parse.d: object.h
read_entry.d: term.h
read_entry.d: object.h
dump.d: compiler.h
dump.d: term.h
lib_setup.d: curses.h
lib_setup.d: curses.priv.h
lib_setup.d: term.h
lib_fixterm.d: curses.h
lib_fixterm.d: curses.priv.h
lib_fixterm.d: term.h
lib_tparm.d: curses.h
lib_tparm.d: curses.priv.h
lib_tparm.d: term.h
lib_tputs.d: curses.h
lib_tputs.d: curses.priv.h
lib_tputs.d: term.h
lib_raw.d: curses.h
lib_raw.d: curses.priv.h
lib_raw.d: term.h
lib_vidattr.d: curses.h
lib_vidattr.d: curses.priv.h
lib_vidattr.d: term.h
lib_trace.d: term.h
lib_trace.d: curses.h
lib_trace.d: curses.priv.h
lib_data.d: curses.priv.h
lib_data.d: curses.h
lib_data.d: term.h
lib_beep.d: curses.h
lib_beep.d: curses.priv.h
lib_beep.d: term.h
lib_doupdate.d: curses.h
lib_doupdate.d: curses.priv.h
lib_doupdate.d: term.h
lib_refresh.d: curses.h
lib_refresh.d: curses.priv.h
lib_initscr.d: curses.h
lib_initscr.d: curses.priv.h
lib_newwin.d: term.h
lib_newwin.d: curses.h
lib_newwin.d: curses.priv.h
lib_addch.d: curses.h
lib_addch.d: curses.priv.h
lib_addch.d: unctrl.h
lib_addstr.d: curses.h
lib_addstr.d: curses.priv.h
lib_scroll.d: curses.h
lib_scroll.d: curses.priv.h
lib_clreol.d: curses.h
lib_clreol.d: curses.priv.h
lib_touchwin.d: curses.h
lib_touchwin.d: curses.priv.h
lib_mvcur.d: term.h
lib_mvcur.d: curses.h
lib_mvcur.d: curses.priv.h
lib_delwin.d: curses.h
lib_delwin.d: curses.priv.h
lib_endwin.d: term.h
lib_endwin.d: curses.h
lib_endwin.d: curses.priv.h
lib_clrbot.d: curses.h
lib_clrbot.d: curses.priv.h
lib_move.d: curses.h
lib_move.d: curses.priv.h
lib_printw.d: curses.h
lib_printw.d: curses.priv.h
lib_scanw.d: curses.h
lib_scanw.d: curses.priv.h
lib_erase.d: curses.h
lib_erase.d: curses.priv.h
lib_getch.d: curses.h
lib_getch.d: curses.priv.h
lib_options.d: term.h
lib_options.d: curses.h
lib_options.d: curses.priv.h
lib_box.d: curses.h
lib_box.d: curses.priv.h
lib_clear.d: curses.h
lib_clear.d: curses.priv.h
lib_delch.d: curses.h
lib_delch.d: curses.priv.h
lib_delch.d: term.h
lib_deleteln.d: curses.h
lib_deleteln.d: curses.priv.h
lib_insch.d: curses.h
lib_insch.d: curses.priv.h
lib_insertln.d: curses.h
lib_insertln.d: curses.priv.h
lib_getstr.d: curses.h
lib_getstr.d: curses.priv.h
lib_getstr.d: unctrl.h
lib_mvwin.d: curses.h
lib_mvwin.d: curses.priv.h
lib_longname.d: curses.h
lib_longname.d: curses.priv.h
lib_tstp.d: term.h
lib_tstp.d: curses.h
lib_tstp.d: curses.priv.h
lib_newterm.d: curses.h
lib_newterm.d: term.h
lib_newterm.d: curses.priv.h
lib_set_term.d: curses.h
lib_set_term.d: curses.priv.h
lib_set_term.d: term.h
lib_overlay.d: curses.h
lib_overlay.d: curses.priv.h
lib_scrreg.d: curses.h
lib_scrreg.d: curses.priv.h
comp_main.o: compiler.h
comp_hash.o: compiler.h
comp_hash.o: term.h
comp_captab.o: compiler.h
comp_captab.o: term.h
comp_scan.o: compiler.h
comp_error.o: compiler.h
comp_parse.o: compiler.h
comp_parse.o: term.h
comp_parse.o: object.h
read_entry.o: term.h
read_entry.o: object.h
dump.o: compiler.h
dump.o: term.h
lib_setup.o: curses.h
lib_setup.o: curses.priv.h
lib_setup.o: term.h
lib_fixterm.o: curses.h
lib_fixterm.o: curses.priv.h
lib_fixterm.o: term.h
lib_tparm.o: curses.h
lib_tparm.o: curses.priv.h
lib_tparm.o: term.h
lib_tputs.o: curses.h
lib_tputs.o: curses.priv.h
lib_tputs.o: term.h
lib_raw.o: curses.h
lib_raw.o: curses.priv.h
lib_raw.o: term.h
lib_vidattr.o: curses.h
lib_vidattr.o: curses.priv.h
lib_vidattr.o: term.h
lib_trace.o: term.h
lib_trace.o: curses.h
lib_trace.o: curses.priv.h
lib_data.o: curses.priv.h
lib_data.o: curses.h
lib_data.o: term.h
lib_beep.o: curses.h
lib_beep.o: curses.priv.h
lib_beep.o: term.h
lib_doupdate.o: curses.h
lib_doupdate.o: curses.priv.h
lib_doupdate.o: term.h
lib_refresh.o: curses.h
lib_refresh.o: curses.priv.h
lib_initscr.o: curses.h
lib_initscr.o: curses.priv.h
lib_newwin.o: term.h
lib_newwin.o: curses.h
lib_newwin.o: curses.priv.h
lib_addch.o: curses.h
lib_addch.o: curses.priv.h
lib_addch.o: unctrl.h
lib_addstr.o: curses.h
lib_addstr.o: curses.priv.h
lib_scroll.o: curses.h
lib_scroll.o: curses.priv.h
lib_clreol.o: curses.h
lib_clreol.o: curses.priv.h
lib_touchwin.o: curses.h
lib_touchwin.o: curses.priv.h
lib_mvcur.o: term.h
lib_mvcur.o: curses.h
lib_mvcur.o: curses.priv.h
lib_delwin.o: curses.h
lib_delwin.o: curses.priv.h
lib_endwin.o: term.h
lib_endwin.o: curses.h
lib_endwin.o: curses.priv.h
lib_clrbot.o: curses.h
lib_clrbot.o: curses.priv.h
lib_move.o: curses.h
lib_move.o: curses.priv.h
lib_printw.o: curses.h
lib_printw.o: curses.priv.h
lib_scanw.o: curses.h
lib_scanw.o: curses.priv.h
lib_erase.o: curses.h
lib_erase.o: curses.priv.h
lib_getch.o: curses.h
lib_getch.o: curses.priv.h
lib_options.o: term.h
lib_options.o: curses.h
lib_options.o: curses.priv.h
lib_box.o: curses.h
lib_box.o: curses.priv.h
lib_clear.o: curses.h
lib_clear.o: curses.priv.h
lib_delch.o: curses.h
lib_delch.o: curses.priv.h
lib_delch.o: term.h
lib_deleteln.o: curses.h
lib_deleteln.o: curses.priv.h
lib_insch.o: curses.h
lib_insch.o: curses.priv.h
lib_insertln.o: curses.h
lib_insertln.o: curses.priv.h
lib_getstr.o: curses.h
lib_getstr.o: curses.priv.h
lib_getstr.o: unctrl.h
lib_mvwin.o: curses.h
lib_mvwin.o: curses.priv.h
lib_longname.o: curses.h
lib_longname.o: curses.priv.h
lib_tstp.o: term.h
lib_tstp.o: curses.h
lib_tstp.o: curses.priv.h
lib_newterm.o: curses.h
lib_newterm.o: term.h
lib_newterm.o: curses.priv.h
lib_set_term.o: curses.h
lib_set_term.o: curses.priv.h
lib_set_term.o: term.h
lib_overlay.o: curses.h
lib_overlay.o: curses.priv.h
lib_scrreg.o: curses.h
lib_scrreg.o: curses.priv.h

# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE, IT WILL GO AWAY
# See make depend, above
