Blame


1 b4e0c548 2004-02-29 devnull #!/bin/sh
2 b4e0c548 2004-02-29 devnull
3 df29f2ce 2005-12-30 devnull dobuild=true
4 df29f2ce 2005-12-30 devnull doinstall=true
5 df29f2ce 2005-12-30 devnull
6 df29f2ce 2005-12-30 devnull case "x$1" in
7 df29f2ce 2005-12-30 devnull x)
8 df29f2ce 2005-12-30 devnull ;;
9 df29f2ce 2005-12-30 devnull x-b)
10 df29f2ce 2005-12-30 devnull dobuild=true
11 df29f2ce 2005-12-30 devnull doinstall=false
12 df29f2ce 2005-12-30 devnull ;;
13 df29f2ce 2005-12-30 devnull x-c)
14 df29f2ce 2005-12-30 devnull dobuild=false
15 df29f2ce 2005-12-30 devnull doinstall=true
16 df29f2ce 2005-12-30 devnull ;;
17 89ec3cde 2011-06-02 rsc x-r)
18 9c38253d 2018-11-14 rsc shift
19 9c38253d 2018-11-14 rsc PLAN9_TARGET=$1 export PLAN9_TARGET
20 9c38253d 2018-11-14 rsc ;;
21 df29f2ce 2005-12-30 devnull *)
22 89ec3cde 2011-06-02 rsc echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
23 df29f2ce 2005-12-30 devnull exit 1
24 df29f2ce 2005-12-30 devnull esac
25 df29f2ce 2005-12-30 devnull
26 b4e0c548 2004-02-29 devnull PLAN9=`pwd` export PLAN9
27 90550261 2005-07-22 devnull PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
28 80c90f27 2010-04-09 rsc case `uname` in
29 80c90f27 2010-04-09 rsc SunOS)
30 80c90f27 2010-04-09 rsc awk=nawk
31 80c90f27 2010-04-09 rsc ;;
32 80c90f27 2010-04-09 rsc *)
33 80c90f27 2010-04-09 rsc awk=awk
34 80c90f27 2010-04-09 rsc ;;
35 80c90f27 2010-04-09 rsc esac
36 b4e0c548 2004-02-29 devnull
37 a3993885 2017-09-01 rsc echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
38 a3993885 2017-09-01 rsc echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
39 a3993885 2017-09-01 rsc echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
40 1d534ed6 2009-07-29 rsc echo " "
41 7495a529 2005-11-26 devnull echo "* Resetting $PLAN9/config"
42 52fdc1a5 2005-02-02 devnull rm -f config
43 7a2c8850 2005-01-17 devnull
44 95d46638 2005-01-14 devnull (
45 dad9d0ac 2013-01-31 rsc if [ `uname` = FreeBSD ]; then
46 9c38253d 2018-11-14 rsc case `cc -v 2>&1` in
47 9c38253d 2018-11-14 rsc *clang*)
48 9c38253d 2018-11-14 rsc echo "CC9=clang" >> $PLAN9/config
49 9c38253d 2018-11-14 rsc ;;
50 9c38253d 2018-11-14 rsc *)
51 9c38253d 2018-11-14 rsc ;;
52 9c38253d 2018-11-14 rsc esac
53 9c38253d 2018-11-14 rsc echo "* Running on FreeBSD, adjusting linker flags"
54 9c38253d 2018-11-14 rsc echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config
55 dad9d0ac 2013-01-31 rsc fi
56 dad9d0ac 2013-01-31 rsc
57 20035ed4 2014-02-28 minux.ma if [ `uname` = DragonFly ]; then
58 9c38253d 2018-11-14 rsc echo "* Running on DragonFly BSD, adjusting linker flags"
59 9c38253d 2018-11-14 rsc echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
60 9c38253d 2018-11-14 rsc echo "CFLAGS='-pthread'" >> $PLAN9/config
61 20035ed4 2014-02-28 minux.ma fi
62 20035ed4 2014-02-28 minux.ma
63 1a512ec0 2012-12-11 rsc if [ `uname` = OpenBSD ]; then
64 9c38253d 2018-11-14 rsc echo "* Running on OpenBSD, adjusting linker flags"
65 9c38253d 2018-11-14 rsc echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
66 1a512ec0 2012-12-11 rsc fi
67 1a512ec0 2012-12-11 rsc
68 7a2c8850 2005-01-17 devnull if [ `uname` = Linux ]; then
69 7a2c8850 2005-01-17 devnull # On Linux, we use the kernel version to decide whether
70 7a2c8850 2005-01-17 devnull # to use pthreads or not. On 2.6 versions that aren't
71 7a2c8850 2005-01-17 devnull # linking with NPTL by default, pretend to be an older kernel.
72 7495a529 2005-11-26 devnull echo "* Running on Linux: checking for NPTL..."
73 d338028e 2005-01-17 devnull gcc lib/linux-isnptl.c -lpthread
74 8327d419 2005-01-23 devnull if ./a.out >/dev/null
75 7a2c8850 2005-01-17 devnull then
76 7a2c8850 2005-01-17 devnull echo " NPTL found."
77 fc567f47 2011-08-02 rsc echo "SYSVERSION=2.6.x" >>$PLAN9/config
78 7a2c8850 2005-01-17 devnull else
79 7a2c8850 2005-01-17 devnull echo " NPTL not found."
80 fc567f47 2011-08-02 rsc echo "SYSVERSION=2.4.x" >>$PLAN9/config
81 7a2c8850 2005-01-17 devnull fi
82 b04c42e9 2005-01-17 devnull rm -f ./a.out
83 7a2c8850 2005-01-17 devnull fi
84 52fdc1a5 2005-02-02 devnull
85 e78ed7a6 2014-03-05 minux.ma if [ `uname` = SunOS ]; then
86 e78ed7a6 2014-03-05 minux.ma # On Solaris x86, uname -p cannot be trusted.
87 9c38253d 2018-11-14 rsc echo "* Running on Solaris: checking architecture..."
88 9c38253d 2018-11-14 rsc case "$(isainfo -n)" in
89 e78ed7a6 2014-03-05 minux.ma *amd64*)
90 e78ed7a6 2014-03-05 minux.ma echo " x86-64 found."
91 e78ed7a6 2014-03-05 minux.ma echo "OBJTYPE=x86_64" >>$PLAN9/config
92 e78ed7a6 2014-03-05 minux.ma echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
93 e78ed7a6 2014-03-05 minux.ma ;;
94 e78ed7a6 2014-03-05 minux.ma *i386*)
95 e78ed7a6 2014-03-05 minux.ma echo " i386 found."
96 e78ed7a6 2014-03-05 minux.ma echo "OBJTYPE=386" >>$PLAN9/config
97 e78ed7a6 2014-03-05 minux.ma echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
98 e78ed7a6 2014-03-05 minux.ma ;;
99 9c38253d 2018-11-14 rsc *sparc*)
100 e78ed7a6 2014-03-05 minux.ma echo " Sparc found."
101 e78ed7a6 2014-03-05 minux.ma echo "OBJTYPE=sparc" >>$PLAN9/config
102 e78ed7a6 2014-03-05 minux.ma ;;
103 e78ed7a6 2014-03-05 minux.ma esac
104 e78ed7a6 2014-03-05 minux.ma fi
105 e78ed7a6 2014-03-05 minux.ma
106 fc567f47 2011-08-02 rsc if [ `uname` = Darwin ]; then
107 fc567f47 2011-08-02 rsc # On Darwin, uname -m -p cannot be trusted.
108 fc567f47 2011-08-02 rsc echo "* Running on Darwin: checking architecture..."
109 fc567f47 2011-08-02 rsc rm -f ./a.out
110 baf127ad 2014-01-22 rsc if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
111 baf127ad 2014-01-22 rsc echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
112 baf127ad 2014-01-22 rsc echo "See http://swtch.com/go/xcodegcc for details." >&2
113 baf127ad 2014-01-22 rsc exit 1
114 baf127ad 2014-01-22 rsc fi
115 fc567f47 2011-08-02 rsc case "$(file ./a.out 2>/dev/null)" in
116 fc567f47 2011-08-02 rsc *x86_64*)
117 fc567f47 2011-08-02 rsc echo " x86-64 found."
118 fc567f47 2011-08-02 rsc echo "OBJTYPE=x86_64" >>$PLAN9/config
119 fe92b4a0 2018-11-16 rsc echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
120 fc567f47 2011-08-02 rsc ;;
121 fc567f47 2011-08-02 rsc *i386*)
122 fc567f47 2011-08-02 rsc echo " i386 found."
123 fc567f47 2011-08-02 rsc echo "OBJTYPE=386" >>$PLAN9/config
124 fc567f47 2011-08-02 rsc ;;
125 813b3eea 2011-10-23 rsc *ppc*)
126 9c38253d 2018-11-14 rsc echo " power found."
127 813b3eea 2011-10-23 rsc echo "OBJTYPE=power" >>$PLAN9/config
128 813b3eea 2011-10-23 rsc ;;
129 fc567f47 2011-08-02 rsc esac
130 fc567f47 2011-08-02 rsc rm -f ./a.out
131 fc567f47 2011-08-02 rsc fi
132 fc567f47 2011-08-02 rsc
133 cb71c0bd 2012-12-18 rsc if [ `uname` != Darwin ]; then
134 cb71c0bd 2012-12-18 rsc # Determine whether fontsrv X11 files are available.
135 cb71c0bd 2012-12-18 rsc rm -f a.out
136 8ee5da7c 2015-11-10 rsc gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
137 8ee5da7c 2015-11-10 rsc -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
138 cb71c0bd 2012-12-18 rsc if [ -f a.out ]; then
139 cb71c0bd 2012-12-18 rsc echo " fontsrv dependencies found."
140 cb71c0bd 2012-12-18 rsc echo "FONTSRV=fontsrv" >>$PLAN9/config
141 cb71c0bd 2012-12-18 rsc else
142 cb71c0bd 2012-12-18 rsc echo " fontsrv dependencies not found."
143 cb71c0bd 2012-12-18 rsc echo "FONTSRV=" >>$PLAN9/config
144 cb71c0bd 2012-12-18 rsc rm -f bin/fontsrv
145 cb71c0bd 2012-12-18 rsc fi
146 cb71c0bd 2012-12-18 rsc rm -f a.out
147 cb71c0bd 2012-12-18 rsc fi
148 cb71c0bd 2012-12-18 rsc
149 52fdc1a5 2005-02-02 devnull if [ -f LOCAL.config ]; then
150 52fdc1a5 2005-02-02 devnull echo Using LOCAL.config options:
151 52fdc1a5 2005-02-02 devnull sed 's/^/ /' LOCAL.config
152 52fdc1a5 2005-02-02 devnull cat LOCAL.config >>config
153 52fdc1a5 2005-02-02 devnull fi
154 52fdc1a5 2005-02-02 devnull
155 9c38253d 2018-11-14 rsc echo "* Compiler version:"
156 9c38253d 2018-11-14 rsc 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
157 9c38253d 2018-11-14 rsc
158 b4e0c548 2004-02-29 devnull cd src
159 df29f2ce 2005-12-30 devnull if $dobuild; then
160 df29f2ce 2005-12-30 devnull if [ ! -x ../bin/mk ]; then
161 df29f2ce 2005-12-30 devnull echo "* Building mk..."
162 df29f2ce 2005-12-30 devnull ../dist/buildmk 2>&1 | sed 's/^[+] //'
163 df29f2ce 2005-12-30 devnull fi
164 df29f2ce 2005-12-30 devnull if [ ! -x ../bin/mk ]; then
165 df29f2ce 2005-12-30 devnull echo "* Error: mk failed to build."
166 6637b803 2005-11-28 devnull exit 1
167 6637b803 2005-11-28 devnull fi
168 df29f2ce 2005-12-30 devnull
169 df29f2ce 2005-12-30 devnull echo "* Building everything (be patient)..."
170 df29f2ce 2005-12-30 devnull mk clean
171 df29f2ce 2005-12-30 devnull mk libs-nuke
172 df29f2ce 2005-12-30 devnull mk all || exit 1
173 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
174 df29f2ce 2005-12-30 devnull echo "* Warning: not all binaries built successfully."
175 df29f2ce 2005-12-30 devnull fi
176 df29f2ce 2005-12-30 devnull echo "* Installing everything in $PLAN9/bin..."
177 c49b45ed 2011-10-03 rsc mk -k install || exit 1
178 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
179 6637b803 2005-11-28 devnull echo " "
180 df29f2ce 2005-12-30 devnull echo "* Warning: not all binaries built successfully."
181 6637b803 2005-11-28 devnull fi
182 734ca635 2014-11-07 0intro if [ -f $PLAN9/bin/quote1 ]; then
183 734ca635 2014-11-07 0intro cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
184 734ca635 2014-11-07 0intro cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
185 fbe3f344 2014-06-03 rsc fi
186 df29f2ce 2005-12-30 devnull echo "* Cleaning up..."
187 df29f2ce 2005-12-30 devnull mk clean
188 6637b803 2005-11-28 devnull fi
189 6637b803 2005-11-28 devnull
190 df29f2ce 2005-12-30 devnull if $doinstall; then
191 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
192 df29f2ce 2005-12-30 devnull # Cleanname and sam are needed for moveplan9.sh and the man updates.
193 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname ]; then
194 df29f2ce 2005-12-30 devnull echo " "
195 df29f2ce 2005-12-30 devnull echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
196 df29f2ce 2005-12-30 devnull exit 1
197 df29f2ce 2005-12-30 devnull fi
198 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/sam ]; then
199 df29f2ce 2005-12-30 devnull echo " "
200 df29f2ce 2005-12-30 devnull echo "* Installation failed: $PLAN9/bin/sam does not exist."
201 df29f2ce 2005-12-30 devnull exit 1
202 df29f2ce 2005-12-30 devnull fi
203 df29f2ce 2005-12-30 devnull echo "* NOT renaming hard-coded /usr/local/plan9 paths."
204 df29f2ce 2005-12-30 devnull echo "* NOT building web manual."
205 df29f2ce 2005-12-30 devnull else
206 df29f2ce 2005-12-30 devnull echo "* Renaming hard-coded /usr/local/plan9 paths..."
207 df29f2ce 2005-12-30 devnull cd $PLAN9
208 df29f2ce 2005-12-30 devnull sh lib/moveplan9.sh
209 df29f2ce 2005-12-30 devnull echo "* Building web manual..."
210 df29f2ce 2005-12-30 devnull (
211 df29f2ce 2005-12-30 devnull cd $PLAN9/dist
212 df29f2ce 2005-12-30 devnull echo cd `pwd`';' mk man
213 df29f2ce 2005-12-30 devnull mk man
214 df29f2ce 2005-12-30 devnull )
215 df29f2ce 2005-12-30 devnull fi
216 df29f2ce 2005-12-30 devnull
217 df29f2ce 2005-12-30 devnull if [ -x LOCAL.INSTALL ]; then
218 df29f2ce 2005-12-30 devnull echo "* Running local modifications..."
219 df29f2ce 2005-12-30 devnull echo cd `pwd`';' ./LOCAL.INSTALL
220 df29f2ce 2005-12-30 devnull ./LOCAL.INSTALL
221 df29f2ce 2005-12-30 devnull fi
222 df29f2ce 2005-12-30 devnull
223 df29f2ce 2005-12-30 devnull echo "* Done. "
224 df29f2ce 2005-12-30 devnull echo " "
225 df29f2ce 2005-12-30 devnull echo "* Add these to your profile environment."
226 df29f2ce 2005-12-30 devnull echo " PLAN9=$PLAN9 export PLAN9"
227 df29f2ce 2005-12-30 devnull echo ' PATH=$PATH:$PLAN9/bin export PATH'
228 3b1a43f3 2005-01-18 devnull fi
229 80c90f27 2010-04-09 rsc ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum
230 7495a529 2005-11-26 devnull