Blob


1 #!/bin/sh
3 dobuild=true
4 doinstall=true
6 case "x$1" in
7 x)
8 ;;
9 x-b)
10 dobuild=true
11 doinstall=false
12 ;;
13 x-c)
14 dobuild=false
15 doinstall=true
16 ;;
17 *)
18 echo 'usage: INSTALL [-b | -c]' 1>&2
19 exit 1
20 esac
22 PLAN9=`pwd` export PLAN9
23 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
25 echo "+ Mailing list: http://groups.google.com/group/plan9port-dev"
26 echo "+ Issue tracker: http://code.swtch.com/plan9port/issues/"
27 echo "+ Submitting changes: http://swtch.com/go/codereview"
28 echo " "
29 echo "* Resetting $PLAN9/config"
30 rm -f config
32 (
33 echo "* Compiler version:"
34 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /'
36 if [ `uname` = Linux ]; then
37 # On Linux, we use the kernel version to decide whether
38 # to use pthreads or not. On 2.6 versions that aren't
39 # linking with NPTL by default, pretend to be an older kernel.
40 echo "* Running on Linux: checking for NPTL..."
41 gcc lib/linux-isnptl.c -lpthread
42 if ./a.out >/dev/null
43 then
44 echo " NPTL found."
45 echo "SYSVERSION=2.6.x" >$PLAN9/config
46 else
47 echo " NPTL not found."
48 echo "SYSVERSION=2.4.x" >$PLAN9/config
49 fi
50 rm -f ./a.out
51 fi
53 if [ -f LOCAL.config ]; then
54 echo Using LOCAL.config options:
55 sed 's/^/ /' LOCAL.config
56 cat LOCAL.config >>config
57 fi
59 cd src
60 if $dobuild; then
61 if [ ! -x ../bin/mk ]; then
62 echo "* Building mk..."
63 ../dist/buildmk 2>&1 | sed 's/^[+] //'
64 fi
65 if [ ! -x ../bin/mk ]; then
66 echo "* Error: mk failed to build."
67 exit 1
68 fi
70 echo "* Building everything (be patient)..."
71 mk clean
72 mk libs-nuke
73 mk all || exit 1
74 if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
75 echo "* Warning: not all binaries built successfully."
76 fi
77 echo "* Installing everything in $PLAN9/bin..."
78 mk install || exit 1
79 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
80 echo " "
81 echo "* Warning: not all binaries built successfully."
82 fi
83 echo "* Cleaning up..."
84 mk clean
85 fi
87 if $doinstall; then
88 if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
89 # Cleanname and sam are needed for moveplan9.sh and the man updates.
90 if [ ! -x $PLAN9/bin/cleanname ]; then
91 echo " "
92 echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
93 exit 1
94 fi
95 if [ ! -x $PLAN9/bin/sam ]; then
96 echo " "
97 echo "* Installation failed: $PLAN9/bin/sam does not exist."
98 exit 1
99 fi
100 echo "* NOT renaming hard-coded /usr/local/plan9 paths."
101 echo "* NOT building web manual."
102 else
103 echo "* Renaming hard-coded /usr/local/plan9 paths..."
104 cd $PLAN9
105 sh lib/moveplan9.sh
106 echo "* Building web manual..."
108 cd $PLAN9/dist
109 echo cd `pwd`';' mk man
110 mk man
112 fi
114 if [ -x LOCAL.INSTALL ]; then
115 echo "* Running local modifications..."
116 echo cd `pwd`';' ./LOCAL.INSTALL
117 ./LOCAL.INSTALL
118 fi
120 echo "* Done. "
121 echo " "
122 echo "* Add these to your profile environment."
123 echo " PLAN9=$PLAN9 export PLAN9"
124 echo ' PATH=$PATH:$PLAN9/bin export PATH'
125 fi
126 ) 2>&1 | tee install.log | awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum