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