[Zope-CVS] CVS: Zope - configure:1.1.4.6

Chris McDonough chrism@zope.com
Tue, 10 Sep 2002 17:56:17 -0400


Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv18812

Modified Files:
      Tag: chrism-install-branch
	configure 
Log Message:
Add "--with-python" argument to configure.  This allows people to name a Python interpreter instead of relying on configure to search for one for them.


=== Zope/configure 1.1.4.5 => 1.1.4.6 ===
--- Zope/configure:1.1.4.5	Sun Sep  8 22:33:49 2002
+++ Zope/configure	Tue Sep 10 17:56:16 2002
@@ -4,59 +4,106 @@
 # $Id$
 # $Revision$
 
-# bootstrap ourselves by finding a Python interpreter
 HERE=`dirname $0`
-OLDIFS="$IFS"
-IFS=":"
-TARGET=2.1.3
-ACCEPTABLE="2.1.2 2.1.1 2.1.0 2.2 2.2.1"
-EXENAMES="python python2 python2.1 python2.2"
-FOUND=""
-VERSION=""
-echo
-echo "Configuring Zope installation"
-echo
-echo "Testing for an acceptable Python interpreter..."
+
+usage()
+{
+    echo
+    echo "configure [--help] [--with-python=path] [--prefix=path] "
+    echo "          [--ignore-largefile]"
+    echo
+    echo " Creates a Makefile suitable for building and installing Zope"
+    echo
+    echo " Options: "
+    echo "  --help              shows usage and quits"
+    echo "  --with-python       specify a Python interpreter to use"
+    echo "  --prefix            specify an installation path for binary data"
+    echo "  --ignore-largefile  ignore large file support warnings"
+    echo
+    echo " Given no options, configure will search your PATH for a suitable"
+    echo " Python interpreter and will use '/usr/local/zope' as a prefix."
+    echo
+}
+
+get_python()
+{
+    # bootstrap ourselves by finding a Python interpreter if necessary
+    OLDIFS="$IFS"
+    IFS=":"
+    TARGET="2.1.3"
+    ACCEPTABLE="2.1.2 2.1.1 2.1.0 2.2 2.2.1 2.3"
+    EXENAMES="python python2 python2.1 python2.2 python2.3"
+    FOUND=""
+    VERSION=""
+    echo "Testing for an acceptable Python interpreter..."
+    echo
+    for DIR in $PATH; do
+	IFS=$OLDIFS
+	for EXECUTABLE in $EXENAMES; do
+	    FULL=$DIR/$EXECUTABLE
+	    if [ -x $FULL ]; then
+		CMD="import string,sys;print string.split(sys.version)[0]"
+		VERSION=`$FULL -c "$CMD"`
+		echo "  Python version $VERSION found at $FULL"
+		if [ $VERSION = $TARGET ]; then
+		    FOUND=$FULL
+		    FOUNDVERSION=$VERSION
+		    break 2
+		else
+		    for ACC in $ACCEPTABLE; do
+			if [ $VERSION = $ACC ]; then
+			    FOUND=$FULL
+			    FOUNDVERSION=$VERSION
+			fi
+		    done
+		fi
+	    fi
+	done
+    done
+    if [ -z "$FOUND" ]; then
+	echo "  No suitable Python version found.  You must install Python"
+	echo "  version $TARGET before continuing.  Versions $ACCEPTABLE"
+	echo "  also work, but not as optimally."
+	exit 127
+    elif [ $VERSION = $TARGET ]; then
+	echo "  The optimimum Python version ($TARGET) was found at $FOUND."
+    else
+	echo "  !! WARNING !! "
+	echo "  An acceptable, but non-optimal Python version ($FOUNDVERSION) "
+	echo "  was found at '$FOUND' but consider installing version $TARGET"
+	echo "  before running 'make'."
+fi
 echo
-for dir in $PATH; do
-    IFS=$OLDIFS
-    for executable in $EXENAMES; do
-        full="$dir/$executable"
-        if [ -x $full ]; then
-            cmd="import string,sys;print string.split(sys.version)[0]"
-            VERSION=`$full -c "$cmd"`
-            echo "  Python version $VERSION found at $full"
-            if [ $VERSION = $TARGET ]; then
-                FOUND=$full
-                FOUNDVERSION=$VERSION
-		break 2
-            else
-                for acceptable in $ACCEPTABLE; do
-                    if [ $VERSION = $acceptable ]; then
-                        FOUND=$full
-                        FOUNDVERSION=$VERSION
-                    fi
-                done
-            fi
+}
+
+for OPT in $@; do
+    case "$OPT" in
+    --h* | -h*)
+        usage
+	exit 0
+	;;
+    --with-python=*)
+	# pop this argument from the arglist, it is not valid to
+	# pass this along to the Python configurator.
+	shift; 
+	FOUND=`echo $OPT | sed -e 's/--with-python\=//'`
+        if [ ! -x $FOUND ]; then
+           echo "$FOUND is not a valid Python interpreter."
+           exit 127
         fi
-    done
+        echo
+        echo "Using Python interpreter at $FOUND"
+    esac
 done
+        	
 echo
-PYTHON=$FOUND
+echo "Configuring Zope installation"
+echo
+
 if [ -z "$FOUND" ]; then
-    echo "  No suitable Python version found.  You must install Python"
-    echo "  version $TARGET before continuing.  Versions $ACCEPTABLE"
-    echo "  also work, but not as optimally."
-    exit 127
-elif [ $VERSION = $TARGET ]; then
-    echo "  The optimimum Python version ($TARGET) was found at $FOUND."
-else
-    echo "  !! WARNING !! "
-    echo "  An acceptable, but non-optimal version of Python ($FOUNDVERSION) "
-    echo "  was found at '$FOUND' but consider installing version $TARGET"
-    echo "  before running 'make'."
+    get_python
 fi
-echo
 
+PYTHON=$FOUND
 # run the Python configurator
-$FOUND $HERE/inst/configure.py $@
+$PYTHON $HERE/inst/configure.py $@