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
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 [ -z "$PLAN9_TARGET" ] && PLAN9_TARGET="$PLAN9"
36 export PLAN9_TARGET
38 case `uname` in
39 SunOS)
40 awk=nawk
41 ;;
42 DragonFly|*BSD)
43 case `cc -v 2>&1` in
44 *clang*)
45 echo "CC9=clang" >> $PLAN9/config
46 ;;
47 *gcc*)
48 echo "CC9=gcc" >> $PLAN9/config
49 ;;
50 esac
51 echo "* Running on" `uname`", adjusting linker flags"
52 case `uname` in
53 OpenBSD)
54 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
55 ;;
56 NetBSD)
57 echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
58 ;;
59 *)
60 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
61 ;;
62 esac
63 echo "CFLAGS='-pthread'" >> $PLAN9/config
64 awk=awk
65 ;;
66 *)
67 awk=awk
68 ;;
69 esac
71 (
72 if [ `uname` = SunOS ]; then
73 # On Solaris x86, uname -p cannot be trusted.
74 echo "* Running on Solaris: checking architecture..."
75 case "$(isainfo -n)" in
76 *amd64*)
77 echo " x86-64 found; using gcc."
78 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
79 ;;
80 *i386*)
81 echo " i386 found; using gcc."
82 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
83 ;;
84 *sparc*)
85 echo " Sparc found."
86 ;;
87 esac
88 fi
90 if [ `uname` = Darwin ]; then
91 export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
92 # On Darwin, uname -m -p cannot be trusted.
93 echo "* Running on Darwin..."
94 rm -f ./a.out
95 if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
96 echo "Cannot find 'xcrun --sdk macosx clang'." >&2
97 echo "You may need to install the command-line tools using Xcode." >&2
98 echo "See http://swtch.com/go/xcodegcc for details." >&2
99 exit 1
100 fi
101 CC9="xcrun --sdk macosx clang"
102 case "$(uname -a)" in
103 *ARM64*)
104 CC9="$CC9 -arch arm64"
105 echo ' Forcing arm64 binaries with clang.'
106 ;;
107 esac
109 echo "CC9='$CC9'" >>$PLAN9/config
110 rm -f ./a.out
111 fi
113 if [ `uname` != Darwin ]; then
114 # Determine whether fontsrv X11 files are available.
115 rm -f a.out
116 cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
117 -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
118 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
119 if [ -f a.out ]; then
120 echo " fontsrv dependencies found."
121 echo "FONTSRV=fontsrv" >>$PLAN9/config
122 else
123 echo " fontsrv dependencies not found."
124 echo "FONTSRV=" >>$PLAN9/config
125 rm -f bin/fontsrv
126 fi
127 rm -f a.out
128 fi
130 if [ -f LOCAL.config ]; then
131 echo Using LOCAL.config options:
132 sed 's/^/ /' LOCAL.config
133 cat LOCAL.config >>config
134 fi
136 echo "* Compiler version:"
137 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
139 cd src
140 if $dobuild; then
141 echo "* Building mk..."
142 ../dist/buildmk 2>&1 | sed 's/^[+] //'
144 if [ ! -x ../bin/mk ]; then
145 echo "* Error: mk failed to build."
146 exit 1
147 fi
149 echo "* Building everything (be patient)..."
150 mk clean
151 mk libs-nuke
152 mk all || exit 1
153 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
154 echo "* Warning: not all binaries built successfully."
155 fi
156 echo "* Installing everything in $PLAN9/bin..."
157 mk -k install || exit 1
158 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
159 echo " "
160 echo "* Warning: not all binaries built successfully."
161 fi
162 if [ -f $PLAN9/bin/quote1 ]; then
163 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
164 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
165 fi
166 echo "* Cleaning up..."
167 mk clean
168 fi
170 if $doinstall; then
171 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
172 # Cleanname and sam are needed for moveplan9.sh and the man updates.
173 if [ ! -x $PLAN9/bin/cleanname ]; then
174 echo " "
175 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
176 exit 1
177 fi
178 if [ ! -x $PLAN9/bin/sam ]; then
179 echo " "
180 echo "* Installation failed: $PLAN9/bin/sam does not exist."
181 exit 1
182 fi
183 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
184 echo "* NOT building web manual."
185 else
186 echo "* Renaming hard-coded /usr/local/plan9 paths..."
187 cd $PLAN9
188 sh lib/moveplan9.sh
189 echo "* Building web manual..."
191 cd $PLAN9/dist
192 echo cd `pwd`';' mk man
193 mk man
195 fi
197 if [ -x LOCAL.INSTALL ]; then
198 echo "* Running local modifications..."
199 echo cd `pwd`';' ./LOCAL.INSTALL
200 ./LOCAL.INSTALL
201 fi
203 echo "* Done. "
204 echo " "
205 echo "* Add these to your profile environment."
206 echo " PLAN9=$PLAN9 export PLAN9"
207 echo ' PATH=$PATH:$PLAN9/bin export PATH'
208 fi
209 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum