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