blob: e0c7c8b0fa1eddbb950ff9a174563289fd83314b [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(
rsc7a2c8852005-01-17 21:30:05 +000029if [ `uname` = Linux ]; then
30 # On Linux, we use the kernel version to decide whether
31 # to use pthreads or not. On 2.6 versions that aren't
32 # linking with NPTL by default, pretend to be an older kernel.
rsc7495a522005-11-26 15:39:46 +000033 echo "* Running on Linux: checking for NPTL..."
rscd3380282005-01-17 21:38:20 +000034 gcc lib/linux-isnptl.c -lpthread
rsc8327d412005-01-23 01:55:42 +000035 if ./a.out >/dev/null
rsc7a2c8852005-01-17 21:30:05 +000036 then
37 echo " NPTL found."
rsc7ca70592005-01-21 20:21:12 +000038 echo "SYSVERSION=2.6.x" >$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000039 else
40 echo " NPTL not found."
rsc7ca70592005-01-21 20:21:12 +000041 echo "SYSVERSION=2.4.x" >$PLAN9/config
rsc7a2c8852005-01-17 21:30:05 +000042 fi
rscb04c42e2005-01-17 21:32:55 +000043 rm -f ./a.out
rsc7a2c8852005-01-17 21:30:05 +000044fi
rsc52fdc1a2005-02-02 22:08:10 +000045
46if [ -f LOCAL.config ]; then
47 echo Using LOCAL.config options:
48 sed 's/^/ /' LOCAL.config
49 cat LOCAL.config >>config
50fi
51
rscb4e0c542004-02-29 22:53:01 +000052cd src
rscdf29f2c2005-12-30 18:52:40 +000053if $dobuild; then
54 if [ ! -x ../bin/mk ]; then
55 echo "* Building mk..."
56 ../dist/buildmk 2>&1 | sed 's/^[+] //'
57 fi
58 if [ ! -x ../bin/mk ]; then
59 echo "* Error: mk failed to build."
rsc6637b802005-11-28 21:14:44 +000060 exit 1
61 fi
rscdf29f2c2005-12-30 18:52:40 +000062
63 echo "* Building everything (be patient)..."
64 mk clean
65 mk libs-nuke
66 mk all || exit 1
67 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
68 echo "* Warning: not all binaries built successfully."
rsc6637b802005-11-28 21:14:44 +000069 fi
rscdf29f2c2005-12-30 18:52:40 +000070 echo "* Installing everything in $PLAN9/bin..."
71 mk install || exit 1
72 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
73 echo " "
74 echo "* Warning: not all binaries built successfully."
75 fi
76 echo "* Cleaning up..."
77 mk clean
rsc6637b802005-11-28 21:14:44 +000078fi
79
rscdf29f2c2005-12-30 18:52:40 +000080if $doinstall; then
81 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
82 # Cleanname and sam are needed for moveplan9.sh and the man updates.
83 if [ ! -x $PLAN9/bin/cleanname ]; then
84 echo " "
85 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
86 exit 1
87 fi
88 if [ ! -x $PLAN9/bin/sam ]; then
89 echo " "
90 echo "* Installation failed: $PLAN9/bin/sam does not exist."
91 exit 1
92 fi
93 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
94 echo "* NOT building web manual."
95 else
96 echo "* Renaming hard-coded /usr/local/plan9 paths..."
97 cd $PLAN9
98 sh lib/moveplan9.sh
99 echo "* Building web manual..."
100 (
101 cd $PLAN9/dist
102 echo cd `pwd`';' mk man
103 mk man
104 )
105 fi
106
107 if [ -x LOCAL.INSTALL ]; then
108 echo "* Running local modifications..."
109 echo cd `pwd`';' ./LOCAL.INSTALL
110 ./LOCAL.INSTALL
111 fi
112
113 echo "* Done. "
114 echo " "
115 echo "* Add these to your profile environment."
116 echo " PLAN9=$PLAN9 export PLAN9"
117 echo ' PATH=$PATH:$PLAN9/bin export PATH'
rsc3b1a43f2005-01-18 20:17:42 +0000118fi
rsc7495a522005-11-26 15:39:46 +0000119) 2>&1 | tee install.log | awk -f $PLAN9/dist/isum.awk | tee install.sum
120