* [PATCH 1/3] configure: Add test for Perl
@ 2006-07-06 12:40 Dennis Stosberg
2006-07-06 13:03 ` Randal L. Schwartz
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Dennis Stosberg @ 2006-07-06 12:40 UTC (permalink / raw)
To: git
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.
It also adds a --perl=/path parameter to override the autodetection
of the perl binary.
Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
---
config-lib.sh | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/config-lib.sh b/config-lib.sh
index 68fecc5..69999a8 100755
--- a/config-lib.sh
+++ b/config-lib.sh
@@ -262,6 +262,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 +297,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 +412,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=`which perl`
+ test "$_perl" || die "cannot find path to perl"
+ fi
+ echores "$_perl"
+
+ echocheck "perl version"
+ _perl_version=`"$_perl" -e 'require 5.6.0;printf "%vd", $^V'`
+ if test -z "$_perl_version" ; then
+ die "your perl version is too old"
+ fi
+ echores "$_perl_version"
+}
write_config() {
echo "Creating config.mak.autogen"
@@ -420,6 +436,7 @@ write_config() {
# -------- Generated by configure -----------
CC = $_cc
+PERL_PATH = $_perl
INSTALL = $_install
EOF
--
1.4.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 12:40 [PATCH 1/3] configure: Add test for Perl Dennis Stosberg
@ 2006-07-06 13:03 ` Randal L. Schwartz
2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 15:40 ` Alex Riesen
2 siblings, 0 replies; 14+ messages in thread
From: Randal L. Schwartz @ 2006-07-06 13:03 UTC (permalink / raw)
To: Dennis Stosberg; +Cc: git
>>>>> "Dennis" == Dennis Stosberg <dennis@stosberg.net> writes:
Dennis> + _perl_version=`"$_perl" -e 'require 5.6.0;printf "%vd", $^V'`
perl -V:version gives you the version like:
version='5.8.6';
nice and eval-able. :) But you can just rely on the exit status from
perl -e 'eval { require 5.006; 1 } or exit 1'
which will be good (0) if the perl is new enough, and bad (1) if the perl is
too old. (Perl4 will really barf and give an error as well, but still
be an exit 1.)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 12:40 [PATCH 1/3] configure: Add test for Perl Dennis Stosberg
2006-07-06 13:03 ` Randal L. Schwartz
@ 2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 13:29 ` Dennis Stosberg
` (2 more replies)
2006-07-06 15:40 ` Alex Riesen
2 siblings, 3 replies; 14+ messages in thread
From: Timo Hirvonen @ 2006-07-06 13:10 UTC (permalink / raw)
To: Dennis Stosberg; +Cc: git
Dennis Stosberg <dennis@stosberg.net> wrote:
> + echocheck "for perl"
> + if test -z "$_perl" ; then
> + _perl=`which perl`
> + test "$_perl" || die "cannot find path to perl"
> + fi
> + echores "$_perl"
"which" isn't portable. On SunOS 5.9 "which foo" prints error message to
stdout and returns 0. I use this in my own configure scripts:
path_find()
{
if test -x "$1"
then
echo "$1"
return 0
fi
for i in `echo $PATH | sed 's/:/ /g'`
do
if test -x "$i/$1"
then
echo "$i/$1"
return 0
fi
done
return 1
}
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 13:10 ` Timo Hirvonen
@ 2006-07-06 13:29 ` Dennis Stosberg
2006-07-06 13:58 ` Matthias Lederhofer
2006-07-07 11:06 ` Petr Baudis
2 siblings, 0 replies; 14+ messages in thread
From: Dennis Stosberg @ 2006-07-06 13:29 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: git
Timo Hirvonen wrote:
> "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
> stdout and returns 0. I use this in my own configure scripts:
Yes, you're right and that function looks fine. I will resend the
patches later, but I'll wait a few hours for further comments.
Regards,
Dennis
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 13:29 ` Dennis Stosberg
@ 2006-07-06 13:58 ` Matthias Lederhofer
2006-07-06 14:17 ` Gerrit Pape
2006-07-06 14:27 ` Timo Hirvonen
2006-07-07 11:06 ` Petr Baudis
2 siblings, 2 replies; 14+ messages in thread
From: Matthias Lederhofer @ 2006-07-06 13:58 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: Dennis Stosberg, git
> "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
> stdout and returns 0. I use this in my own configure scripts:
>
> path_find()
> {
> if test -x "$1"
> then
> echo "$1"
> return 0
> fi
> for i in `echo $PATH | sed 's/:/ /g'`
> do
> if test -x "$i/$1"
> then
> echo "$i/$1"
> return 0
> fi
> done
> return 1
> }
This will not work with spaces in $PATH. I'd do something like this if
cut is portable (I have only freebsd and linux to test):
path_find()
{
path="$PATH"
while [ "$path" != "" ]; do
p="`echo $path | cut -d : -f 1`"
if [ "$p" = "$path" ]; then
path=""
else
path="`echo $path | cut -d : -f 2-`"
fi
if [ -x "$p/$1" ]; then
echo "$p/$1"
return 0
fi
done
return 1
}
Is there any reason to check the current directory first? "which"
doesn't do it for me and without ./ in the front it does not work
(without . is not in $PATH).
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 13:58 ` Matthias Lederhofer
@ 2006-07-06 14:17 ` Gerrit Pape
2006-07-06 14:25 ` Dennis Stosberg
2006-07-06 14:27 ` Timo Hirvonen
1 sibling, 1 reply; 14+ messages in thread
From: Gerrit Pape @ 2006-07-06 14:17 UTC (permalink / raw)
To: git; +Cc: Timo Hirvonen, Dennis Stosberg
On Thu, Jul 06, 2006 at 03:58:47PM +0200, Matthias Lederhofer wrote:
> This will not work with spaces in $PATH. I'd do something like this if
> cut is portable (I have only freebsd and linux to test):
This should work with shell/builtins only, no sed/cut:
path=${PATH}:
while test -n "$path"; do
p=${path%%:*}/$1
test ! -x "$p" || { echo "$p"; return 0; }
path=${path#*:}
done
test ! -x "$1" || { echo "$1" && return 0; }
return 1
Regards, Gerrit.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 14:17 ` Gerrit Pape
@ 2006-07-06 14:25 ` Dennis Stosberg
0 siblings, 0 replies; 14+ messages in thread
From: Dennis Stosberg @ 2006-07-06 14:25 UTC (permalink / raw)
To: git, Timo Hirvonen
Gerrit Pape wrote:
> This should work with shell/builtins only, no sed/cut:
>
> path=${PATH}:
> while test -n "$path"; do
> p=${path%%:*}/$1
> test ! -x "$p" || { echo "$p"; return 0; }
> path=${path#*:}
$ exec /bin/sh
$ uname -a
SunOS hostname 5.9 Generic_118558-25 sun4u sparc SUNW,Ultra-5_10 Solaris
$ echo ${PATH%%:*}
bad substitution
$ echo ${PATH#*:}
bad substitution
Regards,
Dennis
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 13:58 ` Matthias Lederhofer
2006-07-06 14:17 ` Gerrit Pape
@ 2006-07-06 14:27 ` Timo Hirvonen
2006-07-06 15:34 ` Dennis Stosberg
1 sibling, 1 reply; 14+ messages in thread
From: Timo Hirvonen @ 2006-07-06 14:27 UTC (permalink / raw)
To: Matthias Lederhofer; +Cc: dennis, git
Matthias Lederhofer <matled@gmx.net> wrote:
> This will not work with spaces in $PATH. I'd do something like this if
> cut is portable (I have only freebsd and linux to test):
This works at least with SunOS /bin/sh, dash, posh and bash.
path_find()
{
if test -x "$1"
then
echo "$1"
return 0
fi
_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
}
> Is there any reason to check the current directory first? "which"
> doesn't do it for me and without ./ in the front it does not work
> (without . is not in $PATH).
It is not needed but might be useful if PERL is user configurable
variable and can contain either full path or basename. For example this
code
test "$PROG" || PROG=prog
PROG=`path_find "$PROG"`
works with these cases
$ PROG=/usr/bin/program ./configure
$ PROG=program-1.2 ./configure
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 14:27 ` Timo Hirvonen
@ 2006-07-06 15:34 ` Dennis Stosberg
0 siblings, 0 replies; 14+ messages in thread
From: Dennis Stosberg @ 2006-07-06 15:34 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: Matthias Lederhofer, git
Timo Hirvonen wrote:
> if test -x "$1"
> then
> echo "$1"
> return 0
> fi
When run in the Git source directory, this will find the perl/
subdir. If the user gives an absolute path to the perl binary,
there will be no auto-detection anyway, so I think we don't need it.
> It is not needed but might be useful if PERL is user configurable
> variable and can contain either full path or basename. For example this
> code
>
> test "$PROG" || PROG=prog
> PROG=`path_find "$PROG"`
>
> works with these cases
>
> $ PROG=/usr/bin/program ./configure
> $ PROG=program-1.2 ./configure
I will add that. For the compiler, the script already checks $CC.
I wonder whether
--with-perl=...
--with-python=...
is more common (more similar to autoconf) than
--perl=
--python=
Regards,
Dennis
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 13:29 ` Dennis Stosberg
2006-07-06 13:58 ` Matthias Lederhofer
@ 2006-07-07 11:06 ` Petr Baudis
2006-07-07 11:20 ` Junio C Hamano
2006-07-07 11:23 ` Timo Hirvonen
2 siblings, 2 replies; 14+ messages in thread
From: Petr Baudis @ 2006-07-07 11:06 UTC (permalink / raw)
To: Timo Hirvonen; +Cc: Dennis Stosberg, git
Dear diary, on Thu, Jul 06, 2006 at 03:10:11PM CEST, I got a letter
where Timo Hirvonen <tihirvon@gmail.com> said that...
> Dennis Stosberg <dennis@stosberg.net> wrote:
>
> > + echocheck "for perl"
> > + if test -z "$_perl" ; then
> > + _perl=`which perl`
> > + test "$_perl" || die "cannot find path to perl"
> > + fi
> > + echores "$_perl"
>
> "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
> stdout and returns 0.
Wait, Git runs on SunOS 5.9?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-07 11:06 ` Petr Baudis
@ 2006-07-07 11:20 ` Junio C Hamano
2006-07-07 11:23 ` Timo Hirvonen
1 sibling, 0 replies; 14+ messages in thread
From: Junio C Hamano @ 2006-07-07 11:20 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Petr Baudis <pasky@suse.cz> writes:
>> "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
>> stdout and returns 0.
>
> Wait, Git runs on SunOS 5.9?
I thought so. In any case, the traditionalist way is to split $PATH
by hand with "IFS=:" -- somebody already posted that on this
thread.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-07 11:06 ` Petr Baudis
2006-07-07 11:20 ` Junio C Hamano
@ 2006-07-07 11:23 ` Timo Hirvonen
1 sibling, 0 replies; 14+ messages in thread
From: Timo Hirvonen @ 2006-07-07 11:23 UTC (permalink / raw)
To: Petr Baudis; +Cc: dennis, git
Petr Baudis <pasky@suse.cz> wrote:
> Dear diary, on Thu, Jul 06, 2006 at 03:10:11PM CEST, I got a letter
> where Timo Hirvonen <tihirvon@gmail.com> said that...
> > "which" isn't portable. On SunOS 5.9 "which foo" prints error message to
> > stdout and returns 0.
>
> Wait, Git runs on SunOS 5.9?
I have no idea. I noticed the problem with "which" when I ported my
cmus configure scripts to SunOS.
In the git Makefile there are:
ifeq ($(uname_S),SunOS)
...
ifeq ($(uname_R),5.8)
...
ifeq ($(uname_R),5.9)
so it at least tries to work ;) Oh and that 5.9 is apparently kernel
version, not OS version. Sorry for the confusion.
--
http://onion.dynserv.net/~timo/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/3] configure: Add test for Perl
2006-07-06 12:40 [PATCH 1/3] configure: Add test for Perl Dennis Stosberg
2006-07-06 13:03 ` Randal L. Schwartz
2006-07-06 13:10 ` Timo Hirvonen
@ 2006-07-06 15:40 ` Alex Riesen
2006-07-06 15:44 ` Dennis Stosberg
2 siblings, 1 reply; 14+ messages in thread
From: Alex Riesen @ 2006-07-06 15:40 UTC (permalink / raw)
To: Dennis Stosberg; +Cc: git
On 7/6/06, Dennis Stosberg <dennis@stosberg.net> wrote:
> Miscellaneous options:
> --cc=COMPILER use this C compiler to build MPlayer [gcc]
Is it still MPlayer's?
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-07-07 11:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-06 12:40 [PATCH 1/3] configure: Add test for Perl Dennis Stosberg
2006-07-06 13:03 ` Randal L. Schwartz
2006-07-06 13:10 ` Timo Hirvonen
2006-07-06 13:29 ` Dennis Stosberg
2006-07-06 13:58 ` Matthias Lederhofer
2006-07-06 14:17 ` Gerrit Pape
2006-07-06 14:25 ` Dennis Stosberg
2006-07-06 14:27 ` Timo Hirvonen
2006-07-06 15:34 ` Dennis Stosberg
2006-07-07 11:06 ` Petr Baudis
2006-07-07 11:20 ` Junio C Hamano
2006-07-07 11:23 ` Timo Hirvonen
2006-07-06 15:40 ` Alex Riesen
2006-07-06 15:44 ` Dennis Stosberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).