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