#! /bin/sh # Installation script for less. # This script prompts the operator for various information # and constructs a makefile. echo "This script will build a makefile for less." echo "If you already have a file called \"makefile\" it will be overwritten." echo "Press RETURN to continue." read ans echo "I will ask you some questions about your system." echo "If you do not know the answer to any question," echo "just press RETURN and I will choose a default for you." echo "Press RETURN now." read ans ECHO=./vecho if [ ! -x $ECHO ] then echo "One moment..." cc -o $ECHO vecho.c echo "" fi $ECHO "Most Unix systems are derived from either System V" $ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc." $ECHO "" $ECHO "Is your system closest to:" $ECHO " 1. System V" $ECHO " 2. BSD 4.1" $ECHO " 3. BSD 4.2 or later" $ECHO " 4. Xenix" $ECHO "Enter a number, or just RETURN if you don't know: \c" read ans xenix=0 case "X$ans" in X1) sys=sys5; sysname="System V" ;; X2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;; X3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;; X4) sys=sys5; xenix=1; sysname="Xenix" ;; *) sys=unknown ;; esac $ECHO "" DATE=`date` cat >makefile <>makefile <<"EOF" # # Invoked as: # make all # or make install # Plain "make" is equivalent to "make all". # # If you add or delete functions, remake funcs.h by doing: # make newfuncs # This depends on the coding convention of function headers looking like: # " \t public \n ( ... ) " # # Also provided: # make lint # Runs "lint" on all the sources. # make clean # Removes "less" and the .o files. # make clobber # Pretty much the same as make "clean". SHELL = /bin/sh EOF cat >defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>defines.h <>makefile <>makefile <>makefile <>makefile <<"EOF" # OPTIM is passed to the compiler and the loader. # It is normally "-O" but may be, for example, "-g". OPTIM = -O CFLAGS = $(OPTIM) ########################################################################## # Files ########################################################################## SRC1 = main.c option.c prim.c ch.c position.c input.c linenum.c SRC2 = screen.c prompt.c line.c signal.c os.c help.c ttyin.c command.c SRC3 = output.c decode.c tags.c version.c SRC = $(SRC1) $(SRC2) $(SRC3) OBJ = main.o option.o prim.o ch.o position.o input.o output.o \ screen.o prompt.o line.o signal.o os.o help.o ttyin.o \ decode.o command.o linenum.o tags.o version.o ########################################################################## # Rules for building stuff ########################################################################## EOF if [ "$USERFILE" = "1" ] then cat >>makefile <<"EOF" all: less lesskey install: install_less install_help install_key install_lman install_kman EOF else cat >>makefile <<"EOF" all: less install: install_less install_help install_lman EOF fi cat >>makefile <<"EOF" less: $(OBJ) $(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS) lesskey: lesskey.o $(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS) # help.o depends on makefile for the definition of HELPFILE help.o: makefile $(CC) $(CFLAGS) -c -DHELPFILE=\"$(HELPFILE)\" help.c install_less: less for f in $(INSTALL_LESS); do rm -f $$f; cp less $$f; done touch install_less install_key: lesskey for f in $(INSTALL_KEY); do rm -f $$f; cp lesskey $$f; done touch install_key install_help: less.help for f in $(INSTALL_HELP); do rm -f $$f; cp less.help $$f; done touch install_help install_lman: $(LESS_MANUAL) for f in $(INSTALL_LESSMAN); do rm -f $$f; cp $(LESS_MANUAL) $$f; done touch install_lman install_kman: $(KEY_MANUAL) for f in $(INSTALL_KEYMAN); do rm -f $$f; cp $(KEY_MANUAL) $$f; done touch install_kman ########################################################################## # Maintenance ########################################################################## lint: lint -hp $(SRC) newfuncs: mv funcs.h funcs.h.OLD awk -f mkfuncs.awk $(SRC) >funcs.h clean: rm -f $(OBJ) lesskey.o less lesskey vecho clobber: rm -f *.o less lesskey vecho install_less install_key \ install_help install_lman install_kman shar: shar -v linstall less.h position.h funcs.h cmd.h \ vecho.c lesskey.c less.nro lesskey.nro lesskey.man > less.shar.a shar -v $(SRC1) > less.shar.b shar -v $(SRC2) > less.shar.c shar -v $(SRC3) less.man README less.help *.awk >less.shar.d ########################################################################## # Dependencies ########################################################################## $(OBJ): less.h funcs.h defines.h position.h command.o decode.o: cmd.h lesskey.o: less.h funcs.h defines.h cmd.h EOF $ECHO "" $ECHO "The makefile has been built." $ECHO "You should check it to make sure everything is as you want it to be." $ECHO "When you are satisfied with the makefile, just type \"make\"" $ECHO "and \"less\" will be built."