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