19 PLAN9_TARGET=$1 export PLAN9_TARGET
22 echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
26 PLAN9=`pwd` export PLAN9
27 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
37 echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
38 echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
39 echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
41 echo "* Resetting $PLAN9/config"
45 if [ `uname` = FreeBSD ]; then
48 echo "CC9=clang" >> $PLAN9/config
53 echo "* Running on FreeBSD, adjusting linker flags"
54 echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config
57 if [ `uname` = DragonFly ]; then
58 echo "* Running on DragonFly BSD, adjusting linker flags"
59 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
60 echo "CFLAGS='-pthread'" >> $PLAN9/config
63 if [ `uname` = OpenBSD ]; then
64 echo "* Running on OpenBSD, adjusting linker flags"
65 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
68 if [ `uname` = Linux ]; then
69 # On Linux, we use the kernel version to decide whether
70 # to use pthreads or not. On 2.6 versions that aren't
71 # linking with NPTL by default, pretend to be an older kernel.
72 echo "* Running on Linux: checking for NPTL..."
73 gcc lib/linux-isnptl.c -lpthread
77 echo "SYSVERSION=2.6.x" >>$PLAN9/config
79 echo " NPTL not found."
80 echo "SYSVERSION=2.4.x" >>$PLAN9/config
85 if [ `uname` = SunOS ]; then
86 # On Solaris x86, uname -p cannot be trusted.
87 echo "* Running on Solaris: checking architecture..."
88 case "$(isainfo -n)" in
91 echo "OBJTYPE=x86_64" >>$PLAN9/config
92 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
96 echo "OBJTYPE=386" >>$PLAN9/config
97 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
101 echo "OBJTYPE=sparc" >>$PLAN9/config
106 if [ `uname` = Darwin ]; then
107 export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
108 # On Darwin, uname -m -p cannot be trusted.
109 echo "* Running on Darwin: checking architecture..."
111 if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
112 echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
113 echo "See http://swtch.com/go/xcodegcc for details." >&2
116 case "$(file ./a.out 2>/dev/null)" in
118 echo " x86-64 found."
119 echo "OBJTYPE=x86_64" >>$PLAN9/config
120 echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
124 echo "OBJTYPE=386" >>$PLAN9/config
128 echo "OBJTYPE=power" >>$PLAN9/config
134 if [ `uname` != Darwin ]; then
135 # Determine whether fontsrv X11 files are available.
137 gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
138 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
139 if [ -f a.out ]; then
140 echo " fontsrv dependencies found."
141 echo "FONTSRV=fontsrv" >>$PLAN9/config
143 echo " fontsrv dependencies not found."
144 echo "FONTSRV=" >>$PLAN9/config
150 if [ -f LOCAL.config ]; then
151 echo Using LOCAL.config options:
152 sed 's/^/ /' LOCAL.config
153 cat LOCAL.config >>config
156 echo "* Compiler version:"
157 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
161 if [ ! -x ../bin/mk ]; then
162 echo "* Building mk..."
163 ../dist/buildmk 2>&1 | sed 's/^[+] //'
165 if [ ! -x ../bin/mk ]; then
166 echo "* Error: mk failed to build."
170 echo "* Building everything (be patient)..."
174 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
175 echo "* Warning: not all binaries built successfully."
177 echo "* Installing everything in $PLAN9/bin..."
178 mk -k install || exit 1
179 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
181 echo "* Warning: not all binaries built successfully."
183 if [ -f $PLAN9/bin/quote1 ]; then
184 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
185 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
187 echo "* Cleaning up..."
192 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
193 # Cleanname and sam are needed for moveplan9.sh and the man updates.
194 if [ ! -x $PLAN9/bin/cleanname ]; then
196 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
199 if [ ! -x $PLAN9/bin/sam ]; then
201 echo "* Installation failed: $PLAN9/bin/sam does not exist."
204 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
205 echo "* NOT building web manual."
207 echo "* Renaming hard-coded /usr/local/plan9 paths..."
210 echo "* Building web manual..."
213 echo cd `pwd`';' mk man
218 if [ -x LOCAL.INSTALL ]; then
219 echo "* Running local modifications..."
220 echo cd `pwd`';' ./LOCAL.INSTALL
226 echo "* Add these to your profile environment."
227 echo " PLAN9=$PLAN9 export PLAN9"
228 echo ' PATH=$PATH:$PLAN9/bin export PATH'
230 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum