Tim Edwards | 44e7efa | 2021-08-20 13:20:55 -0400 | [diff] [blame] | 1 | # =========================================================================== |
| 2 | # https://www.gnu.org/software/autoconf-archive/ax_python_module.html |
| 3 | # =========================================================================== |
| 4 | # |
| 5 | # SYNOPSIS |
| 6 | # |
| 7 | # AX_PYTHON_MODULE(modname[, fatal, python]) |
| 8 | # |
| 9 | # DESCRIPTION |
| 10 | # |
| 11 | # Checks for Python module. |
| 12 | # |
| 13 | # If fatal is non-empty then absence of a module will trigger an error. |
| 14 | # The third parameter can either be "python" for Python 2 or "python3" for |
| 15 | # Python 3; defaults to Python 3. |
| 16 | # |
| 17 | # LICENSE |
| 18 | # |
| 19 | # Copyright (c) 2008 Andrew Collier |
| 20 | # |
| 21 | # Copying and distribution of this file, with or without modification, are |
| 22 | # permitted in any medium without royalty provided the copyright notice |
| 23 | # and this notice are preserved. This file is offered as-is, without any |
| 24 | # warranty. |
| 25 | |
| 26 | #serial 9 |
| 27 | |
| 28 | AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE]) |
| 29 | AC_DEFUN([AX_PYTHON_MODULE],[ |
| 30 | if test -z $PYTHON; |
| 31 | then |
| 32 | if test -z "$3"; |
| 33 | then |
| 34 | PYTHON="python3" |
| 35 | else |
| 36 | PYTHON="$3" |
| 37 | fi |
| 38 | fi |
| 39 | PYTHON_NAME=`basename $PYTHON` |
| 40 | AC_MSG_CHECKING($PYTHON_NAME module: $1) |
| 41 | $PYTHON -c "import $1" 2>/dev/null |
| 42 | if test $? -eq 0; |
| 43 | then |
| 44 | AC_MSG_RESULT(yes) |
| 45 | eval AS_TR_CPP(HAVE_PYMOD_$1)=yes |
| 46 | else |
| 47 | AC_MSG_RESULT(no) |
| 48 | eval AS_TR_CPP(HAVE_PYMOD_$1)=no |
| 49 | # |
| 50 | if test -n "$2" |
| 51 | then |
| 52 | AC_MSG_ERROR(failed to find required module $1) |
| 53 | exit 1 |
| 54 | fi |
| 55 | fi |
| 56 | ]) |