22 echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
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"
30 echo "* Resetting $PLAN9/config"
33 PLAN9=`pwd` export PLAN9
34 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
35 [ -z "$PLAN9_TARGET" ] && PLAN9_TARGET="$PLAN9"
45 echo "CC9=clang" >> $PLAN9/config
48 echo "CC9=gcc" >> $PLAN9/config
51 echo "* Running on" `uname`", adjusting linker flags"
54 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
57 echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
60 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
63 echo "CFLAGS='-pthread'" >> $PLAN9/config
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
77 echo " x86-64 found; using gcc."
78 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
81 echo " i386 found; using gcc."
82 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
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..."
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
101 CC9="xcrun --sdk macosx clang"
102 case "$(uname -a)" in
104 CC9="$CC9 -arch arm64"
105 echo ' Forcing arm64 binaries with clang.'
109 echo "CC9='$CC9'" >>$PLAN9/config
113 if [ `uname` != Darwin ]; then
114 # Determine whether fontsrv X11 files are available.
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
123 echo " fontsrv dependencies not found."
124 echo "FONTSRV=" >>$PLAN9/config
130 if [ -f LOCAL.config ]; then
131 echo Using LOCAL.config options:
132 sed 's/^/ /' LOCAL.config
133 cat LOCAL.config >>config
136 echo "* Compiler version:"
137 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
141 echo "* Building mk..."
142 ../dist/buildmk 2>&1 | sed 's/^[+] //'
144 if [ ! -x ../bin/mk ]; then
145 echo "* Error: mk failed to build."
149 echo "* Building everything (be patient)..."
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."
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
160 echo "* Warning: not all binaries built successfully."
162 if [ -f $PLAN9/bin/quote1 ]; then
163 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
164 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
166 echo "* Cleaning up..."
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
175 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
178 if [ ! -x $PLAN9/bin/sam ]; then
180 echo "* Installation failed: $PLAN9/bin/sam does not exist."
183 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
184 echo "* NOT building web manual."
186 echo "* Renaming hard-coded /usr/local/plan9 paths..."
189 echo "* Building web manual..."
192 echo cd `pwd`';' mk man
197 if [ -x LOCAL.INSTALL ]; then
198 echo "* Running local modifications..."
199 echo cd `pwd`';' ./LOCAL.INSTALL
205 echo "* Add these to your profile environment."
206 echo " PLAN9=$PLAN9 export PLAN9"
207 echo ' PATH=$PATH:$PLAN9/bin export PATH'
209 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum