124139Sjoerg#!/bin/csh -f
224139Sjoerg#
324139Sjoerg# Configuration script for top.
424139Sjoerg#
524139Sjoerg# Use with version 3.0 and higher.
624139Sjoerg#
724139Sjoergset PRIME = "/usr/games/primes"
824139Sjoergset vars = (module LoadMax topn NominalTopn delay owner group mode random \
924139Sjoerg	TableSize bindir mandir manext mansty \
1024139Sjoerg	Cmdshell Cmdcc Cmdawk Cmdinstall cdefs)
1124139Sjoergset fastrack = 0
1224139Sjoergset yesno = (no yes)
1324139Sjoerg
1424139Sjoergonintr byebye
1524139Sjoerg
1624139Sjoerg# make sure that getans is there and ready
1724139Sjoergif (! -e getans) then
1824139Sjoerg   echo 'This package is not complete.  The shell file "getans" is missing.'
1924139Sjoerg   exit 10
2024139Sjoergendif
2124139Sjoergchmod +x getans
2224139Sjoerg
2324139Sjoergif ($#argv > 0) then
2424139Sjoerg# fast track configuration
2524139Sjoerg   set fastrack = 1
2624139Sjoergelse
2724139Sjoergcat <<'EOF'
2889750SdwmaloneConfiguration for top, version 3.5
2924139Sjoerg
3024139SjoergOne moment....
3124139Sjoerg'EOF'
3224139Sjoergendif
3324139Sjoerg
3424139Sjoerg# collect file names and module names
3524139Sjoergls machine/m_*.c >$$.f
3624139Sjoergls machine/m_*.man >$$.m
3724139Sjoergsed -e 's@^machine/m_@@' -e 's/.c$//' $$.f >$$.n
3824139Sjoerg
3924139Sjoerg# build Make.desc
4089750Sdwmalonesed -e 's@\.c@.desc\\@' $$.f | sed -e '$s/\\//' >$$.a
4189750Sdwmalonesed -e "/^DESCS/r $$.a" Make.desc.X >Make.desc
4224139Sjoerg
4324139Sjoerg# build desc files and SYNOPSIS as needed
4424139Sjoergmake -f Make.desc >/dev/null
4589750Sdwmaloneif ($status != 0) then
4689750Sdwmalone   echo "Unable to build the synopsis."
4789750Sdwmalone   echo 'Make sure the command "make" is on your path and try'
4889750Sdwmalone   echo 'running Configure again.'
4989750Sdwmalone   exit 1
5089750Sdwmaloneendif
5124139Sjoerg
5224139Sjoergif (-e .defaults) then
5324139Sjoerg   echo ""
5424139Sjoerg   echo "Reading configuration from last time..."
5524139Sjoerg   source .defaults
5624139Sjoerg   set nodefaults = 0
5724139Sjoerg   if ($fastrack == 1) then
5824139Sjoerg      set module = $1
5924139Sjoerg   endif
6024139Sjoergelse
6124139Sjoerg   if ($fastrack == 1) then
6224139Sjoerg      echo "No previous configuration was found."
6324139Sjoerg      set fastrack = 0
6424139Sjoerg      set module = $1
6524139Sjoerg   else
6624139Sjoerg      set module = ""
6724139Sjoerg   endif
6824139Sjoerg   set LoadMax     = 5.0
6924139Sjoerg   set topn        = 15
7024139Sjoerg   set NominalTopn = 18
7124139Sjoerg   set delay       = 5
7224139Sjoerg   set TableSize   = 0
7324139Sjoerg   set bindir      = /usr/local/bin
7424139Sjoerg   set mandir      = /usr/man/manl
7524139Sjoerg   set manext      = l
7624139Sjoerg   set mansty      = man
7724139Sjoerg   set nodefaults  = 1
7824139Sjoerg   set Cmdshell    = /bin/sh
7924139Sjoerg   set Cmdawk      = awk
8024139Sjoerg   set Cmdinstall  = ./install
8124139Sjoerg   set Cmdcc       = cc
8224139Sjoerg   set cdefs       = -O
8324139Sjoergendif
8424139Sjoergecho ""
8524139Sjoerg
8624139Sjoergif ($fastrack == 1) then
8724139Sjoerg   grep -s $module $$.n >/dev/null
8824139Sjoerg   if ($status != 0) then
8924139Sjoerg      echo "$module is not recognized.  To see a list of available modules"
9024139Sjoerg      echo 'run "Configure" with no arguments.'
9189750Sdwmalone      rm -f $$.[fmna]
9224139Sjoerg      exit 1
9324139Sjoerg   endif
9424139Sjoerg   set random1 = `expr $random + 1`
9524139Sjoerg   cat <<EOF
9624139SjoergUsing these settings:
9724139Sjoerg        Bourne Shell   $Cmdshell
9824139Sjoerg          C compiler   $Cmdcc
9924139Sjoerg    Compiler options   $cdefs
10024139Sjoerg         Awk command   $Cmdawk
10124139Sjoerg     Install command   $Cmdinstall
10224139Sjoerg
10324139Sjoerg              Module   $module
10424139Sjoerg             LoadMax   $LoadMax
10524139Sjoerg        Default TOPN   $topn
10624139Sjoerg        Nominal TOPN   $NominalTopn
10724139Sjoerg       Default Delay   $delay
10824139SjoergRandom passwd access   $yesno[$random1]
10924139Sjoerg          Table Size   $TableSize
11024139Sjoerg               Owner   $owner
11124139Sjoerg         Group Owner   $group
11224139Sjoerg                Mode   $mode
11324139Sjoerg       bin directory   $bindir
11424139Sjoerg       man directory   $mandir
11524139Sjoerg       man extension   $manext
11624139Sjoerg       man style       $mansty
11724139Sjoerg
11824139SjoergEOF
11924139Sjoerg   goto fast
12024139Sjoergendif
12124139Sjoerg
12224139Sjoergcat <<'EOF'
12324139SjoergYou will be asked a series of questions.  Each question will have a
12424139Sjoergdefault answer enclosed in brackets, such as "[5.0]".  In most cases,
12524139Sjoergthe default answer will work well.  To use that value, merely press
12624139Sjoergreturn.
12724139Sjoerg
12824139Sjoerg'EOF'
12924139Sjoerg
13024139Sjoerg# display synopses
13124139Sjoerg
13224139Sjoerggetmod:
13324139Sjoergcat <<'EOF'
13424139Sjoerg
13524139SjoergThe following machine-dependent modules are available:
13624139Sjoerg'EOF'
13789750Sdwmaloneawk -F: ' { printf "%-10s %s\n", $1, $2 }' SYNOPSIS
13824139Sjoergecho ''
13924139Sjoerg./getans "What module is appropriate for this machine? " string "$module" .$$
14024139Sjoergset module = `cat .$$`
14124139Sjoerg
14224139Sjoergif ("$module" == "") then
14324139Sjoerg    echo "Please specify a valid module name."
14424139Sjoerg    goto getmod
14524139Sjoergendif
14624139Sjoerg
14724139Sjoerg# is it a valid one?
14824139Sjoerggrep -s "$module" $$.n >/dev/null
14924139Sjoergif ($status != 0) then
15024139Sjoerg    echo "That is not a recognized module name."
15124139Sjoerg    goto getmod
15224139Sjoergendif
15324139Sjoerg
15424139Sjoerg# display a full description
15524139Sjoergsed -e '1,/DESCRIPTION:/d' -e '/^$/,$d' machine/m_${module}.desc
15624139Sjoerg
15724139Sjoerg# verify it
15824139Sjoergecho ""
15924139Sjoerg./getans "Is this what you want to use?" yesno 1 .$$
16024139Sjoergif (`cat .$$` == 0) then
16124139Sjoerg   goto getmod
16224139Sjoergendif
16324139Sjoergendif
16424139Sjoerg
16524139Sjoergcat <<'EOF'
16624139Sjoerg
16724139SjoergFirst we need to find out a little bit about the executables needed to
16824139Sjoergcompile top.
16924139Sjoerg
17024139Sjoerg'EOF'
17124139Sjoerg./getans "What is the full path name for the Bourne shell" file "$Cmdshell" .$$
17224139Sjoergset Cmdshell = `cat .$$`
17324139Sjoerg
17424139Sjoergcat <<'EOF'
17524139Sjoerg
17624139SjoergPlease supply the name of the appropriate command.  It need not be a
17724139Sjoergfull path name, but the named command does need to exist somewhere on
17824139Sjoergthe current path.
17924139Sjoerg
18024139Sjoerg'EOF'
18124139Sjoerg./getans "AWK Interpreter" path "$Cmdawk" .$$
18224139Sjoergset Cmdawk = `cat .$$`
18324139Sjoerg./getans "C Compiler" path "$Cmdcc" .$$
18424139Sjoergset Cmdcc = `cat .$$`
18524139Sjoerg
18624139Sjoergcat <<'EOF'
18724139Sjoerg
18824139SjoergThe installer command needs to understand Berkeley-esque arguments:
18924139Sjoerg"-o" for owner, "-g" for group, and "-m" for mode.  A shell script
19024139Sjoergcalled "install" is distributed with top and is suitable for use by
19124139Sjoergtop.  You can specify a different program here if you like, or use
19224139Sjoergthe shell script (the default).
19324139Sjoerg
19424139Sjoerg'EOF'
19524139Sjoerg./getans "Installer" path "$Cmdinstall" .$$
19624139Sjoergset Cmdinstall = `cat .$$`
19724139Sjoerg
19824139Sjoergcat <<EOF
19924139Sjoerg
20024139SjoergWhat other options should be used with the $Cmdcc command (use "none" to
20124139Sjoergspecify no options)?
20224139SjoergEOF
20324139Sjoerg./getans "Compiler options" string "$cdefs" .$$
20424139Sjoergset cdefs = `cat .$$`
20524139Sjoergif ("$cdefs" == "none") then
20624139Sjoerg    set cdefs = ""
20724139Sjoergendif
20824139Sjoerg
20924139Sjoergcat <<'EOF'
21024139Sjoerg
21124139SjoergNow you need to answer some questions concerning the configuration of
21224139Sjoergtop itself.
21324139Sjoerg
21424139SjoergThe space command forces an immediate update.  Sometimes, on loaded
21524139Sjoergsystems, this update will take a significant period of time (because all
21624139Sjoergthe output is buffered).  So, if the short-term load average is above
21724139Sjoerg"LoadMax", then top will put the cursor home immediately after the space
21824139Sjoergis pressed before the next update is attempted.  This serves as a visual
21924139Sjoergacknowledgement of the command.  "LoadMax" should always be specified as a
22024139Sjoergfloating point number.
22124139Sjoerg
22224139Sjoerg'EOF'
22324139Sjoerg./getans "LoadMax" number "$LoadMax" .$$
22424139Sjoergset LoadMax = `cat .$$`
22524139Sjoerg
22624139Sjoergcat <<'EOF'
22724139Sjoerg
22824139Sjoerg"Default TOPN" is the default number of processes to show.  This is the
22924139Sjoergnumber that will be used when the user does not specify the number of
23024139Sjoergprocesses to show.  If you want "all" (or infinity) as the default, use
23124139Sjoergthe value "-1".
23224139Sjoerg
23324139Sjoerg'EOF'
23424139Sjoerg
23524139Sjoerg./getans "Default TOPN" neginteger "$topn" .$$
23624139Sjoergset topn = `cat .$$`
23724139Sjoerg
23824139Sjoergcat <<'EOF'
23924139Sjoerg
24024139Sjoerg"Nominal_TOPN" is used as the default TOPN when Default_TOPN is Infinity
24124139Sjoergand the output is a dumb terminal.  If we didn't do this, then
24224139Sjoerginstallations who use a default TOPN of Infinity will get every process in
24324139Sjoergthe system when running top on a dumb terminal (or redirected to a file).
24424139SjoergNote that Nominal_TOPN is a default: it can still be overridden on the
24524139Sjoergcommand line, even with the value "infinity".
24624139Sjoerg
24724139Sjoerg'EOF'
24824139Sjoerg
24924139Sjoerg./getans "Nominal TOPN" integer "$NominalTopn" .$$
25024139Sjoergset NominalTopn = `cat .$$`
25124139Sjoerg
25224139Sjoergcat <<'EOF'
25324139Sjoerg
25424139SjoergDefault Delay is the default number of seconds to wait between screen
25524139Sjoergupdates.
25624139Sjoerg
25724139Sjoerg'EOF'
25824139Sjoerg
25924139Sjoerg./getans "Default Delay" integer "$delay" .$$
26024139Sjoergset delay = `cat .$$`
26124139Sjoerg
26224139Sjoergecho ""
26324139Sjoerg
26424139Sjoergset rand = 0
26589750Sdwmaloneif (-e /etc/nsswitch.conf) then
26689750Sdwmalone   set rand = `grep '^passwd:.*nis' /etc/nsswitch.conf | wc -l`
26789750Sdwmalone   if ($rand > 1) then
26889750Sdwmalone      set rand = 1
26989750Sdwmalone   endif
27089750Sdwmaloneelse
27189750Sdwmalone   ypwhich >&/dev/null
27289750Sdwmalone   if ($status == 0 || -e /etc/passwd.dir || -e /etc/pwd.db) then
27389750Sdwmalone      set rand = 1
27489750Sdwmalone   endif
27524139Sjoergendif
27624139Sjoerg
27724139Sjoergif ($rand == 1) then
27824139Sjoerg   echo "It looks like you have a passwd file that can be accessed at random."
27924139Sjoerg   set pr = 'Do you want top to take advantage of this'
28024139Sjoergelse
28124139Sjoerg   echo "It looks like you have conventional passwd file access.  Top can take"
28224139Sjoerg   echo "advantage of a random access passwd mechanism if such exists.  Do"
28324139Sjoerg   echo "you want top to assume that accesses to the file /etc/passwd are done"
28424139Sjoerg   set pr = 'with random access rather than sequential'
28524139Sjoergendif
28624139Sjoerg
28724139Sjoergif ($nodefaults == 1) then
28824139Sjoerg   set random = $rand
28924139Sjoergendif
29024139Sjoerg
29124139Sjoerg./getans "${pr}?" yesno $random .$$
29224139Sjoergset random = `cat .$$`
29324139Sjoerg
29424139Sjoergecho ""
29524139Sjoergecho "Compiling prime.c"
29624139Sjoerg$Cmdcc $cdefs -o prime prime.c -lm
29724139Sjoergif ($status != 0) then
29824139Sjoerg    echo "Oh well."
29924139Sjoerg    rm -f prime
30024139Sjoergendif
30124139Sjoerg
30224139Sjoergecho ""
30324139Sjoerg
30424139Sjoergypcat passwd.byname >&/tmp/$$.a
30524139Sjoergif ($status == 0) then
30624139Sjoerg   set cnt = `wc -l </tmp/$$.a`
30724139Sjoerg   set mapfile = "NIS map"
30824139Sjoergelse
30989750Sdwmalone   rm /tmp/$$.a
31089750Sdwmalone   niscat passwd.org_dir >&/tmp/$$.a
31189750Sdwmalone   if ($status == 0) then
31289750Sdwmalone      set cnt = `wc -l </tmp/$$.a`
31389750Sdwmalone      set mapfile = "NISPLUS map"
31489750Sdwmalone   else
31589750Sdwmalone      set cnt = `wc -l </etc/passwd`
31689750Sdwmalone      set mapfile = "file"
31789750Sdwmalone   endif
31824139Sjoergendif
31924139Sjoergrm /tmp/$$.a
32024139Sjoergset double = `expr $cnt \* 2`
32124139Sjoergecho "I found $cnt entries in your passwd $mapfile.  Top hashes the username to"
32224139Sjoergecho "uid mappings as it goes along and it needs a good guess on the size of"
32324139Sjoergecho "that hash table.  This number should be the next highest prime number"
32424139Sjoergecho "after $double."
32524139Sjoergecho ""
32624139Sjoergif (-e prime) then
32724139Sjoerg   set pr = `./prime $double`
32824139Sjoerg   echo "I have calculated that to be $pr."
32924139Sjoergelse if (-e $PRIME) then
33024139Sjoerg   set pr = `$PRIME $double | head -1`
33124139Sjoerg   echo "I have calculated that to be $pr."
33224139Sjoergelse
33324139Sjoerg   set pr = $double
33424139Sjoerg   echo "I cannot calculate that prime number, so you will need to provide it for me."
33524139Sjoergendif
33624139Sjoerg
33724139Sjoergif ($TableSize == 0) then
33824139Sjoerg   set TableSize = $pr
33924139Sjoergendif
34024139Sjoerg
34124139Sjoerg./getans "Enter the hash table size" integer "$TableSize" .$$
34224139Sjoergset TableSize = `cat .$$`
34324139Sjoerg
34424139Sjoergecho ""
34524139Sjoerg
34624139Sjoerg# !!! I need to fix this:  /dev/kmem might not exist on some machines !!!
34724139Sjoerg
34824139Sjoerg# determine the right way to invoke ls to get full output
34924139Sjoergset ls = "ls -l"
35024139Sjoergif (`$ls getans | wc -w` < 9) then
35124139Sjoerg   set ls = "ls -lg"
35224139Sjoergendif
35324139Sjoerg
35424139Sjoergset t_owner = root
35524139Sjoergset t_group = `$ls -d /usr/bin | awk ' { print $4 }'`
35624139Sjoergif (-e /proc) then
35724139Sjoerg   cat <<EOF
35889750SdwmaloneI see /proc out there.  Many Unix variants provide the /proc file
35989750Sdwmalonesystem as a mechanism to get to a process's address space.  This
36089750Sdwmalonedirectory is typically only accessible by root.  However, there are a
36189750Sdwmalonefew systems (such as DG/UX) on which this directory exists, but isn't
36289750Sdwmaloneused.
36324139Sjoerg
36424139SjoergEOF
36589750Sdwmalone   if (-r /proc/0/psinfo) then
36689750Sdwmalone       set t_mode = 2711
36789750Sdwmalone       set mode = 2711
36889750Sdwmalone       set t_group = sys
36989750Sdwmalone       set group = sys
37089750Sdwmalone       cat <<EOF
37189750SdwmaloneIt looks like this system is running Solaris 2.6 or greater.  If this
37289750Sdwmaloneis the case, then top can function just fine installed set group id to
37389750Sdwmalonesys.  It does not need to be installed set-uid to root.
37489750Sdwmalone
37589750SdwmaloneEOF
37689750Sdwmalone   else
37789750Sdwmalone       set t_mode = 4711
37889750Sdwmalone       set mode = 4711
37989750Sdwmalone       cat <<EOF
38089750SdwmaloneI'm going to assume that top needs to run setuid to root, but you
38189750Sdwmaloneshould double check and use mode 2755 (set group id) if top doesn't
38289750Sdwmalonereally need root access.  If you are running SunOS 5.0 through SunOS
38389750Sdwmalone5.5.1 (that's Solaris 2.0 through Solaris 2.5.1) then you will need to
38489750Sdwmaloneinstall top setuid root (owner root and mode 4711).  In SunOS 5.6 
38589750Sdwmaloneand higher top only requires set group id sys permissions.
38689750Sdwmalone
38789750SdwmaloneEOF
38889750Sdwmalone    endif
38924139Sjoergelse if (-e /dev/kmem) then
39024139Sjoerg   $ls /dev/kmem >/tmp/$$.b
39124139Sjoerg   grep '^....r..r..' /tmp/$$.b >&/dev/null
39224139Sjoerg   if ($status == 1) then
39324139Sjoerg      grep '^....r..-..' /tmp/$$.b >&/dev/null
39424139Sjoerg      if ($status == 0) then
39524139Sjoerg         set t_group = `awk ' { print $4 }' /tmp/$$.b`
39624139Sjoerg         set t_mode = 2755
39724139Sjoerg         echo "It looks like only group $t_group can read the memory devices."
39824139Sjoerg      else
39924139Sjoerg         set t_mode = 4755
40024139Sjoerg         echo "It looks like only root can read the memory devices."
40124139Sjoerg      endif
40224139Sjoerg   else
40324139Sjoerg      set t_mode = 755
40424139Sjoerg      echo "It looks like anybody can read the memory devices."
40524139Sjoerg   endif
40624139Sjoergelse
40724139Sjoerg   echo "It looks like there are no memory device special files."
40824139Sjoerg   set t_mode = 755
40924139Sjoergendif
41024139Sjoergif ($nodefaults) then
41124139Sjoerg   set owner = $t_owner
41224139Sjoerg   set group = $t_group
41324139Sjoerg   set mode =  $t_mode
41424139Sjoergendif
41524139Sjoergecho "Tell me how to set the following when top is installed:"
41624139Sjoerg./getans "Owner" user "$owner" .$$
41724139Sjoergset owner = `cat .$$`
41824139Sjoerg./getans "Group owner" group "$group" .$$
41924139Sjoergset group = `cat .$$`
42024139Sjoerg./getans "Mode" integer "$mode" .$$
42124139Sjoergset mode = `cat .$$`
42224139Sjoergrm -f /tmp/$$.b
42324139Sjoerg
42424139Sjoergecho ""
42524139Sjoerg./getans "Install the executable in this directory" file "$bindir" .$$
42624139Sjoergset bindir = `cat .$$`
42724139Sjoerg
42824139Sjoergecho ""
42924139Sjoerg./getans "Install the manual page in this directory" file "$mandir" .$$
43024139Sjoergset mandir = `cat .$$`
43124139Sjoerg
43224139Sjoergecho ""
43324139Sjoerg./getans "Install the manual page with this extension" string "$manext" .$$
43424139Sjoergset manext = `cat .$$`
43524139Sjoerg
43624139Sjoergecho ""
43724139Sjoerg./getans "Install the manual page as 'man' or 'catman'" string "$mansty" .$$
43824139Sjoergset mansty = `cat .$$`
43924139Sjoerg
44024139Sjoergecho ""
44124139Sjoergecho "We are done with the questions."
44224139Sjoerg
44324139Sjoerg# Some Unix environments are so poor that their csh doesn't even support
44424139Sjoerg# the "eval" builtin.  Check for this before relying on its use to save
44524139Sjoerg# the current configuration.
44689750Sdwmalone/bin/csh -fc "eval echo foo" >&/dev/null
44724139Sjoergif ($status == 1) then
44824139Sjoerg   echo "Can't save configuration (nonfatal)"
44924139Sjoergelse
45024139Sjoerg   echo "Saving configuration..."
45124139Sjoerg# save settings to use as defaults the next time
45224139Sjoerg   rm -f .defaults
45389750Sdwmalone   touch .defaults
45424139Sjoerg   foreach v ($vars)
45524139Sjoerg      set tmp = `eval echo \$$v`
45624139Sjoerg      echo set $v = "'$tmp'" >>.defaults
45724139Sjoerg   end
45824139Sjoergendif
45924139Sjoerg
46024139Sjoergfast:
46124139Sjoerg
46224139Sjoerg# clean up
46389750Sdwmalonerm -f $$.[fmna]
46424139Sjoerg
46524139Sjoerg# set the link for machine.c
46624139Sjoergrm -f machine.c machine.o
46724139Sjoergln -s machine/m_${module}.c machine.c
46824139Sjoerg
46924139Sjoerg# get definitions out of the module file
47024139Sjoergset libs = `grep LIBS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
47124139Sjoergset cflgs = `grep CFLAGS: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
47224139Sjoergset tcap = `grep TERMCAP: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
47389750Sdwmaloneset math = `grep MATH: machine/m_${module}.desc | sed -e 's/^.[^:]*: *//'`
47424139Sjoerg
47589750Sdwmalone# get osrev defition, if we can
47689750Sdwmaloneset uname=""
47789750Sdwmaloneif (-e /usr/bin/uname) then
47889750Sdwmalone    set uname=/usr/bin/uname
47989750Sdwmaloneelse if (-e /bin/uname) then
48089750Sdwmalone    set uname=/bin/uname
48189750Sdwmaloneendif
48289750Sdwmalone
48389750Sdwmaloneif ("$uname" != "") then
48489750Sdwmalone# different versions of tr can't agree on the way to specify ranges, so
48589750Sdwmalone# we will have to give the range explicitly.....sigh.
48689750Sdwmalone    set osrev="-DOSREV=`$uname -r | tr -cd ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`"
48789750Sdwmaloneelse
48889750Sdwmalone    set osrev=""
48989750Sdwmaloneendif
49089750Sdwmalone
49124139Sjoerg# default for tcap (termcap)
49224139Sjoergif ("$tcap" == "") then
49324139Sjoerg    set tcap="-ltermcap"
49489750Sdwmaloneelse if ("$tcap" == "none") then
49589750Sdwmalone    set tcap=""
49624139Sjoergendif
49724139Sjoerg
49889750Sdwmalone# allow for the module to override or remove -lm
49989750Sdwmaloneif ("$math" == "") then
50089750Sdwmalone    set math="-lm"
50189750Sdwmaloneelse if ("$math" == "none") then
50289750Sdwmalone    set math=""
50389750Sdwmaloneendif
50489750Sdwmalone
50524139Sjoergif ( { grep -s SIGKILL /usr/include/signal.h } ) then
50624139Sjoerg    set signal="/usr/include/signal.h"
50724139Sjoergelse
50824139Sjoerg    set signal="/usr/include/sys/signal.h"
50924139Sjoergendif
51024139Sjoerg
51124139Sjoerg
51224139Sjoergecho "Building Makefile..."
51324139Sjoergsed -e "s|%topn%|$topn|" \
51424139Sjoerg    -e "s|%delay%|$delay|" \
51524139Sjoerg    -e "s|%owner%|$owner|" \
51624139Sjoerg    -e "s|%group%|$group|" \
51724139Sjoerg    -e "s|%mode%|$mode|" \
51824139Sjoerg    -e "s|%bindir%|$bindir|" \
51924139Sjoerg    -e "s|%mandir%|$mandir|" \
52024139Sjoerg    -e "s|%manext%|$manext|" \
52124139Sjoerg    -e "s|%mansty%|$mansty|" \
52224139Sjoerg    -e "s|%tablesize%|$TableSize|" \
52324139Sjoerg    -e "s|%libs%|$libs|" \
52424139Sjoerg    -e "s|%cflgs%|$cflgs|" \
52524139Sjoerg    -e "s|%termcap%|$tcap|" \
52689750Sdwmalone    -e "s|%math%|$math|" \
52724139Sjoerg    -e "s|%cdefs%|$cdefs|" \
52824139Sjoerg    -e "s|%signal%|$signal|" \
52924139Sjoerg    -e "s|%cc%|$Cmdcc|" \
53024139Sjoerg    -e "s|%awk%|$Cmdawk|" \
53124139Sjoerg    -e "s|%install%|$Cmdinstall|" \
53224139Sjoerg    -e "s|%shell%|$Cmdshell|" \
53389750Sdwmalone    -e "s|%osrev%|$osrev|" \
53424139Sjoerg	Makefile.X >Makefile
53524139Sjoerg
53624139Sjoergecho "Building top.local.h..."
53724139Sjoergsed -e "s|%LoadMax%|$LoadMax|" \
53824139Sjoerg    -e "s|%TableSize%|$TableSize|" \
53924139Sjoerg    -e "s|%NominalTopn%|$NominalTopn|" \
54024139Sjoerg    -e "s|%topn%|$topn|" \
54124139Sjoerg    -e "s|%delay%|$delay|" \
54224139Sjoerg    -e "s|%random%|$random|" \
54324139Sjoerg	top.local.H >top.local.h
54424139Sjoerg
54524139Sjoergecho "Building top.1..."
54624139Sjoergsed -e "s|%topn%|$topn|" \
54724139Sjoerg    -e "s|%delay%|$delay|" \
54824139Sjoerg	top.X >top.1
54924139Sjoergif (-e machine/m_${module}.man ) then
55024139Sjoerg    cat machine/m_${module}.man >>top.1
55124139Sjoergendif
55224139Sjoerg
55324139Sjoerg# clean up
55424139Sjoergrm -f .$$
55524139Sjoerg
55624139Sjoergecho 'Doing a "make clean".'
55724139Sjoergmake clean
55824139Sjoerg
55924139Sjoergecho 'To create the executable, type "make".'
56024139Sjoergecho 'To install the executable, type "make install".'
56124139Sjoergexit 0
56224139Sjoerg
56324139Sjoergbyebye:
56489750Sdwmalonerm -f .$$ $$.[fmna] /tmp/$$.[ab]
56524139Sjoergexit 1
566