1#
2# Makefile template for rlfe 
3#
4# See machine dependant config.h for more configuration options.
5#
6
7srcdir = @srcdir@
8VPATH = @srcdir@
9
10DESTDIR = 
11
12# Where to install screen.
13
14prefix = @prefix@
15exec_prefix = @exec_prefix@
16
17# don't forget to change mandir and infodir in doc/Makefile.
18bindir  = $(exec_prefix)/bin
19
20VERSION = @VERSION@
21SCREEN = screen-$(VERSION)
22
23CC = @CC@
24CFLAGS = @CFLAGS@
25CPPFLAGS = @CPPFLAGS@
26#LDFLAGS = -L$(READLINE_DIR)
27LDFLAGS = @LDFLAGS@
28LIBS = -lreadline -lhistory -lncurses @LIBS@
29
30CPP=@CPP@
31CPP_DEPEND=$(CC) -MM
32
33INSTALL = @INSTALL@
34INSTALL_PROGRAM = @INSTALL_PROGRAM@
35INSTALL_DATA = @INSTALL_DATA@
36
37AWK = @AWK@
38
39OPTIONS=
40#OPTIONS= -DDEBUG
41
42SHELL=/bin/sh
43
44CFILES=	rlfe.c pty.c
45HFILES= extern.h os.h screen.h
46EXTRA_DIST=configure.in configure Makefile.in config.h.in ChangeLog README
47OFILES=	rlfe.o pty.o
48
49all:	rlfe
50
51rlfe: $(OFILES)
52	$(CC) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)
53
54rlfe-$(VERSION).tar.gz:
55	tar czf $@ $(CFILES) $(HFILES) $(EXTRA_DIST)
56
57.c.o:
58	$(CC) -c -I. -I$(srcdir) $(M_CFLAGS) $(DEFS) $(OPTIONS) $(CFLAGS) $<
59
60install_bin: .version screen
61	-if [ -f $(DESTDIR)$(bindir)/$(SCREEN) ] && [ ! -f $(DESTDIR)$(bindir)/$(SCREEN).old ]; \
62		then mv $(DESTDIR)$(bindir)/$(SCREEN) $(DESTDIR)$(bindir)/$(SCREEN).old; fi
63	$(INSTALL_PROGRAM) screen $(DESTDIR)$(bindir)/$(SCREEN)
64	-chown root $(DESTDIR)$(bindir)/$(SCREEN) && chmod 4755 $(DESTDIR)$(bindir)/$(SCREEN)
65# This doesn't work if $(bindir)/screen is a symlink
66	-if [ -f $(DESTDIR)$(bindir)/screen ] && [ ! -f $(DESTDIR)$(bindir)/screen.old ]; then mv $(DESTDIR)$(bindir)/screen $(DESTDIR)$(bindir)/screen.old; fi
67	rm -f $(DESTDIR)$(bindir)/screen
68	(cd $(DESTDIR)$(bindir) && ln -sf $(SCREEN) screen)
69	cp $(srcdir)/utf8encodings/?? $(DESTDIR)$(SCREENENCODINGS)
70
71
72uninstall: .version
73	rm -f $(DESTDIR)$(bindir)/$(SCREEN)
74	rm -f $(DESTDIR)$(bindir)/screen
75	-mv $(DESTDIR)$(bindir)/screen.old $(DESTDIR)$(bindir)/screen
76	rm -f $(DESTDIR)$(ETCSCREENRC)
77	cd doc; $(MAKE) uninstall
78
79shadow:
80	mkdir shadow;
81	cd shadow; ln -s ../*.[ch] ../*.in ../*.sh ../configure ../doc ../terminfo ../etc .
82	rm -f shadow/term.h shadow/tty.c shadow/comm.h shadow/osdef.h
83	echo "install all Makefiles and config:" > shadow/Makefile
84	echo "	rm -f config.cache" >> shadow/Makefile
85	echo "	sh ./configure" >> shadow/Makefile
86
87term.h: term.c term.sh
88	AWK=$(AWK) srcdir=$(srcdir) sh $(srcdir)/term.sh
89
90kmapdef.c: term.h
91
92tty.c:	tty.sh 
93	sh $(srcdir)/tty.sh tty.c
94
95mostlyclean:
96	rm -f $(OFILES) rlfe *.o
97
98clean celan: mostlyclean
99	rm -f tty.c term.h comm.h osdef.h kmapdef.c core
100
101# Delete all files from the current directory that are created by 
102# configuring or building the program.
103# building of term.h/comm.h requires awk. Keep it in the distribution
104# we keep config.h, as this file knows where 'make dist' finds the ETCSCREENRC.
105#distclean:	mostlyclean
106#	rm -f $(SCREEN).tar $(SCREEN).tar.gz
107#	rm -f config.status Makefile
108#	rm -f osdef.h doc/Makefile
109
110maintainer-clean:
111	@echo "This command is not even intended for maintainers to use;"
112	@echo "it deletes files that may require special tools to rebuild."
113
114
115# Delete everything from the current directory that can be
116# reconstructed with this Makefile.
117realclean: .version mostlyclean
118	rm -f $(SCREEN).tar $(SCREEN).tar.gz
119	rm -f config.status Makefile doc/Makefile
120	rm -f tty.c term.h comm.h osdef.h kmapdef.c
121	rm -f config.h
122	echo "install all Makefiles and config:" > Makefile
123	echo "  sh ./configure" >> Makefile
124
125tags TAGS: $(CFILES)
126	-ctags    *.sh $(CFILES) *.h
127	-ctags -e *.sh $(CFILES) *.h
128
129dist: .version $(SCREEN).tar.gz
130
131
132# Perform self-tests (if any).
133check:
134
135config:
136	rm -f config.cache
137	sh ./configure
138
139
140###############################################################################
141
142.version:
143	@rev=`sed < $(srcdir)/patchlevel.h -n -e '/#define REV/s/#define REV  *//p'`; \
144	vers=`sed < $(srcdir)/patchlevel.h -n -e '/#define VERS/s/#define VERS  *//p'`; \
145	pat=`sed < $(srcdir)/patchlevel.h -n -e '/#define PATCHLEVEL/s/#define PATCHLEVEL  *//p'`; \
146	if [ "$${rev}.$${vers}.$${pat}" != "$(VERSION)" ]; then \
147	echo "This distribution is screen-$${rev}.$${vers}.$${pat}, but"; \
148	echo "the Makefile is from $(VERSION). Please update!"; exit 1; fi
149
150###############################################################################
151
152mdepend: $(CFILES) term.h
153	@rm -f DEPEND ; \
154	for i in ${CFILES} ; do \
155	  echo "$$i" ; \
156	  echo `echo "$$i" | sed -e 's/.c$$/.o/'`": $$i" `\
157            cc -E $$i |\
158            grep '^# .*"\./.*\.h"' |\
159            (sort -t'"' -u -k 2,2 2>/dev/null || sort -t'"' -u +1 -2) |\
160            sed -e 's/.*"\.\/\(.*\)".*/\1/'\
161          ` >> DEPEND ; \
162	done
163
164depend: depend.in
165	./config.status || ./configure
166
167depend.in: $(CFILES) term.h
168	cp Makefile.in Makefile.in~
169	sed -e '/\#\#\# Dependencies/q' < Makefile.in > tmp_make
170	for i in $(CFILES); do echo $$i; $(CPP_DEPEND) $$i >> tmp_make; done 
171	mv tmp_make Makefile.in
172
173###############################################################################
174
175### Dependencies:
176pty.o: pty.c config.h
177