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` = OpenBSD ]; then
49 echo "* Running on OpenBSD, adjusting linker flags"
50 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
51 fi
53 if [ `uname` = Linux ]; then
54 # On Linux, we use the kernel version to decide whether
55 # to use pthreads or not. On 2.6 versions that aren't
56 # linking with NPTL by default, pretend to be an older kernel.
57 echo "* Running on Linux: checking for NPTL..."
58 gcc lib/linux-isnptl.c -lpthread
59 if ./a.out >/dev/null
60 then
61 echo " NPTL found."
62 echo "SYSVERSION=2.6.x" >>$PLAN9/config
63 else
64 echo " NPTL not found."
65 echo "SYSVERSION=2.4.x" >>$PLAN9/config
66 fi
67 rm -f ./a.out
68 fi
70 if [ `uname` = Darwin ]; then
71 # On Darwin, uname -m -p cannot be trusted.
72 echo "* Running on Darwin: checking architecture..."
73 rm -f ./a.out
74 gcc lib/darwin-main.c >/dev/null 2>&1
75 case "$(file ./a.out 2>/dev/null)" in
76 *x86_64*)
77 echo " x86-64 found."
78 echo "OBJTYPE=x86_64" >>$PLAN9/config
79 ;;
80 *i386*)
81 echo " i386 found."
82 echo "OBJTYPE=386" >>$PLAN9/config
83 ;;
84 *ppc*)
85 echo " power found."
86 echo "OBJTYPE=power" >>$PLAN9/config
87 ;;
88 esac
89 rm -f ./a.out
90 fi
92 if [ -f LOCAL.config ]; then
93 echo Using LOCAL.config options:
94 sed 's/^/ /' LOCAL.config
95 cat LOCAL.config >>config
96 fi
98 cd src
99 if $dobuild; then
100 if [ ! -x ../bin/mk ]; then
101 echo "* Building mk..."
102 ../dist/buildmk 2>&1 | sed 's/^[+] //'
103 fi
104 if [ ! -x ../bin/mk ]; then
105 echo "* Error: mk failed to build."
106 exit 1
107 fi
109 echo "* Building everything (be patient)..."
110 mk clean
111 mk libs-nuke
112 mk all || exit 1
113 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
114 echo "* Warning: not all binaries built successfully."
115 fi
116 echo "* Installing everything in $PLAN9/bin..."
117 mk -k install || exit 1
118 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
119 echo " "
120 echo "* Warning: not all binaries built successfully."
121 fi
122 echo "* Cleaning up..."
123 mk clean
124 fi
126 if $doinstall; then
127 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
128 # Cleanname and sam are needed for moveplan9.sh and the man updates.
129 if [ ! -x $PLAN9/bin/cleanname ]; then
130 echo " "
131 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
132 exit 1
133 fi
134 if [ ! -x $PLAN9/bin/sam ]; then
135 echo " "
136 echo "* Installation failed: $PLAN9/bin/sam does not exist."
137 exit 1
138 fi
139 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
140 echo "* NOT building web manual."
141 else
142 echo "* Renaming hard-coded /usr/local/plan9 paths..."
143 cd $PLAN9
144 sh lib/moveplan9.sh
145 echo "* Building web manual..."
147 cd $PLAN9/dist
148 echo cd `pwd`';' mk man
149 mk man
151 fi
153 if [ -x LOCAL.INSTALL ]; then
154 echo "* Running local modifications..."
155 echo cd `pwd`';' ./LOCAL.INSTALL
156 ./LOCAL.INSTALL
157 fi
159 echo "* Done. "
160 echo " "
161 echo "* Add these to your profile environment."
162 echo " PLAN9=$PLAN9 export PLAN9"
163 echo ' PATH=$PATH:$PLAN9/bin export PATH'
164 fi
165 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum