Configure (24139) | Configure (89750) |
---|---|
1#!/bin/csh -f 2# 3# Configuration script for top. 4# 5# Use with version 3.0 and higher. 6# 7set PRIME = "/usr/games/primes" 8set vars = (module LoadMax topn NominalTopn delay owner group mode random \ --- 11 unchanged lines hidden (view full) --- 20endif 21chmod +x getans 22 23if ($#argv > 0) then 24# fast track configuration 25 set fastrack = 1 26else 27cat <<'EOF' | 1#!/bin/csh -f 2# 3# Configuration script for top. 4# 5# Use with version 3.0 and higher. 6# 7set PRIME = "/usr/games/primes" 8set vars = (module LoadMax topn NominalTopn delay owner group mode random \ --- 11 unchanged lines hidden (view full) --- 20endif 21chmod +x getans 22 23if ($#argv > 0) then 24# fast track configuration 25 set fastrack = 1 26else 27cat <<'EOF' |
28Configuration for top, version 3.4 | 28Configuration for top, version 3.5 |
29 30One moment.... 31'EOF' 32endif 33 34# collect file names and module names 35ls machine/m_*.c >$$.f 36ls machine/m_*.man >$$.m 37sed -e 's@^machine/m_@@' -e 's/.c$//' $$.f >$$.n 38 39# build Make.desc | 29 30One moment.... 31'EOF' 32endif 33 34# collect file names and module names 35ls machine/m_*.c >$$.f 36ls machine/m_*.man >$$.m 37sed -e 's@^machine/m_@@' -e 's/.c$//' $$.f >$$.n 38 39# build Make.desc |
40set descs = `sed -e 's@\.c$@.desc@' $$.f` 41sed -e "s@%descs%@$descs@" Make.desc.X >Make.desc | 40sed -e 's@\.c@.desc\\@' $$.f | sed -e '$s/\\//' >$$.a 41sed -e "/^DESCS/r $$.a" Make.desc.X >Make.desc |
42 43# build desc files and SYNOPSIS as needed 44make -f Make.desc >/dev/null | 42 43# build desc files and SYNOPSIS as needed 44make -f Make.desc >/dev/null |
45if ($status != 0) then 46 echo "Unable to build the synopsis." 47 echo 'Make sure the command "make" is on your path and try' 48 echo 'running Configure again.' 49 exit 1 50endif |
|
45 46if (-e .defaults) then 47 echo "" 48 echo "Reading configuration from last time..." 49 source .defaults 50 set nodefaults = 0 51 if ($fastrack == 1) then 52 set module = $1 --- 24 unchanged lines hidden (view full) --- 77endif 78echo "" 79 80if ($fastrack == 1) then 81 grep -s $module $$.n >/dev/null 82 if ($status != 0) then 83 echo "$module is not recognized. To see a list of available modules" 84 echo 'run "Configure" with no arguments.' | 51 52if (-e .defaults) then 53 echo "" 54 echo "Reading configuration from last time..." 55 source .defaults 56 set nodefaults = 0 57 if ($fastrack == 1) then 58 set module = $1 --- 24 unchanged lines hidden (view full) --- 83endif 84echo "" 85 86if ($fastrack == 1) then 87 grep -s $module $$.n >/dev/null 88 if ($status != 0) then 89 echo "$module is not recognized. To see a list of available modules" 90 echo 'run "Configure" with no arguments.' |
85 rm -f $$.[fmn] | 91 rm -f $$.[fmna] |
86 exit 1 87 endif 88 set random1 = `expr $random + 1` 89 cat <<EOF 90Using these settings: 91 Bourne Shell $Cmdshell 92 C compiler $Cmdcc 93 Compiler options $cdefs --- 29 unchanged lines hidden (view full) --- 123 124# display synopses 125 126getmod: 127cat <<'EOF' 128 129The following machine-dependent modules are available: 130'EOF' | 92 exit 1 93 endif 94 set random1 = `expr $random + 1` 95 cat <<EOF 96Using these settings: 97 Bourne Shell $Cmdshell 98 C compiler $Cmdcc 99 Compiler options $cdefs --- 29 unchanged lines hidden (view full) --- 129 130# display synopses 131 132getmod: 133cat <<'EOF' 134 135The following machine-dependent modules are available: 136'EOF' |
131awk -F: ' { printf "%-8s %s\n", $1, $2 }' SYNOPSIS | 137awk -F: ' { printf "%-10s %s\n", $1, $2 }' SYNOPSIS |
132echo '' 133./getans "What module is appropriate for this machine? " string "$module" .$$ 134set module = `cat .$$` 135 136if ("$module" == "") then 137 echo "Please specify a valid module name." 138 goto getmod 139endif --- 111 unchanged lines hidden (view full) --- 251'EOF' 252 253./getans "Default Delay" integer "$delay" .$$ 254set delay = `cat .$$` 255 256echo "" 257 258set rand = 0 | 138echo '' 139./getans "What module is appropriate for this machine? " string "$module" .$$ 140set module = `cat .$$` 141 142if ("$module" == "") then 143 echo "Please specify a valid module name." 144 goto getmod 145endif --- 111 unchanged lines hidden (view full) --- 257'EOF' 258 259./getans "Default Delay" integer "$delay" .$$ 260set delay = `cat .$$` 261 262echo "" 263 264set rand = 0 |
259ypwhich >&/dev/null 260if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then 261 set rand = 1 | 265if (-e /etc/nsswitch.conf) then 266 set rand = `grep '^passwd:.*nis' /etc/nsswitch.conf | wc -l` 267 if ($rand > 1) then 268 set rand = 1 269 endif 270else 271 ypwhich >&/dev/null 272 if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then 273 set rand = 1 274 endif |
262endif 263 264if ($rand == 1) then 265 echo "It looks like you have a passwd file that can be accessed at random." 266 set pr = 'Do you want top to take advantage of this' 267else 268 echo "It looks like you have conventional passwd file access. Top can take" 269 echo "advantage of a random access passwd mechanism if such exists. Do" --- 18 unchanged lines hidden (view full) --- 288 289echo "" 290 291ypcat passwd.byname >&/tmp/$$.a 292if ($status == 0) then 293 set cnt = `wc -l </tmp/$$.a` 294 set mapfile = "NIS map" 295else | 275endif 276 277if ($rand == 1) then 278 echo "It looks like you have a passwd file that can be accessed at random." 279 set pr = 'Do you want top to take advantage of this' 280else 281 echo "It looks like you have conventional passwd file access. Top can take" 282 echo "advantage of a random access passwd mechanism if such exists. Do" --- 18 unchanged lines hidden (view full) --- 301 302echo "" 303 304ypcat passwd.byname >&/tmp/$$.a 305if ($status == 0) then 306 set cnt = `wc -l </tmp/$$.a` 307 set mapfile = "NIS map" 308else |
296 set cnt = `wc -l </etc/passwd` 297 set mapfile = "file" | 309 rm /tmp/$$.a 310 niscat passwd.org_dir >&/tmp/$$.a 311 if ($status == 0) then 312 set cnt = `wc -l </tmp/$$.a` 313 set mapfile = "NISPLUS map" 314 else 315 set cnt = `wc -l </etc/passwd` 316 set mapfile = "file" 317 endif |
298endif 299rm /tmp/$$.a 300set double = `expr $cnt \* 2` 301echo "I found $cnt entries in your passwd $mapfile. Top hashes the username to" 302echo "uid mappings as it goes along and it needs a good guess on the size of" 303echo "that hash table. This number should be the next highest prime number" 304echo "after $double." 305echo "" --- 24 unchanged lines hidden (view full) --- 330if (`$ls getans | wc -w` < 9) then 331 set ls = "ls -lg" 332endif 333 334set t_owner = root 335set t_group = `$ls -d /usr/bin | awk ' { print $4 }'` 336if (-e /proc) then 337 cat <<EOF | 318endif 319rm /tmp/$$.a 320set double = `expr $cnt \* 2` 321echo "I found $cnt entries in your passwd $mapfile. Top hashes the username to" 322echo "uid mappings as it goes along and it needs a good guess on the size of" 323echo "that hash table. This number should be the next highest prime number" 324echo "after $double." 325echo "" --- 24 unchanged lines hidden (view full) --- 350if (`$ls getans | wc -w` < 9) then 351 set ls = "ls -lg" 352endif 353 354set t_owner = root 355set t_group = `$ls -d /usr/bin | awk ' { print $4 }'` 356if (-e /proc) then 357 cat <<EOF |
338Uh oh! I see /proc out there. Some new Unix variants provide the /proc 339file system as a mechanism to get to a process's address space. This 340directory is typically only accessible by root. However, there are a few 341systems (such as DG/UX) on which this directory exists, but isn't used. 342I'm going to assume that top needs to run setuid to root, but you should 343double check and use mode 2755 (set group id) if top doesn't really need 344root access. If you are running SunOS 5.x then you will need to install 345top setuid root (owner root and mode 4711). | 358I see /proc out there. Many Unix variants provide the /proc file 359system as a mechanism to get to a process's address space. This 360directory is typically only accessible by root. However, there are a 361few systems (such as DG/UX) on which this directory exists, but isn't 362used. |
346 347EOF | 363 364EOF |
348 set t_mode = 4711 349 set mode = 4711 | 365 if (-r /proc/0/psinfo) then 366 set t_mode = 2711 367 set mode = 2711 368 set t_group = sys 369 set group = sys 370 cat <<EOF 371It looks like this system is running Solaris 2.6 or greater. If this 372is the case, then top can function just fine installed set group id to 373sys. It does not need to be installed set-uid to root. 374 375EOF 376 else 377 set t_mode = 4711 378 set mode = 4711 379 cat <<EOF 380I'm going to assume that top needs to run setuid to root, but you 381should double check and use mode 2755 (set group id) if top doesn't 382really need root access. If you are running SunOS 5.0 through SunOS 3835.5.1 (that's Solaris 2.0 through Solaris 2.5.1) then you will need to 384install top setuid root (owner root and mode 4711). In SunOS 5.6 385and higher top only requires set group id sys permissions. 386 387EOF 388 endif |
350else if (-e /dev/kmem) then 351 $ls /dev/kmem >/tmp/$$.b 352 grep '^....r..r..' /tmp/$$.b >&/dev/null 353 if ($status == 1) then 354 grep '^....r..-..' /tmp/$$.b >&/dev/null 355 if ($status == 0) then 356 set t_group = `awk ' { print $4 }' /tmp/$$.b` 357 set t_mode = 2755 --- 41 unchanged lines hidden (view full) --- 399set mansty = `cat .$$` 400 401echo "" 402echo "We are done with the questions." 403 404# Some Unix environments are so poor that their csh doesn't even support 405# the "eval" builtin. Check for this before relying on its use to save 406# the current configuration. | 389else if (-e /dev/kmem) then 390 $ls /dev/kmem >/tmp/$$.b 391 grep '^....r..r..' /tmp/$$.b >&/dev/null 392 if ($status == 1) then 393 grep '^....r..-..' /tmp/$$.b >&/dev/null 394 if ($status == 0) then 395 set t_group = `awk ' { print $4 }' /tmp/$$.b` 396 set t_mode = 2755 --- 41 unchanged lines hidden (view full) --- 438set mansty = `cat .$$` 439 440echo "" 441echo "We are done with the questions." 442 443# Some Unix environments are so poor that their csh doesn't even support 444# the "eval" builtin. Check for this before relying on its use to save 445# the current configuration. |
407/bin/csh -c "eval echo foo" >&/dev/null | 446/bin/csh -fc "eval echo foo" >&/dev/null |
408if ($status == 1) then 409 echo "Can't save configuration (nonfatal)" 410else 411 echo "Saving configuration..." 412# save settings to use as defaults the next time 413 rm -f .defaults | 447if ($status == 1) then 448 echo "Can't save configuration (nonfatal)" 449else 450 echo "Saving configuration..." 451# save settings to use as defaults the next time 452 rm -f .defaults |
453 touch .defaults |
|
414 foreach v ($vars) 415 set tmp = `eval echo \$$v` 416 echo set $v = "'$tmp'" >>.defaults 417 end 418endif 419 420fast: 421 | 454 foreach v ($vars) 455 set tmp = `eval echo \$$v` 456 echo set $v = "'$tmp'" >>.defaults 457 end 458endif 459 460fast: 461 |
422# set variables which contain module lists 423set modules = `cat $$.f` 424set manmodules = `cat $$.m` 425 | |
426# clean up | 462# clean up |
427rm -f $$.f $$.m $$.n | 463rm -f $$.[fmna] |
428 429# set the link for machine.c 430rm -f machine.c machine.o 431ln -s machine/m_${module}.c machine.c 432 433# get definitions out of the module file 434set libs = `grep LIBS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` 435set cflgs = `grep CFLAGS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` 436set tcap = `grep TERMCAP: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` | 464 465# set the link for machine.c 466rm -f machine.c machine.o 467ln -s machine/m_${module}.c machine.c 468 469# get definitions out of the module file 470set libs = `grep LIBS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` 471set cflgs = `grep CFLAGS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` 472set tcap = `grep TERMCAP: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` |
473set math = `grep MATH: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'` |
|
437 | 474 |
475# get osrev defition, if we can 476set uname="" 477if (-e /usr/bin/uname) then 478 set uname=/usr/bin/uname 479else if (-e /bin/uname) then 480 set uname=/bin/uname 481endif 482 483if ("$uname" != "") then 484# different versions of tr can't agree on the way to specify ranges, so 485# we will have to give the range explicitly.....sigh. 486 set osrev="-DOSREV=`$uname -r | tr -cd ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`" 487else 488 set osrev="" 489endif 490 |
|
438# default for tcap (termcap) 439if ("$tcap" == "") then 440 set tcap="-ltermcap" | 491# default for tcap (termcap) 492if ("$tcap" == "") then 493 set tcap="-ltermcap" |
494else if ("$tcap" == "none") then 495 set tcap="" |
|
441endif 442 | 496endif 497 |
498# allow for the module to override or remove -lm 499if ("$math" == "") then 500 set math="-lm" 501else if ("$math" == "none") then 502 set math="" 503endif 504 |
|
443if ( { grep -s SIGKILL /usr/include/signal.h } ) then 444 set signal="/usr/include/signal.h" 445else 446 set signal="/usr/include/sys/signal.h" 447endif 448 449 450echo "Building Makefile..." --- 5 unchanged lines hidden (view full) --- 456 -e "s|%bindir%|$bindir|" \ 457 -e "s|%mandir%|$mandir|" \ 458 -e "s|%manext%|$manext|" \ 459 -e "s|%mansty%|$mansty|" \ 460 -e "s|%tablesize%|$TableSize|" \ 461 -e "s|%libs%|$libs|" \ 462 -e "s|%cflgs%|$cflgs|" \ 463 -e "s|%termcap%|$tcap|" \ | 505if ( { grep -s SIGKILL /usr/include/signal.h } ) then 506 set signal="/usr/include/signal.h" 507else 508 set signal="/usr/include/sys/signal.h" 509endif 510 511 512echo "Building Makefile..." --- 5 unchanged lines hidden (view full) --- 518 -e "s|%bindir%|$bindir|" \ 519 -e "s|%mandir%|$mandir|" \ 520 -e "s|%manext%|$manext|" \ 521 -e "s|%mansty%|$mansty|" \ 522 -e "s|%tablesize%|$TableSize|" \ 523 -e "s|%libs%|$libs|" \ 524 -e "s|%cflgs%|$cflgs|" \ 525 -e "s|%termcap%|$tcap|" \ |
526 -e "s|%math%|$math|" \ |
|
464 -e "s|%cdefs%|$cdefs|" \ | 527 -e "s|%cdefs%|$cdefs|" \ |
465 -e "s|%modules%|$modules|" \ 466 -e "s|%manmodules%|$manmodules|" \ | |
467 -e "s|%signal%|$signal|" \ 468 -e "s|%cc%|$Cmdcc|" \ 469 -e "s|%awk%|$Cmdawk|" \ 470 -e "s|%install%|$Cmdinstall|" \ 471 -e "s|%shell%|$Cmdshell|" \ | 528 -e "s|%signal%|$signal|" \ 529 -e "s|%cc%|$Cmdcc|" \ 530 -e "s|%awk%|$Cmdawk|" \ 531 -e "s|%install%|$Cmdinstall|" \ 532 -e "s|%shell%|$Cmdshell|" \ |
533 -e "s|%osrev%|$osrev|" \ |
|
472 Makefile.X >Makefile 473 474echo "Building top.local.h..." 475sed -e "s|%LoadMax%|$LoadMax|" \ 476 -e "s|%TableSize%|$TableSize|" \ 477 -e "s|%NominalTopn%|$NominalTopn|" \ 478 -e "s|%topn%|$topn|" \ 479 -e "s|%delay%|$delay|" \ --- 14 unchanged lines hidden (view full) --- 494echo 'Doing a "make clean".' 495make clean 496 497echo 'To create the executable, type "make".' 498echo 'To install the executable, type "make install".' 499exit 0 500 501byebye: | 534 Makefile.X >Makefile 535 536echo "Building top.local.h..." 537sed -e "s|%LoadMax%|$LoadMax|" \ 538 -e "s|%TableSize%|$TableSize|" \ 539 -e "s|%NominalTopn%|$NominalTopn|" \ 540 -e "s|%topn%|$topn|" \ 541 -e "s|%delay%|$delay|" \ --- 14 unchanged lines hidden (view full) --- 556echo 'Doing a "make clean".' 557make clean 558 559echo 'To create the executable, type "make".' 560echo 'To install the executable, type "make install".' 561exit 0 562 563byebye: |
502rm -f .$$ $$.[fmn] /tmp/$$.[ab] | 564rm -f .$$ $$.[fmna] /tmp/$$.[ab] |
503exit 1 | 565exit 1 |