1f08c3bdfSopenharmony_ci# ===========================================================================
2f08c3bdfSopenharmony_ci#   https://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html
3f08c3bdfSopenharmony_ci# ===========================================================================
4f08c3bdfSopenharmony_ci#
5f08c3bdfSopenharmony_ci# SYNOPSIS
6f08c3bdfSopenharmony_ci#
7f08c3bdfSopenharmony_ci#   AX_PROG_PERL_MODULES([MODULES], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
8f08c3bdfSopenharmony_ci#
9f08c3bdfSopenharmony_ci# DESCRIPTION
10f08c3bdfSopenharmony_ci#
11f08c3bdfSopenharmony_ci#   Checks to see if the given perl modules are available. If true the shell
12f08c3bdfSopenharmony_ci#   commands in ACTION-IF-TRUE are executed. If not the shell commands in
13f08c3bdfSopenharmony_ci#   ACTION-IF-FALSE are run. Note if $PERL is not set (for example by
14f08c3bdfSopenharmony_ci#   calling AC_CHECK_PROG, or AC_PATH_PROG), AC_CHECK_PROG(PERL, perl, perl)
15f08c3bdfSopenharmony_ci#   will be run.
16f08c3bdfSopenharmony_ci#
17f08c3bdfSopenharmony_ci#   MODULES is a space separated list of module names. To check for a
18f08c3bdfSopenharmony_ci#   minimum version of a module, append the version number to the module
19f08c3bdfSopenharmony_ci#   name, separated by an equals sign.
20f08c3bdfSopenharmony_ci#
21f08c3bdfSopenharmony_ci#   Example:
22f08c3bdfSopenharmony_ci#
23f08c3bdfSopenharmony_ci#     AX_PROG_PERL_MODULES( Text::Wrap Net::LDAP=1.0.3, ,
24f08c3bdfSopenharmony_ci#                           AC_MSG_WARN(Need some Perl modules)
25f08c3bdfSopenharmony_ci#
26f08c3bdfSopenharmony_ci# LICENSE
27f08c3bdfSopenharmony_ci#
28f08c3bdfSopenharmony_ci#   Copyright (c) 2009 Dean Povey <povey@wedgetail.com>
29f08c3bdfSopenharmony_ci#
30f08c3bdfSopenharmony_ci#   Copying and distribution of this file, with or without modification, are
31f08c3bdfSopenharmony_ci#   permitted in any medium without royalty provided the copyright notice
32f08c3bdfSopenharmony_ci#   and this notice are preserved. This file is offered as-is, without any
33f08c3bdfSopenharmony_ci#   warranty.
34f08c3bdfSopenharmony_ci
35f08c3bdfSopenharmony_ci#serial 8
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ciAU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES])
38f08c3bdfSopenharmony_ciAC_DEFUN([AX_PROG_PERL_MODULES],[dnl
39f08c3bdfSopenharmony_ci
40f08c3bdfSopenharmony_cim4_define([ax_perl_modules])
41f08c3bdfSopenharmony_cim4_foreach([ax_perl_module], m4_split(m4_normalize([$1])),
42f08c3bdfSopenharmony_ci	  [
43f08c3bdfSopenharmony_ci	   m4_append([ax_perl_modules],
44f08c3bdfSopenharmony_ci		     [']m4_bpatsubst(ax_perl_module,=,[ ])[' ])
45f08c3bdfSopenharmony_ci          ])
46f08c3bdfSopenharmony_ci
47f08c3bdfSopenharmony_ci# Make sure we have perl
48f08c3bdfSopenharmony_ciif test -z "$PERL"; then
49f08c3bdfSopenharmony_ciAC_CHECK_PROG(PERL,perl,perl)
50f08c3bdfSopenharmony_cifi
51f08c3bdfSopenharmony_ci
52f08c3bdfSopenharmony_ciif test "x$PERL" != x; then
53f08c3bdfSopenharmony_ci  ax_perl_modules_failed=0
54f08c3bdfSopenharmony_ci  for ax_perl_module in ax_perl_modules; do
55f08c3bdfSopenharmony_ci    AC_MSG_CHECKING(for perl module $ax_perl_module)
56f08c3bdfSopenharmony_ci
57f08c3bdfSopenharmony_ci    # Would be nice to log result here, but can't rely on autoconf internals
58f08c3bdfSopenharmony_ci    $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1
59f08c3bdfSopenharmony_ci    if test $? -ne 0; then
60f08c3bdfSopenharmony_ci      AC_MSG_RESULT(no);
61f08c3bdfSopenharmony_ci      ax_perl_modules_failed=1
62f08c3bdfSopenharmony_ci   else
63f08c3bdfSopenharmony_ci      AC_MSG_RESULT(ok);
64f08c3bdfSopenharmony_ci    fi
65f08c3bdfSopenharmony_ci  done
66f08c3bdfSopenharmony_ci
67f08c3bdfSopenharmony_ci  # Run optional shell commands
68f08c3bdfSopenharmony_ci  if test "$ax_perl_modules_failed" = 0; then
69f08c3bdfSopenharmony_ci    :
70f08c3bdfSopenharmony_ci    $2
71f08c3bdfSopenharmony_ci  else
72f08c3bdfSopenharmony_ci    :
73f08c3bdfSopenharmony_ci    $3
74f08c3bdfSopenharmony_ci  fi
75f08c3bdfSopenharmony_cielse
76f08c3bdfSopenharmony_ci  AC_MSG_WARN(could not find perl)
77f08c3bdfSopenharmony_cifi])dnl
78