# Generated automatically from Makefile.in by configure.
#
# Makefile template for screen 
#
# See machine dependant config.h for more configuration options.
#

srcdir = .

# Where to install screen.

prefix = /usr/contrib
exec_prefix = $(prefix)

# don't forget to change mandir and infodir in doc/Makefile.
bindir  = $(exec_prefix)/bin

VERSION = 3.7.0

ETCSCREENRC = `sed < config.h -n -e '/define ETCSCREENRC/s/^.*"\([^"]*\)"/\1/p'`

CC = gcc
CFLAGS = -O
LDFLAGS =
LIBS = -ltermcap  -lutil

CPP_DEPEND=/lib/cpp -MM

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

AWK = awk

### Chose some debug configuration options:
# -DDEBUG
#	Turn on really heavy debug output. This is written to 
#	/tmp/debug/screen.{front,back} Look at these files and quote 
#	questionable sections when sending bug-reports to the author.
# -DTMPTEST
#	Change the socket directory to a location that does not interfere
#	with the (suid-root) installed screen version. Use that in
#	combination with -DDEBUG
# -DDUMPSHADOW
#	With shadow-pw screen would never dump core. Use this option if you
#	still want to have a core. Use only for debugging.
# -DFORKDEBUG
#	Swap roles of father and son when forking the SCREEN process. 
#	Useful only for debugging.
OPTIONS=
#OPTIONS= -DDEBUG -DTMPTEST

SHELL=/bin/sh

CFILES=	screen.c ansi.c fileio.c mark.c misc.c resize.c socket.c \
	search.c tty.c term.c window.c utmp.c loadav.c putenv.c help.c \
	termcap.c input.c attacher.c pty.c process.c display.c comm.c \
	kmapdef.c acls.c
OFILES=	screen.o ansi.o fileio.o mark.o misc.o resize.o socket.o \
	search.o tty.o term.o window.o utmp.o loadav.o putenv.o help.o \
	termcap.o input.o attacher.o pty.o process.o display.o comm.o \
	kmapdef.o acls.o

all:	screen screen.info

screen: $(OFILES)
	$(CC) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)

.c.o:
	$(CC) -c -I. -I$(srcdir) $(M_CFLAGS) $(DEFS) $(OPTIONS) $(CFLAGS) $<

install_bin: screen
	$(INSTALL_PROGRAM) screen $(bindir)/screen-$(VERSION)
	-chown root $(bindir)/screen-$(VERSION) && chmod 4755 $(bindir)/screen-$(VERSION)
# This doesn't work if $(bindir)/screen is a symlink
	-if [ -f $(bindir)/screen ] && [ ! -f $(bindir)/screen.old ]; then mv $(bindir)/screen $(bindir)/screen.old; fi
	rm -f $(bindir)/screen
	ln -s screen-$(VERSION) $(bindir)/screen

install: installdirs install_bin
	cd doc ; $(MAKE) install
	-tic ${srcdir}/terminfo/screeninfo.src
# Better do this by hand. E.g. under RCS...
#	cat ${srcdir}/terminfo/screencap >> /etc/termcap
	@echo "termcap entry (${srcdir}/terminfo/screencap) should be installed manually."
	@echo "You may also want to install $(srcdir)/etc/etcscreenrc in" $(ETCSCREENRC)

installdirs:
# Path leading to ETCSCREENRC and Socketdirectory not checked.
	$(srcdir)/etc/mkinstalldirs $(bindir)
	cd doc ; $(MAKE) installdirs

uninstall:
	rm -f $(bindir)/screen-$(VERSION)
	rm -f $(bindir)/screen
	-mv $(bindir)/screen.old $(bindir)/screen
	rm -f $(ETCSCREENRC)
	cd doc; $(MAKE) uninstall

shadow:
	mkdir shadow;
	cd shadow; ln -s ../*.[ch] ../*.in ../*.sh ../configure ../doc ../terminfo .
	rm -f shadow/term.h shadow/tty.c shadow/comm.h shadow/osdef.h

term.h: term.c term.sh
	AWK=$(AWK) srcdir=$(srcdir) sh $(srcdir)/term.sh

kmapdef.c: term.h

tty.c:	tty.sh 
	sh $(srcdir)/tty.sh tty.c

comm.h: comm.c comm.sh config.h
	AWK=$(AWK) CC="$(CC) $(CFLAGS)" srcdir=${srcdir} sh $(srcdir)/comm.sh

osdef.h: osdef.sh config.h osdef.h.in
	CC="$(CC) $(CFLAGS)" srcdir=${srcdir} sh $(srcdir)/osdef.sh

docs:
	cd doc; $(MAKE) dvi screen.info

dvi info screen.info:
	-cd doc; $(MAKE) $@

mostlyclean:
	rm -f $(OFILES) screen

clean celan: mostlyclean
	rm -f tty.c term.h comm.h osdef.h

# Delete all files from the current directory that are created by 
# configuring or building the program.
# building of term.h/comm.h requires awk. Keep it in the distribution
# we keep config.h, as this file knows where 'make dist' finds the ETCSCREENRC.
distclean:	mostlyclean
	rm -f screen-$(VERSION).tar screen-$(VERSION).TZ
	rm -f config.status Makefile
	rm -f osdef.h doc/Makefile
	echo "install all Makefiles and config:" > Makefile
	echo "	sh ./configure" >> Makefile

# Delete everything from the current directory that can be
# reconstructed with this Makefile.
realclean:	distclean
	rm -f tty.c term.h comm.h
	rm -f config.h

TAGS: $(CFILES)
	ctags $(CFILES) *.h
	ctags -e $(CFILES) *.h

dist: screen-$(VERSION).tar.gz

screen-$(VERSION).tar: term.h comm.h tty.c kmapdef.c
	-rm -rf dist
	mkdir dist
	mkdir dist/screen-$(VERSION)
	ln acls.h ansi.h display.h extern.h mark.h os.h overlay.h \
	   patchlevel.h rcs.h screen.h window.h image.h \
	   osdef.h.in term.sh tty.sh comm.sh osdef.sh \
	   acls.c ansi.c attacher.c comm.c display.c window.c fileio.c help.c \
	   input.c loadav.c mark.c misc.c process.c pty.c putenv.c \
	   screen.c search.c socket.c term.c termcap.c utmp.c resize.c \
	   ChangeLog COPYING INSTALL NEWS* install.sh \
	   dist/screen-$(VERSION)
	ln configure.in configure dist/screen-$(VERSION)
	sed -e 's@"/local/screens@"/tmp/screens@' -e 's@"/local@"/usr/local@g' < config.h.in > dist/screen-$(VERSION)/config.h.in
	sed -e 's@[	 ]/local@ /usr/local@g' -e 's/^CFLAGS = -g/CFLAGS = -O/' < Makefile.in > dist/screen-$(VERSION)/Makefile.in
	ln term.h dist/screen-$(VERSION)/term.h.dist
	ln comm.h dist/screen-$(VERSION)/comm.h.dist
	ln tty.c dist/screen-$(VERSION)/tty.c.dist
	ln kmapdef.c dist/screen-$(VERSION)/kmapdef.c.dist
	ln README dist/screen-$(VERSION)/README
	ln tek.patch dist/screen-$(VERSION)/tek.patch
	mkdir dist/screen-$(VERSION)/terminfo
	cd terminfo; ln 8bits README checktc.c sco.mail screencap \
	  screeninfo.src test.txt tetris.c \
	  ../dist/screen-$(VERSION)/terminfo
	mkdir dist/screen-$(VERSION)/etc
	cd etc; ln * ../dist/screen-$(VERSION)/etc
	sed -e 's/^startup/#startup/' -e 's/^autodetach/#autodetach/' < $(ETCSCREENRC) > dist/screen-$(VERSION)/etc/etcscreenrc 
	cp $(HOME)/.screenrc dist/screen-$(VERSION)/etc/screenrc
	mkdir dist/screen-$(VERSION)/doc
	sed -e 's@/local/emacs@/usr/local@g' < doc/Makefile.in > dist/screen-$(VERSION)/doc/Makefile.in
	cd doc; ln FAQ screen.1 screen.texinfo fdpat.ps \
	  ../dist/screen-$(VERSION)/doc
	cd doc; if test -f screen.info; then ln screen.info* \
	   ../dist/screen-$(VERSION)/doc; fi
	cd dist/screen-$(VERSION)/doc; ln -s ../install.sh .
	cd dist/screen-$(VERSION); ln -s doc/FAQ .
	echo "install all Makefiles and config:" > dist/screen-$(VERSION)/Makefile
	echo "	sh ./configure" >> dist/screen-$(VERSION)/Makefile
	cd dist; tar chf ../screen-$(VERSION).tar screen-$(VERSION)
	rm -rf dist

screen-$(VERSION).tar.gz: screen-$(VERSION).tar
	gzip -f screen-$(VERSION).tar

# Perform self-tests (if any).
check:

lint:
	lint -I. $(CFILES)

saber:
	#load $(CFLAGS) screen.c ansi.c $(LIBS)

mdepend: $(CFILES) term.h
	@rm -f DEPEND ; \
	for i in ${CFILES} ; do \
	  echo "$$i" ; \
	  echo `echo "$$i" | sed -e 's/.c$$/.o/'`": $$i" `\
            cc -E $$i |\
            grep '^# .*"\./.*\.h"' |\
            sort -t'"' -u +1 -2 |\
            sed -e 's/.*"\.\/\(.*\)".*/\1/'\
          ` >> DEPEND ; \
	done


depend: $(CFILES) term.h
	cp Makefile Makefile~
	sed -e '/\#\#\# Dependencies/q' < Makefile > tmp_make
	for i in $(CFILES); do echo $$i; $(CPP_DEPEND) $$i >> tmp_make; done 
	mv tmp_make Makefile

screen.o socket.o: Makefile

### Dependencies:
screen.o: screen.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h patchlevel.h rcs.h screen.h term.h window.h
ansi.o: ansi.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
fileio.o: fileio.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
mark.o: mark.c acls.h ansi.h comm.h config.h display.h extern.h image.h mark.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
misc.o: misc.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
resize.o: resize.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
socket.o: socket.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
search.o: search.c acls.h ansi.h comm.h config.h display.h extern.h image.h mark.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
tty.o: tty.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
term.o: term.c rcs.h term.h
window.o: window.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
utmp.o: utmp.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
loadav.o: loadav.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
putenv.o: putenv.c config.h rcs.h
help.o: help.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
termcap.o: termcap.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
input.o: input.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
attacher.o: attacher.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
pty.o: pty.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
process.o: process.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
display.o: display.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
comm.o: comm.c acls.h comm.h config.h rcs.h
kmapdef.o: kmapdef.c config.h
acls.o: acls.c acls.h ansi.h comm.h config.h display.h extern.h image.h os.h osdef.h overlay.h rcs.h screen.h term.h window.h
