1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ac_perl_module_version.html
3 # ===========================================================================
7 # AC_PERL_MODULE_VERSION([MODULE VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
11 # Checks to see if the list of 'Module Version' are avaiable in the
12 # system. If all the modules in the list are avaiable ACTION-IF-TRUE is
13 # executed. Case one module is not avaiable ACTION-IF-FALSE is executed
14 # and the macro execution is aborted. NOTE: Perl is needed.
18 # AC_PERL_MODULE_VERSION(CGI::Test 0.104 CGI::Ajax 0.694, ,
19 # AC_MSG_ERROR(Need some Perl modules))
27 # Copyright (c) 2008 Marco Gomes <mpglesi@gmail.com>
28 # Copyright (c) 2008 Ruben Fonseca <fonseka@gmail.com>
30 # Copying and distribution of this file, with or without modification, are
31 # permitted in any medium without royalty provided the copyright notice
32 # and this notice are preserved.
34 AC_DEFUN([AC_PERL_MODULE_VERSION],[dnl
35 ac_perl_list_modules="$1"
36 # Make sure we have perl
37 if test -z "$PERL"; then
38 AC_CHECK_PROG(PERL,perl,perl)
41 # Check the number of arguments
42 args_num=`echo $ac_perl_list_modules | wc -w`
43 let "ckeck_args = $args_num % 2"
44 if test "$check_args" = "1" ; then
45 AC_MSG_ERROR(syntax error)
50 if test "x$PERL" != x; then
52 while test ${#ac_perl_list_modules} -gt 2 ; do
53 module_name=`echo $ac_perl_list_modules | cut -d " " -f 1`
54 module_version=`echo $ac_perl_list_modules | cut -d " " -f 2`
55 ac_perl_list_modules=`echo $ac_perl_list_modules | cut -d " " -f 3-`
56 AC_MSG_CHECKING(for perl module $module_name version $module_version)
58 $PERL "-M$module_name" -e exit > /dev/null 2>&1
59 if test $? -ne 0; then
62 ac_perl_list_modules=""
64 version=`$PERL "-M$module_name" -e 'print $'"$module_name::VERSION" 2>&1`
65 $PERL -e 'exit(shift cmp shift)' "$version" "$module_version"
66 if test $? -eq 0 -o $? -eq 1 ; then
71 ac_perl_list_modules=""
76 if test "$ac_failed" = 0; then
84 AC_MSG_ERROR(could not find perl)