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: https://groups.google.com/group/plan9port-dev"
38 echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
39 echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
40 echo " "
41 echo "* Resetting $PLAN9/config"
42 rm -f config
44 (
45 if [ `uname` = FreeBSD ]; then
46 case `cc -v 2>&1` in
47 *clang*)
48 echo "CC9=clang" >> $PLAN9/config
49 ;;
50 *)
51 ;;
52 esac
53 echo "* Running on FreeBSD, adjusting linker flags"
54 echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config
55 fi
57 if [ `uname` = DragonFly ]; then
58 echo "* Running on DragonFly BSD, adjusting linker flags"
59 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
60 echo "CFLAGS='-pthread'" >> $PLAN9/config
61 fi
63 if [ `uname` = OpenBSD ]; then
64 echo "* Running on OpenBSD, adjusting linker flags"
65 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
66 fi
68 if [ `uname` = Linux ]; then
69 # On Linux, we use the kernel version to decide whether
70 # to use pthreads or not. On 2.6 versions that aren't
71 # linking with NPTL by default, pretend to be an older kernel.
72 echo "* Running on Linux: checking for NPTL..."
73 gcc lib/linux-isnptl.c -lpthread
74 if ./a.out >/dev/null
75 then
76 echo " NPTL found."
77 echo "SYSVERSION=2.6.x" >>$PLAN9/config
78 else
79 echo " NPTL not found."
80 echo "SYSVERSION=2.4.x" >>$PLAN9/config
81 fi
82 rm -f ./a.out
83 fi
85 if [ `uname` = SunOS ]; then
86 # On Solaris x86, uname -p cannot be trusted.
87 echo "* Running on Solaris: checking architecture..."
88 case "$(isainfo -n)" in
89 *amd64*)
90 echo " x86-64 found."
91 echo "OBJTYPE=x86_64" >>$PLAN9/config
92 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
93 ;;
94 *i386*)
95 echo " i386 found."
96 echo "OBJTYPE=386" >>$PLAN9/config
97 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
98 ;;
99 *sparc*)
100 echo " Sparc found."
101 echo "OBJTYPE=sparc" >>$PLAN9/config
102 ;;
103 esac
104 fi
106 if [ `uname` = Darwin ]; then
107 # On Darwin, uname -m -p cannot be trusted.
108 echo "* Running on Darwin: checking architecture..."
109 rm -f ./a.out
110 if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
111 echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
112 echo "See http://swtch.com/go/xcodegcc for details." >&2
113 exit 1
114 fi
115 case "$(file ./a.out 2>/dev/null)" in
116 *x86_64*)
117 echo " x86-64 found."
118 echo "OBJTYPE=x86_64" >>$PLAN9/config
119 ;;
120 *i386*)
121 echo " i386 found."
122 echo "OBJTYPE=386" >>$PLAN9/config
123 ;;
124 *ppc*)
125 echo " power found."
126 echo "OBJTYPE=power" >>$PLAN9/config
127 ;;
128 esac
129 rm -f ./a.out
130 fi
132 if [ `uname` != Darwin ]; then
133 # Determine whether fontsrv X11 files are available.
134 rm -f a.out
135 gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
136 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
137 if [ -f a.out ]; then
138 echo " fontsrv dependencies found."
139 echo "FONTSRV=fontsrv" >>$PLAN9/config
140 else
141 echo " fontsrv dependencies not found."
142 echo "FONTSRV=" >>$PLAN9/config
143 rm -f bin/fontsrv
144 fi
145 rm -f a.out
146 fi
148 if [ -f LOCAL.config ]; then
149 echo Using LOCAL.config options:
150 sed 's/^/ /' LOCAL.config
151 cat LOCAL.config >>config
152 fi
154 echo "* Compiler version:"
155 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
157 cd src
158 if $dobuild; then
159 if [ ! -x ../bin/mk ]; then
160 echo "* Building mk..."
161 ../dist/buildmk 2>&1 | sed 's/^[+] //'
162 fi
163 if [ ! -x ../bin/mk ]; then
164 echo "* Error: mk failed to build."
165 exit 1
166 fi
168 echo "* Building everything (be patient)..."
169 mk clean
170 mk libs-nuke
171 mk all || exit 1
172 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
173 echo "* Warning: not all binaries built successfully."
174 fi
175 echo "* Installing everything in $PLAN9/bin..."
176 mk -k install || exit 1
177 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
178 echo " "
179 echo "* Warning: not all binaries built successfully."
180 fi
181 if [ -f $PLAN9/bin/quote1 ]; then
182 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
183 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
184 fi
185 echo "* Cleaning up..."
186 mk clean
187 fi
189 if $doinstall; then
190 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
191 # Cleanname and sam are needed for moveplan9.sh and the man updates.
192 if [ ! -x $PLAN9/bin/cleanname ]; then
193 echo " "
194 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
195 exit 1
196 fi
197 if [ ! -x $PLAN9/bin/sam ]; then
198 echo " "
199 echo "* Installation failed: $PLAN9/bin/sam does not exist."
200 exit 1
201 fi
202 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
203 echo "* NOT building web manual."
204 else
205 echo "* Renaming hard-coded /usr/local/plan9 paths..."
206 cd $PLAN9
207 sh lib/moveplan9.sh
208 echo "* Building web manual..."
210 cd $PLAN9/dist
211 echo cd `pwd`';' mk man
212 mk man
214 fi
216 if [ -x LOCAL.INSTALL ]; then
217 echo "* Running local modifications..."
218 echo cd `pwd`';' ./LOCAL.INSTALL
219 ./LOCAL.INSTALL
220 fi
222 echo "* Done. "
223 echo " "
224 echo "* Add these to your profile environment."
225 echo " PLAN9=$PLAN9 export PLAN9"
226 echo ' PATH=$PATH:$PLAN9/bin export PATH'
227 fi
228 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum