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
35 echo "CC9=clang" >> $PLAN9/config
38 echo "CC9=gcc" >> $PLAN9/config
41 echo "* Running on" `uname`", adjusting linker flags"
44 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
47 echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
50 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
53 echo "CFLAGS='-pthread'" >> $PLAN9/config
61 echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
62 echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
63 echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
65 echo "* Resetting $PLAN9/config"
69 if [ `uname` = Linux ]; then
70 # On Linux, we use the kernel version to decide whether
71 # to use pthreads or not. On 2.6 versions that aren't
72 # linking with NPTL by default, pretend to be an older kernel.
73 echo "* Running on Linux: checking for NPTL..."
74 gcc lib/linux-isnptl.c -lpthread
78 echo "SYSVERSION=2.6.x" >>$PLAN9/config
80 echo " NPTL not found."
81 echo "SYSVERSION=2.4.x" >>$PLAN9/config
86 if [ `uname` = SunOS ]; then
87 # On Solaris x86, uname -p cannot be trusted.
88 echo "* Running on Solaris: checking architecture..."
89 case "$(isainfo -n)" in
92 echo "OBJTYPE=x86_64" >>$PLAN9/config
93 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
97 echo "OBJTYPE=386" >>$PLAN9/config
98 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
102 echo "OBJTYPE=sparc" >>$PLAN9/config
107 if [ `uname` = Darwin ]; then
108 export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
109 # On Darwin, uname -m -p cannot be trusted.
110 echo "* Running on Darwin: checking architecture..."
112 if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
113 echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
114 echo "See http://swtch.com/go/xcodegcc for details." >&2
117 case "$(file ./a.out 2>/dev/null)" in
119 echo " x86-64 found."
120 echo "OBJTYPE=x86_64" >>$PLAN9/config
121 echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
125 echo "OBJTYPE=386" >>$PLAN9/config
129 echo "OBJTYPE=power" >>$PLAN9/config
135 if [ `uname` != Darwin ]; then
136 # Determine whether fontsrv X11 files are available.
138 cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
139 -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
140 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
141 if [ -f a.out ]; then
142 echo " fontsrv dependencies found."
143 echo "FONTSRV=fontsrv" >>$PLAN9/config
145 echo " fontsrv dependencies not found."
146 echo "FONTSRV=" >>$PLAN9/config
152 if [ -f LOCAL.config ]; then
153 echo Using LOCAL.config options:
154 sed 's/^/ /' LOCAL.config
155 cat LOCAL.config >>config
158 echo "* Compiler version:"
159 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
163 if [ ! -x ../bin/mk ]; then
164 echo "* Building mk..."
165 ../dist/buildmk 2>&1 | sed 's/^[+] //'
167 if [ ! -x ../bin/mk ]; then
168 echo "* Error: mk failed to build."
172 echo "* Building everything (be patient)..."
176 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
177 echo "* Warning: not all binaries built successfully."
179 echo "* Installing everything in $PLAN9/bin..."
180 mk -k install || exit 1
181 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
183 echo "* Warning: not all binaries built successfully."
185 if [ -f $PLAN9/bin/quote1 ]; then
186 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
187 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
189 echo "* Cleaning up..."
194 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
195 # Cleanname and sam are needed for moveplan9.sh and the man updates.
196 if [ ! -x $PLAN9/bin/cleanname ]; then
198 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
201 if [ ! -x $PLAN9/bin/sam ]; then
203 echo "* Installation failed: $PLAN9/bin/sam does not exist."
206 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
207 echo "* NOT building web manual."
209 echo "* Renaming hard-coded /usr/local/plan9 paths..."
212 echo "* Building web manual..."
215 echo cd `pwd`';' mk man
220 if [ -x LOCAL.INSTALL ]; then
221 echo "* Running local modifications..."
222 echo cd `pwd`';' ./LOCAL.INSTALL
228 echo "* Add these to your profile environment."
229 echo " PLAN9=$PLAN9 export PLAN9"
230 echo ' PATH=$PATH:$PLAN9/bin export PATH'
232 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum