blob: 8f123b8542f2e18bf71c40f3e4709aecf61d7b03 [file] [log] [blame]
rscb4e0c542004-02-29 22:53:01 +00001#!/bin/sh
2
rscdf29f2c2005-12-30 18:52:40 +00003dobuild=true
4doinstall=true
5
6case "x$1" in
7x)
8 ;;
9x-b)
10 dobuild=true
11 doinstall=false
12 ;;
13x-c)
14 dobuild=false
15 doinstall=true
16 ;;
Peter Saveliev89ec3cd2011-06-02 09:28:23 -040017x-r)
18 shift
19 PLAN9_TARGET=$1 export PLAN9_TARGET
20 ;;
rscdf29f2c2005-12-30 18:52:40 +000021*)
Peter Saveliev89ec3cd2011-06-02 09:28:23 -040022 echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
rscdf29f2c2005-12-30 18:52:40 +000023 exit 1
24esac
25
rscb4e0c542004-02-29 22:53:01 +000026PLAN9=`pwd` export PLAN9
rsc90550262005-07-22 18:44:46 +000027PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
Arvindh Rajesh Tamilmani80c90f22010-04-09 15:28:16 -070028case `uname` in
29SunOS)
30 awk=nawk
31 ;;
32*)
33 awk=awk
34 ;;
35esac
rscb4e0c542004-02-29 22:53:01 +000036
Russ Cox1d534ed2009-07-29 11:30:25 -040037echo "+ Mailing list: http://groups.google.com/group/plan9port-dev"
38echo "+ Issue tracker: http://code.swtch.com/plan9port/issues/"
39echo "+ Submitting changes: http://swtch.com/go/codereview"
40echo " "
rsc7495a522005-11-26 15:39:46 +000041echo "* Resetting $PLAN9/config"
rsc52fdc1a2005-02-02 22:08:10 +000042rm -f config
rsc7a2c8852005-01-17 21:30:05 +000043
rsc95d46632005-01-14 18:02:48 +000044(
Russ Coxb8939322008-05-10 13:34:32 -040045echo "* Compiler version:"
Russ Cox4fbb40c2008-12-06 15:53:13 -0800469c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
Russ Coxb8939322008-05-10 13:34:32 -040047
Martin Neubauerdad9d0a2013-01-30 17:45:28 -080048if [ `uname` = FreeBSD ]; then
49 echo "* Running on FreeBSD, adjusting linker flags"
50 echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config
51fi
52
Shenghou Ma20035ed2014-02-27 23:17:47 -050053if [ `uname` = DragonFly ]; then
54 echo "* Running on DragonFly BSD, adjusting linker flags"
55 echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
56 echo "CFLAGS='-pthread'" >> $PLAN9/config
57fi
58
Christian Kellermann1a512ec2012-12-11 12:45:45 -050059if [ `uname` = OpenBSD ]; then
60 echo "* Running on OpenBSD, adjusting linker flags"
61 echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
62fi
63
rsc7a2c8852005-01-17 21:30:05 +000064if [ `uname` = Linux ]; then
65 # On Linux, we use the kernel version to decide whether
66 # to use pthreads or not. On 2.6 versions that aren't
67 # linking with NPTL by default, pretend to be an older kernel.
rsc7495a522005-11-26 15:39:46 +000068 echo "* Running on Linux: checking for NPTL..."
rscd3380282005-01-17 21:38:20 +000069 gcc lib/linux-isnptl.c -lpthread
rsc8327d412005-01-23 01:55:42 +000070 if ./a.out >/dev/null
rsc7a2c8852005-01-17 21:30:05 +000071 then
72 echo " NPTL found."
Russ Coxfc567f42011-08-02 14:28:04 -040073 echo "SYSVERSION=2.6.x" >>$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000074 else
75 echo " NPTL not found."
Russ Coxfc567f42011-08-02 14:28:04 -040076 echo "SYSVERSION=2.4.x" >>$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000077 fi
rscb04c42e2005-01-17 21:32:55 +000078 rm -f ./a.out
rsc7a2c8852005-01-17 21:30:05 +000079fi
rsc52fdc1a2005-02-02 22:08:10 +000080
Shenghou Mae78ed7a2014-03-05 16:43:20 -050081if [ `uname` = SunOS ]; then
82 # On Solaris x86, uname -p cannot be trusted.
83 echo "* Running on Solaris: checking architecture..."
84 case "$(isainfo -n)" in
85 *amd64*)
86 echo " x86-64 found."
87 echo "OBJTYPE=x86_64" >>$PLAN9/config
88 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
89 ;;
90 *i386*)
91 echo " i386 found."
92 echo "OBJTYPE=386" >>$PLAN9/config
93 echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
94 ;;
95 *sparc*)
96 echo " Sparc found."
97 echo "OBJTYPE=sparc" >>$PLAN9/config
98 ;;
99 esac
100fi
101
Russ Coxfc567f42011-08-02 14:28:04 -0400102if [ `uname` = Darwin ]; then
103 # On Darwin, uname -m -p cannot be trusted.
104 echo "* Running on Darwin: checking architecture..."
105 rm -f ./a.out
Russ Coxbaf127a2014-01-22 11:23:19 -0500106 if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
107 echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
108 echo "See http://swtch.com/go/xcodegcc for details." >&2
109 exit 1
110 fi
Russ Coxfc567f42011-08-02 14:28:04 -0400111 case "$(file ./a.out 2>/dev/null)" in
112 *x86_64*)
113 echo " x86-64 found."
114 echo "OBJTYPE=x86_64" >>$PLAN9/config
115 ;;
116 *i386*)
117 echo " i386 found."
118 echo "OBJTYPE=386" >>$PLAN9/config
119 ;;
Russ Cox813b3ee2011-10-23 17:55:23 -0400120 *ppc*)
121 echo " power found."
122 echo "OBJTYPE=power" >>$PLAN9/config
123 ;;
Russ Coxfc567f42011-08-02 14:28:04 -0400124 esac
125 rm -f ./a.out
126fi
127
Russ Coxcb71c0b2012-12-18 07:22:19 -0800128if [ `uname` != Darwin ]; then
129 # Determine whether fontsrv X11 files are available.
130 rm -f a.out
Gleydson Soares8ee5da72015-06-10 13:02:40 -0300131 gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
132 -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
Russ Coxcb71c0b2012-12-18 07:22:19 -0800133 if [ -f a.out ]; then
134 echo " fontsrv dependencies found."
135 echo "FONTSRV=fontsrv" >>$PLAN9/config
136 else
137 echo " fontsrv dependencies not found."
138 echo "FONTSRV=" >>$PLAN9/config
139 rm -f bin/fontsrv
140 fi
141 rm -f a.out
142fi
143
rsc52fdc1a2005-02-02 22:08:10 +0000144if [ -f LOCAL.config ]; then
145 echo Using LOCAL.config options:
146 sed 's/^/ /' LOCAL.config
147 cat LOCAL.config >>config
148fi
149
rscb4e0c542004-02-29 22:53:01 +0000150cd src
rscdf29f2c2005-12-30 18:52:40 +0000151if $dobuild; then
152 if [ ! -x ../bin/mk ]; then
153 echo "* Building mk..."
154 ../dist/buildmk 2>&1 | sed 's/^[+] //'
155 fi
156 if [ ! -x ../bin/mk ]; then
157 echo "* Error: mk failed to build."
rsc6637b802005-11-28 21:14:44 +0000158 exit 1
159 fi
rscdf29f2c2005-12-30 18:52:40 +0000160
161 echo "* Building everything (be patient)..."
162 mk clean
163 mk libs-nuke
164 mk all || exit 1
165 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
166 echo "* Warning: not all binaries built successfully."
rsc6637b802005-11-28 21:14:44 +0000167 fi
rscdf29f2c2005-12-30 18:52:40 +0000168 echo "* Installing everything in $PLAN9/bin..."
Russ Coxc49b45e2011-10-03 16:08:14 -0400169 mk -k install || exit 1
rscdf29f2c2005-12-30 18:52:40 +0000170 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
171 echo " "
172 echo "* Warning: not all binaries built successfully."
173 fi
David du Colombier734ca632014-11-07 22:52:31 +0100174 if [ -f $PLAN9/bin/quote1 ]; then
175 cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
176 cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
Russ Coxfbe3f342014-06-03 14:29:06 -0400177 fi
rscdf29f2c2005-12-30 18:52:40 +0000178 echo "* Cleaning up..."
179 mk clean
rsc6637b802005-11-28 21:14:44 +0000180fi
181
rscdf29f2c2005-12-30 18:52:40 +0000182if $doinstall; then
183 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
184 # Cleanname and sam are needed for moveplan9.sh and the man updates.
185 if [ ! -x $PLAN9/bin/cleanname ]; then
186 echo " "
187 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
188 exit 1
189 fi
190 if [ ! -x $PLAN9/bin/sam ]; then
191 echo " "
192 echo "* Installation failed: $PLAN9/bin/sam does not exist."
193 exit 1
194 fi
195 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
196 echo "* NOT building web manual."
197 else
198 echo "* Renaming hard-coded /usr/local/plan9 paths..."
199 cd $PLAN9
200 sh lib/moveplan9.sh
201 echo "* Building web manual..."
202 (
203 cd $PLAN9/dist
204 echo cd `pwd`';' mk man
205 mk man
206 )
207 fi
208
209 if [ -x LOCAL.INSTALL ]; then
210 echo "* Running local modifications..."
211 echo cd `pwd`';' ./LOCAL.INSTALL
212 ./LOCAL.INSTALL
213 fi
214
215 echo "* Done. "
216 echo " "
217 echo "* Add these to your profile environment."
218 echo " PLAN9=$PLAN9 export PLAN9"
219 echo ' PATH=$PATH:$PLAN9/bin export PATH'
rsc3b1a43f2005-01-18 20:17:42 +0000220fi
Arvindh Rajesh Tamilmani80c90f22010-04-09 15:28:16 -0700221) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum
rsc7495a522005-11-26 15:39:46 +0000222