2 # Installation script for less.
3 # This script prompts the operator for various information
4 # and constructs a makefile.
6 echo "This script will build a makefile for less."
7 echo "If you already have a file called \"makefile\" it will be overwritten,"
8 echo "as will the file \"defines.h\"."
9 echo "Press RETURN to continue."
12 echo "I will ask you some questions about your system."
13 echo "If you do not know the answer to any question,"
14 echo "just press RETURN and I will choose a default for you."
15 echo "Press RETURN now."
26 $ECHO "Most Unix systems are derived from either System V"
27 $ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc."
29 $ECHO "Is your system closest to:"
32 $ECHO " 3. BSD 4.2 or later"
34 $ECHO "Enter a number, or just RETURN if you don't know: \c"
38 X1) sys=sys5; sysname="System V" ;;
39 X2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
40 X3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
41 X4) sys=sys5; xenix=1; sysname="Xenix" ;;
49 # Generated $DATE by $0.
52 cat >>makefile <<"EOF"
57 # Plain "make" is equivalent to "make all".
59 # If you add or delete functions, remake funcs.h by doing:
61 # This depends on the coding convention of function headers looking like:
62 # " \t public <function-type> \n <function-name> ( ... ) "
65 # make lint # Runs "lint" on all the sources.
66 # make clean # Removes "less" and the .o files.
67 # make clobber # Pretty much the same as make "clean".
74 /* Definition file for less */
75 /* Generated $DATE by $0. */
81 * Define XENIX if running under XENIX 3.0.
90 if [ "X$sys" = "Xunknown" ]
96 $ECHO "Do you want to use ALL the defaults for $sysname?"
97 $ECHO " Enter \"yes\" if you have a STANDARD $sysname."
98 $ECHO " Enter \"no\" if you want to change any of the defaults. [$def] \c"
101 X[yY]*) alldefault=1 ;;
102 X[nN]*) alldefault=0 ;;
107 if [ $alldefault = 0 ]
113 $ECHO "Do you want to use all the optional features of less?"
114 $ECHO " Less has several features which you may or may not"
115 $ECHO " wish to include, such as shell escapes."
116 $ECHO " Enter \"yes\" if you want to include ALL the optional features."
117 $ECHO " Enter \"no\" if you want to select individual features. [$def] \c"
120 X[yY]*) alloptional=1 ;;
121 X[nN]*) alloptional=0 ;;
130 if [ $alldefault = 0 ]
132 $ECHO "Does your C compiler support the \"void\" type? [$def] \c"
140 cat >>defines.h <<EOF
142 * VOID is 1 if your C compiler supports the "void" type,
153 if [ $alldefault = 0 ]
155 $ECHO "Does your C compiler support the \"void *\" type? [$def] \c"
158 X[yY]*) x="void *" ;;
159 X[nN]*) x="char *" ;;
163 cat >>defines.h <<EOF
165 * VOID_POINTER is the definition of a pointer to any object.
167 #define VOID_POINTER $x
174 if [ $alldefault = 0 ]
176 $ECHO "What type is the \"offset\" argument to lseek? [$def] \c"
178 if [ "X$ans" != "X" ]
184 cat >>defines.h <<EOF
186 * offset_t is the type which lseek() returns.
187 * It is also the type of lseek()'s second argument.
189 #define offset_t $def
197 if [ $alldefault = 0 ]
199 $ECHO "Most Unix systems provide the stat() function."
200 $ECHO "Does your system have stat()? [$def] \c"
208 cat >>defines.h <<EOF
210 * STAT is 1 if your system has the stat() call.
220 if [ $alldefault = 0 ]
222 $ECHO "Most Unix systems provide the perror() function."
223 $ECHO "Does your system have perror()? [$def] \c"
231 cat >>defines.h <<EOF
233 * PERROR is 1 if your system has the perror() call.
234 * (Actually, if it has sys_errlist, sys_nerr and errno.)
244 if [ $alldefault = 0 ]
246 $ECHO "Most Unix systems provide the time() function."
247 $ECHO "Does your system have time()? [$def] \c"
255 cat >>defines.h <<EOF
257 * GET_TIME is 1 if your system has the time() call.
265 $ECHO "What is the APPROXIMATE performance of your"
266 $ECHO "machine, as a percentage of a Vax 11/750?"
267 $ECHO "(Enter 100 if your machine is as fast as a Vax,"
268 $ECHO " 50 if it is half as fast, 200 if it is twice as fast, etc.)"
269 $ECHO "The accuracy of this information is not critical."
272 $ECHO "Percent of Vax 11/750 [100]: \c"
278 longloop=`expr "$ans" "*" 3`
283 $ECHO "Enter a number please!"
287 cat >>defines.h <<EOF
289 * LONGLOOP is the number of lines we should process in the line number
290 * scan before displaying a warning that it will take a while.
292 #define LONGLOOP ($longloop)
299 if [ "$sys" = "bsd" ]
305 if [ $alldefault = 0 ]
307 $ECHO "Most System V systems have termio.h, while most"
308 $ECHO "Berkeley-derived systems have sgtty.h."
309 $ECHO "Does your system have termio.h? [$def] \c"
317 cat >>defines.h <<EOF
319 * TERMIO is 1 if your system has /usr/include/termio.h.
320 * This is normally the case for System 5.
321 * If TERMIO is 0 your system must have /usr/include/sgtty.h.
322 * This is normally the case for BSD.
331 if [ "$sys" = "bsd" -a "$bsd41" = "0" ]
337 if [ $alldefault = 0 ]
339 $ECHO "Most BSD 4.2 and 4.3 systems have both _setjmp() and setjmp()."
340 $ECHO "Most System V and BSD 4.1 systems have only setjmp()."
341 $ECHO "Does your system have both _setjmp() and setjmp()? [$def] \c"
349 cat >>defines.h <<EOF
351 * HAS__SETJMP is 1 if your system has the _setjmp() call.
352 * This is normally the case only for BSD 4.2 and up,
353 * not for BSD 4.1 or System 5.
355 #define HAS__SETJMP $x
362 if [ "$sys" = "bsd" -a "$bsd41" = "0" ]
368 if [ $alldefault = 0 ]
370 $ECHO "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
371 $ECHO "Most System V and BSD 4.1 systems do not."
372 $ECHO "Does your system have sigsetmask()? [$def] \c"
380 cat >>defines.h <<EOF
382 * SIGSETMASK is 1 if your system has the sigsetmask() call.
383 * This is normally the case only for BSD 4.2,
384 * not for BSD 4.1 or System 5.
386 #define SIGSETMASK $x
393 if [ "$sys" = "sys5" -a "$xenix" = "0" ]
399 if [ $alldefault = 0 ]
401 $ECHO "Some SCO System V systems need sys/ptem.h included to get"
402 $ECHO "the size of the screen (struct winsize)."
403 $ECHO "Does your system need sys/ptem.h? [$def] \c"
411 cat >>defines.h <<EOF
413 * NEED_PTEM_H is 1 if your system needs sys/ptem.h to declare struct winsize.
414 * This is normally the case only for SCOs System V.
416 #define NEED_PTEM_H $x
421 if [ "$sys" = "bsd" ]
423 def=2; REGCMP=0;RECOMP=1
425 def=1; REGCMP=1;RECOMP=0
427 if [ $alldefault = 0 ]
429 $ECHO "Most System V systems have the regcmp() function."
430 $ECHO "Most Berkeley-derived systems have the re_comp() function."
431 $ECHO "Does your system have:"
434 $ECHO " 3. neither [$def] \c"
437 X1) REGCMP=1;RECOMP=0 ;;
438 X2) REGCMP=0;RECOMP=1 ;;
439 X3) REGCMP=0;RECOMP=0 ;;
443 cat >>defines.h <<EOF
445 * REGCMP is 1 if your system has the regcmp() function.
446 * This is normally the case for System 5.
447 * RECOMP is 1 if your system has the re_comp() function.
448 * This is normally the case for BSD.
449 * If neither is 1, pattern matching is supported, but without metacharacters.
451 #define REGCMP $REGCMP
452 #define RECOMP $RECOMP
461 if [ $alloptional = 0 ]
463 $ECHO "Do you wish to allow shell escapes? [$def] \c"
471 cat >>defines.h <<EOF
473 * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
474 * (This is possible only if your system supplies the system() function.)
476 #define SHELL_ESCAPE $x
485 if [ $alloptional = 0 ]
487 $ECHO "Do you wish to allow editor escapes? [$def] \c"
490 X[nN]*) x=0; edname="" ;;
492 $ECHO "What is the pathname of the default editor? [$edname] \c"
494 if [ "x$ans" != "x" ]
502 cat >>defines.h <<EOF
504 * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
505 * (This is possible only if your system supplies the system() function.)
506 * EDIT_PGM is the name of the (default) editor to be invoked.
509 #define EDIT_PGM "$edname"
518 if [ $alloptional = 0 ]
520 $ECHO "Do you wish to support \"tag\" files? [$def] \c"
528 cat >>defines.h <<EOF
530 * TAGS is 1 if you wish to support tag files.
540 if [ $alloptional = 0 ]
542 $ECHO "Do you wish to allow user-defined key definitions? [$def] \c"
551 cat >>defines.h <<EOF
553 * USERFILE is 1 if you wish to allow a .less file to specify
554 * user-defined key bindings.
564 if [ $alldefault = 0 ]
566 $ECHO "If your system provides the popen() function and"
567 $ECHO "the \"echo\" shell command, you may allow shell metacharacters"
568 $ECHO "to be expanded in filenames."
569 $ECHO "Do you wish to allow shell metacharacters in filenames? [$def] \c"
577 cat >>defines.h <<EOF
579 * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
580 * This will generally work if your system provides the "popen" function
581 * and the "echo" shell command.
586 * PIPEC is 1 if you wish to have the "|" command
587 * which allows the user to pipe data into a shell command.
597 if [ $alloptional = 0 ]
599 $ECHO "Do you wish to allow log files (-l option)? [$def] \c"
607 cat >>defines.h <<EOF
609 * LOGFILE is 1 if you wish to allow the -l option (to create log files).
615 cat >>defines.h <<EOF
617 * ONLY_RETURN is 1 if you want RETURN to be the only input which
618 * will continue past an error message.
619 * Otherwise, any key will continue past an error message.
621 #define ONLY_RETURN 0
627 ##########################################################################
628 # Compilation environment.
629 ##########################################################################
635 if [ "$xenix" = "1" ]
638 elif [ "$sys" = "bsd" ]
642 LIBS="-lcurses -ltermcap -lPW"
644 if [ $alldefault = 0 ]
646 $ECHO "To build \"less\", you must link with libraries supplied by your system."
647 $ECHO "(If this needs to be changed later, edit the makefile"
648 $ECHO "and change the definition of LIBS.)"
649 $ECHO "What libraries should be used [$LIBS] \c"
651 if [ "X$ans" != "X" ]
658 # LIBS is the list of libraries needed.
665 INSTALL_LESS="/usr/local/bin/less"
666 INSTALL_KEY="/usr/local/bin/lesskey"
667 INSTALL_HELP="/usr/local/bin/less.hlp"
668 INSTALL_LESSMAN="/usr/man/man1/less.1"
669 INSTALL_KEYMAN="/usr/man/man1/lesskey.1"
670 LESS_MANUAL="less.nro"
671 KEY_MANUAL="lesskey.nro"
672 if [ $alldefault = 0 ]
674 $ECHO "What is the name of the \"public\" (installed) version of less?"
675 $ECHO " [$INSTALL_LESS] \c"
677 if [ "X$ans" != "X" ]
681 $ECHO "What is the name of the \"public\" (installed) version of lesskey?"
682 $ECHO " [$INSTALL_KEY] \c"
684 if [ "X$ans" != "X" ]
688 $ECHO "What is the name of the \"public\" (installed) version of the help file?"
689 $ECHO " [$INSTALL_HELP] \c"
691 if [ "X$ans" != "X" ]
695 $ECHO "What is the name of the \"public\" (installed) version of the less manual page?"
696 $ECHO " [$INSTALL_LESSMAN] \c"
698 if [ "X$ans" != "X" ]
700 INSTALL_LESSMAN="$ans"
702 $ECHO "What is the name of the \"public\" (installed) version of the lesskey manual page?"
703 $ECHO " [$INSTALL_KEYMAN] \c"
705 if [ "X$ans" != "X" ]
707 INSTALL_KEYMAN="$ans"
712 cat >>defines.h <<EOF
714 * HELPFILE is the full pathname of the help file.
716 #define HELPFILE "$INSTALL_HELP"
721 # INSTALL_LESS is a list of the public versions of less.
722 # INSTALL_KEY is a list of the public versions of lesskey.
723 # INSTALL_HELP is a list of the public version of the help file.
724 # INSTALL_LESSMAN is a list of the public versions of the less manual page.
725 # INSTALL_KEYMAN is a list of the public versions of the lesskey manual page.
726 INSTALL_LESS = \$(ROOT)$INSTALL_LESS
727 INSTALL_KEY = \$(ROOT)$INSTALL_KEY
728 INSTALL_HELP = \$(ROOT)$INSTALL_HELP
729 INSTALL_LESSMAN = \$(ROOT)$INSTALL_LESSMAN
730 INSTALL_KEYMAN = \$(ROOT)$INSTALL_KEYMAN
731 LESS_MANUAL = $LESS_MANUAL
732 KEY_MANUAL = $KEY_MANUAL
733 HELPFILE = $INSTALL_HELP
740 cat >>makefile <<"EOF"
741 # OPTIM is passed to the compiler and the loader.
742 # It is normally "-O" but may be, for example, "-g".
749 ##########################################################################
751 ##########################################################################
753 SRC1 = ch.c cmdbuf.c command.c decode.c help.c input.c
754 SRC2 = line.c linenum.c main.c edit.c option.c optfunc.c \
756 SRC3 = charset.c filename.c lsystem.c output.c position.c ifile.c \
757 brac.c forwback.c jump.c search.c
758 SRC4 = mark.c prompt.c screen.c signal.c tags.c ttyin.c version.c
760 SRC = $(SRC1) $(SRC2) $(SRC3) $(SRC4)
762 OBJ = brac.o ch.o charset.o cmdbuf.o command.o decode.o edit.o filename.o \
763 forwback.o help.o input.o jump.o line.o linenum.o \
764 lsystem.o main.o option.o optfunc.o opttbl.o os.o \
765 output.o position.o mark.o ifile.o prompt.o screen.o \
766 search.o signal.o tags.o ttyin.o version.o
769 ##########################################################################
770 # Rules for building stuff
771 ##########################################################################
775 if [ "$USERFILE" = "1" ]
777 cat >>makefile <<"EOF"
779 install: install_less install_help install_key install_lman install_kman
782 cat >>makefile <<"EOF"
784 install: install_less install_help install_lman
788 cat >>makefile <<"EOF"
791 $(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS)
794 $(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS)
797 for f in $(INSTALL_LESS); do rm -f $$f; cp less $$f; done
801 for f in $(INSTALL_KEY); do rm -f $$f; cp lesskey $$f; done
804 install_help: less.hlp
805 for f in $(INSTALL_HELP); do rm -f $$f; cp less.hlp $$f; done
808 install_lman: $(LESS_MANUAL)
809 for f in $(INSTALL_LESSMAN); do rm -f $$f; cp $(LESS_MANUAL) $$f; done
812 install_kman: $(KEY_MANUAL)
813 for f in $(INSTALL_KEYMAN); do rm -f $$f; cp $(KEY_MANUAL) $$f; done
816 ##########################################################################
818 ##########################################################################
824 if [ -f funcs.h ]; then mv funcs.h funcs.h.OLD; fi
825 awk -f mkfuncs.awk $(SRC) >funcs.h
828 rm -f $(OBJ) lesskey.o less lesskey vecho
831 rm -f *.o less lesskey vecho install_less install_key \
832 install_help install_lman install_kman
835 shar -v README CHANGES linstall \
836 less.nro lesskey.nro \
837 vecho.c mkfuncs.awk > less1.shr
838 shar -v less.man lesskey.man \
839 less.h position.h cmd.h option.h > less2.shr
840 shar -v lesskey.c $(SRC1) > less3.shr
841 shar -v $(SRC2) > less4.shr
842 shar -v $(SRC3) less.hlp > less5.shr
843 shar -v $(SRC4) funcs.h > less6.shr
846 ##########################################################################
848 ##########################################################################
850 $(OBJ): less.h funcs.h defines.h position.h
851 command.o decode.o: cmd.h
852 option.o opttbl.o optfunc.o: option.h
854 lesskey.o: less.h funcs.h defines.h cmd.h
859 $ECHO "The makefile and defines.h have been built."
860 $ECHO "You should check them to make sure everything is as you want it to be."
861 $ECHO "When you are satisfied, just type \"make\", and \"less\" will be built."