Git development
 help / color / mirror / Atom feed
From: Dennis Stosberg <dennis@stosberg.net>
To: git@vger.kernel.org
Subject: [PATCH 1/4] configure: Add test for Perl
Date: Fri, 07 Jul 2006 18:26:38 +0200	[thread overview]
Message-ID: <20060707162637.25746.84757.stgit@leonov.stosberg.net> (raw)
In-Reply-To: <20060707162513.25746.57374.stgit@leonov.stosberg.net>

From: Dennis Stosberg <dennis@stosberg.net>

This patch adds two tests to the configuration script. The first
one tries to find a perl binary in the path.  The second one checks
whether the found perl is of a sufficient version.

The user can override the auto-detection with the --perl parameter
or with the PERL environment variable.

The path_find() function was written by Timo Hirvonen as a replacement
for "which", which cannot be used portably.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---

 config-lib.sh |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/config-lib.sh b/config-lib.sh
index 68fecc5..34dfc05 100755
--- a/config-lib.sh
+++ b/config-lib.sh
@@ -117,6 +117,22 @@ alpha() {
 	esac
 }
 
+# replacement for "which", which cannot be used portably
+path_find()
+{
+        _ifs="$IFS"
+        IFS=:
+        for i in $PATH; do
+                if test -x "$i/$1"; then
+                        IFS="$_ifs"
+                        echo "$i/$1"
+                        return 0
+                fi
+        done
+        IFS="$_ifs"
+        return 1
+}
+
 # not boolean test: implement the posix shell "!" operator for a
 # non-posix /bin/sh.
 #   usage:  not {command}
@@ -240,6 +256,9 @@ process_params() {
 	_cc=cc
 	test "$CC" && _cc="$CC"
 
+	_perl=
+	test "$PERL" && _perl="$PERL"
+
 	for ac_option do
 		case "$ac_option" in
 		--help|-help|-h)
@@ -262,6 +281,7 @@ Installation directories:
 
 Miscellaneous options:
   --cc=COMPILER          use this C compiler to build MPlayer [gcc]
+  --perl=PATH            path to perl binary [autodetect]
   --target=PLATFORM      target platform (i386-linux, arm-linux, etc)
   --with-install=PATH    use a custom install program (useful if your OS uses
                          a GNU-incompatible install utility by default and
@@ -296,6 +316,8 @@ EOF
 
 		--cc=*)
 			_cc=`echo $ac_option | cut -d '=' -f 2` ;;
+		--perl=*)
+			_perl=`echo $ac_option | cut -d '=' -f 2` ;;
 		--target=*)
 			_target=`echo $ac_option | cut -d '=' -f 2` ;;
 		--with-install=*)
@@ -409,8 +431,21 @@ int main(void) { return 0; }
 EOF
 	{ cc_check && tmp_run; } || die "unusable compiler or produced binary"
 	echores yes
-}
 
+	echocheck "for perl"
+	if test -z "$_perl" ; then
+		_perl=`path_find perl`
+		test "$_perl" || die "cannot find path to perl"
+	fi
+	echores "$_perl"
+
+	echocheck "perl version"
+	_perl_version=`"$_perl" -e 'eval{require 5.6.0; printf "%vd", $^V}'`
+	if test -z "$_perl_version" ; then
+		die "your perl is too old. Perl 5.6.0 or newer is required."
+	fi
+	echores "$_perl_version"
+}
 
 write_config() {
 	echo "Creating config.mak.autogen"
@@ -420,6 +455,7 @@ write_config() {
 # -------- Generated by configure -----------
 
 CC = $_cc
+PERL_PATH = $_perl
 INSTALL = $_install
 
 EOF

  reply	other threads:[~2006-07-07 16:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-07 16:25 [PATCH 0/4] More tests for hand-written configure (resend) Dennis Stosberg
2006-07-07 16:26 ` Dennis Stosberg [this message]
2006-07-07 16:26 ` [PATCH 2/4] configure: Add test for Python Dennis Stosberg
2006-07-07 16:26 ` [PATCH 3/4] configure: Try to figure out compiler options Dennis Stosberg
2006-07-07 16:26 ` [PATCH 4/4] configure: Fixes for Solaris Dennis Stosberg
2006-07-07 19:40 ` [PATCH 0/4] More tests for hand-written configure (resend) Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060707162637.25746.84757.stgit@leonov.stosberg.net \
    --to=dennis@stosberg.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox