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 x-r)
18 shift
19 PLAN9_TARGET=$1 export PLAN9_TARGET
20 ;;
21 *)
22 echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
23 exit 1
24 esac
26 PLAN9=`pwd` export PLAN9
27 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
28 case `uname` in
29 SunOS)
30 awk=nawk
31 ;;
32 *)
33 awk=awk
34 ;;
35 esac
37 echo "+ Mailing list: http://groups.google.com/group/plan9port-dev"
38 echo "+ Issue tracker: http://code.swtch.com/plan9port/issues/"
39 echo "+ Submitting changes: http://swtch.com/go/codereview"
40 echo " "
41 echo "* Resetting $PLAN9/config"
42 rm -f config
44 (
45 echo "* Compiler version:"
46 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
48 if [ `uname` = Linux ]; then
49 # On Linux, we use the kernel version to decide whether
50 # to use pthreads or not. On 2.6 versions that aren't
51 # linking with NPTL by default, pretend to be an older kernel.
52 echo "* Running on Linux: checking for NPTL..."
53 gcc lib/linux-isnptl.c -lpthread
54 if ./a.out >/dev/null
55 then
56 echo " NPTL found."
57 echo "SYSVERSION=2.6.x" >>$PLAN9/config
58 else
59 echo " NPTL not found."
60 echo "SYSVERSION=2.4.x" >>$PLAN9/config
61 fi
62 rm -f ./a.out
63 fi
65 if [ `uname` = Darwin ]; then
66 # On Darwin, uname -m -p cannot be trusted.
67 echo "* Running on Darwin: checking architecture..."
68 rm -f ./a.out
69 gcc lib/darwin-main.c >/dev/null 2>&1
70 case "$(file ./a.out 2>/dev/null)" in
71 *x86_64*)
72 echo " x86-64 found."
73 echo "OBJTYPE=x86_64" >>$PLAN9/config
74 ;;
75 *i386*)
76 echo " i386 found."
77 echo "OBJTYPE=386" >>$PLAN9/config
78 ;;
79 *ppc*)
80 echo " power found."
81 echo "OBJTYPE=power" >>$PLAN9/config
82 ;;
83 esac
84 rm -f ./a.out
85 fi
87 if [ -f LOCAL.config ]; then
88 echo Using LOCAL.config options:
89 sed 's/^/ /' LOCAL.config
90 cat LOCAL.config >>config
91 fi
93 cd src
94 if $dobuild; then
95 if [ ! -x ../bin/mk ]; then
96 echo "* Building mk..."
97 ../dist/buildmk 2>&1 | sed 's/^[+] //'
98 fi
99 if [ ! -x ../bin/mk ]; then
100 echo "* Error: mk failed to build."
101 exit 1
102 fi
104 echo "* Building everything (be patient)..."
105 mk clean
106 mk libs-nuke
107 mk all || exit 1
108 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
109 echo "* Warning: not all binaries built successfully."
110 fi
111 echo "* Installing everything in $PLAN9/bin..."
112 mk -k install || exit 1
113 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
114 echo " "
115 echo "* Warning: not all binaries built successfully."
116 fi
117 echo "* Cleaning up..."
118 mk clean
119 fi
121 if $doinstall; then
122 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
123 # Cleanname and sam are needed for moveplan9.sh and the man updates.
124 if [ ! -x $PLAN9/bin/cleanname ]; then
125 echo " "
126 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
127 exit 1
128 fi
129 if [ ! -x $PLAN9/bin/sam ]; then
130 echo " "
131 echo "* Installation failed: $PLAN9/bin/sam does not exist."
132 exit 1
133 fi
134 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
135 echo "* NOT building web manual."
136 else
137 echo "* Renaming hard-coded /usr/local/plan9 paths..."
138 cd $PLAN9
139 sh lib/moveplan9.sh
140 echo "* Building web manual..."
142 cd $PLAN9/dist
143 echo cd `pwd`';' mk man
144 mk man
146 fi
148 if [ -x LOCAL.INSTALL ]; then
149 echo "* Running local modifications..."
150 echo cd `pwd`';' ./LOCAL.INSTALL
151 ./LOCAL.INSTALL
152 fi
154 echo "* Done. "
155 echo " "
156 echo "* Add these to your profile environment."
157 echo " PLAN9=$PLAN9 export PLAN9"
158 echo ' PATH=$PATH:$PLAN9/bin export PATH'
159 fi
160 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum