view configure @ 42:e1017d556437

add unique indexes on number_in_pr
author David A. Holland
date Sun, 15 Jun 2014 18:16:12 -0400
parents 923ea629c29f
children 62d82881799f
line wrap: on
line source

#!/bin/sh
# configure - configure swallowtail
# usage: see configure --help
# note: this is not an autoconf-generated script

help() {
	cat <<EOF
Usage: $0 [args]
where args can be:
	--help			Print usage
	--destdir=DIR		Set install chroot [none]
	--prefix=DIR		Set install prefix [/usr/local]
	--python=FILE		Set path to Python interpreter [probed]
	--sh=FILE		Set path to Bourne shell [/bin/sh]
EOF
}

usage() {
	echo "Usage: $0 [args}" 1>&2
	echo "Try --help" 1>&2
}

############################################################
# args

DESTDIR=
PREFIX=/usr/local
PYTHON=probed
SH=/bin/sh

for ARG in "$@"; do
	case "$ARG" in
		--help) help; exit;;
		--destdir=*) DESTDIR=`echo "$ARG" | sed 's/^[^=]*=//'`;;
		--prefix=*) PREFIX=`echo "$ARG" | sed 's/^[^=]*=//'`;;
		--python=*) PYTHON=`echo "$ARG" | sed 's/^[^=]*=//'`;;
		--sh=*) SHELL=`echo "$ARG" | sed 's/^[^=]*=//'`;;
		*) usage; exit 1;;
	esac
done

############################################################
# check for python

echo -n 'Checking for python... '

nopython() {
	echo "failed"
	echo "$0: $1" 1>&2
	echo "$0: Install python or use --python=PATH option" 1>&2
	exit 1
}

testpython() {
	if [ ! -x "$1" ]; then
		return 1
	fi
	VER=$("$1" -V 2>&1)
	case "$VER" in
		"Python "*.*.*) return 0;;
		"Python "*.*) return 0;;
		*) ;;
	esac
	return 1
}

FOUND=0
case "$PYTHON" in
	probed)
		for D in \
		    /usr/local/bin \
		    /usr/pkg/bin \
		    /usr/contrib/bin \
		    /usr/bin \
		    /opt/bin \
		; do
			for PY in \
				python \
				python2.7 python27 \
				python2.6 python26 \
				python2.5 python25 \
				python2.4 python24 \
			; do
				if testpython $D/$PY; then
					PYTHON="$D/$PY"
					FOUND=1
					break
				fi
			done
			if [ $FOUND = 1 ]; then
				break
			fi
		done
		if [ $FOUND = 0 ]; then
			nopython "Cannot find python"
		fi
	;;
	/*)
		if testpython "$PYTHON"; then
			:
		else
			nopython "$PYTHON does not appear to be python"
		fi
	;;
	*)
		nopython "$PYTHON is not an absolute path"
	;;
esac
echo "$PYTHON"

############################################################
# Generate config.*

echo 'Generating config.sed'

cat > config.sed.new <<EOF
s,@PYTHON@,$PYTHON,
s,@SH@,$SH,
EOF

mv -f config.sed.new config.sed

echo 'Generating config.mk'

cat > config.mk.new <<EOF
DESTDIR=$DESTDIR
PREFIX=$PREFIX
EOF

mv -f config.mk.new config.mk

############################################################
# done

exit 0