xref: /csrg-svn/usr.bin/more/linstall (revision 35209)
1*35209Sbostic#! /bin/sh
2*35209Sbostic# Installation script for less.
3*35209Sbostic# This script prompts the operator for various information
4*35209Sbostic# and constructs a makefile.
5*35209Sbostic
6*35209Sbosticecho "This script will build a makefile for less."
7*35209Sbosticecho "If you already have a file called \"makefile\" it will be overwritten."
8*35209Sbosticecho "Press RETURN to continue."
9*35209Sbosticread ans
10*35209Sbostic
11*35209Sbosticecho "I will ask you some questions about your system."
12*35209Sbosticecho "If you do not know the answer to any question,"
13*35209Sbosticecho "just press RETURN and I will choose a default for you."
14*35209Sbosticecho "Press RETURN now."
15*35209Sbosticread ans
16*35209Sbostic
17*35209SbosticECHO=./vecho
18*35209Sbosticif [ ! -x $ECHO ]
19*35209Sbosticthen
20*35209Sbostic	echo "One moment..."
21*35209Sbostic	cc -o $ECHO vecho.c
22*35209Sbostic	echo ""
23*35209Sbosticfi
24*35209Sbostic
25*35209Sbostic$ECHO "Most Unix systems are derived from either System V"
26*35209Sbostic$ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc."
27*35209Sbostic$ECHO ""
28*35209Sbostic$ECHO "Is your system closest to:"
29*35209Sbostic$ECHO "  1. System V"
30*35209Sbostic$ECHO "  2. BSD 4.1"
31*35209Sbostic$ECHO "  3. BSD 4.2 or later"
32*35209Sbostic$ECHO "  4. Xenix"
33*35209Sbostic$ECHO "Enter a number, or just RETURN if you don't know: \c"
34*35209Sbosticread ans
35*35209Sbosticxenix=0
36*35209Sbosticcase "X$ans" in
37*35209SbosticX1) sys=sys5; sysname="System V" ;;
38*35209SbosticX2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
39*35209SbosticX3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
40*35209SbosticX4) sys=sys5; xenix=1; sysname="Xenix" ;;
41*35209Sbostic*) sys=unknown ;;
42*35209Sbosticesac
43*35209Sbostic$ECHO ""
44*35209Sbostic
45*35209SbosticDATE=`date`
46*35209Sbosticcat >makefile <<EOF
47*35209Sbostic# Makefile for "less"
48*35209Sbostic# Generated $DATE by $0.
49*35209SbosticEOF
50*35209Sbostic
51*35209Sbosticcat >>makefile <<"EOF"
52*35209Sbostic#
53*35209Sbostic# Invoked as:
54*35209Sbostic#	make all
55*35209Sbostic#   or	make install
56*35209Sbostic# Plain "make" is equivalent to "make all".
57*35209Sbostic#
58*35209Sbostic# If you add or delete functions, remake funcs.h by doing:
59*35209Sbostic#	make newfuncs
60*35209Sbostic# This depends on the coding convention of function headers looking like:
61*35209Sbostic#	" \t public <function-type> \n <function-name> ( ... ) "
62*35209Sbostic#
63*35209Sbostic# Also provided:
64*35209Sbostic#	make lint	# Runs "lint" on all the sources.
65*35209Sbostic#	make clean	# Removes "less" and the .o files.
66*35209Sbostic#	make clobber	# Pretty much the same as make "clean".
67*35209Sbostic
68*35209SbosticSHELL = /bin/sh
69*35209Sbostic
70*35209SbosticEOF
71*35209Sbostic
72*35209Sbosticcat >defines.h <<EOF
73*35209Sbostic/* Definition file for less */
74*35209Sbostic/* Generated $DATE by $0. */
75*35209Sbostic
76*35209SbosticEOF
77*35209Sbostic
78*35209Sbosticcat >>defines.h <<EOF
79*35209Sbostic/*
80*35209Sbostic * Define XENIX if running under XENIX 3.0.
81*35209Sbostic */
82*35209Sbostic#define	XENIX		$xenix
83*35209Sbostic
84*35209SbosticEOF
85*35209Sbostic$ECHO ""
86*35209Sbostic
87*35209Sbostic
88*35209Sbostic
89*35209Sbosticif [ "X$sys" = "Xunknown" ]
90*35209Sbosticthen
91*35209Sbostic	alldefault=0
92*35209Sbosticelse
93*35209Sbostic	def=yes
94*35209Sbostic	alldefault=1
95*35209Sbostic	$ECHO "Do you want to use ALL the defaults for $sysname?"
96*35209Sbostic	$ECHO "  Enter \"yes\" if you have a STANDARD $sysname."
97*35209Sbostic	$ECHO "  Enter \"no\" if you want to change any of the defaults. [$def] \c"
98*35209Sbostic	read ans
99*35209Sbostic	case "X$ans" in
100*35209Sbostic	X[yY]*) alldefault=1 ;;
101*35209Sbostic	X[nN]*) alldefault=0 ;;
102*35209Sbostic	esac
103*35209Sbostic	$ECHO ""
104*35209Sbosticfi
105*35209Sbostic
106*35209Sbosticif [ $alldefault = 0 ]
107*35209Sbosticthen
108*35209Sbostic	alloptional=0
109*35209Sbosticelse
110*35209Sbostic	def=yes
111*35209Sbostic	alloptional=1
112*35209Sbostic	$ECHO "Do you want to use all the optional features of less?"
113*35209Sbostic	$ECHO "  Less has several features which you may or may not"
114*35209Sbostic	$ECHO "  wish to include, such as shell escapes."
115*35209Sbostic	$ECHO "  Enter \"yes\" if you want to include ALL the optional features."
116*35209Sbostic	$ECHO "  Enter \"no\" if you want to select individual features. [$def] \c"
117*35209Sbostic	read ans
118*35209Sbostic	case "X$ans" in
119*35209Sbostic	X[yY]*) alloptional=1 ;;
120*35209Sbostic	X[nN]*) alloptional=0 ;;
121*35209Sbostic	esac
122*35209Sbostic	$ECHO ""
123*35209Sbosticfi
124*35209Sbostic
125*35209Sbostic
126*35209Sbostic
127*35209Sbosticdef=yes
128*35209Sbosticx=1
129*35209Sbosticif [ $alldefault = 0 ]
130*35209Sbosticthen
131*35209Sbostic	$ECHO "Does your C compiler support the \"void\" type? [$def] \c"
132*35209Sbostic	read ans
133*35209Sbostic	case "X$ans" in
134*35209Sbostic	X[yY]*) x=1 ;;
135*35209Sbostic	X[nN]*) x=0 ;;
136*35209Sbostic	esac
137*35209Sbostic	$ECHO ""
138*35209Sbosticfi
139*35209Sbosticcat >>defines.h <<EOF
140*35209Sbostic/*
141*35209Sbostic * VOID is 1 if your C compiler supports the "void" type,
142*35209Sbostic * 0 if it does not.
143*35209Sbostic */
144*35209Sbostic#define	VOID		$x
145*35209Sbostic
146*35209SbosticEOF
147*35209Sbostic
148*35209Sbostic
149*35209Sbostic
150*35209Sbosticdef=long
151*35209Sbosticif [ $alldefault = 0 ]
152*35209Sbosticthen
153*35209Sbostic	$ECHO "What type is the \"offset\" argument to lseek? [$def] \c"
154*35209Sbostic	read ans
155*35209Sbostic	if [ "X$ans" != "X" ]
156*35209Sbostic	then
157*35209Sbostic		def=$ans
158*35209Sbostic	fi
159*35209Sbostic	$ECHO ""
160*35209Sbosticfi
161*35209Sbosticcat >>defines.h <<EOF
162*35209Sbostic/*
163*35209Sbostic * offset_t is the type which lseek() returns.
164*35209Sbostic * It is also the type of lseek()'s second argument.
165*35209Sbostic */
166*35209Sbostic#define	offset_t	$def
167*35209Sbostic
168*35209SbosticEOF
169*35209Sbostic
170*35209Sbostic
171*35209Sbostic
172*35209Sbostic
173*35209Sbosticdef=yes; x=1
174*35209Sbosticif [ $alldefault = 0 ]
175*35209Sbosticthen
176*35209Sbostic	$ECHO "Most Unix systems provide the stat() function."
177*35209Sbostic	$ECHO "Does your system have stat()? [$def] \c"
178*35209Sbostic	read ans
179*35209Sbostic	case "X$ans" in
180*35209Sbostic	X[yY]*) x=1 ;;
181*35209Sbostic	X[nN]*) x=0 ;;
182*35209Sbostic	esac
183*35209Sbostic	$ECHO ""
184*35209Sbosticfi
185*35209Sbosticcat >>defines.h <<EOF
186*35209Sbostic/*
187*35209Sbostic * STAT is 1 if your system has the stat() call.
188*35209Sbostic */
189*35209Sbostic#define	STAT		$x
190*35209Sbostic
191*35209SbosticEOF
192*35209Sbostic
193*35209Sbostic
194*35209Sbostic
195*35209Sbostic
196*35209Sbosticdef=yes; x=1
197*35209Sbosticif [ $alldefault = 0 ]
198*35209Sbosticthen
199*35209Sbostic	$ECHO "Most Unix systems provide the perror() function."
200*35209Sbostic	$ECHO "Does your system have perror()? [$def] \c"
201*35209Sbostic	read ans
202*35209Sbostic	case "X$ans" in
203*35209Sbostic	X[yY]*) x=1 ;;
204*35209Sbostic	X[nN]*) x=0 ;;
205*35209Sbostic	esac
206*35209Sbostic	$ECHO ""
207*35209Sbosticfi
208*35209Sbosticcat >>defines.h <<EOF
209*35209Sbostic/*
210*35209Sbostic * PERROR is 1 if your system has the perror() call.
211*35209Sbostic * (Actually, if it has sys_errlist, sys_nerr and errno.)
212*35209Sbostic */
213*35209Sbostic#define	PERROR		$x
214*35209Sbostic
215*35209SbosticEOF
216*35209Sbostic
217*35209Sbostic
218*35209Sbostic
219*35209Sbostic
220*35209Sbosticdef=yes; x=1
221*35209Sbosticif [ $alldefault = 0 ]
222*35209Sbosticthen
223*35209Sbostic	$ECHO "Most Unix systems provide the time() function."
224*35209Sbostic	$ECHO "Does your system have time()? [$def] \c"
225*35209Sbostic	read ans
226*35209Sbostic	case "X$ans" in
227*35209Sbostic	X[yY]*) x=1 ;;
228*35209Sbostic	X[nN]*) x=0 ;;
229*35209Sbostic	esac
230*35209Sbostic	$ECHO ""
231*35209Sbosticfi
232*35209Sbosticcat >>defines.h <<EOF
233*35209Sbostic/*
234*35209Sbostic * GET_TIME is 1 if your system has the time() call.
235*35209Sbostic */
236*35209Sbostic#define	GET_TIME	$x
237*35209Sbostic
238*35209SbosticEOF
239*35209Sbostic
240*35209Sbosticif [ $x = 0 ]
241*35209Sbosticthen
242*35209Sbostic	$ECHO "What is the APPROXIMATE performance of your"
243*35209Sbostic	$ECHO "machine, as a percentage of a Vax 11/750?"
244*35209Sbostic	$ECHO "(Enter 100 if your machine is as fast as a Vax,"
245*35209Sbostic	$ECHO " 50 if it is half as fast, 200 if it is twice as fast, etc.)"
246*35209Sbostic	$ECHO "The accuracy of this information is not critical."
247*35209Sbostic	while :
248*35209Sbostic	do
249*35209Sbostic		$ECHO "Percent of Vax 11/750 [100]: \c"
250*35209Sbostic		read ans
251*35209Sbostic		if [ "X$ans" = "X" ]
252*35209Sbostic		then
253*35209Sbostic			ans=100
254*35209Sbostic		fi
255*35209Sbostic		longloop=`expr "$ans" "*" 3`
256*35209Sbostic		if [ $? = 0 ]
257*35209Sbostic		then
258*35209Sbostic			break
259*35209Sbostic		fi
260*35209Sbostic		$ECHO "Enter a number please!"
261*35209Sbostic	done
262*35209Sbostic	$ECHO ""
263*35209Sbostic
264*35209Sbostic	cat >>defines.h <<EOF
265*35209Sbostic/*
266*35209Sbostic * LONGLOOP is the number of lines we should process in the line number
267*35209Sbostic * scan before displaying a warning that it will take a while.
268*35209Sbostic */
269*35209Sbostic#define	LONGLOOP	($longloop)
270*35209SbosticEOF
271*35209Sbosticfi
272*35209Sbostic
273*35209Sbostic
274*35209Sbostic
275*35209Sbostic
276*35209Sbosticif [ "$sys" = "bsd" ]
277*35209Sbosticthen
278*35209Sbostic	def=no; x=0
279*35209Sbosticelse
280*35209Sbostic	def=yes; x=1
281*35209Sbosticfi
282*35209Sbosticif [ $alldefault = 0 ]
283*35209Sbosticthen
284*35209Sbostic	$ECHO "Most System V systems have termio.h, while most"
285*35209Sbostic	$ECHO "Berkeley-derived systems have sgtty.h."
286*35209Sbostic	$ECHO "Does your system have termio.h? [$def] \c"
287*35209Sbostic	read ans
288*35209Sbostic	case "X$ans" in
289*35209Sbostic	X[yY]*) x=1 ;;
290*35209Sbostic	X[nN]*) x=0 ;;
291*35209Sbostic	esac
292*35209Sbostic	$ECHO ""
293*35209Sbosticfi
294*35209Sbosticcat >>defines.h <<EOF
295*35209Sbostic/*
296*35209Sbostic * TERMIO is 1 if your system has /usr/include/termio.h.
297*35209Sbostic * This is normally the case for System 5.
298*35209Sbostic * If TERMIO is 0 your system must have /usr/include/sgtty.h.
299*35209Sbostic * This is normally the case for BSD.
300*35209Sbostic */
301*35209Sbostic#define	TERMIO		$x
302*35209Sbostic
303*35209SbosticEOF
304*35209Sbostic
305*35209Sbostic
306*35209Sbostic
307*35209Sbostic
308*35209Sbosticif [ "$sys" = "bsd" -a "$bsd41" = "0" ]
309*35209Sbosticthen
310*35209Sbostic	def=yes; x=1
311*35209Sbosticelse
312*35209Sbostic	def=no; x=0
313*35209Sbosticfi
314*35209Sbosticif [ $alldefault = 0 ]
315*35209Sbosticthen
316*35209Sbostic	$ECHO "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
317*35209Sbostic	$ECHO "Most System V and BSD 4.1 systems do not."
318*35209Sbostic	$ECHO "Does your system have sigsetmask()? [$def] \c"
319*35209Sbostic	read ans
320*35209Sbostic	case "X$ans" in
321*35209Sbostic	X[yY]*) x=1 ;;
322*35209Sbostic	X[nN]*) x=0 ;;
323*35209Sbostic	esac
324*35209Sbostic	$ECHO ""
325*35209Sbosticfi
326*35209Sbosticcat >>defines.h <<EOF
327*35209Sbostic/*
328*35209Sbostic * SIGSETMASK is 1 if your system has the sigsetmask() call.
329*35209Sbostic * This is normally the case only for BSD 4.2,
330*35209Sbostic * not for BSD 4.1 or System 5.
331*35209Sbostic */
332*35209Sbostic#define	SIGSETMASK	$x
333*35209Sbostic
334*35209SbosticEOF
335*35209Sbostic
336*35209Sbostic
337*35209Sbostic
338*35209Sbosticif [ "$sys" = "bsd" ]
339*35209Sbosticthen
340*35209Sbostic	def=2; REGCMP=0;RECOMP=1
341*35209Sbosticelse
342*35209Sbostic	def=1; REGCMP=1;RECOMP=0
343*35209Sbosticfi
344*35209Sbosticif [ $alldefault = 0 ]
345*35209Sbosticthen
346*35209Sbostic	$ECHO "Most System V systems have the regcmp() function."
347*35209Sbostic	$ECHO "Most Berkeley-derived systems have the re_comp() function."
348*35209Sbostic	$ECHO "Does your system have:"
349*35209Sbostic	$ECHO "  1. regcmp"
350*35209Sbostic	$ECHO "  2. re_comp"
351*35209Sbostic	$ECHO "  3. neither   [$def] \c"
352*35209Sbostic	read ans
353*35209Sbostic	case "X$ans" in
354*35209Sbostic	X1) REGCMP=1;RECOMP=0 ;;
355*35209Sbostic	X2) REGCMP=0;RECOMP=1 ;;
356*35209Sbostic	X3) REGCMP=0;RECOMP=0 ;;
357*35209Sbostic	esac
358*35209Sbostic	$ECHO ""
359*35209Sbosticfi
360*35209Sbosticcat >>defines.h <<EOF
361*35209Sbostic/*
362*35209Sbostic * REGCMP is 1 if your system has the regcmp() function.
363*35209Sbostic * This is normally the case for System 5.
364*35209Sbostic * RECOMP is 1 if your system has the re_comp() function.
365*35209Sbostic * This is normally the case for BSD.
366*35209Sbostic * If neither is 1, pattern matching is supported, but without metacharacters.
367*35209Sbostic */
368*35209Sbostic#define	REGCMP		$REGCMP
369*35209Sbostic#define	RECOMP		$RECOMP
370*35209Sbostic
371*35209SbosticEOF
372*35209Sbostic
373*35209Sbostic
374*35209Sbostic
375*35209Sbostic
376*35209Sbosticdef=yes
377*35209Sbosticx=1
378*35209Sbosticif [ $alloptional = 0 ]
379*35209Sbosticthen
380*35209Sbostic	$ECHO "Do you wish to allow shell escapes? [$def] \c"
381*35209Sbostic	read ans
382*35209Sbostic	case "X$ans" in
383*35209Sbostic	X[yY]*) x=1 ;;
384*35209Sbostic	X[nN]*) x=0 ;;
385*35209Sbostic	esac
386*35209Sbostic	$ECHO ""
387*35209Sbosticfi
388*35209Sbosticcat >>defines.h <<EOF
389*35209Sbostic/*
390*35209Sbostic * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
391*35209Sbostic * (This is possible only if your system supplies the system() function.)
392*35209Sbostic */
393*35209Sbostic#define	SHELL_ESCAPE	$x
394*35209Sbostic
395*35209SbosticEOF
396*35209Sbostic
397*35209Sbostic
398*35209Sbostic
399*35209Sbosticdef=yes
400*35209Sbosticx=1
401*35209Sbosticedname="vi"
402*35209Sbosticif [ $alloptional = 0 ]
403*35209Sbosticthen
404*35209Sbostic	$ECHO "Do you wish to allow editor escapes? [$def] \c"
405*35209Sbostic	read ans
406*35209Sbostic	case "X$ans" in
407*35209Sbostic	X[nN]*) x=0; edname="" ;;
408*35209Sbostic	X[yY]*) x=1
409*35209Sbostic		$ECHO "What is the pathname of the default editor? [$edname] \c"
410*35209Sbostic		read ans
411*35209Sbostic		if [ "x$ans" != "x" ]
412*35209Sbostic		then
413*35209Sbostic			edname=$ans
414*35209Sbostic		fi
415*35209Sbostic		;;
416*35209Sbostic	esac
417*35209Sbostic	$ECHO ""
418*35209Sbosticfi
419*35209Sbosticcat >>defines.h <<EOF
420*35209Sbostic/*
421*35209Sbostic * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
422*35209Sbostic * (This is possible only if your system supplies the system() function.)
423*35209Sbostic * EDIT_PGM is the name of the (default) editor to be invoked.
424*35209Sbostic */
425*35209Sbostic#define	EDITOR		$x
426*35209Sbostic#define	EDIT_PGM	"$edname"
427*35209Sbostic
428*35209SbosticEOF
429*35209Sbostic
430*35209Sbostic
431*35209Sbostic
432*35209Sbostic
433*35209Sbosticdef=yes
434*35209Sbosticx=1
435*35209Sbosticif [ $alloptional = 0 ]
436*35209Sbosticthen
437*35209Sbostic	$ECHO "Do you wish to support \"tag\" files? [$def] \c"
438*35209Sbostic	read ans
439*35209Sbostic	case "X$ans" in
440*35209Sbostic	X[yY]*) x=1 ;;
441*35209Sbostic	X[nN]*) x=0 ;;
442*35209Sbostic	esac
443*35209Sbostic	$ECHO ""
444*35209Sbosticfi
445*35209Sbosticcat >>defines.h <<EOF
446*35209Sbostic/*
447*35209Sbostic * TAGS is 1 if you wish to support tag files.
448*35209Sbostic */
449*35209Sbostic#define	TAGS		$x
450*35209Sbostic
451*35209SbosticEOF
452*35209Sbostic
453*35209Sbostic
454*35209Sbostic
455*35209Sbosticdef=yes
456*35209Sbosticx=1
457*35209Sbosticif [ $alloptional = 0 ]
458*35209Sbosticthen
459*35209Sbostic	$ECHO "Do you wish to allow user-defined key definitions? [$def] \c"
460*35209Sbostic	read ans
461*35209Sbostic	case "X$ans" in
462*35209Sbostic	X[yY]*) x=1 ;;
463*35209Sbostic	X[nN]*) x=0 ;;
464*35209Sbostic	esac
465*35209Sbostic	$ECHO ""
466*35209Sbosticfi
467*35209SbosticUSERFILE=$x
468*35209Sbosticcat >>defines.h <<EOF
469*35209Sbostic/*
470*35209Sbostic * USERFILE is 1 if you wish to allow a .less file to specify 
471*35209Sbostic * user-defined key bindings.
472*35209Sbostic */
473*35209Sbostic#define	USERFILE	$x
474*35209Sbostic
475*35209SbosticEOF
476*35209Sbostic
477*35209Sbostic
478*35209Sbostic
479*35209Sbosticdef=yes
480*35209Sbosticx=1
481*35209Sbosticif [ $alldefault = 0 ]
482*35209Sbosticthen
483*35209Sbostic	$ECHO "If your system provides the popen() function and"
484*35209Sbostic	$ECHO "the \"$ECHO\" shell command, you may allow shell metacharacters"
485*35209Sbostic	$ECHO "to be expanded in filenames."
486*35209Sbostic	$ECHO "Do you wish to allow shell metacharacters in filenames? [$def] \c"
487*35209Sbostic	read ans
488*35209Sbostic	case "X$ans" in
489*35209Sbostic	X[yY]*) x=1 ;;
490*35209Sbostic	X[nN]*) x=0 ;;
491*35209Sbostic	esac
492*35209Sbostic	$ECHO ""
493*35209Sbosticfi
494*35209Sbosticcat >>defines.h <<EOF
495*35209Sbostic/*
496*35209Sbostic * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
497*35209Sbostic * This will generally work if your system provides the "popen" function
498*35209Sbostic * and the "$ECHO" shell command.
499*35209Sbostic */
500*35209Sbostic#define	GLOB		$x
501*35209Sbostic
502*35209SbosticEOF
503*35209Sbostic
504*35209Sbostic
505*35209Sbostic
506*35209Sbosticdef=yes
507*35209Sbosticx=1
508*35209Sbosticif [ $alloptional = 0 ]
509*35209Sbosticthen
510*35209Sbostic	$ECHO "Do you wish to allow log files (-l option)? [$def] \c"
511*35209Sbostic	read ans
512*35209Sbostic	case "X$ans" in
513*35209Sbostic	X[yY]*) x=1 ;;
514*35209Sbostic	X[nN]*) x=0 ;;
515*35209Sbostic	esac
516*35209Sbostic	$ECHO ""
517*35209Sbosticfi
518*35209Sbosticcat >>defines.h <<EOF
519*35209Sbostic/*
520*35209Sbostic * LOGFILE is 1 if you wish to allow the -l option (to create log files).
521*35209Sbostic */
522*35209Sbostic#define	LOGFILE		$x
523*35209Sbostic
524*35209SbosticEOF
525*35209Sbostic
526*35209Sbosticcat >>defines.h <<EOF
527*35209Sbostic/*
528*35209Sbostic * ONLY_RETURN is 1 if you want RETURN to be the only input which
529*35209Sbostic * will continue past an error message.
530*35209Sbostic * Otherwise, any key will continue past an error message.
531*35209Sbostic */
532*35209Sbostic#define	ONLY_RETURN	0
533*35209Sbostic
534*35209SbosticEOF
535*35209Sbostic
536*35209Sbosticcat >>makefile <<EOF
537*35209Sbostic
538*35209Sbostic##########################################################################
539*35209Sbostic# Compilation environment.
540*35209Sbostic##########################################################################
541*35209Sbostic
542*35209SbosticEOF
543*35209Sbostic
544*35209Sbostic
545*35209Sbostic
546*35209Sbosticif [ "$xenix" = "1" ]
547*35209Sbosticthen
548*35209Sbostic	LIBS="-ltermlib"
549*35209Sbosticelif [ "$sys" = "bsd" ]
550*35209Sbosticthen
551*35209Sbostic	LIBS="-ltermcap"
552*35209Sbosticelse
553*35209Sbostic	LIBS="-lcurses -ltermcap -lPW"
554*35209Sbosticfi
555*35209Sbosticif [ $alldefault = 0 ]
556*35209Sbosticthen
557*35209Sbostic	$ECHO "To build \"less\", you must link with libraries supplied by your system."
558*35209Sbostic	$ECHO "(If this needs to be changed later, edit the makefile"
559*35209Sbostic	$ECHO "and change the definition of LIBS.)"
560*35209Sbostic	$ECHO "What libraries should be used [$LIBS] \c"
561*35209Sbostic	read ans
562*35209Sbostic	if [ "X$ans" != "X" ]
563*35209Sbostic	then
564*35209Sbostic		LIBS="$ans"
565*35209Sbostic	fi
566*35209Sbostic	$ECHO ""
567*35209Sbosticfi
568*35209Sbosticcat >>makefile <<EOF
569*35209Sbostic# LIBS is the list of libraries needed.
570*35209SbosticLIBS = $LIBS
571*35209Sbostic
572*35209SbosticEOF
573*35209Sbostic
574*35209Sbostic
575*35209Sbostic
576*35209SbosticINSTALL_LESS="/usr/local/bin/less"
577*35209SbosticINSTALL_KEY="/usr/local/bin/lesskey"
578*35209SbosticINSTALL_HELP="/usr/local/bin/less.help"
579*35209SbosticINSTALL_LESSMAN="/usr/man/man1/less.1"
580*35209SbosticINSTALL_KEYMAN="/usr/man/man1/lesskey.1"
581*35209SbosticLESS_MANUAL="less.nro"
582*35209SbosticKEY_MANUAL="lesskey.nro"
583*35209Sbosticif [ $alldefault = 0 ]
584*35209Sbosticthen
585*35209Sbostic	$ECHO "What is the name of the \"public\" (installed) version of less?"
586*35209Sbostic	$ECHO " [$INSTALL_LESS] \c"
587*35209Sbostic	read ans
588*35209Sbostic	if [ "X$ans" != "X" ]
589*35209Sbostic	then
590*35209Sbostic		INSTALL_LESS="$ans"
591*35209Sbostic	fi
592*35209Sbostic	$ECHO "What is the name of the \"public\" (installed) version of lesskey?"
593*35209Sbostic	$ECHO " [$INSTALL_KEY] \c"
594*35209Sbostic	read ans
595*35209Sbostic	if [ "X$ans" != "X" ]
596*35209Sbostic	then
597*35209Sbostic		INSTALL_KEY="$ans"
598*35209Sbostic	fi
599*35209Sbostic	$ECHO "What is the name of the \"public\" (installed) version of the help file?"
600*35209Sbostic	$ECHO " [$INSTALL_HELP] \c"
601*35209Sbostic	read ans
602*35209Sbostic	if [ "X$ans" != "X" ]
603*35209Sbostic	then
604*35209Sbostic		INSTALL_HELP="$ans"
605*35209Sbostic	fi
606*35209Sbostic	$ECHO "What is the name of the \"public\" (installed) version of the less manual page?"
607*35209Sbostic	$ECHO " [$INSTALL_LESSMAN] \c"
608*35209Sbostic	read ans
609*35209Sbostic	if [ "X$ans" != "X" ]
610*35209Sbostic	then
611*35209Sbostic		INSTALL_LESSMAN="$ans"
612*35209Sbostic	fi
613*35209Sbostic	$ECHO "What is the name of the \"public\" (installed) version of the lesskey manual page?"
614*35209Sbostic	$ECHO " [$INSTALL_KEYMAN] \c"
615*35209Sbostic	read ans
616*35209Sbostic	if [ "X$ans" != "X" ]
617*35209Sbostic	then
618*35209Sbostic		INSTALL_KEYMAN="$ans"
619*35209Sbostic	fi
620*35209Sbostic	$ECHO ""
621*35209Sbosticfi
622*35209Sbosticcat >>makefile <<EOF
623*35209Sbostic# INSTALL_LESS is a list of the public versions of less.
624*35209Sbostic# INSTALL_KEY is a list of the public versions of lesskey.
625*35209Sbostic# INSTALL_HELP is a list of the public version of the help file.
626*35209Sbostic# INSTALL_LESSMAN is a list of the public versions of the less manual page.
627*35209Sbostic# INSTALL_KEYMAN is a list of the public versions of the lesskey manual page.
628*35209SbosticINSTALL_LESS =		\$(ROOT)$INSTALL_LESS
629*35209SbosticINSTALL_KEY =		\$(ROOT)$INSTALL_KEY
630*35209SbosticINSTALL_HELP =		\$(ROOT)$INSTALL_HELP
631*35209SbosticINSTALL_LESSMAN =	\$(ROOT)$INSTALL_LESSMAN
632*35209SbosticINSTALL_KEYMAN =	\$(ROOT)$INSTALL_KEYMAN
633*35209SbosticLESS_MANUAL =		$LESS_MANUAL
634*35209SbosticKEY_MANUAL =		$KEY_MANUAL
635*35209SbosticHELPFILE =		$INSTALL_HELP
636*35209Sbostic
637*35209Sbostic
638*35209SbosticEOF
639*35209Sbostic
640*35209Sbostic
641*35209Sbostic
642*35209Sbosticcat >>makefile <<"EOF"
643*35209Sbostic# OPTIM is passed to the compiler and the loader.
644*35209Sbostic# It is normally "-O" but may be, for example, "-g".
645*35209SbosticOPTIM = -O
646*35209Sbostic
647*35209SbosticCFLAGS = $(OPTIM)
648*35209Sbostic
649*35209Sbostic
650*35209Sbostic
651*35209Sbostic##########################################################################
652*35209Sbostic# Files
653*35209Sbostic##########################################################################
654*35209Sbostic
655*35209SbosticSRC1 =	main.c option.c prim.c ch.c position.c input.c linenum.c
656*35209SbosticSRC2 =	screen.c prompt.c line.c signal.c os.c help.c ttyin.c command.c
657*35209SbosticSRC3 =	output.c decode.c tags.c version.c
658*35209SbosticSRC =	$(SRC1) $(SRC2) $(SRC3)
659*35209SbosticOBJ =	main.o option.o prim.o ch.o position.o input.o output.o \
660*35209Sbostic	screen.o prompt.o line.o signal.o os.o help.o ttyin.o \
661*35209Sbostic	decode.o command.o linenum.o tags.o version.o
662*35209Sbostic
663*35209Sbostic
664*35209Sbostic##########################################################################
665*35209Sbostic# Rules for building stuff
666*35209Sbostic##########################################################################
667*35209Sbostic
668*35209SbosticEOF
669*35209Sbostic
670*35209Sbosticif [ "$USERFILE" = "1" ]
671*35209Sbosticthen
672*35209Sbostic	cat >>makefile <<"EOF"
673*35209Sbosticall: less lesskey
674*35209Sbosticinstall: install_less install_help install_key install_lman install_kman
675*35209SbosticEOF
676*35209Sbosticelse
677*35209Sbostic	cat >>makefile <<"EOF"
678*35209Sbosticall: less
679*35209Sbosticinstall: install_less install_help install_lman
680*35209SbosticEOF
681*35209Sbosticfi
682*35209Sbostic
683*35209Sbosticcat >>makefile <<"EOF"
684*35209Sbostic
685*35209Sbosticless: $(OBJ)
686*35209Sbostic	$(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS)
687*35209Sbostic
688*35209Sbosticlesskey: lesskey.o
689*35209Sbostic	$(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS)
690*35209Sbostic
691*35209Sbostic# help.o depends on makefile for the definition of HELPFILE
692*35209Sbostichelp.o: makefile
693*35209Sbostic	$(CC) $(CFLAGS) -c -DHELPFILE=\"$(HELPFILE)\" help.c
694*35209Sbostic
695*35209Sbosticinstall_less: less
696*35209Sbostic	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
697*35209Sbostic	touch install_less
698*35209Sbostic
699*35209Sbosticinstall_key: lesskey
700*35209Sbostic	for f in $(INSTALL_KEY); do  rm -f $$f; cp lesskey $$f;  done
701*35209Sbostic	touch install_key
702*35209Sbostic
703*35209Sbosticinstall_help: less.help
704*35209Sbostic	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.help $$f;  done
705*35209Sbostic	touch install_help
706*35209Sbostic
707*35209Sbosticinstall_lman: $(LESS_MANUAL)
708*35209Sbostic	for f in $(INSTALL_LESSMAN); do  rm -f $$f; cp $(LESS_MANUAL) $$f;  done
709*35209Sbostic	touch install_lman
710*35209Sbostic
711*35209Sbosticinstall_kman: $(KEY_MANUAL)
712*35209Sbostic	for f in $(INSTALL_KEYMAN); do  rm -f $$f; cp $(KEY_MANUAL) $$f;  done
713*35209Sbostic	touch install_kman
714*35209Sbostic
715*35209Sbostic##########################################################################
716*35209Sbostic# Maintenance
717*35209Sbostic##########################################################################
718*35209Sbostic
719*35209Sbosticlint:
720*35209Sbostic	lint -hp $(SRC)
721*35209Sbostic
722*35209Sbosticnewfuncs:
723*35209Sbostic	mv funcs.h funcs.h.OLD
724*35209Sbostic	awk -f mkfuncs.awk $(SRC) >funcs.h
725*35209Sbostic
726*35209Sbosticclean:
727*35209Sbostic	rm -f $(OBJ) lesskey.o less lesskey vecho
728*35209Sbostic
729*35209Sbosticclobber:
730*35209Sbostic	rm -f *.o less lesskey vecho install_less install_key \
731*35209Sbostic		install_help install_lman install_kman
732*35209Sbostic
733*35209Sbosticshar:
734*35209Sbostic	shar -v linstall less.h position.h funcs.h cmd.h \
735*35209Sbostic		vecho.c lesskey.c less.nro lesskey.nro lesskey.man > less.shar.a
736*35209Sbostic	shar -v $(SRC1) > less.shar.b
737*35209Sbostic	shar -v $(SRC2) > less.shar.c
738*35209Sbostic	shar -v $(SRC3) less.man README less.help *.awk >less.shar.d
739*35209Sbostic
740*35209Sbostic
741*35209Sbostic##########################################################################
742*35209Sbostic# Dependencies
743*35209Sbostic##########################################################################
744*35209Sbostic
745*35209Sbostic$(OBJ): less.h funcs.h defines.h position.h
746*35209Sbosticcommand.o decode.o: cmd.h
747*35209Sbosticlesskey.o: less.h funcs.h defines.h cmd.h
748*35209Sbostic
749*35209SbosticEOF
750*35209Sbostic$ECHO ""
751*35209Sbostic
752*35209Sbostic$ECHO "The makefile has been built."
753*35209Sbostic$ECHO "You should check it to make sure everything is as you want it to be."
754*35209Sbostic$ECHO "When you are satisfied with the makefile, just type \"make\""
755*35209Sbostic$ECHO "and \"less\" will be built."
756