Blob


1 #!/bin/sh
3 dobuild=true
4 doinstall=true
6 case "x$1" in
7 x)
8 ;;
9 x-b)
10 dobuild=true
11 doinstall=false
12 ;;
13 x-c)
14 dobuild=false
15 doinstall=true
16 ;;
17 *)
18 echo 'usage: INSTALL [-b | -c]' 1>&2
19 exit 1
20 esac
22 PLAN9=`pwd` export PLAN9
23 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
25 echo "* Resetting $PLAN9/config"
26 rm -f config
28 (
29 if [ `uname` = Linux ]; then
30 # On Linux, we use the kernel version to decide whether
31 # to use pthreads or not. On 2.6 versions that aren't
32 # linking with NPTL by default, pretend to be an older kernel.
33 echo "* Running on Linux: checking for NPTL..."
34 gcc lib/linux-isnptl.c -lpthread
35 if ./a.out >/dev/null
36 then
37 echo " NPTL found."
38 echo "SYSVERSION=2.6.x" >$PLAN9/config
39 else
40 echo " NPTL not found."
41 echo "SYSVERSION=2.4.x" >$PLAN9/config
42 fi
43 rm -f ./a.out
44 fi
46 if [ -f LOCAL.config ]; then
47 echo Using LOCAL.config options:
48 sed 's/^/ /' LOCAL.config
49 cat LOCAL.config >>config
50 fi
52 cd src
53 if $dobuild; then
54 if [ ! -x ../bin/mk ]; then
55 echo "* Building mk..."
56 ../dist/buildmk 2>&1 | sed 's/^[+] //'
57 fi
58 if [ ! -x ../bin/mk ]; then
59 echo "* Error: mk failed to build."
60 exit 1
61 fi
63 echo "* Building everything (be patient)..."
64 mk clean
65 mk libs-nuke
66 mk all || exit 1
67 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
68 echo "* Warning: not all binaries built successfully."
69 fi
70 echo "* Installing everything in $PLAN9/bin..."
71 mk install || exit 1
72 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
73 echo " "
74 echo "* Warning: not all binaries built successfully."
75 fi
76 echo "* Cleaning up..."
77 mk clean
78 fi
80 if $doinstall; then
81 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
82 # Cleanname and sam are needed for moveplan9.sh and the man updates.
83 if [ ! -x $PLAN9/bin/cleanname ]; then
84 echo " "
85 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
86 exit 1
87 fi
88 if [ ! -x $PLAN9/bin/sam ]; then
89 echo " "
90 echo "* Installation failed: $PLAN9/bin/sam does not exist."
91 exit 1
92 fi
93 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
94 echo "* NOT building web manual."
95 else
96 echo "* Renaming hard-coded /usr/local/plan9 paths..."
97 cd $PLAN9
98 sh lib/moveplan9.sh
99 echo "* Building web manual..."
101 cd $PLAN9/dist
102 echo cd `pwd`';' mk man
103 mk man
105 fi
107 if [ -x LOCAL.INSTALL ]; then
108 echo "* Running local modifications..."
109 echo cd `pwd`';' ./LOCAL.INSTALL
110 ./LOCAL.INSTALL
111 fi
113 echo "* Done. "
114 echo " "
115 echo "* Add these to your profile environment."
116 echo " PLAN9=$PLAN9 export PLAN9"
117 echo ' PATH=$PATH:$PLAN9/bin export PATH'
118 fi
119 ) 2>&1 | tee install.log | awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum