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: Fri, 25 Jul 2003 01:09:36 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313



Dustin Mitchell wrote:
I noticed a significant lack of Python support in the ac macro archive.
So here's the first of two macros I use.  Let me know what you think.

--snip--
dnl @synopsis AX_PROG_PYTHON
dnl
dnl Locates an installed Python binary.  Accepts --with-python, and failing
dnl that searches for python in the path.  If python is found, $PYTHON is
dnl set to the full path of the binary; otherwise, nothing is changed.
dnl
dnl Example:
dnl
dnl   AX_PROG_PYTHON
dnl   if test -z "$PYTHON"
dnl   then
dnl     AC_MSG_ERROR("Python executable not found")
dnl   fi
dnl
dnl @author Dustin Mitchell <address@hidden>
AC_DEFUN([AX_PROG_PYTHON],
[
 AC_MSG_CHECKING(for --with-python)
 AC_ARG_WITH(python,
             AC_HELP_STRING([--with-python=PYTHON],
                            [absolute path name of Python executable]),
  [
    if test -f $withval -a -x $withval;
    then
       AC_MSG_RESULT($withval)
       PYTHON="$withval"
       AC_SUBST(PYTHON)
    else
       AC_MSG_RESULT($withval is not executable)
    fi
  ], [
    AC_MSG_RESULT(no)
  ])

  # if it's not found, check the paths.
if test -z "$PYTHON" then
    AC_PATH_PROGS(PYTHON, [python2.2 python])
    AC_SUBST(PYTHON)
  fi
])

Well, most users of scripting languages tend to use configure scripts
written in their preferred scripting idiom - the perl installation
even has a few library routines to help with the tasks, ye know, and
most other projects have been fine with simply using AC_PATH_PROG.

Coming back to your macro, you might want to add a bit more meat
to the body, ... which in turn would justify its preferred usage
over the simplistic AC_PATH_PROG macro.

- add some ACTION-IF-NOT-FOUND part, currently you just put out
  informative messages but AC_PATH_PROG itself has that action-arg.
- may be call it AX_WITH_PYTHON to reflect the --with addition
- consider an extra (optional) argument representing a minimal
  version number, and check the python interpreters versioncode
  with it - ac_path_prog can't do such on its own. Perhaps choose
  2.2 as the default ;-)
- allow a user to set a "precious variable" PYTHON _before_ the
  configure script will hit this macro, not just a --with-argument
  but a shell-variable that is. That makes it easier to set up a
  home profile environment variable pointing to the preferred
  PYTHON interpreter.
- remember to fully quote everything, including "$withval" as it
  might be left empty and result in syntax errors. Also consider
  to get rid of `test -a` as there are some portability problems
  attached.

HTH, cheers,
-- guido                                  http://google.de/search?q=guidod
GCS/E/S/P C++/++++$ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X- (geekcode)





reply via email to

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