AFS-PAG
view release on metacpan or search on metacpan
#!/usr/bin/perl
#
# Build script for the AFS::PAG distribution.
#
# Written by Russ Allbery <rra@cpan.org>
# Copyright 2013, 2014
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
use 5.010;
use autodie;
use strict;
use warnings;
use Config::AutoConf;
use File::Basename qw(basename);
use File::Path qw(remove_tree);
use File::Spec;
use Module::Build;
# Check whether it's possible to link a program that uses a particular
# function. This is written like a Config::AutoConf method and should ideally
# be incorporated into that module. This macro caches its result in the
# ac_cv_func_FUNCTION variable.
#
# $self - The Config::AutoConf state object
# $function - The function to check for
# $found_ref - Code reference to call if the function was found
# $notfound_ref - Code reference to call if the function wasn't found
#
# Returns: True if the function was found, false otherwise
sub check_func {
my ($self, $function, $found_ref, $notfound_ref) = @_;
$self = $self->_get_instance();
# Build the name of the cache variable.
my $cache_name = $self->_cache_name('func', $function);
# Wrap the actual check in a closure so that we can use check_cached.
my $check_sub = sub {
my $have_func = $self->link_if_else($self->lang_call(q{}, $function));
if ($have_func) {
if (defined($found_ref) && ref($found_ref) eq 'CODE') {
$found_ref->();
}
} else {
if (defined($notfound_ref) && ref($notfound_ref) eq 'CODE') {
$notfound_ref->();
}
}
return $have_func;
};
# Run the check and cache the results.
return $self->check_cached($cache_name, "for $function", $check_sub);
}
# The same as check_func, but takes a list of functions to look for and checks
# for each in turn. Define HAVE_FUNCTION for each function that was found,
( run in 0.588 second using v1.01-cache-2.11-cpan-39bf76dae61 )