| [715085] | 1 | # ===========================================================================
 | 
|---|
 | 2 | #         http://www.gnu.org/software/autoconf-archive/ax_python.html
 | 
|---|
 | 3 | # ===========================================================================
 | 
|---|
 | 4 | #
 | 
|---|
 | 5 | # SYNOPSIS
 | 
|---|
 | 6 | #
 | 
|---|
 | 7 | #   AX_PYTHON
 | 
|---|
 | 8 | #
 | 
|---|
 | 9 | # DESCRIPTION
 | 
|---|
 | 10 | #
 | 
|---|
 | 11 | #   This macro does a complete Python development environment check.
 | 
|---|
 | 12 | #
 | 
|---|
| [e06010] | 13 | #   It recurses through several python versions (from 2.1 to 2.7 in this
 | 
|---|
| [715085] | 14 | #   version), looking for an executable. When it finds an executable, it
 | 
|---|
 | 15 | #   looks to find the header files and library.
 | 
|---|
 | 16 | #
 | 
|---|
 | 17 | #   It sets PYTHON_BIN to the name of the python executable,
 | 
|---|
 | 18 | #   PYTHON_INCLUDE_DIR to the directory holding the header files, and
 | 
|---|
 | 19 | #   PYTHON_LIB to the name of the Python library.
 | 
|---|
 | 20 | #
 | 
|---|
 | 21 | #   This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG),
 | 
|---|
 | 22 | #   PYTHON_INCLUDE_DIR and PYTHON_LIB.
 | 
|---|
 | 23 | #
 | 
|---|
 | 24 | # LICENSE
 | 
|---|
 | 25 | #
 | 
|---|
 | 26 | #   Copyright (c) 2008 Michael Tindal
 | 
|---|
 | 27 | #
 | 
|---|
 | 28 | #   This program is free software; you can redistribute it and/or modify it
 | 
|---|
 | 29 | #   under the terms of the GNU General Public License as published by the
 | 
|---|
 | 30 | #   Free Software Foundation; either version 2 of the License, or (at your
 | 
|---|
 | 31 | #   option) any later version.
 | 
|---|
 | 32 | #
 | 
|---|
 | 33 | #   This program is distributed in the hope that it will be useful, but
 | 
|---|
 | 34 | #   WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 35 | #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 | 
|---|
 | 36 | #   Public License for more details.
 | 
|---|
 | 37 | #
 | 
|---|
 | 38 | #   You should have received a copy of the GNU General Public License along
 | 
|---|
 | 39 | #   with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
 | 40 | #
 | 
|---|
 | 41 | #   As a special exception, the respective Autoconf Macro's copyright owner
 | 
|---|
 | 42 | #   gives unlimited permission to copy, distribute and modify the configure
 | 
|---|
 | 43 | #   scripts that are the output of Autoconf when processing the Macro. You
 | 
|---|
 | 44 | #   need not follow the terms of the GNU General Public License when using
 | 
|---|
 | 45 | #   or distributing such scripts, even though portions of the text of the
 | 
|---|
 | 46 | #   Macro appear in them. The GNU General Public License (GPL) does govern
 | 
|---|
 | 47 | #   all other use of the material that constitutes the Autoconf Macro.
 | 
|---|
 | 48 | #
 | 
|---|
 | 49 | #   This special exception to the GPL applies to versions of the Autoconf
 | 
|---|
 | 50 | #   Macro released by the Autoconf Archive. When you make and distribute a
 | 
|---|
 | 51 | #   modified version of the Autoconf Macro, you may extend this special
 | 
|---|
 | 52 | #   exception to the GPL to apply to your modified version as well.
 | 
|---|
 | 53 | #
 | 
|---|
 | 54 | #  Modifications:
 | 
|---|
 | 55 | #       2011-09-20: (Frederik Heber)
 | 
|---|
 | 56 | #               added tailing to last of locate to prevent multiple hits
 | 
|---|
 | 57 | #
 | 
|---|
| [e06010] | 58 | # 2011-11-11 (Frederik Heber)
 | 
|---|
 | 59 | #   added support for python2.7
 | 
|---|
 | 60 | #
 | 
|---|
| [715085] | 61 | 
 | 
|---|
| [e06010] | 62 | #serial 10
 | 
|---|
| [715085] | 63 | 
 | 
|---|
 | 64 | AC_DEFUN([AX_PYTHON],
 | 
|---|
 | 65 | [AC_MSG_CHECKING(for python build information)
 | 
|---|
 | 66 | AC_MSG_RESULT([])
 | 
|---|
| [e06010] | 67 | for python in python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
 | 
|---|
| [715085] | 68 | AC_CHECK_PROGS(PYTHON_BIN, [$python])
 | 
|---|
 | 69 | ax_python_bin=$PYTHON_BIN
 | 
|---|
 | 70 | if test x$ax_python_bin != x; then
 | 
|---|
 | 71 |    AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no)
 | 
|---|
 | 72 |    AC_CHECK_HEADER([$ax_python_bin/Python.h],
 | 
|---|
 | 73 |    [[ax_python_header=`locate $ax_python_bin/Python.h | sed -e s,/Python.h,, | tail -n 1`]],
 | 
|---|
 | 74 |    ax_python_header=no)
 | 
|---|
 | 75 |    if test $ax_python_lib != no; then
 | 
|---|
 | 76 |      if test $ax_python_header != no; then
 | 
|---|
 | 77 |        break;
 | 
|---|
 | 78 |      fi
 | 
|---|
 | 79 |    fi
 | 
|---|
 | 80 | fi
 | 
|---|
 | 81 | done
 | 
|---|
 | 82 | if test x$ax_python_bin = x; then
 | 
|---|
 | 83 |    ax_python_bin=no
 | 
|---|
 | 84 | fi
 | 
|---|
 | 85 | if test x$ax_python_header = x; then
 | 
|---|
 | 86 |    ax_python_header=no
 | 
|---|
 | 87 | fi
 | 
|---|
 | 88 | if test x$ax_python_lib = x; then
 | 
|---|
 | 89 |    ax_python_lib=no
 | 
|---|
 | 90 | fi
 | 
|---|
 | 91 | 
 | 
|---|
 | 92 | AC_MSG_RESULT([  results of the Python check:])
 | 
|---|
 | 93 | AC_MSG_RESULT([    Binary:      $ax_python_bin])
 | 
|---|
 | 94 | AC_MSG_RESULT([    Library:     $ax_python_lib])
 | 
|---|
 | 95 | AC_MSG_RESULT([    Include Dir: $ax_python_header])
 | 
|---|
 | 96 | 
 | 
|---|
 | 97 | if test x$ax_python_header != xno; then
 | 
|---|
 | 98 |   PYTHON_INCLUDE_DIR=$ax_python_header
 | 
|---|
 | 99 |   AC_SUBST(PYTHON_INCLUDE_DIR)
 | 
|---|
 | 100 | fi
 | 
|---|
 | 101 | if test x$ax_python_lib != xno; then
 | 
|---|
 | 102 |   PYTHON_LIB=$ax_python_lib
 | 
|---|
 | 103 |   AC_SUBST(PYTHON_LIB)
 | 
|---|
 | 104 | fi
 | 
|---|
 | 105 | ])dnl
 | 
|---|