plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

INSTALL (4999B)


      1 #!/bin/sh
      2 
      3 dobuild=true
      4 doinstall=true
      5 
      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 x-r)
     18 	shift
     19 	PLAN9_TARGET=$1
     20 	;;
     21 *)
     22 	echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2
     23 	exit 1
     24 esac
     25 
     26 PLAN9=`pwd` export PLAN9
     27 
     28 echo "+ Mailing list: https://groups.google.com/group/plan9port-dev"
     29 echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/"
     30 echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls"
     31 echo " "
     32 echo "* Resetting $PLAN9/config"
     33 rm -f config
     34 
     35 PLAN9=`pwd` export PLAN9
     36 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH
     37 [ -z "$PLAN9_TARGET" ] && PLAN9_TARGET="$PLAN9"
     38 export PLAN9_TARGET
     39 
     40 case `uname` in
     41 SunOS)
     42 	awk=nawk
     43 	;;
     44 DragonFly|*BSD)
     45 	case `cc -v 2>&1` in
     46 	*clang*)
     47 		echo "CC9=clang" >> $PLAN9/config
     48 		;;
     49 	*gcc*)
     50 		echo "CC9=gcc" >> $PLAN9/config
     51 		;;
     52 	esac
     53 	echo "* Running on" `uname`", adjusting linker flags"
     54 	case `uname` in
     55 	OpenBSD)
     56 		echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config
     57 		;;
     58 	NetBSD)
     59 		echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config
     60 		;;
     61 	*)
     62 		echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config
     63 		;;
     64 	esac
     65 	echo "CFLAGS='-pthread'" >> $PLAN9/config
     66 	awk=awk
     67 	;;
     68 *)
     69 	awk=awk
     70 	;;
     71 esac
     72 
     73 (
     74 if [ `uname` = SunOS ]; then
     75 	# On Solaris x86, uname -p cannot be trusted.
     76 	echo "* Running on Solaris: checking architecture..."
     77 	case "$(isainfo -n)" in
     78 	*amd64*)
     79 		echo "	x86-64 found; using gcc."
     80 		echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
     81 		;;
     82 	*i386*)
     83 		echo "	i386 found; using gcc."
     84 		echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
     85 		;;
     86 	*sparc*)
     87 		echo "	Sparc found."
     88 		;;
     89 	esac
     90 fi
     91 
     92 if [ `uname` = Darwin ]; then
     93 	export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
     94 	# On Darwin, uname -m -p cannot be trusted.
     95 	echo "* Running on Darwin..."
     96 	rm -f ./a.out
     97 	if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
     98 		echo "Cannot find 'xcrun --sdk macosx clang'." >&2
     99 		echo "You may need to install the command-line tools using Xcode." >&2
    100 		echo "See http://swtch.com/go/xcodegcc for details." >&2
    101 		exit 1
    102 	fi
    103 	CC9="xcrun --sdk macosx clang"
    104 	case "$(uname -a)" in
    105 	*ARM64*)
    106 		CC9="$CC9 -arch arm64"
    107 		echo '	Forcing arm64 binaries with clang.'
    108 		;;
    109 	esac
    110 
    111 	echo "CC9='$CC9'" >>$PLAN9/config
    112 	rm -f ./a.out
    113 fi
    114 
    115 if [ `uname` != Darwin ]; then
    116 	# Determine whether fontsrv X11 files are available.
    117 	rm -f a.out
    118 	cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \
    119 	    -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
    120 	    -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1
    121 	if [ -f a.out ]; then
    122 		echo "	fontsrv dependencies found."
    123 		echo "FONTSRV=fontsrv" >>$PLAN9/config
    124 	else
    125 		echo "	fontsrv dependencies not found."
    126 		echo "FONTSRV=" >>$PLAN9/config
    127 		rm -f bin/fontsrv
    128 	fi
    129 	rm -f a.out
    130 fi
    131 
    132 if [ -f LOCAL.config ]; then
    133 	echo Using LOCAL.config options:
    134 	sed 's/^/	/' LOCAL.config
    135 	cat LOCAL.config >>config
    136 fi
    137 
    138 echo "* Compiler version:"
    139 9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/	/'
    140 
    141 cd src
    142 if $dobuild; then
    143 	echo "* Building mk..."
    144 	../dist/buildmk 2>&1 | sed 's/^[+] //'
    145 
    146 	if [ ! -x ../bin/mk ]; then
    147 		echo "* Error: mk failed to build."
    148 		exit 1
    149 	fi
    150 
    151 	echo "* Building everything (be patient)..."
    152 	mk clean
    153 	mk libs-nuke
    154 	mk all || exit 1
    155 	if [ ! -x $PLAN9/src/cmd/o.cleanname -o ! -x $PLAN9/src/cmd/acme/o.acme ]; then
    156 		echo "* Warning: not all binaries built successfully."
    157 	fi
    158 	echo "* Installing everything in $PLAN9/bin..."
    159 	mk -k install || exit 1
    160 	if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/acme -o ! -x $PLAN9/bin/sam ]; then
    161 		echo " "
    162 		echo "* Warning: not all binaries built successfully."
    163 	fi
    164 	if [ -f $PLAN9/bin/quote1 ]; then
    165 		cp $PLAN9/bin/quote1 $PLAN9/bin/'"'
    166 		cp $PLAN9/bin/quote2 $PLAN9/bin/'""'
    167 	fi
    168 	echo "* Cleaning up..."
    169 	mk clean
    170 fi
    171 
    172 if $doinstall; then
    173 	if [ ! -x $PLAN9/bin/cleanname -o ! -x $PLAN9/bin/sam ]; then
    174 		# Cleanname and sam are needed for moveplan9.sh and the man updates.
    175 		if [ ! -x $PLAN9/bin/cleanname ]; then
    176 			echo " "
    177 			echo "* Installation failed: $PLAN9/bin/cleanname does not exist."
    178 			exit 1
    179 		fi
    180 		if [ ! -x $PLAN9/bin/sam ]; then
    181 			echo " "
    182 			echo "* Installation failed: $PLAN9/bin/sam does not exist."
    183 			exit 1
    184 		fi
    185 		echo "* NOT renaming hard-coded /usr/local/plan9 paths."
    186 		echo "* NOT building web manual."
    187 	else
    188 		echo "* Renaming hard-coded /usr/local/plan9 paths..."
    189 		cd $PLAN9
    190 		sh lib/moveplan9.sh
    191 		echo "* Building web manual..."
    192 		(
    193 			cd $PLAN9/dist
    194 			echo cd `pwd`';' mk man
    195 			mk man
    196 		)
    197 	fi
    198 
    199 	if [ -x LOCAL.INSTALL ]; then
    200 		echo "* Running local modifications..."
    201 		echo cd `pwd`';' ./LOCAL.INSTALL
    202 		./LOCAL.INSTALL
    203 	fi
    204 
    205 	echo "* Done. "
    206 	echo "	"
    207 	echo "* Add these to your profile environment."
    208 	echo "	PLAN9=$PLAN9 export PLAN9"
    209 	echo '	PATH=$PATH:$PLAN9/bin export PATH'
    210 fi
    211 ) 2>&1 | tee install.log | $awk -f $PLAN9/dist/isum.awk -v 'copy='install.sum
    212