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.

86 lines
2.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_perl_module_version.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_PERL_MODULE_VERSION([MODULE VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks to see if the list of 'Module Version' are available in the
  12. # system. If all the modules in the list are available ACTION-IF-TRUE is
  13. # executed. Case one module is not available ACTION-IF-FALSE is executed
  14. # and the macro execution is aborted. NOTE: Perl is needed.
  15. #
  16. # Example:
  17. #
  18. # AX_PERL_MODULE_VERSION(CGI::Test 0.104 CGI::Ajax 0.694, ,
  19. # AC_MSG_ERROR(Need some Perl modules))
  20. #
  21. # LICENSE
  22. #
  23. # Copyright (c) 2009 Marco Gomes <mpglesi@gmail.com>
  24. # Copyright (c) 2009 Ruben Fonseca <fonseka@gmail.com>
  25. #
  26. # Copying and distribution of this file, with or without modification, are
  27. # permitted in any medium without royalty provided the copyright notice
  28. # and this notice are preserved. This file is offered as-is, without any
  29. # warranty.
  30. #serial 10
  31. AU_ALIAS([AC_PERL_MODULE_VERSION], [AX_PERL_MODULE_VERSION])
  32. AC_DEFUN([AX_PERL_MODULE_VERSION],[dnl
  33. ac_perl_list_modules="$1"
  34. # Make sure we have perl
  35. if test -z "$PERL"; then
  36. AC_CHECK_PROG(PERL,perl,perl)
  37. fi
  38. # Check the number of arguments
  39. args_num=`echo $ac_perl_list_modules | wc -w`
  40. check_args=$(( $args_num % 2 ))
  41. if test "$check_args" = "1" ; then
  42. AC_MSG_ERROR(syntax error)
  43. else
  44. eval
  45. fi
  46. if test "x$PERL" != x; then
  47. ac_failed=0
  48. while test ${#ac_perl_list_modules} -gt 2 ; do
  49. module_name=`echo $ac_perl_list_modules | cut -d " " -f 1`
  50. module_version=`echo $ac_perl_list_modules | cut -d " " -f 2`
  51. ac_perl_list_modules=`echo $ac_perl_list_modules | cut -d " " -f 3-`
  52. AC_MSG_CHECKING(for perl module $module_name version $module_version)
  53. $PERL "-M$module_name" -e exit > /dev/null 2>&1
  54. if test $? -ne 0; then
  55. AC_MSG_RESULT(no);
  56. ac_failed=1
  57. ac_perl_list_modules=""
  58. else
  59. version=`$PERL "-M$module_name" -e 'print $'"$module_name::VERSION" 2>&1`
  60. $PERL -e 'exit(shift cmp shift)' "$version" "$module_version"
  61. if test $? -eq 0 -o $? -eq 1 ; then
  62. AC_MSG_RESULT(ok);
  63. else
  64. AC_MSG_RESULT(no)
  65. ac_failed=1
  66. ac_perl_list_modules=""
  67. fi
  68. fi;
  69. done
  70. if test "$ac_failed" = 0; then
  71. :
  72. $2
  73. else
  74. :
  75. $3
  76. fi
  77. else
  78. AC_MSG_ERROR(could not find perl)
  79. fi])dnl