ac-archive-maintainers
[Top][All Lists]
Advanced

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

Re: ax_prog_python.m4


From: Guido Draheim
Subject: Re: ax_prog_python.m4
Date: Sat, 26 Jul 2003 10:16:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313



Dustin Mitchell wrote:
I had thought of that, but in fact AC_PATH_PROG doesn't have an
ACTION-IF-NOT-FOUND:

  AC_PATH_PROG (variable, prog-to-check-for, [value-if-not-found], [path])

Indeed! That slipped from my mind it seems ;-)


It seems it would be better to follow the AC_PATH_PROG model, and
provide a [value-if-not-found] parameter, which I have done.

Definitly!


As for the rest of your (very helpful!) comments: duly noted and new
version supplied below.

Thanks. It's real good macro. I am sure people will pick it up :-))

The only comments left are mostly cosmetical, I am modifying them
here while writing it:
- the description block at the start has a max of 82 chars per line.
- the description block should have a @version tag with a cvs entry
- changing a few PYTHON -> [PYTHON], while it might be handy to
  override PYTHON on the m4 level, it's makes debugging a desparate
  task for macro calls at least, as the error will spring up a
  dozen expansions later.
- using 'dnl' allows to put a break in the macro text which will
  not be a line break in the expanded configure script - that is
  an interesting trick for long AC_MSG_ arguments, or arguments
  to `...` as shown here.
- convert code comments from '# comment' into 'dnl comment'
  most of these are not needed in the expanded configure shell script,
  they just make up for longer configure shell scripts. it's simply
  that dnl-comments are skipped while parsing the m4 text, ye know

As for coding style,
- at the moment, there is no user notice message when the PYTHON
  precious variable was found. It seems to me that the version-check
  should be done even with a user-variable. I am deleting the 'else'
  around the last block. Interesting: the `..` block uses "python"
  instead of the auto-detected $PYTHON (oops) changing that as well.
- which brings me to the conclusion to set PYTHON="python" as the
  general fallback support, and folding fallback support into the
  next-earlier AC_PATH_PROG expansion
- and finally, provide a $3 matching that of AC_PATH_PROG which
  is handed down in that very macro just there.
- and final change, modifiying the sh-if for $1 into an m4-if,
  so there will be no extra lines in the configure script when
  the version arg has been left empty

The modified macro is attached. Perhaps consider to simplify the
code flow with the added knowledge that AC_ARG_WITH does not
only set $withval in its argument context parts but it does also
set a global variable named $with_python for each _WITH(python,...
Personally, I did the argument based stuff always wrong and it
did help me to move the blocks out into normal shell if's, i.e.
AC_ARG_WITH(me,--me option,,with_me="no")
if "$with_me" != "no" ; then ME="$with_me"; ... fi

have fun, guido










dnl @synopsis AX_WITH_PYTHON([minimum-version], [value-if-not-found], [path])
dnl 
dnl Locates an installed Python binary, placing the result in the precious
dnl variable $PYTHON.  Accepts a present $PYTHON, then --with-python, and 
dnl failing
dnl
dnl that searches for python in the given path (which defaults to the system
dnl path).  If python is found, $PYTHON is set to the full path of the binary 
dnl and ACTION-IF-FOUND is executed; otherwise ACTION-IF-NOT-FOUND is executed.
dnl 
dnl Example:
dnl
dnl   AX_WITH_PYTHON(2.2, missing)
dnl
dnl @author Dustin Mitchell <address@hidden>
dnl @version $Id: $

AC_DEFUN([AX_WITH_PYTHON],
[
  AC_ARG_VAR([PYTHON])
 
  dnl unless PYTHON was supplied to us (as a precious variable)
  if test -z "$PYTHON"
  then
    AC_MSG_CHECKING(for --with-python)
    AC_ARG_WITH(python,
                AC_HELP_STRING([--with-python=PYTHON],
                               [absolute path name of Python executable]),
                [ if test "$withval" != "yes"
                  then
                    PYTHON="$withval"
                    AC_MSG_RESULT($withval)
                  else
                    AC_MSG_RESULT(no)
                  fi
                ],
                [ AC_MSG_RESULT(no)
                ])
  fi

  dnl if it's still not found, check the paths, or use the fallback
  if test -z "$PYTHON" 
  then
    AC_PATH_PROG([PYTHON], python,m4_ifval([$2],[$2],[python]),$3)
  fi

  dnl check version if required
  m4_ifvaln([$1],[
    AC_MSG_CHECKING($PYTHON version >= $1)
    if test `$PYTHON -c ["import sys; dnl
print sys.version[:3] >= \"$1\" and \"OK\" or \"OLD\""]` = "OK"
    then
      AC_MSG_RESULT(ok)
    else
      AC_MSG_RESULT(no)
      PYTHON="$2"
    fi]
])

reply via email to

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