autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is this perl checking code not working for me?


From: Russ Allbery
Subject: Re: Why is this perl checking code not working for me?
Date: Fri, 07 Aug 2009 16:01:07 -0700
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

"Dr. David Kirkby" <address@hidden> writes:

> I'm trying to check if the version of perl is at least x.y.z
>
> I found a macro with this syntax.
>
> AX_PROG_PERL_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
>
> http://www.nongnu.org/autoconf-archive/ax_prog_perl_version.html
>
> The documentation says one needs to run AC_CHECK_PROG or AC_PATH_PROG
> first, so $PERL is set to the path to perl. But it keeps failing on me:
>
> AC_PATH_PROG([PERL],[perl])
> AX_PROG_PERL_VERSION([5.8.0],[],[])

That macro is using a questionable technique to accomplish this (parsing
the output of perl -v and then relying on AX_COMPARE_VERSION).  Here's a
much simpler macro that accomplishes the same thing:

AC_DEFUN([AX_PROG_PERL_VERSION],
[AC_CACHE_CHECK([for Perl version $1 or later], [ax_cv_prog_perl_version],
    [AS_IF(["$PERL" -e 'require $1;' >/dev/null 2>&1], [$1], [$2])])])

This uses Perl's built-in require command, which supports 5.8.0-style
version numbers and always does the right ordering check.  (Although you
may want to use 5.008 for backward compatibility with pre-5.6 versions of
Perl.)

There's some room for improvement in that check since the cache variable
used doesn't vary based on the version number of Perl desired, so it won't
work properly if invoked more than once with different versions.  This is
based on a macro that I'm currently using, but I rewrote it a bit to use a
more modern idiom and haven't tested the version above, so it's possible
there are stupid typos.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]