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` = SunOS ]; then
70 # On Solaris x86, uname -p cannot be trusted.
71 echo "* Running on Solaris: checking architecture..."
72 case "$(isainfo -n)" in
73 *amd64*)
74 echo " x86-64 found; using gcc."
75 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
76 ;;
77 *i386*)
78 echo " i386 found; using gcc."
79 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
80 ;;
81 *sparc*)
82 echo " Sparc found."
83 ;;
84 esac
85 fi
87 if [ `uname` = Darwin ]; then
88 export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
89 # On Darwin, uname -m -p cannot be trusted.
90 echo "* Running on Darwin..."
91 rm -f ./a.out
92 if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
93 echo "Cannot find 'xcrun --sdk macosx clang'." >&2
94 echo "You may need to install the command-line tools using Xcode." >&2
95 echo "See http://swtch.com/go/xcodegcc for details." >&2
96 exit 1
97 fi
98 echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
99 rm -f ./a.out
100 fi
102 if [ `uname` != Darwin ]; then
103 # Determine whether fontsrv X11 files are available.
104 rm -f a.out
105 cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
106 -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
107 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
108 if [ -f a.out ]; then
109 echo " fontsrv dependencies found."
110 echo "FONTSRV=fontsrv" >>$PLAN9/config
111 else
112 echo " fontsrv dependencies not found."
113 echo "FONTSRV=" >>$PLAN9/config
114 rm -f bin/fontsrv
115 fi
116 rm -f a.out
117 fi
119 if [ -f LOCAL.config ]; then
120 echo Using LOCAL.config options:
121 sed 's/^/ /' LOCAL.config
122 cat LOCAL.config >>config
123 fi
125 echo "* Compiler version:"
126 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
128 cd src
129 if $dobuild; then
130 echo "* Building mk..."
131 ../dist/buildmk 2>&1 | sed 's/^[+] //'
133 if [ ! -x ../bin/mk ]; then
134 echo "* Error: mk failed to build."
135 exit 1
136 fi
138 echo "* Building everything (be patient)..."
139 mk clean
140 mk libs-nuke
141 mk all || exit 1
142 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
143 echo "* Warning: not all binaries built successfully."
144 fi
145 echo "* Installing everything in $PLAN9/bin..."
146 mk -k install || exit 1
147 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
148 echo " "
149 echo "* Warning: not all binaries built successfully."
150 fi
151 if [ -f $PLAN9/bin/quote1 ]; then
152 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
153 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
154 fi
155 echo "* Cleaning up..."
156 mk clean
157 fi
159 if $doinstall; then
160 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
161 # Cleanname and sam are needed for moveplan9.sh and the man updates.
162 if [ ! -x $PLAN9/bin/cleanname ]; then
163 echo " "
164 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
165 exit 1
166 fi
167 if [ ! -x $PLAN9/bin/sam ]; then
168 echo " "
169 echo "* Installation failed: $PLAN9/bin/sam does not exist."
170 exit 1
171 fi
172 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
173 echo "* NOT building web manual."
174 else
175 echo "* Renaming hard-coded /usr/local/plan9 paths..."
176 cd $PLAN9
177 sh lib/moveplan9.sh
178 echo "* Building web manual..."
180 cd $PLAN9/dist
181 echo cd `pwd`';' mk man
182 mk man
184 fi
186 if [ -x LOCAL.INSTALL ]; then
187 echo "* Running local modifications..."
188 echo cd `pwd`';' ./LOCAL.INSTALL
189 ./LOCAL.INSTALL
190 fi
192 echo "* Done. "
193 echo " "
194 echo "* Add these to your profile environment."
195 echo " PLAN9=$PLAN9 export PLAN9"
196 echo ' PATH=$PATH:$PLAN9/bin export PATH'
197 fi
198 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum