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 952a9afa 2020-01-14 rsc echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
27 952a9afa 2020-01-14 rsc echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
28 952a9afa 2020-01-14 rsc echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
29 952a9afa 2020-01-14 rsc echo " "
30 952a9afa 2020-01-14 rsc echo "* Resetting $PLAN9/config"
31 952a9afa 2020-01-14 rsc rm -f config
32 952a9afa 2020-01-14 rsc
33 b4e0c548 2004-02-29 devnull PLAN9=`pwd` export PLAN9
34 90550261 2005-07-22 devnull PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
35 80c90f27 2010-04-09 rsc case `uname` in
36 80c90f27 2010-04-09 rsc SunOS)
37 80c90f27 2010-04-09 rsc awk=nawk
38 80c90f27 2010-04-09 rsc ;;
39 cf6b7787 2020-01-07 crossd DragonFly|*BSD)
40 cf6b7787 2020-01-07 crossd case `cc -v 2>&1` in
41 cf6b7787 2020-01-07 crossd *clang*)
42 cf6b7787 2020-01-07 crossd echo "CC9=clang" >> $PLAN9/config
43 cf6b7787 2020-01-07 crossd ;;
44 cf6b7787 2020-01-07 crossd *gcc*)
45 cf6b7787 2020-01-07 crossd echo "CC9=gcc" >> $PLAN9/config
46 cf6b7787 2020-01-07 crossd ;;
47 cf6b7787 2020-01-07 crossd esac
48 cf6b7787 2020-01-07 crossd echo "* Running on" `uname`", adjusting linker flags"
49 cf6b7787 2020-01-07 crossd case `uname` in
50 cf6b7787 2020-01-07 crossd OpenBSD)
51 cf6b7787 2020-01-07 crossd echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
52 cf6b7787 2020-01-07 crossd ;;
53 cf6b7787 2020-01-07 crossd NetBSD)
54 cf6b7787 2020-01-07 crossd echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
55 cf6b7787 2020-01-07 crossd ;;
56 cf6b7787 2020-01-07 crossd *)
57 cf6b7787 2020-01-07 crossd echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
58 cf6b7787 2020-01-07 crossd ;;
59 cf6b7787 2020-01-07 crossd esac
60 cf6b7787 2020-01-07 crossd echo "CFLAGS='-pthread'" >> $PLAN9/config
61 cf6b7787 2020-01-07 crossd awk=awk
62 cf6b7787 2020-01-07 crossd ;;
63 80c90f27 2010-04-09 rsc *)
64 80c90f27 2010-04-09 rsc awk=awk
65 80c90f27 2010-04-09 rsc ;;
66 80c90f27 2010-04-09 rsc esac
67 b4e0c548 2004-02-29 devnull
68 95d46638 2005-01-14 devnull (
69 e78ed7a6 2014-03-05 minux.ma if [ `uname` = SunOS ]; then
70 e78ed7a6 2014-03-05 minux.ma # On Solaris x86, uname -p cannot be trusted.
71 9c38253d 2018-11-14 rsc echo "* Running on Solaris: checking architecture..."
72 9c38253d 2018-11-14 rsc case "$(isainfo -n)" in
73 e78ed7a6 2014-03-05 minux.ma *amd64*)
74 99dee78c 2020-12-30 rsc echo " x86-64 found; using gcc."
75 e78ed7a6 2014-03-05 minux.ma echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
76 e78ed7a6 2014-03-05 minux.ma ;;
77 e78ed7a6 2014-03-05 minux.ma *i386*)
78 99dee78c 2020-12-30 rsc echo " i386 found; using gcc."
79 e78ed7a6 2014-03-05 minux.ma echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
80 e78ed7a6 2014-03-05 minux.ma ;;
81 9c38253d 2018-11-14 rsc *sparc*)
82 e78ed7a6 2014-03-05 minux.ma echo " Sparc found."
83 e78ed7a6 2014-03-05 minux.ma ;;
84 e78ed7a6 2014-03-05 minux.ma esac
85 e78ed7a6 2014-03-05 minux.ma fi
86 e78ed7a6 2014-03-05 minux.ma
87 fc567f47 2011-08-02 rsc if [ `uname` = Darwin ]; then
88 ad2d4950 2018-11-16 rsc export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
89 fc567f47 2011-08-02 rsc # On Darwin, uname -m -p cannot be trusted.
90 99dee78c 2020-12-30 rsc echo "* Running on Darwin..."
91 fc567f47 2011-08-02 rsc rm -f ./a.out
92 99dee78c 2020-12-30 rsc if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
93 99dee78c 2020-12-30 rsc echo "Cannot find 'xcrun --sdk macosx clang'." >&2
94 99dee78c 2020-12-30 rsc echo "You may need to install the command-line tools using Xcode." >&2
95 baf127ad 2014-01-22 rsc echo "See http://swtch.com/go/xcodegcc for details." >&2
96 baf127ad 2014-01-22 rsc exit 1
97 baf127ad 2014-01-22 rsc fi
98 bab7b73b 2022-01-24 rsc CC9="xcrun --sdk macosx clang"
99 bab7b73b 2022-01-24 rsc case "$(uname -a)" in
100 bab7b73b 2022-01-24 rsc *ARM64*)
101 bab7b73b 2022-01-24 rsc CC9="$CC9 -arch arm64"
102 bab7b73b 2022-01-24 rsc echo ' Forcing arm64 binaries with clang.'
103 bab7b73b 2022-01-24 rsc ;;
104 bab7b73b 2022-01-24 rsc esac
105 bab7b73b 2022-01-24 rsc
106 bab7b73b 2022-01-24 rsc echo "CC9='$CC9'" >>$PLAN9/config
107 fc567f47 2011-08-02 rsc rm -f ./a.out
108 fc567f47 2011-08-02 rsc fi
109 fc567f47 2011-08-02 rsc
110 cb71c0bd 2012-12-18 rsc if [ `uname` != Darwin ]; then
111 cb71c0bd 2012-12-18 rsc # Determine whether fontsrv X11 files are available.
112 cb71c0bd 2012-12-18 rsc rm -f a.out
113 2607cc56 2018-11-16 rsc cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
114 cf6b7787 2020-01-07 crossd -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
115 8ee5da7c 2015-11-10 rsc -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
116 cb71c0bd 2012-12-18 rsc if [ -f a.out ]; then
117 cb71c0bd 2012-12-18 rsc echo " fontsrv dependencies found."
118 cb71c0bd 2012-12-18 rsc echo "FONTSRV=fontsrv" >>$PLAN9/config
119 cb71c0bd 2012-12-18 rsc else
120 cb71c0bd 2012-12-18 rsc echo " fontsrv dependencies not found."
121 cb71c0bd 2012-12-18 rsc echo "FONTSRV=" >>$PLAN9/config
122 cb71c0bd 2012-12-18 rsc rm -f bin/fontsrv
123 cb71c0bd 2012-12-18 rsc fi
124 cb71c0bd 2012-12-18 rsc rm -f a.out
125 cb71c0bd 2012-12-18 rsc fi
126 cb71c0bd 2012-12-18 rsc
127 52fdc1a5 2005-02-02 devnull if [ -f LOCAL.config ]; then
128 52fdc1a5 2005-02-02 devnull echo Using LOCAL.config options:
129 52fdc1a5 2005-02-02 devnull sed 's/^/ /' LOCAL.config
130 52fdc1a5 2005-02-02 devnull cat LOCAL.config >>config
131 52fdc1a5 2005-02-02 devnull fi
132 52fdc1a5 2005-02-02 devnull
133 9c38253d 2018-11-14 rsc echo "* Compiler version:"
134 9c38253d 2018-11-14 rsc 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
135 9c38253d 2018-11-14 rsc
136 b4e0c548 2004-02-29 devnull cd src
137 df29f2ce 2005-12-30 devnull if $dobuild; then
138 06687f70 2020-05-18 rsc echo "* Building mk..."
139 06687f70 2020-05-18 rsc ../dist/buildmk 2>&1 | sed 's/^[+] //'
140 06687f70 2020-05-18 rsc
141 df29f2ce 2005-12-30 devnull if [ ! -x ../bin/mk ]; then
142 df29f2ce 2005-12-30 devnull echo "* Error: mk failed to build."
143 6637b803 2005-11-28 devnull exit 1
144 6637b803 2005-11-28 devnull fi
145 cb8f7357 2020-01-20 rsc
146 df29f2ce 2005-12-30 devnull echo "* Building everything (be patient)..."
147 df29f2ce 2005-12-30 devnull mk clean
148 df29f2ce 2005-12-30 devnull mk libs-nuke
149 df29f2ce 2005-12-30 devnull mk all || exit 1
150 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
151 df29f2ce 2005-12-30 devnull echo "* Warning: not all binaries built successfully."
152 df29f2ce 2005-12-30 devnull fi
153 df29f2ce 2005-12-30 devnull echo "* Installing everything in $PLAN9/bin..."
154 c49b45ed 2011-10-03 rsc mk -k install || exit 1
155 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
156 6637b803 2005-11-28 devnull echo " "
157 df29f2ce 2005-12-30 devnull echo "* Warning: not all binaries built successfully."
158 6637b803 2005-11-28 devnull fi
159 734ca635 2014-11-07 0intro if [ -f $PLAN9/bin/quote1 ]; then
160 734ca635 2014-11-07 0intro cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
161 734ca635 2014-11-07 0intro cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
162 fbe3f344 2014-06-03 rsc fi
163 df29f2ce 2005-12-30 devnull echo "* Cleaning up..."
164 df29f2ce 2005-12-30 devnull mk clean
165 6637b803 2005-11-28 devnull fi
166 6637b803 2005-11-28 devnull
167 df29f2ce 2005-12-30 devnull if $doinstall; then
168 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
169 df29f2ce 2005-12-30 devnull # Cleanname and sam are needed for moveplan9.sh and the man updates.
170 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/cleanname ]; then
171 df29f2ce 2005-12-30 devnull echo " "
172 df29f2ce 2005-12-30 devnull echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
173 df29f2ce 2005-12-30 devnull exit 1
174 df29f2ce 2005-12-30 devnull fi
175 df29f2ce 2005-12-30 devnull if [ ! -x $PLAN9/bin/sam ]; then
176 df29f2ce 2005-12-30 devnull echo " "
177 df29f2ce 2005-12-30 devnull echo "* Installation failed: $PLAN9/bin/sam does not exist."
178 df29f2ce 2005-12-30 devnull exit 1
179 df29f2ce 2005-12-30 devnull fi
180 df29f2ce 2005-12-30 devnull echo "* NOT renaming hard-coded /usr/local/plan9 paths."
181 df29f2ce 2005-12-30 devnull echo "* NOT building web manual."
182 df29f2ce 2005-12-30 devnull else
183 df29f2ce 2005-12-30 devnull echo "* Renaming hard-coded /usr/local/plan9 paths..."
184 df29f2ce 2005-12-30 devnull cd $PLAN9
185 df29f2ce 2005-12-30 devnull sh lib/moveplan9.sh
186 df29f2ce 2005-12-30 devnull echo "* Building web manual..."
187 df29f2ce 2005-12-30 devnull (
188 df29f2ce 2005-12-30 devnull cd $PLAN9/dist
189 df29f2ce 2005-12-30 devnull echo cd `pwd`';' mk man
190 df29f2ce 2005-12-30 devnull mk man
191 df29f2ce 2005-12-30 devnull )
192 df29f2ce 2005-12-30 devnull fi
193 cb8f7357 2020-01-20 rsc
194 df29f2ce 2005-12-30 devnull if [ -x LOCAL.INSTALL ]; then
195 df29f2ce 2005-12-30 devnull echo "* Running local modifications..."
196 df29f2ce 2005-12-30 devnull echo cd `pwd`';' ./LOCAL.INSTALL
197 df29f2ce 2005-12-30 devnull ./LOCAL.INSTALL
198 df29f2ce 2005-12-30 devnull fi
199 cb8f7357 2020-01-20 rsc
200 df29f2ce 2005-12-30 devnull echo "* Done. "
201 df29f2ce 2005-12-30 devnull echo " "
202 df29f2ce 2005-12-30 devnull echo "* Add these to your profile environment."
203 df29f2ce 2005-12-30 devnull echo " PLAN9=$PLAN9 export PLAN9"
204 df29f2ce 2005-12-30 devnull echo ' PATH=$PATH:$PLAN9/bin export PATH'
205 3b1a43f3 2005-01-18 devnull fi
206 80c90f27 2010-04-09 rsc ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum
207 7495a529 2005-11-26 devnull