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