Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5KB

  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. #serial 9
  26. AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
  27. AC_DEFUN([AX_PYTHON_MODULE],[
  28. if test -z $PYTHON;
  29. then
  30. if test -z "$3";
  31. then
  32. PYTHON="python3"
  33. else
  34. PYTHON="$3"
  35. fi
  36. fi
  37. PYTHON_NAME=`basename $PYTHON`
  38. AC_MSG_CHECKING($PYTHON_NAME module: $1)
  39. $PYTHON -c "import $1" 2>/dev/null
  40. if test $? -eq 0;
  41. then
  42. AC_MSG_RESULT(yes)
  43. eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
  44. else
  45. AC_MSG_RESULT(no)
  46. eval AS_TR_CPP(HAVE_PYMOD_$1)=no
  47. #
  48. if test -n "$2"
  49. then
  50. AC_MSG_ERROR(failed to find required module $1)
  51. exit 1
  52. fi
  53. fi
  54. ])