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