blob: 5bbced6365744f133ee8227535e53111bf9a5353 [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 ;;
17*)
18 echo 'usage: INSTALL [-b | -c]' 1>&2
19 exit 1
20esac
21
rscb4e0c542004-02-29 22:53:01 +000022PLAN9=`pwd` export PLAN9
rsc90550262005-07-22 18:44:46 +000023PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
rscb4e0c542004-02-29 22:53:01 +000024
rsc7495a522005-11-26 15:39:46 +000025echo "* Resetting $PLAN9/config"
rsc52fdc1a2005-02-02 22:08:10 +000026rm -f config
rsc7a2c8852005-01-17 21:30:05 +000027
rsc95d46632005-01-14 18:02:48 +000028(
Russ Coxb8939322008-05-10 13:34:32 -040029echo "* Compiler version:"
Russ Cox4fbb40c2008-12-06 15:53:13 -0800309c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
Russ Coxb8939322008-05-10 13:34:32 -040031
rsc7a2c8852005-01-17 21:30:05 +000032if [ `uname` = Linux ]; then
33 # On Linux, we use the kernel version to decide whether
34 # to use pthreads or not. On 2.6 versions that aren't
35 # linking with NPTL by default, pretend to be an older kernel.
rsc7495a522005-11-26 15:39:46 +000036 echo "* Running on Linux: checking for NPTL..."
rscd3380282005-01-17 21:38:20 +000037 gcc lib/linux-isnptl.c -lpthread
rsc8327d412005-01-23 01:55:42 +000038 if ./a.out >/dev/null
rsc7a2c8852005-01-17 21:30:05 +000039 then
40 echo " NPTL found."
rsc7ca70592005-01-21 20:21:12 +000041 echo "SYSVERSION=2.6.x" >$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000042 else
43 echo " NPTL not found."
rsc7ca70592005-01-21 20:21:12 +000044 echo "SYSVERSION=2.4.x" >$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000045 fi
rscb04c42e2005-01-17 21:32:55 +000046 rm -f ./a.out
rsc7a2c8852005-01-17 21:30:05 +000047fi
rsc52fdc1a2005-02-02 22:08:10 +000048
49if [ -f LOCAL.config ]; then
50 echo Using LOCAL.config options:
51 sed 's/^/ /' LOCAL.config
52 cat LOCAL.config >>config
53fi
54
rscb4e0c542004-02-29 22:53:01 +000055cd src
rscdf29f2c2005-12-30 18:52:40 +000056if $dobuild; then
57 if [ ! -x ../bin/mk ]; then
58 echo "* Building mk..."
59 ../dist/buildmk 2>&1 | sed 's/^[+] //'
60 fi
61 if [ ! -x ../bin/mk ]; then
62 echo "* Error: mk failed to build."
rsc6637b802005-11-28 21:14:44 +000063 exit 1
64 fi
rscdf29f2c2005-12-30 18:52:40 +000065
66 echo "* Building everything (be patient)..."
67 mk clean
68 mk libs-nuke
69 mk all || exit 1
70 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
71 echo "* Warning: not all binaries built successfully."
rsc6637b802005-11-28 21:14:44 +000072 fi
rscdf29f2c2005-12-30 18:52:40 +000073 echo "* Installing everything in $PLAN9/bin..."
74 mk install || exit 1
75 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
76 echo " "
77 echo "* Warning: not all binaries built successfully."
78 fi
79 echo "* Cleaning up..."
80 mk clean
rsc6637b802005-11-28 21:14:44 +000081fi
82
rscdf29f2c2005-12-30 18:52:40 +000083if $doinstall; then
84 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
85 # Cleanname and sam are needed for moveplan9.sh and the man updates.
86 if [ ! -x $PLAN9/bin/cleanname ]; then
87 echo " "
88 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
89 exit 1
90 fi
91 if [ ! -x $PLAN9/bin/sam ]; then
92 echo " "
93 echo "* Installation failed: $PLAN9/bin/sam does not exist."
94 exit 1
95 fi
96 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
97 echo "* NOT building web manual."
98 else
99 echo "* Renaming hard-coded /usr/local/plan9 paths..."
100 cd $PLAN9
101 sh lib/moveplan9.sh
102 echo "* Building web manual..."
103 (
104 cd $PLAN9/dist
105 echo cd `pwd`';' mk man
106 mk man
107 )
108 fi
109
110 if [ -x LOCAL.INSTALL ]; then
111 echo "* Running local modifications..."
112 echo cd `pwd`';' ./LOCAL.INSTALL
113 ./LOCAL.INSTALL
114 fi
115
116 echo "* Done. "
117 echo " "
118 echo "* Add these to your profile environment."
119 echo " PLAN9=$PLAN9 export PLAN9"
120 echo ' PATH=$PATH:$PLAN9/bin export PATH'
rsc3b1a43f2005-01-18 20:17:42 +0000121fi
rsc8f8ef0c2006-07-24 19:05:01 +0000122) 2>&1 | tee install.log | awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum
rsc7495a522005-11-26 15:39:46 +0000123