[libconfig-autoconf-perl] 05/18: Imported Upstream version 0.307

Peter Pentchev roam at ringlet.net
Mon Feb 16 12:43:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

roam-guest pushed a commit to branch master
in repository libconfig-autoconf-perl.

commit 4f14c9eabe04041954e9d8c39aab2878017eebfc
Author: Peter Pentchev <roam at ringlet.net>
Date:   Fri Feb 13 11:09:09 2015 +0200

    Imported Upstream version 0.307
---
 Changes                |   17 +
 MANIFEST               |    3 +-
 MANIFEST.SKIP          |    2 +-
 META.json              |    7 +-
 META.yml               |    7 +-
 Makefile.PL            |   62 +-
 lib/Config/AutoConf.pm | 3655 +++++++++++++++++++++++++++++++-----------------
 t/00.load.t            |    5 +-
 t/01.checkprog.t       |  147 +-
 t/02.compile.t         |  153 +-
 t/03.link.t            |  118 +-
 t/05.settings.t        |   81 --
 12 files changed, 2651 insertions(+), 1606 deletions(-)

diff --git a/Changes b/Changes
index b1c59c7..c07ca68 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,22 @@
 Revision history for Config-AutoConf
 
+0.307	2014-12-14
+    - no Changes since 0.306_002
+
+0.306_002	2014-12-08
+	- fix perl_api_link test for broken environments of some windows
+	  testers
+
+0.306_001	2014-12-01
+	- indent source as requested via issue#4 by Dave Rolsky
+	- consolidate check_... function on_*_true/false parameters
+	  (Thanks to Peter Rabbitson for being sounding board)
+	- introduce more Perlish tests whether XS build is sane:
+	  check_produce_xs_build, check_produce_loadable_xs_build
+	  (Thanks to Peter Rabbitson for being sounding board)
+	- extensive refactoring with some API modifcations (warned
+	  users via mail and issue#5)
+
 0.305	2014-06-12
 	- skip compiler based tests when compiler seems weird
 	- add check_sane_xs composition as discussed on cpan-workers@
diff --git a/MANIFEST b/MANIFEST
index d89c956..4bf2131 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,14 +1,13 @@
 Changes
 lib/Config/AutoConf.pm
 Makefile.PL
-MANIFEST
+MANIFEST			This list of files
 MANIFEST.SKIP
 README
 t/00.load.t
 t/01.checkprog.t
 t/02.compile.t
 t/03.link.t
-t/05.settings.t
 t/testdata/foo.pc
 META.yml                                 Module YAML meta-data (added by MakeMaker)
 META.json                                Module JSON meta-data (added by MakeMaker)
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index a7548e6..b153c7c 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -6,7 +6,7 @@
 \.old$
 \.tdy$
 \.tmp$
-\..*swp
+\..*sw?
 ^Makefile$
 ^Build$
 ^Build\.bat$
diff --git a/META.json b/META.json
index e7b93b5..abf9fcd 100644
--- a/META.json
+++ b/META.json
@@ -5,7 +5,7 @@
       "Jens Rehsack <rehsack at cpan.org"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520",
+   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240",
    "license" : [
       "perl_5"
    ],
@@ -42,6 +42,7 @@
       },
       "runtime" : {
          "recommends" : {
+            "ExtUtils::CBuilder" : "0.280220",
             "File::Slurp::Tiny" : "0",
             "Scalar::Util" : "1.18"
          },
@@ -51,7 +52,6 @@
             "Config" : "0",
             "Cwd" : "0",
             "Exporter" : "0",
-            "ExtUtils::CBuilder" : "0.23",
             "File::Basename" : "0",
             "File::Spec" : "0",
             "File::Temp" : "0",
@@ -63,6 +63,7 @@
       },
       "test" : {
          "requires" : {
+            "ExtUtils::CBuilder" : "0.23",
             "Test::More" : "0.9"
          }
       }
@@ -82,5 +83,5 @@
          "web" : "https://github.com/ambs/Config-AutoConf"
       }
    },
-   "version" : "0.305"
+   "version" : "0.307"
 }
diff --git a/META.yml b/META.yml
index 8405eb2..db74aa9 100644
--- a/META.yml
+++ b/META.yml
@@ -4,11 +4,12 @@ author:
   - 'Alberto Simoes <ambs at cpan.org>'
   - 'Jens Rehsack <rehsack at cpan.org'
 build_requires:
+  ExtUtils::CBuilder: '0.23'
   Test::More: '0.9'
 configure_requires:
   ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.141520'
+generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -19,6 +20,7 @@ no_index:
     - t
     - inc
 recommends:
+  ExtUtils::CBuilder: '0.280220'
   File::Slurp::Tiny: '0'
   Scalar::Util: '1.18'
 requires:
@@ -27,7 +29,6 @@ requires:
   Config: '0'
   Cwd: '0'
   Exporter: '0'
-  ExtUtils::CBuilder: '0.23'
   File::Basename: '0'
   File::Spec: '0'
   File::Temp: '0'
@@ -40,4 +41,4 @@ resources:
   homepage: https://metacpan.org/release/Config-AutoConf
   license: http://dev.perl.org/licenses/
   repository: https://github.com/ambs/Config-AutoConf
-version: '0.305'
+version: '0.307'
diff --git a/Makefile.PL b/Makefile.PL
index 105fced..b6c1d4b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -3,24 +3,26 @@ use warnings;
 use ExtUtils::MakeMaker;
 
 my %RUN_DEPS = (
-    'base'               => 0,
-    'strict'             => 0,
-    'warnings'           => 0,
-    'Carp'               => 0,
-    'Capture::Tiny'      => 0,
-    'Config'             => 0,
-    'Cwd'                => 0,
-    'Exporter'           => 0,
-    'ExtUtils::CBuilder' => '0.23',
-    'File::Basename'     => 0,
-    'File::Spec'         => 0,
-    'File::Temp'         => 0,
-    'Text::ParseWords'   => 0,
+    'base'             => 0,
+    'strict'           => 0,
+    'warnings'         => 0,
+    'Carp'             => 0,
+    'Capture::Tiny'    => 0,
+    'Config'           => 0,
+    'Cwd'              => 0,
+    'Exporter'         => 0,
+    'File::Basename'   => 0,
+    'File::Spec'       => 0,
+    'File::Temp'       => 0,
+    'Text::ParseWords' => 0,
 );
 my %CONFIGURE_DEPS = ( 'ExtUtils::MakeMaker' => 0 );
 my %BUILD_DEPS = ();
 
-my %TEST_DEPS = ( 'Test::More' => 0.90 );
+my %TEST_DEPS = (
+    'Test::More'         => 0.90,
+    'ExtUtils::CBuilder' => '0.23'
+);
 $] < 5.008 and $TEST_DEPS{'IO::String'} = 0;
 
 WriteMakefile1(
@@ -61,10 +63,11 @@ WriteMakefile1(
                 requires => {%TEST_DEPS},
             },
             runtime => {
-                requires   => { %RUN_DEPS, },
+                requires   => {%RUN_DEPS},
                 recommends => {
-                    'Scalar::Util'      => '1.18',
-                    'File::Slurp::Tiny' => 0,
+                    'ExtUtils::CBuilder' => '0.280220',
+                    'File::Slurp::Tiny'  => 0,
+                    'Scalar::Util'       => '1.18',
                 },
             },
         },
@@ -87,23 +90,14 @@ sub WriteMakefile1
     $eumm_version = eval $eumm_version;
     die "EXTRA_META is deprecated" if ( exists( $params{EXTRA_META} ) );
     die "License not specified"    if ( !exists( $params{LICENSE} ) );
-    if ( $params{TEST_REQUIRES} and ( $eumm_version < 6.6303 ) )
-    {
-        if ( $params{BUILD_REQUIRES} )
-        {
-            $params{BUILD_REQUIRES} = { %{ $params{BUILD_REQUIRES} }, %{ delete $params{TEST_REQUIRES} } };
-        }
-        else
-        {
-            $params{BUILD_REQUIRES} = delete $params{TEST_REQUIRES};
-        }
-    }
-    if ( $params{BUILD_REQUIRES} and ( $eumm_version < 6.5503 ) )
-    {
-        #EUMM 6.5502 has problems with BUILD_REQUIRES
-        $params{PREREQ_PM} = { %{ $params{PREREQ_PM} || {} }, %{ $params{BUILD_REQUIRES} } };
-        delete $params{BUILD_REQUIRES};
-    }
+    $params{TEST_REQUIRES}
+      and $eumm_version < 6.6303
+      and $params{BUILD_REQUIRES} =
+      $params{BUILD_REQUIRES} ? { %{ $params{BUILD_REQUIRES} }, %{ $params{TEST_REQUIRES} } } : delete $params{TEST_REQUIRES};
+    #EUMM 6.5502 has problems with BUILD_REQUIRES
+    $params{BUILD_REQUIRES}
+      and $eumm_version < 6.5503
+      and $params{PREREQ_PM} = { %{ $params{PREREQ_PM} || {} }, %{ delete $params{BUILD_REQUIRES} } };
     $params{AUTHOR} = join( ", ", @{ $params{AUTHOR} } ) if ( $eumm_version < 6.58 and "ARRAY" eq ref $params{AUTHOR} );
     delete $params{CONFIGURE_REQUIRES}    if ( $eumm_version < 6.52 );
     delete $params{MIN_PERL_VERSION}      if ( $eumm_version < 6.48 );
diff --git a/lib/Config/AutoConf.pm b/lib/Config/AutoConf.pm
index 31d6a49..bc4d85e 100644
--- a/lib/Config/AutoConf.pm
+++ b/lib/Config/AutoConf.pm
@@ -5,12 +5,10 @@ use strict;
 
 use base 'Exporter';
 
-our @EXPORT = ('$LIBEXT', '$EXEEXT');
+our @EXPORT = ( '$LIBEXT', '$EXEEXT' );
 
 use constant QUOTE => do { $^O eq "MSWin32" ? q["] : q['] };
 
-use ExtUtils::CBuilder;
-
 use Config;
 use Carp qw/croak/;
 
@@ -71,18 +69,20 @@ EOP
 
 # PA-RISC1.1-thread-multi
 my %special_dlext = (
-  darwin => ".dylib",
-  MSWin32 => ".dll",
-  ($Config{archname} =~ m/PA-RISC/i ? ("hpux" => ".sl") : ()),
+    darwin  => ".dylib",
+    MSWin32 => ".dll",
+    ( $Config{archname} =~ m/PA-RISC/i ? ( "hpux" => ".sl" ) : () ),
 );
 
-our ($LIBEXT, $EXEEXT);
+our ( $LIBEXT, $EXEEXT );
 
 defined $LIBEXT
-  or $LIBEXT = defined $Config{so} ? "." . $Config{so} :
-               defined $special_dlext{$^O} ? $special_dlext{$^O} : ".so";
+  or $LIBEXT =
+    defined $Config{so}         ? "." . $Config{so}
+  : defined $special_dlext{$^O} ? $special_dlext{$^O}
+  :                               ".so";
 defined $EXEEXT
-  or $EXEEXT = ($^O eq "MSWin32") ? ".exe" : "";
+  or $EXEEXT = ( $^O eq "MSWin32" ) ? ".exe" : "";
 
 =encoding UTF-8
 
@@ -92,7 +92,8 @@ Config::AutoConf - A module to implement some of AutoConf macros in pure perl.
 
 =cut
 
-our $VERSION = '0.305';
+our $VERSION = '0.307';
+$VERSION = eval $VERSION;
 
 =head1 ABSTRACT
 
@@ -132,37 +133,40 @@ environment variable C<PERL5_AUTOCONF_OPTS>.
 
 =cut
 
-sub new {
-  my $class = shift;
-  ref $class and $class = ref $class;
-  my %args = @_;
-
-  my %flags = map {
-    my ($k, $v) = split("=", $_, 2); defined $v or $v = 1; ($k, $v)
-  } split( ":", $ENV{PERL5_AUTOCONF_OPTS} ) if($ENV{PERL5_AUTOCONF_OPTS});
-
-  my %instance = (
-    msg_prefix => 'configure: ',
-    lang => "C",
-    lang_stack => [],
-    lang_supported => {
-      "C" => "ExtUtils::CBuilder",
-    },
-    cache => {},
-    defines => {},
-    extra_libs => [],
-    extra_lib_dirs => [],
-    extra_include_dirs => [],
-    extra_preprocess_flags => [],
-    extra_compile_flags => {
-      "C" => [],
-    },
-    extra_link_flags => [],
-    logfile => "config.log",
-    c_ac_flags => {%flags},
-    %args
-  );
-  bless( \%instance, $class );
+sub new
+{
+    my $class = shift;
+    ref $class and $class = ref $class;
+    my %args = @_;
+
+    my %flags = map {
+        my ( $k, $v ) = split( "=", $_, 2 );
+        defined $v or $v = 1;
+        ( $k, $v )
+    } split( ":", $ENV{PERL5_AC_OPTS} ) if ( $ENV{PERL5_AC_OPTS} );
+
+    my %instance = (
+        msg_prefix     => 'configure: ',
+        lang           => "C",
+        lang_stack     => [],
+        lang_supported => {
+            "C" => $class->can("check_prog_cc"),
+        },
+        cache                  => {},
+        defines                => {},
+        extra_libs             => [],
+        extra_lib_dirs         => [],
+        extra_include_dirs     => [],
+        extra_preprocess_flags => [],
+        extra_compile_flags    => {
+            "C" => [],
+        },
+        extra_link_flags => [],
+        logfile          => "config.log",
+        c_ac_flags       => {%flags},
+        %args
+    );
+    bless( \%instance, $class );
 }
 
 =head2 check_file
@@ -173,12 +177,12 @@ don't need to use a function call.
 
 =cut
 
-sub check_file {
-  my ($self, $file) = @_;
-  -f $file && -r $file;
+sub check_file
+{
+    my ( $self, $file ) = @_;
+    -f $file && -r $file;
 }
 
-
 =head2 check_files
 
 This function checks if a set of files exist in the system and are
@@ -186,25 +190,28 @@ readable by the user. Returns a boolean.
 
 =cut
 
-sub check_files {
-  my $self = shift;
+sub check_files
+{
+    my $self = shift;
 
-  for (@_) {
-    return 0 unless $self->check_file($_)
-  }
+    for (@_)
+    {
+        return 0 unless $self->check_file($_);
+    }
 
-  1;
+    1;
 }
 
-sub _sanitize_prog {
-  my ($self, $prog) = @_;
-  (scalar Text::ParseWords::shellwords $prog) > 1 and $prog = QUOTE . $prog . QUOTE;
-  $prog;
+sub _sanitize_prog
+{
+    my ( $self, $prog ) = @_;
+    ( scalar Text::ParseWords::shellwords $prog) > 1 and $prog = QUOTE . $prog . QUOTE;
+    $prog;
 }
 
 my @exe_exts = ( $^O eq "MSWin32" ? qw(.exe .com .bat .cmd) : ("") );
 
-=head2 check_prog(prog,[dirlist])
+=head2 check_prog( $prog, \@dirlist?, \%options? )
 
 This function checks for a program with the supplied name. In success
 returns the full path for the executable;
@@ -212,24 +219,43 @@ returns the full path for the executable;
 An optional array reference containing a list of directories to be searched
 instead of $PATH is gracefully honored.
 
-=cut
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
 
-sub check_prog {
-  my $self = shift;
-  # sanitize ac_prog
-  my $ac_prog = _sanitize(shift @_);
-  my @dirlist;
-  @_ and scalar @_ > 1 and @dirlist = @_;
-  @_ and scalar @_ == 1 and ref $_[0] eq "ARRAY" and @dirlist = @{$_[0]};
-  @dirlist or @dirlist = split(/$Config{path_sep}/,$ENV{PATH});
+=cut
 
-  for my $p (@dirlist) {
-    for my $e (@exe_exts) {
-      my $cmd = $self->_sanitize_prog(File::Spec->catfile($p,$ac_prog.$e));
-      return $cmd if -x $cmd;
+sub check_prog
+{
+    my $self = shift;
+    # sanitize ac_prog
+    my $ac_prog = _sanitize( shift @_ );
+
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my @dirlist;
+    @_ and scalar @_ > 1 and @dirlist = @_;
+    @_ and scalar @_ == 1 and ref $_[0] eq "ARRAY" and @dirlist = @{ $_[0] };
+    @dirlist or @dirlist = split( /$Config{path_sep}/, $ENV{PATH} );
+
+    for my $p (@dirlist)
+    {
+        for my $e (@exe_exts)
+        {
+            my $cmd = $self->_sanitize_prog( File::Spec->catfile( $p, $ac_prog . $e ) );
+            -x $cmd
+              and $options->{action_on_true}
+              and ref $options->{action_on_true} eq "CODE"
+              and $options->{action_on_true}->();
+            -x $cmd and return $cmd;
+        }
     }
-  }
-  return;
+
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and $options->{action_on_false}->();
+
+    return;
 }
 
 =head2 check_progs(progs, [dirlist])
@@ -240,26 +266,49 @@ the first found on the system. Returns undef if none was found.
 An optional array reference containing a list of directories to be searched
 instead of $PATH is gracefully honored.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively. The
+name of the I<$prog> to check and the found full path are passed as first
+and second argument to the I<action_on_true> callback.
+
 =cut
 
-sub check_progs {
-  my $self = shift;
-  my @dirlist;
-  scalar @_ > 1 and ref $_[-1] eq "ARRAY" and @dirlist = @{pop @_};
-  @dirlist or @dirlist = split(/$Config{path_sep}/,$ENV{PATH});
+sub check_progs
+{
+    my $self = shift;
 
-  my @progs = @_;
-  for (@progs) {
-    defined $_ or next;
-    my $ans = $self->check_prog($_, \@dirlist);
-    return $ans if $ans;
-  }
-  return;
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my @dirlist;
+    scalar @_ > 1 and ref $_[-1] eq "ARRAY" and @dirlist = @{ pop @_ };
+    @dirlist or @dirlist = split( /$Config{path_sep}/, $ENV{PATH} );
+
+    my @progs = @_;
+    foreach my $prog (@progs)
+    {
+        defined $prog or next;
+
+        my $ans = $self->check_prog( $prog, \@dirlist );
+              $ans
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_if_true}->( $prog, $ans );
+
+        $ans and return $ans;
+    }
+
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and $options->{action_on_false}->();
+
+    return;
 }
 
-sub _append_prog_args {
-  my ($self, $prog) = @_;
-  join(" ", $self->_sanitize_prog($prog), @_);
+sub _append_prog_args
+{
+    my ( $self, $prog ) = @_;
+    join( " ", $self->_sanitize_prog($prog), @_ );
 }
 
 =head2 check_prog_yacc
@@ -275,20 +324,25 @@ Returns the full path, if found.
 
 =cut
 
-sub check_prog_yacc {
-  my $self = shift;
-
-# my ($self, $cache_name, $message, $check_sub) = @_;
-
-  my $cache_name = $self->_cache_name("prog", "YACC");
-  $self->check_cached( $cache_name, "for yacc",
-    sub {
-      defined $ENV{YACC} and return $ENV{YACC};
-      my $binary = $self->check_progs(qw/bison byacc yacc/);
-      defined $binary and $binary =~ /bison(?:\.(?:exe|com|bat|cmd))?$/
-        and $binary = $self->_append_prog_args($binary, "-y");
-      return $binary;
-    } );
+sub check_prog_yacc
+{
+    my $self = shift;
+
+    # my ($self, $cache_name, $message, $check_sub) = @_;
+
+    my $cache_name = $self->_cache_name( "prog", "YACC" );
+    $self->check_cached(
+        $cache_name,
+        "for yacc",
+        sub {
+            defined $ENV{YACC} and return $ENV{YACC};
+            my $binary = $self->check_progs(qw/bison byacc yacc/);
+            defined $binary
+              and $binary =~ /bison(?:\.(?:exe|com|bat|cmd))?$/
+              and $binary = $self->_append_prog_args( $binary, "-y" );
+            return $binary;
+        }
+    );
 }
 
 =head2 check_prog_awk
@@ -305,14 +359,13 @@ Note that it returns the full path, if found.
 
 =cut
 
-sub check_prog_awk {
-  my $self = shift;
-  my $cache_name = $self->_cache_name("prog", "AWK");
-  $self->check_cached( $cache_name, "for awk",
-    sub {$ENV{AWK} || $self->check_progs(qw/gawk mawk nawk awk/)} );
+sub check_prog_awk
+{
+    my $self = shift;
+    my $cache_name = $self->_cache_name( "prog", "AWK" );
+    $self->check_cached( $cache_name, "for awk", sub { $ENV{AWK} || $self->check_progs(qw/gawk mawk nawk awk/) } );
 }
 
-
 =head2 check_prog_egrep
 
 From the autoconf documentation,
@@ -326,23 +379,28 @@ Note that it returns the full path, if found.
 
 =cut
 
-sub check_prog_egrep {
-  my $self = shift;
-
-  my $cache_name = $self->_cache_name("prog", "EGREP");
-  $self->check_cached( $cache_name, "for egrep",
-    sub {
-      defined $ENV{EGREP} and return $ENV{EGREP};
-      my $grep;
-      $grep = $self->check_progs("egrep") and return $grep;
-
-      if ($grep = $self->check_prog("grep")) {
-        # check_run - Capture::Tiny, Open3 ... ftw!
-        my $ans = `echo a | ($grep -E '(a|b)') 2>/dev/null`;
-        chomp $ans;
-        $ans eq "a" and return $self->_append_prog_args($grep,  "-E");
-      }
-    } );
+sub check_prog_egrep
+{
+    my $self = shift;
+
+    my $cache_name = $self->_cache_name( "prog", "EGREP" );
+    $self->check_cached(
+        $cache_name,
+        "for egrep",
+        sub {
+            defined $ENV{EGREP} and return $ENV{EGREP};
+            my $grep;
+            $grep = $self->check_progs("egrep") and return $grep;
+
+            if ( $grep = $self->check_prog("grep") )
+            {
+                # check_run - Capture::Tiny, Open3 ... ftw!
+                my $ans = `echo a | ($grep -E '(a|b)') 2>/dev/null`;
+                chomp $ans;
+                $ans eq "a" and return $self->_append_prog_args( $grep, "-E" );
+            }
+        }
+    );
 }
 
 =head2 check_prog_lex
@@ -366,17 +424,20 @@ The structure $self->{lex} is set with attributes
 
 =cut
 
-sub check_prog_lex {
-  my $self = shift->_get_instance;
-  my $cache_name = $self->_cache_name("prog", "LEX");
-  my $lex = $self->check_cached( $cache_name, "for lex",
-    sub {$ENV{LEX} || $self->check_progs(qw/flex lex/)} );
-  if($lex) {
-    defined $self->{lex}->{prog} or $self->{lex}->{prog} = $lex;
-    my $lex_root_var = $self->check_cached( "ac_cv_prog_lex_root", "for lex output file root",
-      sub {
-        my ($fh, $filename) = tempfile( "testXXXXXX", SUFFIX => '.l');
-        my $src = <<'EOLEX';
+sub check_prog_lex
+{
+    my $self       = shift->_get_instance;
+    my $cache_name = $self->_cache_name( "prog", "LEX" );
+    my $lex        = $self->check_cached( $cache_name, "for lex", sub { $ENV{LEX} || $self->check_progs(qw/flex lex/) } );
+    if ($lex)
+    {
+        defined $self->{lex}->{prog} or $self->{lex}->{prog} = $lex;
+        my $lex_root_var = $self->check_cached(
+            "ac_cv_prog_lex_root",
+            "for lex output file root",
+            sub {
+                my ( $fh, $filename ) = tempfile( "testXXXXXX", SUFFIX => '.l' );
+                my $src = <<'EOLEX';
 %%
 a { ECHO; }
 b { REJECT; }
@@ -397,55 +458,56 @@ main (void)
 }
 EOLEX
 
-        print {$fh} $src;
-        close $fh;
-
-        my ( $stdout, $stderr, $exit ) =
-          capture { system( $lex, $filename ); };
-        chomp $stdout;
-        unlink $filename;
-        -f "lex.yy.c" and return "lex.yy";
-        -f "lexyy.c" and return "lexyy";
-        $self->msg_error("cannot find output from $lex; giving up");
-      });
-    defined $self->{lex}->{root} or $self->{lex}->{root} = $lex_root_var;
-
-    my $conftest = read_file($lex_root_var.".c");
-    unlink $lex_root_var.".c";
-
-    $cache_name = $self->_cache_name( "lib", "lex" );
-    my $check_sub = sub {
-      my @save_libs = @{$self->{extra_libs}};
-      my $have_lib = 0;
-      foreach my $libstest ( undef, qw(-lfl -ll) ) {
-        # XXX would local work on array refs? can we omit @save_libs?
-        $self->{extra_libs} = [ @save_libs ];
-        defined( $libstest ) and unshift( @{$self->{extra_libs}}, $libstest );
-        $self->link_if_else( $conftest )
-          and ( $have_lib = defined( $libstest ) ? $libstest : "none required" )
-          and last;
-      }
-      $self->{extra_libs} = [ @save_libs ];
-
-      if( $have_lib ) {
-        $self->define_var( _have_lib_define_name( "lex" ), $have_lib,
-                           "defined when lex library is available" );
-      }
-      else {
-        $self->define_var( _have_lib_define_name( "lex" ), undef,
-                           "defined when lex library is available" );
-      }
-      return $have_lib;
-    };
-
-    my $lex_lib = $self->check_cached( $cache_name, "lex library", $check_sub );
-    defined $self->{lex}->{lib} or $self->{lex}->{lib} = $lex_lib;
-  }
+                print {$fh} $src;
+                close $fh;
+
+                my ( $stdout, $stderr, $exit ) =
+                  capture { system( $lex, $filename ); };
+                chomp $stdout;
+                unlink $filename;
+                -f "lex.yy.c" and return "lex.yy";
+                -f "lexyy.c"  and return "lexyy";
+                $self->msg_error("cannot find output from $lex; giving up");
+            }
+        );
+        defined $self->{lex}->{root} or $self->{lex}->{root} = $lex_root_var;
+
+        my $conftest = read_file( $lex_root_var . ".c" );
+        unlink $lex_root_var . ".c";
+
+        $cache_name = $self->_cache_name( "lib", "lex" );
+        my $check_sub = sub {
+            my @save_libs = @{ $self->{extra_libs} };
+            my $have_lib  = 0;
+            foreach my $libstest ( undef, qw(-lfl -ll) )
+            {
+                # XXX would local work on array refs? can we omit @save_libs?
+                $self->{extra_libs} = [@save_libs];
+                defined($libstest) and unshift( @{ $self->{extra_libs} }, $libstest );
+                $self->link_if_else($conftest)
+                  and ( $have_lib = defined($libstest) ? $libstest : "none required" )
+                  and last;
+            }
+            $self->{extra_libs} = [@save_libs];
+
+            if ($have_lib)
+            {
+                $self->define_var( _have_lib_define_name("lex"), $have_lib, "defined when lex library is available" );
+            }
+            else
+            {
+                $self->define_var( _have_lib_define_name("lex"), undef, "defined when lex library is available" );
+            }
+            return $have_lib;
+        };
+
+        my $lex_lib = $self->check_cached( $cache_name, "lex library", $check_sub );
+        defined $self->{lex}->{lib} or $self->{lex}->{lib} = $lex_lib;
+    }
 
-  $lex;
+    $lex;
 }
 
-
 =head2 check_prog_sed
 
 From the autoconf documentation,
@@ -462,35 +524,95 @@ Note that it returns the full path, if found.
 
 =cut
 
-sub check_prog_sed {
-  my $self = shift;
-  my $cache_name = $self->_cache_name("prog", "SED");
-  $self->check_cached( $cache_name, "for sed",
-    sub {$ENV{SED} || $self->check_progs(qw/gsed sed/)} );
+sub check_prog_sed
+{
+    my $self = shift;
+    my $cache_name = $self->_cache_name( "prog", "SED" );
+    $self->check_cached( $cache_name, "for sed", sub { $ENV{SED} || $self->check_progs(qw/gsed sed/) } );
 }
 
-
 =head2 check_prog_pkg_config
 
 Checks for C<pkg-config> program. No additional tests are made for it ...
 
 =cut
- 
-sub check_prog_pkg_config {
-  my $self = shift->_get_instance();
-  my $cache_name = $self->_cache_name("prog", "PKG_CONFIG");
-  $self->check_cached( $cache_name, "for pkg-config",
-    sub {$self->check_prog("pkg-config")} );
+
+sub check_prog_pkg_config
+{
+    my $self = shift->_get_instance();
+    my $cache_name = $self->_cache_name( "prog", "PKG_CONFIG" );
+    $self->check_cached( $cache_name, "for pkg-config", sub { $self->check_prog("pkg-config") } );
+}
+
+=head2 check_prog_cc
+
+This function checks if you have a runable C compiler.
+
+=cut
+
+sub check_prog_cc
+{
+    my $self = shift;
+    my $cache_name = $self->_cache_name( "prog", "CC" );
+
+    $self->check_cached(
+        $cache_name,
+        "for cc",
+        sub {
+            $self->{lang_supported}->{C} = undef;
+            eval "use ExtUtils::CBuilder;";
+            $@ and return;
+            my $cb = ExtUtils::CBuilder->new( quiet => 1 );
+            $cb->have_compiler or return;
+            $self->{lang_supported}->{C} = "ExtUtils::CBuilder";
+            $cb->{config}->{cc};
+        }
+    );
 }
 
 =head2 check_cc
 
-This function checks if you have a running C compiler.
+(Depreciated) Old name of L</check_prog_cc>.
 
 =cut
 
-sub check_cc {
-  ExtUtils::CBuilder->new(quiet => 1)->have_compiler;
+sub check_cc { shift->check_prog_cc(@_) }
+
+=head2 check_valid_compiler
+
+This function checks for a valid compiler for the currently active language.
+At the very moment only C<C> is understood (corresponding to your compiler
+default options, e.g. -std=gnu89).
+
+=cut
+
+sub check_valid_compiler
+{
+    my $self = shift->_get_instance;
+    my $lang = $self->{lang};
+    $lang eq "C" or $self->msg_error("Language $lang is not supported");
+    $self->check_prog_cc;
+}
+
+=head2 check_valid_compilers(;\@)
+
+Checks for valid compilers for each given language. When unspecified
+defaults to C<[ "C" ]>.
+
+=cut
+
+sub check_valid_compilers
+{
+    my $self = shift;
+    for my $lang ( @{ $_[0] } )
+    {
+        $self->push_lang($lang);
+        my $supp = $self->check_valid_compiler;
+        $self->pop_lang($lang);
+        $supp or return 0;
+    }
+
+    1;
 }
 
 =head2 msg_checking
@@ -499,12 +621,13 @@ Prints "Checking @_ ..."
 
 =cut
 
-sub msg_checking {
-  my $self = shift->_get_instance();
-  $self->{quiet} or
-    print "Checking " . join(" ", @_) . "... ";
-  $self->_add_log_entry( "Checking " . join( " ", @_, "..." ) );
-  return;
+sub msg_checking
+{
+    my $self = shift->_get_instance();
+    $self->{quiet}
+      or print "Checking " . join( " ", @_ ) . "... ";
+    $self->_add_log_entry( "Checking " . join( " ", @_, "..." ) );
+    return;
 }
 
 =head2 msg_result
@@ -517,17 +640,18 @@ my @_num_to_msg = qw/no yes/;
 
 sub _neat
 {
-  defined $_[0] or return "";
-  looks_like_number( $_[0] ) and defined $_num_to_msg[$_[0]] and return $_num_to_msg[$_[0]];
-  $_[0];
+    defined $_[0] or return "";
+    looks_like_number( $_[0] ) and defined $_num_to_msg[ $_[0] ] and return $_num_to_msg[ $_[0] ];
+    $_[0];
 }
 
-sub msg_result {
-  my $self = shift->_get_instance();
-  $self->{quiet} or
-    print join( " ", map { _neat $_ } @_ ), "\n";
-  $self->_add_log_entry( join( " ", map { _neat $_ } @_ ), "\n" );
-  return;
+sub msg_result
+{
+    my $self = shift->_get_instance();
+    $self->{quiet}
+      or print join( " ", map { _neat $_ } @_ ), "\n";
+    $self->_add_log_entry( join( " ", map { _neat $_ } @_ ), "\n" );
+    return;
 }
 
 =head2 msg_notice
@@ -536,12 +660,13 @@ Prints "configure: " @_ to stdout
 
 =cut
 
-sub msg_notice {
-  my $self = shift->_get_instance();
-  $self->{quiet} or
-    print $self->{msg_prefix} . join( " ", @_ ) . "\n";
-  $self->_add_log_entry( $self->{msg_prefix} . join( " ", @_ ) . "\n" );
-  return;
+sub msg_notice
+{
+    my $self = shift->_get_instance();
+    $self->{quiet}
+      or print $self->{msg_prefix} . join( " ", @_ ) . "\n";
+    $self->_add_log_entry( $self->{msg_prefix} . join( " ", @_ ) . "\n" );
+    return;
 }
 
 =head2 msg_warn
@@ -550,11 +675,12 @@ Prints "configure: " @_ to stderr
 
 =cut
 
-sub msg_warn {
-  my $self = shift->_get_instance();
-  print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
-  $self->_add_log_entry( "WARNING: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
-  return;
+sub msg_warn
+{
+    my $self = shift->_get_instance();
+    print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
+    $self->_add_log_entry( "WARNING: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
+    return;
 }
 
 =head2 msg_error
@@ -564,11 +690,12 @@ toolchain to stop here and report unsupported environment)
 
 =cut
 
-sub msg_error {
-  my $self = shift->_get_instance();
-  print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
-  $self->_add_log_entry( "ERROR: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
-  exit(0); # #toolchain agreement: prevents configure stage to finish
+sub msg_error
+{
+    my $self = shift->_get_instance();
+    print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
+    $self->_add_log_entry( "ERROR: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
+    exit(0);    # #toolchain agreement: prevents configure stage to finish
 }
 
 =head2 msg_failure
@@ -580,28 +707,29 @@ later stage).
 
 =cut
 
-sub msg_failure {
-  my $self = shift->_get_instance();
-  print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
-  $self->_add_log_entry( "FAILURE: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
-  exit(0); # #toolchain agreement: prevents configure stage to finish
+sub msg_failure
+{
+    my $self = shift->_get_instance();
+    print STDERR $self->{msg_prefix} . join( " ", @_ ) . "\n";
+    $self->_add_log_entry( "FAILURE: " . $self->{msg_prefix} . join( " ", @_ ) . "\n" );
+    exit(0);    # #toolchain agreement: prevents configure stage to finish
 }
 
 =head2 define_var( $name, $value [, $comment ] )
 
 Defines a check variable for later use in further checks or code to compile.
+Returns the value assigned value
 
 =cut
 
-sub define_var {
-  my $self = shift->_get_instance();
-  my ($name, $value, $comment) = @_;
-
-  defined( $name ) or croak( "Need a name to add a define" );
-
-  $self->{defines}->{$name} = [ $value, $comment ];
+sub define_var
+{
+    my $self = shift->_get_instance();
+    my ( $name, $value, $comment ) = @_;
 
-  return;
+    defined($name) or croak("Need a name to add a define");
+    $self->{defines}->{$name} = [ $value, $comment ];
+    $value;
 }
 
 =head2 write_config_h( [$target] )
@@ -612,17 +740,20 @@ Writes the defined constants into given target:
 
 =cut
 
-sub write_config_h {
-  my $self = shift->_get_instance();
-  my $tgt;
-  
-  defined( $_[0] )
-    ? ( ref( $_[0] )
-      ? $tgt = $_[0]
-      : open( $tgt, ">", $_[0] ) )
-    : open( $tgt, ">", "config.h" );
-
-  my $conf_h = <<'EOC';
+sub write_config_h
+{
+    my $self = shift->_get_instance();
+    my $tgt;
+
+    defined( $_[0] )
+      ? (
+        ref( $_[0] )
+        ? $tgt = $_[0]
+        : open( $tgt, ">", $_[0] )
+      )
+      : open( $tgt, ">", "config.h" );
+
+    my $conf_h = <<'EOC';
 /**
  * Generated from Config::AutoConf
  *
@@ -637,21 +768,24 @@ sub write_config_h {
 
 EOC
 
-  while( my ($defname, $defcnt) = each( %{ $self->{defines} } ) ) {
-    if( $defcnt->[0] ) {
-      defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n";
-      $conf_h .= join( " ", "#define", $defname, $defcnt->[0] ) . "\n";
+    while ( my ( $defname, $defcnt ) = each( %{ $self->{defines} } ) )
+    {
+        if ( $defcnt->[0] )
+        {
+            defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n";
+            $conf_h .= join( " ", "#define", $defname, $defcnt->[0] ) . "\n";
+        }
+        else
+        {
+            defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n";
+            $conf_h .= "/* " . join( " ", "#undef", $defname ) . " */\n\n";
+        }
     }
-    else {
-      defined $defcnt->[1] and $conf_h .= "/* " . $defcnt->[1] . " */\n";
-      $conf_h .= "/* " . join( " ", "#undef", $defname ) . " */\n\n";
-    }
-  }
-  $conf_h .= "#endif /* ?__CONFIG_H__ */\n";
+    $conf_h .= "#endif /* ?__CONFIG_H__ */\n";
 
-  print {$tgt} $conf_h;
+    print {$tgt} $conf_h;
 
-  return;
+    return;
 }
 
 =head2 push_lang(lang [, implementor ])
@@ -661,12 +795,13 @@ for subsequent operations until ending pop_lang call.
 
 =cut
 
-sub push_lang {
-  my $self = shift->_get_instance();
+sub push_lang
+{
+    my $self = shift->_get_instance();
 
-  push @{$self->{lang_stack}}, [ $self->{lang} ];
+    push @{ $self->{lang_stack} }, [ $self->{lang} ];
 
-  $self->_set_language( @_ );
+    $self->_set_language(@_);
 }
 
 =head2 pop_lang([ lang ])
@@ -677,14 +812,16 @@ equals to specified language (helps finding control flow bugs).
 
 =cut
 
-sub pop_lang {
-  my $self = shift->_get_instance();
+sub pop_lang
+{
+    my $self = shift->_get_instance();
 
-  scalar( @{$self->{lang_stack}} ) > 0 or croak( "Language stack empty" );
-  defined( $_[0] ) and $self->{lang} ne $_[0] and
-    croak( "pop_lang( $_[0] ) doesn't match language in use (" . $self->{lang} . ")" );
+    scalar( @{ $self->{lang_stack} } ) > 0 or croak("Language stack empty");
+    defined( $_[0] )
+      and $self->{lang} ne $_[0]
+      and croak( "pop_lang( $_[0] ) doesn't match language in use (" . $self->{lang} . ")" );
 
-  $self->_set_language( @{ pop @{ $self->{lang} } } );
+    $self->_set_language( @{ pop @{ $self->{lang_stack} } } );
 }
 
 =head2 lang_call( [prologue], function )
@@ -695,12 +832,13 @@ includes are used.
 
 =cut
 
-sub lang_call {
-  my ($self, $prologue, $function) = @_;
-  ref $self or $self = $self->_get_instance();
+sub lang_call
+{
+    my ( $self, $prologue, $function ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  defined( $prologue ) or $prologue = $self->_default_includes();
-  $prologue .= <<"_ACEOF";
+    defined($prologue) or $prologue = $self->_default_includes();
+    $prologue .= <<"_ACEOF";
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
@@ -712,10 +850,10 @@ char $function ();
 }
 #endif
 _ACEOF
-  my $body = "return $function ();";
-  $body = $self->_build_main( $body );
+    my $body = "return $function ();";
+    $body = $self->_build_main($body);
 
-  $self->_fill_defines() . "\n$prologue\n\n$body\n";
+    $self->_fill_defines() . "\n$prologue\n\n$body\n";
 }
 
 =head2 lang_build_program( prologue, body )
@@ -753,15 +891,16 @@ will create
 
 =cut
 
-sub lang_build_program {
-  my ($self, $prologue, $body) = @_;
-  ref $self or $self = $self->_get_instance();
+sub lang_build_program
+{
+    my ( $self, $prologue, $body ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  defined( $prologue ) or $prologue = $self->_default_includes();
-  defined( $body ) or $body = "";
-  $body = $self->_build_main( $body );
+    defined($prologue) or $prologue = $self->_default_includes();
+    defined($body)     or $body     = "";
+    $body = $self->_build_main($body);
 
-  $self->_fill_defines() . "\n$prologue\n\n$body\n";
+    $self->_fill_defines() . "\n$prologue\n\n$body\n";
 }
 
 =head2 lang_build_bool_test (prologue, test, [@decls])
@@ -772,19 +911,21 @@ before the test code at the variable definition place.
 
 =cut
 
-sub lang_build_bool_test {
-  my ($self, $prologue, $test, @decls) = @_;
-  ref $self or $self = $self->_get_instance();
+sub lang_build_bool_test
+{
+    my ( $self, $prologue, $test, @decls ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  defined( $test ) or $test = "1";
-  my $test_code = <<ACEOF;
+    defined($test) or $test = "1";
+    my $test_code = <<ACEOF;
   static int test_array [($test) ? 1 : -1 ];
   test_array [0] = 0
 ACEOF
-  if( @decls ) {
-    $test_code = join( "\n", @decls, $test_code );
-  }
-  $self->lang_build_program( $prologue, $test_code );
+    if (@decls)
+    {
+        $test_code = join( "\n", @decls, $test_code );
+    }
+    $self->lang_build_program( $prologue, $test_code );
 }
 
 =head2 push_includes
@@ -795,13 +936,14 @@ which might be created during the build.
 
 =cut
 
-sub push_includes {
-  my ($self, @includes) = @_;
-  ref $self or $self = $self->_get_instance();
+sub push_includes
+{
+    my ( $self, @includes ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  push( @{$self->{extra_include_dirs}}, @includes );
+    push( @{ $self->{extra_include_dirs} }, @includes );
 
-  return;
+    return;
 }
 
 =head2 push_preprocess_flags
@@ -810,13 +952,14 @@ Adds given flags to the parameter list for preprocessor invocation.
 
 =cut
 
-sub push_preprocess_flags {
-  my ($self, @cpp_flags) = @_;
-  ref $self or $self = $self->_get_instance();
+sub push_preprocess_flags
+{
+    my ( $self, @cpp_flags ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  push( @{$self->{extra_preprocess_flags}}, @cpp_flags );
+    push( @{ $self->{extra_preprocess_flags} }, @cpp_flags );
 
-  return;
+    return;
 }
 
 =head2 push_compiler_flags
@@ -825,21 +968,23 @@ Adds given flags to the parameter list for compiler invocation.
 
 =cut
 
-sub push_compiler_flags {
-  my ($self, @compiler_flags) = @_;
-  ref $self or $self = $self->_get_instance();
-  my $lang = $self->{lang};
-
-  if( scalar( @compiler_flags ) && ( ref($compiler_flags[-1]) eq "HASH" ) ) {
-    my $lang_opt = pop( @compiler_flags );
-    defined( $lang_opt->{lang} ) or croak( "Missing lang attribute in language options" );
-    $lang = $lang_opt->{lang};
-    defined( $self->{lang_supported}->{$lang} ) or croak( "Unsupported language '$lang'" );
-  }
+sub push_compiler_flags
+{
+    my ( $self, @compiler_flags ) = @_;
+    ref $self or $self = $self->_get_instance();
+    my $lang = $self->{lang};
+
+    if ( scalar(@compiler_flags) && ( ref( $compiler_flags[-1] ) eq "HASH" ) )
+    {
+        my $lang_opt = pop(@compiler_flags);
+        defined( $lang_opt->{lang} ) or croak("Missing lang attribute in language options");
+        $lang = $lang_opt->{lang};
+        defined( $self->{lang_supported}->{$lang} ) or croak("Unsupported language '$lang'");
+    }
 
-  push( @{$self->{extra_compile_flags}->{$lang}}, @compiler_flags );
+    push( @{ $self->{extra_compile_flags}->{$lang} }, @compiler_flags );
 
-  return;
+    return;
 }
 
 =head2 push_libraries
@@ -848,13 +993,14 @@ Adds given list of libraries to the parameter list for linker invocation.
 
 =cut
 
-sub push_libraries {
-  my ($self, @libs) = @_;
-  ref $self or $self = $self->_get_instance();
+sub push_libraries
+{
+    my ( $self, @libs ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  push( @{$self->{extra_libs}}, @libs );
+    push( @{ $self->{extra_libs} }, @libs );
 
-  return;
+    return;
 }
 
 =head2 push_library_paths
@@ -863,13 +1009,14 @@ Adds given list of library paths to the parameter list for linker invocation.
 
 =cut
 
-sub push_library_paths {
-  my ($self, @libdirs) = @_;
-  ref $self or $self = $self->_get_instance();
+sub push_library_paths
+{
+    my ( $self, @libdirs ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  push( @{$self->{extra_lib_dirs}}, @libdirs );
+    push( @{ $self->{extra_lib_dirs} }, @libdirs );
 
-  return;
+    return;
 }
 
 =head2 push_link_flags
@@ -878,165 +1025,223 @@ Adds given flags to the parameter list for linker invocation.
 
 =cut
 
-sub push_link_flags {
-  my ($self, @link_flags) = @_;
-  ref $self or $self = $self->_get_instance();
+sub push_link_flags
+{
+    my ( $self, @link_flags ) = @_;
+    ref $self or $self = $self->_get_instance();
 
-  push( @{$self->{extra_link_flags}}, @link_flags );
+    push( @{ $self->{extra_link_flags} }, @link_flags );
 
-  return;
+    return;
 }
 
-=head2 compile_if_else( $src [, action-if-true [, action-if-false ] ] )
+=head2 compile_if_else( $src, \%options? )
 
-This function trys to compile specified code and runs action-if-true on success
-or action-if-false otherwise.
+This function trys to compile specified code and returns a boolean value
+containing check success state.
 
-Returns a boolean value containing check success state.
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
 
 =cut
 
-sub compile_if_else {
-  my ($self, $src, $action_if_true, $action_if_false) = @_;
-  ref $self or $self = $self->_get_instance();
-  my $builder = $self->_get_builder();
+sub compile_if_else
+{
+    my ( $self, $src ) = @_;
+    ref $self or $self = $self->_get_instance();
+
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
 
-  my ($fh, $filename) = tempfile("testXXXXXX", SUFFIX => '.c', , UNLINK => 0);
+    my $builder = $self->_get_builder();
 
-  print {$fh} $src;
-  close $fh;
+    my ( $fh, $filename ) = tempfile(
+        "testXXXXXX",
+        SUFFIX => '.c',
+        , UNLINK => 0
+    );
 
-  my ($obj_file, $outbuf, $errbuf, $exception);
-  ($outbuf, $errbuf) = capture {
-    eval {
-      $obj_file = $builder->compile(
-        source => $filename,
-        include_dirs => $self->{extra_include_dirs},
-        extra_compiler_flags => $self->_get_extra_compiler_flags() );
+    print {$fh} $src;
+    close $fh;
+
+    my ( $obj_file, $outbuf, $errbuf, $exception );
+    ( $outbuf, $errbuf ) = capture
+    {
+        eval {
+            $obj_file = $builder->compile(
+                source               => $filename,
+                include_dirs         => $self->{extra_include_dirs},
+                extra_compiler_flags => $self->_get_extra_compiler_flags()
+            );
+        };
+
+        $exception = $@;
     };
 
-    $exception = $@;
-  };
+    unlink $filename;
+    unlink $obj_file if $obj_file;
 
-  unlink $filename;
-  unlink $obj_file if $obj_file;
+    if ( $exception || !$obj_file )
+    {
+        $self->_add_log_lines( "compile stage failed" . ( $exception ? " - " . $exception : "" ) );
+        $errbuf
+          and $self->_add_log_lines($errbuf);
+        $self->_add_log_lines( "failing program is:\n" . $src );
+        $outbuf
+          and $self->_add_log_lines( "stdout was :\n" . $outbuf );
 
-  if ($exception || !$obj_file) {
-    $self->_add_log_lines( "compile stage failed" . ( $exception ? " - " . $exception : "" ) );
-    $errbuf and
-      $self->_add_log_lines( $errbuf );
-    $self->_add_log_lines( "failing program is:\n" . $src );
-    $outbuf and
-      $self->_add_log_lines( "stdout was :\n" . $outbuf );
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and $options->{action_on_false}->();
 
-    defined( $action_if_false ) and "CODE" eq ref( $action_if_false ) and &{$action_if_false}();
-    return 0;
-  }
+        return 0;
+    }
 
-  defined( $action_if_true ) and "CODE" eq ref( $action_if_true ) and &{$action_if_true}();
-  1;
+    $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
+
+    1;
 }
 
-=head2 link_if_else( $src [, action-if-true [, action-if-false ] ] )
+=head2 link_if_else( $src, \%options? )
 
-This function trys to compile and link specified code and runs action-if-true on success
-or action-if-false otherwise.
+This function trys to compile and link specified code and returns a boolean
+value containing check success state.
 
-Returns a boolean value containing check success state.
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
 
 =cut
 
-sub link_if_else {
-  my ($self, $src, $action_if_true, $action_if_false) = @_;
-  ref $self or $self = $self->_get_instance();
-  my $builder = $self->_get_builder();
-
-  my ($fh, $filename) = tempfile( "testXXXXXX", SUFFIX => '.c');
+sub link_if_else
+{
+    my ( $self, $src ) = @_;
+    ref $self or $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my $builder = $self->_get_builder();
+
+    my ( $fh, $filename ) = tempfile( "testXXXXXX", SUFFIX => '.c' );
+
+    print {$fh} $src;
+    close $fh;
+
+    my ( $obj_file, $outbuf, $errbuf, $exception );
+    ( $outbuf, $errbuf ) = capture
+    {
+        eval {
+            $obj_file = $builder->compile(
+                source               => $filename,
+                include_dirs         => $self->{extra_include_dirs},
+                extra_compiler_flags => $self->_get_extra_compiler_flags()
+            );
+        };
+
+        $exception = $@;
+    };
 
-  print {$fh} $src;
-  close $fh;
+    if ( $exception || !$obj_file )
+    {
+        $self->_add_log_lines( "compile stage failed" . ( $exception ? " - " . $exception : "" ) );
+        $errbuf
+          and $self->_add_log_lines($errbuf);
+        $self->_add_log_lines( "failing program is:\n" . $src );
+        $outbuf
+          and $self->_add_log_lines( "stdout was :\n" . $outbuf );
 
-  my ($obj_file, $outbuf, $errbuf, $exception);
-  ($outbuf, $errbuf) = capture {
-    eval {
-      $obj_file = $builder->compile(
-        source => $filename,
-        include_dirs => $self->{extra_include_dirs},
-        extra_compiler_flags => $self->_get_extra_compiler_flags() );
-    };
+        unlink $filename;
+        unlink $obj_file if $obj_file;
 
-    $exception = $@;
-  };
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and $options->{action_on_false}->();
 
-  if ($exception || !$obj_file) {
-    $self->_add_log_lines( "compile stage failed" . ( $exception ? " - " . $exception : "" ) );
-    $errbuf and
-      $self->_add_log_lines( $errbuf );
-    $self->_add_log_lines( "failing program is:\n" . $src );
-    $outbuf and
-      $self->_add_log_lines( "stdout was :\n" . $outbuf );
+        return 0;
+    }
 
+    my $exe_file;
+    ( $outbuf, $errbuf ) = capture
+    {
+        eval {
+            $exe_file = $builder->link_executable(
+                objects            => $obj_file,
+                extra_linker_flags => $self->_get_extra_linker_flags()
+            );
+        };
+
+        $exception = $@;
+    };
     unlink $filename;
     unlink $obj_file if $obj_file;
-    defined( $action_if_false ) and "CODE" eq ref( $action_if_false ) and &{$action_if_false}();
-    return 0;
-  }
-
-  my $exe_file;
-  ($outbuf, $errbuf) = capture {
-    eval {
-      $exe_file = $builder->link_executable(
-        objects => $obj_file,
-        extra_linker_flags => $self->_get_extra_linker_flags() );
-    };
+    unlink $exe_file if $exe_file;
+
+    if ( $exception || !$exe_file )
+    {
+        $self->_add_log_lines( "link stage failed" . ( $exception ? " - " . $exception : "" ) );
+        $errbuf
+          and $self->_add_log_lines($errbuf);
+        $self->_add_log_lines( "failing program is:\n" . $src );
+        $outbuf
+          and $self->_add_log_lines( "stdout was :\n" . $outbuf );
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and $options->{action_on_false}->();
+
+        return 0;
+    }
 
-    $exception = $@;
-  };
-  unlink $filename;
-  unlink $obj_file if $obj_file;
-  unlink $exe_file if $exe_file;
-
-  if ($exception || !$exe_file) {
-    $self->_add_log_lines( "link stage failed" . ( $exception ? " - " . $exception : "" ) );
-    $errbuf and
-      $self->_add_log_lines( $errbuf );
-    $self->_add_log_lines( "failing program is:\n" . $src );
-    $outbuf and
-      $self->_add_log_lines( "stdout was :\n" . $outbuf );
-
-    defined( $action_if_false ) and "CODE" eq ref( $action_if_false ) and &{$action_if_false}();
-    return 0;
-  }
+    $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-  defined( $action_if_true ) and "CODE" eq ref( $action_if_true ) and &{$action_if_true}();
-  1;
+    1;
 }
 
-=head2 check_cached( cache-var, message, sub-to-check )
+=head2 check_cached( $cache-key, $check-title, \&check-call, \%options? )
 
-This function checks whether a specified cache variable is set or not, and if not
-it's going to set it using specified sub-to-check.
+Retrieves the result of a previous L</check_cached> invocation from
+C<cache-key>, or (when called for the first time) populates the cache
+by invoking C<\&check_call>. 
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed on B<every> call
+to check_cached (not just the first cache-populating invocation), respectively.
 
 =cut
 
-sub check_cached {
-  my ($self, $cache_name, $message, $check_sub) = @_;
-  ref $self or $self = $self->_get_instance();
+sub check_cached
+{
+    my ( $self, $cache_name, $message, $check_sub ) = @_;
+    ref $self or $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 4 and ref $_[-1] eq "HASH" and $options = pop @_;
 
-  $self->msg_checking( $message );
+    $self->msg_checking($message);
 
-  defined $ENV{$cache_name} and not defined $self->{cache}->{$cache_name}
-    and $self->{cache}->{$cache_name} = $ENV{$cache_name};
+    defined $ENV{$cache_name}
+      and not defined $self->{cache}->{$cache_name}
+      and $self->{cache}->{$cache_name} = $ENV{$cache_name};
 
-  if( defined($self->{cache}->{$cache_name}) ) {
-    $self->msg_result( "(cached)", $self->{cache}->{$cache_name} );
-  }
-  else {
-    $self->{cache}->{$cache_name} = &{$check_sub}();
-    $self->msg_result( $self->{cache}->{$cache_name} );
-  }
+    my @cached_result;
+    defined( $self->{cache}->{$cache_name} ) and push @cached_result, "(cached)";
+    defined( $self->{cache}->{$cache_name} ) or $self->{cache}->{$cache_name} = $check_sub->();
+
+    $self->msg_result( @cached_result, $self->{cache}->{$cache_name} );
+
+    $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $self->{cache}->{$cache_name}
+      and $options->{action_on_true}->();
+
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$self->{cache}->{$cache_name}
+      and $options->{action_on_false}->();
 
-  $self->{cache}->{$cache_name};
+    $self->{cache}->{$cache_name};
 }
 
 =head2 cache_val
@@ -1045,20 +1250,15 @@ This functions returns the value of a previously check_cached call.
 
 =cut
 
-sub cache_val {
-  my ($self, $cache_name) = @_;
-  ref $self or $self = $self->_get_instance();
-  defined $self->{cache}->{$cache_name} or return;
-  $self->{cache}->{$cache_name};
+sub cache_val
+{
+    my ( $self, $cache_name ) = @_;
+    ref $self or $self = $self->_get_instance();
+    defined $self->{cache}->{$cache_name} or return;
+    $self->{cache}->{$cache_name};
 }
 
-=head2 check_decl( symbol, [action-if-found], [action-if-not-found], [prologue = default includes] )
-
-If symbol (a function, variable or constant) is not declared in includes and
-a declaration is needed, run the code ref given in I<action-if-not-found>,
-otherwise I<action-if-found>. includes is a series of include directives,
-defaulting to I<default includes>, which are used prior to the declaration
-under test.
+=head2 check_decl( $symbol, \%options? )
 
 This method actually tests whether symbol is defined as a macro or can be
 used as an r-value, not whether it is really declared, because it is much
@@ -1067,104 +1267,276 @@ In order to facilitate use of C++ and overloaded function declarations, it
 is possible to specify function argument types in parentheses for types
 which can be zero-initialized:
 
-          Config::AutoConf->check_decl("basename(char *)")
+  Config::AutoConf->check_decl("basename(char *)")
 
-This method caches its result in the C<ac_cv_decl_E<lt>set langE<gt>>_symbol variable.
+This method caches its result in the C<ac_cv_decl_E<lt>set langE<gt>>_symbol
+variable.
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
 
 =cut
 
-sub check_decl {
-  my ($self, $symbol, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-  defined( $symbol ) or return; # XXX prefer croak
-  ref( $symbol ) eq "" or return;
-  ( my $sym_plain = $symbol ) =~ s/ *\(.*//;
-  my $sym_call = $symbol;
-  $sym_call =~ s/\(/((/;
-  $sym_call =~ s/\)/) 0)/;
-  $sym_call =~ s/,/) 0, (/g;
+sub check_decl
+{
+    my ( $self, $symbol ) = @_;
+    $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    defined($symbol)   or return croak("No symbol to check for");
+    ref($symbol) eq "" or return croak("No symbol to check for");
+    ( my $sym_plain = $symbol ) =~ s/ *\(.*//;
+    my $sym_call = $symbol;
+    $sym_call =~ s/\(/((/;
+    $sym_call =~ s/\)/) 0)/;
+    $sym_call =~ s/,/) 0, (/g;
+
+    my $cache_name = $self->_cache_name( "decl", $self->{lang}, $symbol );
+    my $check_sub = sub {
 
-  my $cache_name = $self->_cache_name( "decl", $self->{lang}, $symbol );
-  my $check_sub = sub {
-  
-    my $body = <<ACEOF;
+        my $body = <<ACEOF;
 #ifndef $sym_plain
   (void) $sym_call;
 #endif
 ACEOF
-    my $conftest = $self->lang_build_program( $prologue, $body );
+        my $conftest = $self->lang_build_program( $options->{prologue}, $body );
 
-    my $have_decl = $self->compile_if_else( $conftest );
-    if( $have_decl ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-    }
+        my $have_decl = $self->compile_if_else(
+            $conftest,
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
 
-    $have_decl;
-  };
+        $have_decl;
+    };
 
-  $self->check_cached( $cache_name, "whether $symbol is declared", $check_sub );
+    $self->check_cached(
+        $cache_name,
+        "whether $symbol is declared",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-=head2 check_decls( symbols, [action-if-found], [action-if-not-found], [prologue = default includes] )
+=head2 check_decls( symbols, \%options? )
 
 For each of the symbols (with optional function argument types for C++
-overloads), run L<check_decl>. If I<action-if-not-found> is given, it
-is additional code to execute when one of the symbol declarations is
-needed, otherwise I<action-if-found> is executed.
+overloads), run L<check_decl>.
 
 Contrary to GNU autoconf, this method does not declare HAVE_DECL_symbol
 macros for the resulting C<confdefs.h>, because it differs as C<check_decl>
 between compiling languages.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+Given callbacks for I<action_on_symbol_true> or I<action_on_symbol_false> are
+called for each symbol checked using L</check_decl> receiving the symbol as
+first argument.
+
 =cut
 
-sub check_decls {
-  my ($self, $symbols, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
+sub check_decls
+{
+    my ( $self, $symbols ) = @_;
+    $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $have_syms = 1;
+    foreach my $symbol (@$symbols)
+    {
+        $have_syms &= $self->check_decl(
+            $symbol,
+            {
+                %pass_options,
+                (
+                    $options->{action_on_symbol_true} && "CODE" eq ref $options->{action_on_symbol_true}
+                    ? ( action_on_true => sub { $options->{action_on_symbol_true}->($symbol) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_symbol_false} && "CODE" eq ref $options->{action_on_symbol_false}
+                    ? ( action_on_false => sub { $options->{action_on_symbol_false}->($symbol) } )
+                    : ()
+                ),
+            }
+        );
+    }
 
-  my $have_syms = 1;
-  foreach my $symbol (@$symbols) {
-    $have_syms &= $self->check_decl( $symbol, undef, undef, $prologue );
-  }
+          $have_syms
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-  if( $have_syms ) {
-    if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-      &{$action_if_found}();
-    }
-  }
-  else {
-    if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-      &{$action_if_not_found}();
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_syms
+      and $options->{action_on_false}->();
+
+    $have_syms;
+}
+
+sub _have_func_define_name
+{
+    my $func      = $_[0];
+    my $have_name = "HAVE_" . uc($func);
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    $have_name;
+}
+
+=head2 check_func( $function, \%options? )
+
+This method actually tests whether I<$funcion> can be linked into a program
+trying to call I<$function>.  This method caches its result in the
+ac_cv_func_FUNCTION variable.
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+If any of I<action_on_cache_true>, I<action_on_cache_false> is defined,
+both callbacks are passed to L</check_cached> as I<action_on_true> or
+I<action_on_false> to C<check_cached>, respectively.
+
+Returns: True if the function was found, false otherwise
+
+=cut
+
+sub check_func
+{
+    my ( $self, $function ) = @_;
+    $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    # 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 ),
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
+        $have_func;
+    };
+
+    # Run the check and cache the results.
+    return $self->check_cached(
+        $cache_name,
+        "for $function",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
+}
+
+=head2 check_funcs( \@functions-list, $action-if-true?, $action-if-false? )
+
+The same as check_func, but takes a list of functions in I<\@functions-list>
+to look for and checks for each in turn. Define HAVE_FUNCTION for each
+function that was found.
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+If any of I<action_on_cache_true>, I<action_on_cache_false> is defined,
+both callbacks are passed to L</check_cached> as I<action_on_true> or
+I<action_on_false> to C<check_cached>, respectively.  Given callbacks
+for I<action_on_function_true> or I<action_on_function_false> are called for
+each symbol checked using L</check_func> receiving the symbol as first
+argument.
+
+=cut
+
+sub check_funcs
+{
+    my ( $self, $functions_ref ) = @_;
+    $self = $self->_get_instance();
+
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my %pass_options;
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    # Go through the list of functions and call check_func for each one. We
+    # generate new closures for the found and not-found functions that pass in
+    # the relevant function name.
+    my $have_funcs = 1;
+    for my $function ( @{$functions_ref} )
+    {
+
+        # Build the code reference to run when a function was found. This defines
+        # a HAVE_FUNCTION symbol, plus runs the current $action-if-true if there is
+        # one.
+        $pass_options{action_on_true} = sub {
+            # XXX think about doing this always (move to check_func)
+            $self->define_var( _have_func_define_name($function), 1, "Defined when $function is available" );
+
+            # Run the user-provided hook, if there is one.
+            defined $options->{action_on_function_true}
+              and ref $options->{action_on_function_true} eq "CODE"
+              and $options->{action_on_function_true}->($function);
+        };
+
+        defined $options->{action_on_function_false}
+          and ref $options->{action_on_function_false} eq "CODE"
+          and $pass_options{action_on_false} = sub { $options->{action_on_function_false}->($function); };
+
+        $have_funcs &= check_func( $self, $function, \%pass_options );
     }
-  }
 
-  $have_syms;
+          $have_funcs
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
+
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_funcs
+      and $options->{action_on_false}->();
+
+    return $have_funcs;
 }
 
-sub _have_type_define_name {
-  my $type = $_[0];
-  my $have_name = "HAVE_" . uc($type);
-  $have_name =~ tr/*/P/;
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  $have_name;
+sub _have_type_define_name
+{
+    my $type      = $_[0];
+    my $have_name = "HAVE_" . uc($type);
+    $have_name =~ tr/*/P/;
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    $have_name;
 }
 
-=head2 check_type (type, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_type( $symbol, \%options? )
 
 Check whether type is defined. It may be a compiler builtin type or defined
-by the includes. I<prologue> should be a series of include directives,
-defaulting to I<default includes>, which are used prior to the type under
-test.
-
-In C, type must be a type-name, so that the expression C<sizeof (type)> is
-valid (but C<sizeof ((type))> is not)
+by the includes.  In C, type must be a type-name, so that the expression
+C<sizeof (type)> is valid (but C<sizeof ((type))> is not).
 
 If I<type> type is defined, preprocessor macro HAVE_I<type> (in all
 capitals, with "*" replaced by "P" and spaces and dots replaced by
@@ -1172,226 +1544,328 @@ underscores) is defined.
 
 This method caches its result in the C<ac_cv_type_>type variable.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+
 =cut
 
-sub check_type {
-  my ($self, $type, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-  defined $type or return; # XXX prefer croak
-  ref $type eq "" or return;
+sub check_type
+{
+    my ( $self, $type ) = @_;
+    $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    defined($type)   or return croak("No type to check for");
+    ref($type) eq "" or return croak("No type to check for");
 
-  my $cache_name = $self->_cache_type_name( "type", $type );
-  my $check_sub = sub {
-  
-    my $body = <<ACEOF;
+    my $cache_name = $self->_cache_type_name( "type", $type );
+    my $check_sub = sub {
+
+        my $body = <<ACEOF;
   if( sizeof ($type) )
     return 0;
 ACEOF
-    my $conftest = $self->lang_build_program( $prologue, $body );
-
-    my $have_type = $self->compile_if_else( $conftest );
-    $self->define_var( _have_type_define_name( $type ), $have_type ? $have_type : undef, "defined when $type is available" );
-    if( $have_type ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-    }
-
-    $have_type;
-  };
+        my $conftest = $self->lang_build_program( $options->{prologue}, $body );
+
+        my $have_type = $self->compile_if_else(
+            $conftest,
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
+        $self->define_var( _have_type_define_name($type), $have_type ? $have_type : undef, "defined when $type is available" );
+        $have_type;
+    };
 
-  $self->check_cached( $cache_name, "for $type", $check_sub );
+    $self->check_cached(
+        $cache_name,
+        "for $type",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-=head2 check_types (types, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_types( \@type-list, \%options? )
 
-For each type L<check_type> is called to check for type.
+For each type in I<@type-list>, call L<check_type> is called to check
+for type and return the accumulated result (accumulation op is binary and).
 
-If I<action-if-found> is given, it is additionally executed when all of the
-types are found. If I<action-if-not-found> is given, it is executed when one
-of the types is not found.
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+Given callbacks for I<action_on_type_true> or I<action_on_type_false> are
+called for each symbol checked using L</check_type> receiving the symbol as
+first argument.
 
 =cut
 
-sub check_types {
-  my ($self, $types, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
+sub check_types
+{
+    my ( $self, $types ) = @_;
+    $self = $self->_get_instance();
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $have_types = 1;
+    foreach my $type (@$types)
+    {
+        $have_types &= $self->check_type(
+            $type,
+            {
+                %pass_options,
+                (
+                    $options->{action_on_type_true} && "CODE" eq ref $options->{action_on_type_true}
+                    ? ( action_on_true => sub { $options->{action_on_type_true}->($type) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_type_false} && "CODE" eq ref $options->{action_on_type_false}
+                    ? ( action_on_false => sub { $options->{action_on_type_false}->($type) } )
+                    : ()
+                ),
+            }
+        );
+    }
 
-  my $have_types = 1;
-  foreach my $type (@$types) {
-    $have_types &= $self->check_type( $type, undef, undef, $prologue );
-  }
+          $have_types
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-  if( $have_types ) {
-    if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-      &{$action_if_found}();
-    }
-  }
-  else {
-    if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-      &{$action_if_not_found}();
-    }
-  }
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_types
+      and $options->{action_on_false}->();
 
-  $have_types;
-}
-
-sub _compute_int_compile {
-  my ($self, $expr, $prologue, @decls) = @_;
-  $self = $self->_get_instance();
-
-  my( $body, $conftest, $compile_result );
-
-  my ($low, $mid, $high) = (0, 0, 0);
-  if( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) >= 0", @decls ) ) ) {
-    $low = $mid = 0;
-    while( 1 ) {
-      if( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) <= $mid", @decls ) ) ) {
-	$high = $mid;
-	last;
-      }
-      $low = $mid + 1;
-      # avoid overflow
-      if( $low <= $mid ) {
-	$low = 0;
-	last;
-      }
-      $mid = $low * 2;
-    }
-  }
-  elsif( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) < 0", @decls ) ) ) {
-    $high = $mid = -1;
-    while( 1 ) {
-      if( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) >= $mid", @decls ) ) ) {
-	$low = $mid;
-	last;
-      }
-      $high = $mid - 1;
-      # avoid overflow
-      if( $mid < $high ) {
-	$high = 0;
-	last;
-      }
-      $mid = $high * 2;
-    }
-  }
+    $have_types;
+}
 
-  # perform binary search between $low and $high
-  while( $low <= $high ) {
-    $mid = int( ( $high - $low ) / 2 + $low );
-    if( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) < $mid", @decls ) ) ) {
-      $high = $mid - 1;
+sub _compute_int_compile
+{
+    my ( $self, $expr, $prologue, @decls ) = @_;
+    $self = $self->_get_instance();
+
+    my ( $body, $conftest, $compile_result );
+
+    my ( $low, $mid, $high ) = ( 0, 0, 0 );
+    if ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) >= 0", @decls ) ) )
+    {
+        $low = $mid = 0;
+        while (1)
+        {
+            if ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) <= $mid", @decls ) ) )
+            {
+                $high = $mid;
+                last;
+            }
+            $low = $mid + 1;
+            # avoid overflow
+            if ( $low <= $mid )
+            {
+                $low = 0;
+                last;
+            }
+            $mid = $low * 2;
+        }
     }
-    elsif( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) > $mid", @decls ) ) ) {
-      $low = $mid + 1;
+    elsif ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) < 0", @decls ) ) )
+    {
+        $high = $mid = -1;
+        while (1)
+        {
+            if ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) >= $mid", @decls ) ) )
+            {
+                $low = $mid;
+                last;
+            }
+            $high = $mid - 1;
+            # avoid overflow
+            if ( $mid < $high )
+            {
+                $high = 0;
+                last;
+            }
+            $mid = $high * 2;
+        }
     }
-    else {
-      return $mid;
+
+    # perform binary search between $low and $high
+    while ( $low <= $high )
+    {
+        $mid = int( ( $high - $low ) / 2 + $low );
+        if ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) < $mid", @decls ) ) )
+        {
+            $high = $mid - 1;
+        }
+        elsif ( $self->compile_if_else( $self->lang_build_bool_test( $prologue, "((long int)($expr)) > $mid", @decls ) ) )
+        {
+            $low = $mid + 1;
+        }
+        else
+        {
+            return $mid;
+        }
     }
-  }
 
-  return;
+    return;
 }
 
-=head2 compute_int (expression, [action-if-fails], [prologue = default includes], [@decls])
+=head2 compute_int( $expression, @decls?, \%options )
 
 Returns the value of the integer I<expression>. The value should fit in an
 initializer in a C variable of type signed long.  It should be possible
 to evaluate the expression at compile-time. If no includes are specified,
 the default includes are used.
 
-Execute I<action-if-fails> if the value cannot be determined correctly.
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
 
 =cut
 
-sub compute_int {
-  my ($self, $expr, $action_if_fails, $prologue, @decls) = @_;
-  $self = $self->_get_instance();
+sub compute_int
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $expr, @decls ) = @_;
+    $self = $self->_get_instance();
 
-  my $cache_name = $self->_cache_type_name( "compute_int", $self->{lang}, $expr );
-  my $check_sub = sub {
+    my $cache_name = $self->_cache_type_name( "compute_int", $self->{lang}, $expr );
+    my $check_sub = sub {
+        my $val = $self->_compute_int_compile( $expr, $options->{prologue}, @decls );
 
-    my $val = $self->_compute_int_compile( $expr, $prologue, @decls);
-    unless( defined( $val ) ) {
-      if( defined( $action_if_fails ) and "CODE" eq ref( $action_if_fails ) ) {
-	&{$action_if_fails}();
-      }
-    }
+        defined $val
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
 
-    $val;
-  };
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !defined $val
+          and $options->{action_on_false}->();
 
-  $self->check_cached( $cache_name, "for compute result of ($expr)", $check_sub );
+        $val;
+    };
+
+    $self->check_cached(
+        $cache_name,
+        "for compute result of ($expr)",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-sub _sizeof_type_define_name {
-  my $type = $_[0];
-  my $have_name = "SIZEOF_" . uc($type);
-  $have_name =~ tr/*/P/;
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  $have_name;
+sub _sizeof_type_define_name
+{
+    my $type      = $_[0];
+    my $have_name = "SIZEOF_" . uc($type);
+    $have_name =~ tr/*/P/;
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    $have_name;
 }
 
-=head2 check_sizeof_type (type, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_sizeof_type( $type, \%options? )
 
-Checks for the size of the specified type by compiling. If no size can
-determined, I<action-if-not-found> is invoked when given. Otherwise
-I<action-if-found> is invoked and C<SIZEOF_type> is defined using the
-determined size.
+Checks for the size of the specified type by compiling and define
+C<SIZEOF_type> using the determined size.
 
 In opposition to GNU AutoConf, this method can determine size of structure
 members, eg.
 
-  $ac->check_sizeof_type( "SV.sv_refcnt", undef, undef, $include_perl );
+  $ac->check_sizeof_type( "SV.sv_refcnt", { prologue => $include_perl } );
   # or
-  $ac->check_sizeof_type( "struct utmpx.ut_id", undef, undef, "#include <utmpx.h>" );
+  $ac->check_sizeof_type( "struct utmpx.ut_id", { prologue => "#include <utmpx.h>" } );
 
 This method caches its result in the C<ac_cv_sizeof_E<lt>set langE<gt>>_type variable.
 
-=cut
-
-sub check_sizeof_type {
-  my ($self, $type, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-  defined( $type ) or return; # XXX prefer croak
-  ref( $type ) eq "" or return;
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
 
-  my $cache_name = $self->_cache_type_name( "sizeof", $self->{lang}, $type );
-  my $check_sub = sub {
-
-    my @decls;
-    if( $type =~ m/^([^.]+)\.([^.]+)$/ ) {
-      my $struct = $1;
-      $type = "_ac_test_aggr.$2";
-      my $decl = "static $struct _ac_test_aggr;";
-      push( @decls, $decl );
-    }
-  
-    my $typesize = $self->_compute_int_compile( "sizeof($type)", $prologue, @decls );
-    $self->define_var( _sizeof_type_define_name( $type ), $typesize ? $typesize : undef, "defined when sizeof($type) is available" );
-    if( $typesize ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-    }
+=cut
 
-    $typesize;
-  };
+sub check_sizeof_type
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $type ) = @_;
+    $self = $self->_get_instance();
+    defined($type)   or return croak("No type to check for");
+    ref($type) eq "" or return croak("No type to check for");
+
+    my $cache_name = $self->_cache_type_name( "sizeof", $self->{lang}, $type );
+    my $check_sub = sub {
+        my @decls;
+        if ( $type =~ m/^([^.]+)\.([^.]+)$/ )
+        {
+            my $struct = $1;
+            $type = "_ac_test_aggr.$2";
+            my $decl = "static $struct _ac_test_aggr;";
+            push( @decls, $decl );
+        }
+
+        my $typesize = $self->_compute_int_compile( "sizeof($type)", $options->{prologue}, @decls );
+        $self->define_var(
+            _sizeof_type_define_name($type),
+            $typesize ? $typesize : undef,
+            "defined when sizeof($type) is available"
+        );
+
+              $typesize
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !$typesize
+          and $options->{action_on_false}->();
+
+        $typesize;
+    };
 
-  $self->check_cached( $cache_name, "for size of $type", $check_sub );
+    $self->check_cached(
+        $cache_name,
+        "for size of $type",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-=head2 check_sizeof_types (type, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_sizeof_types( type, \%options? )
 
 For each type L<check_sizeof_type> is called to check for size of type.
 
@@ -1399,42 +1873,79 @@ If I<action-if-found> is given, it is additionally executed when all of the
 sizes of the types could determined. If I<action-if-not-found> is given, it
 is executed when one size of the types could not determined.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+Given callbacks for I<action_on_size_true> or I<action_on_size_false> are
+called for each symbol checked using L</check_sizeof_type> receiving the
+symbol as first argument.
+
 =cut
 
-sub check_sizeof_types {
-  my ($self, $types, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
+sub check_sizeof_types
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $types ) = @_;
+    $self = $self->_get_instance();
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $have_sizes = 1;
+    foreach my $type (@$types)
+    {
+        $have_sizes &= !!(
+            $self->check_sizeof_type(
+                $type,
+                {
+                    %pass_options,
+                    (
+                        $options->{action_on_size_true} && "CODE" eq ref $options->{action_on_size_true}
+                        ? ( action_on_true => sub { $options->{action_on_size_true}->($type) } )
+                        : ()
+                    ),
+                    (
+                        $options->{action_on_size_false} && "CODE" eq ref $options->{action_on_size_false}
+                        ? ( action_on_false => sub { $options->{action_on_size_false}->($type) } )
+                        : ()
+                    ),
+                }
+            )
+        );
+    }
 
-  my $have_sizes = 1;
-  foreach my $type (@$types) {
-    $have_sizes &= ! ! ($self->check_sizeof_type ( $type, undef, undef, $prologue ));
-  }
+          $have_sizes
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-  if( $have_sizes ) {
-    if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-      &{$action_if_found}();
-    }
-  }
-  else {
-    if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-      &{$action_if_not_found}();
-    }
-  }
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_sizes
+      and $options->{action_on_false}->();
 
-  $have_sizes;
+    $have_sizes;
 }
 
-sub _alignof_type_define_name {
-  my $type = $_[0];
-  my $have_name = "ALIGNOF_" . uc($type);
-  $have_name =~ tr/*/P/;
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  $have_name;
+sub _alignof_type_define_name
+{
+    my $type      = $_[0];
+    my $have_name = "ALIGNOF_" . uc($type);
+    $have_name =~ tr/*/P/;
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    $have_name;
 }
 
-=head2 check_alignof_type (type, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_alignof_type( type, \%options? )
 
-Define ALIGNOF_type to be the alignment in bytes of type. I<type y;> must
+Define ALIGNOF_type to be the alignment in bytes of type. I<type> must
 be valid as a structure member declaration or I<type> must be a structure
 member itself.
 
@@ -1442,55 +1953,77 @@ This method caches its result in the C<ac_cv_alignof_E<lt>set langE<gt>>_type
 variable, with I<*> mapped to C<p> and other characters not suitable for a
 variable name mapped to underscores.
 
-=cut
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
 
-sub check_alignof_type {
-  my ($self, $type, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-  defined( $type ) or return; # XXX prefer croak
-  ref( $type ) eq "" or return;
+=cut
 
-  my $cache_name = $self->_cache_type_name( "alignof", $self->{lang}, $type );
-  my $check_sub = sub {
+sub check_alignof_type
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $type ) = @_;
+    $self = $self->_get_instance();
+    defined($type)   or return croak("No type to check for");
+    ref($type) eq "" or return croak("No type to check for");
+
+    my $cache_name = $self->_cache_type_name( "alignof", $self->{lang}, $type );
+    my $check_sub = sub {
+        my @decls = (
+            "#ifndef offsetof",
+            "# ifdef __ICC",
+            "#  define offsetof(type,memb) ((size_t)(((char *)(&((type*)0)->memb)) - ((char *)0)))",
+            "# else", "#  define offsetof(type,memb) ((size_t)&((type*)0)->memb)",
+            "# endif", "#endif"
+        );
+
+        my ( $struct, $memb );
+        if ( $type =~ m/^([^.]+)\.([^.]+)$/ )
+        {
+            $struct = $1;
+            $memb   = $2;
+        }
+        else
+        {
+            push( @decls, "typedef struct { char x; $type y; } ac__type_alignof_;" );
+            $struct = "ac__type_alignof_";
+            $memb   = "y";
+        }
+
+        my $typealign = $self->_compute_int_compile( "offsetof($struct, $memb)", $options->{prologue}, @decls );
+        $self->define_var(
+            _alignof_type_define_name($type),
+            $typealign ? $typealign : undef,
+            "defined when alignof($type) is available"
+        );
+
+              $typealign
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !$typealign
+          and $options->{action_on_false}->();
+
+        $typealign;
+    };
 
-    my @decls = (
-      "#ifndef offsetof",
-      "# ifdef __ICC",
-      "#  define offsetof(type,memb) ((size_t)(((char *)(&((type*)0)->memb)) - ((char *)0)))",
-      "# else",
-      "#  define offsetof(type,memb) ((size_t)&((type*)0)->memb)",
-      "# endif",
-      "#endif"
+    $self->check_cached(
+        $cache_name,
+        "for align of $type",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
     );
-
-    my ($struct, $memb);
-    if( $type =~ m/^([^.]+)\.([^.]+)$/ ) {
-      $struct = $1;
-      $memb = $2;
-    }
-    else {
-      push( @decls, "typedef struct { char x; $type y; } ac__type_alignof_;" );
-      $struct = "ac__type_alignof_";
-      $memb = "y";
-    }
-  
-    my $typealign = $self->_compute_int_compile( "offsetof($struct, $memb)", $prologue, @decls );
-    $self->define_var( _alignof_type_define_name( $type ), $typealign ? $typealign : undef, "defined when alignof($type) is available" );
-    if( $typealign ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-    }
-
-    $typealign;
-  };
-
-  $self->check_cached( $cache_name, "for align of $type", $check_sub );
 }
 
 =head2 check_alignof_types (type, [action-if-found], [action-if-not-found], [prologue = default includes])
@@ -1501,50 +2034,88 @@ If I<action-if-found> is given, it is additionally executed when all of the
 aligns of the types could determined. If I<action-if-not-found> is given, it
 is executed when one align of the types could not determined.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+Given callbacks for I<action_on_align_true> or I<action_on_align_false> are
+called for each symbol checked using L</check_alignof_type> receiving the
+symbol as first argument.
+
 =cut
 
-sub check_alignof_types {
-  my ($self, $types, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
+sub check_alignof_types
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $types ) = @_;
+    $self = $self->_get_instance();
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $have_aligns = 1;
+    foreach my $type (@$types)
+    {
+        $have_aligns &= !!(
+            $self->check_alignof_type(
+                $type,
+                {
+                    %pass_options,
+                    (
+                        $options->{action_on_align_true} && "CODE" eq ref $options->{action_on_align_true}
+                        ? ( action_on_true => sub { $options->{action_on_align_true}->($type) } )
+                        : ()
+                    ),
+                    (
+                        $options->{action_on_align_false} && "CODE" eq ref $options->{action_on_align_false}
+                        ? ( action_on_false => sub { $options->{action_on_align_false}->($type) } )
+                        : ()
+                    ),
+                }
+            )
+        );
+    }
 
-  my $have_aligns = 1;
-  foreach my $type (@$types) {
-    $have_aligns &= ! ! ($self->check_alignof_type ( $type, undef, undef, $prologue ));
-  }
+          $have_aligns
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-  if( $have_aligns ) {
-    if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-      &{$action_if_found}();
-    }
-  }
-  else {
-    if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-      &{$action_if_not_found}();
-    }
-  }
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_aligns
+      and $options->{action_on_false}->();
 
-  $have_aligns;
+    $have_aligns;
 }
 
-sub _have_member_define_name {
-  my $member = $_[0];
-  my $have_name = "HAVE_" . uc($member);
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  $have_name;
+sub _have_member_define_name
+{
+    my $member    = $_[0];
+    my $have_name = "HAVE_" . uc($member);
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    $have_name;
 }
 
-=head2 check_member (member, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_member( member, \%options? )
 
 Check whether I<member> is in form of I<aggregate>.I<member> and
-I<member> is a member of the I<aggregate> aggregate. I<prologue>
-should be a series of include directives, defaulting to
-I<default includes>, which are used prior to the aggregate under test.
+I<member> is a member of the I<aggregate> aggregate.
+
+which are used prior to the aggregate under test.
 
   Config::AutoConf->check_member(
     "struct STRUCT_SV.sv_refcnt",
-    undef,
-    sub { Config::AutoConf->msg_failure( "sv_refcnt member required for struct STRUCT_SV" ); }
-    "#include <EXTERN.h>\n#include <perl.h>"
+    {
+      action_on_false => sub { Config::AutoConf->msg_failure( "sv_refcnt member required for struct STRUCT_SV" ); },
+      prologue => "#include <EXTERN.h>\n#include <perl.h>"
+    }
   );
 
 If I<aggregate> aggregate has I<member> member, preprocessor
@@ -1553,113 +2124,153 @@ and dots replaced by underscores) is defined.
 
 This macro caches its result in the C<ac_cv_>aggr_member variable.
 
-=cut
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
 
-sub check_member {
-  my ($self, $member, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-  defined( $member ) or return; # XXX prefer croak
-  ref( $member ) eq "" or return;
+=cut
 
-  $member =~ m/^([^.]+)\.([^.]+)$/ or return;
-  my $type = $1;
-  $member = $2;
+sub check_member
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $member ) = @_;
+    $self = $self->_get_instance();
+    defined($member)   or return croak("No type to check for");
+    ref($member) eq "" or return croak("No type to check for");
+
+    $member =~ m/^([^.]+)\.([^.]+)$/ or return croak("check_member(\"struct foo.member\", \%options)");
+    my $type = $1;
+    $member = $2;
+
+    my $cache_name = $self->_cache_type_name( "member", $type );
+    my $check_sub = sub {
 
-  my $cache_name = $self->_cache_type_name( "member", $type );
-  my $check_sub = sub {
-  
-    my $body = <<ACEOF;
+        my $body = <<ACEOF;
   static $type check_aggr;
   if( check_aggr.$member )
     return 0;
 ACEOF
-    my $conftest = $self->lang_build_program( $prologue, $body );
-
-    my $have_member = $self->compile_if_else( $conftest );
-    $self->define_var( _have_member_define_name( $member ), $have_member ? $have_member : undef, "defined when $member is available" );
-    if( $have_member ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-    }
-
-    $have_member;
-  };
+        my $conftest = $self->lang_build_program( $options->{prologue}, $body );
+
+        my $have_member = $self->compile_if_else(
+            $conftest,
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
+        $self->define_var(
+            _have_member_define_name($member),
+            $have_member ? $have_member : undef,
+            "defined when $member is available"
+        );
+        $have_member;
+    };
 
-  $self->check_cached( $cache_name, "for $type.$member", $check_sub );
+    $self->check_cached(
+        $cache_name,
+        "for $type.$member",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-=head2 check_members (members, [action-if-found], [action-if-not-found], [prologue = default includes])
+=head2 check_members( members, \%options? )
 
 For each member L<check_member> is called to check for member of aggregate.
 
-If I<action-if-found> is given, it is additionally executed when all of the
-aggregate members are found. If I<action-if-not-found> is given, it is
-executed when one of the aggregate members is not found.
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be favoured
+over C<default includes> (represented by L</_default_includes>). If any of
+I<action_on_cache_true>, I<action_on_cache_false> is defined, both callbacks
+are passed to L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+Given callbacks for I<action_on_member_true> or I<action_on_member_false> are
+called for each symbol checked using L</check_member> receiving the symbol as
+first argument.
 
 =cut
 
-sub check_members {
-  my ($self, $members, $action_if_found, $action_if_not_found, $prologue) = @_;
-  $self = $self->_get_instance();
-
-  my $have_members = 1;
-  foreach my $member (@$members) {
-    $have_members &= $self->check_member( $member, undef, undef, $prologue );
-  }
-
-  if( $have_members ) {
-    if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-      &{$action_if_found}();
-    }
-  }
-  else {
-    if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-      &{$action_if_not_found}();
+sub check_members
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $members ) = @_;
+    $self = $self->_get_instance();
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $have_members = 1;
+    foreach my $member (@$members)
+    {
+        $have_members &= !!(
+            $self->check_member(
+                $member,
+                {
+                    %pass_options,
+                    (
+                        $options->{action_on_member_true} && "CODE" eq ref $options->{action_on_member_true}
+                        ? ( action_on_true => sub { $options->{action_on_member_true}->($member) } )
+                        : ()
+                    ),
+                    (
+                        $options->{action_on_member_false} && "CODE" eq ref $options->{action_on_member_false}
+                        ? ( action_on_false => sub { $options->{action_on_member_false}->($member) } )
+                        : ()
+                    ),
+                }
+            )
+        );
     }
-  }
-
-  $have_members;
-}
 
-=head2 check_headers
-
-This function uses check_header to check if a set of include files exist in the system and can
-be included and compiled by the available compiler. Returns the name of the first header file found.
+          $have_members
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
 
-=cut
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$have_members
+      and $options->{action_on_false}->();
 
-sub check_headers {
-  my $self = shift;
-  $self->check_header($_) and return $_ for(@_);
-  return;
+    $have_members;
 }
 
-sub _have_header_define_name {
-  my $header = $_[0];
-  my $have_name = "HAVE_" . uc($header);
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  return $have_name;
+sub _have_header_define_name
+{
+    my $header    = $_[0];
+    my $have_name = "HAVE_" . uc($header);
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    return $have_name;
 }
 
-sub _check_header {
-  my ($self, $header, $prologue, $body) = @_;
+sub _check_header
+{
+    my $options = {};
+    scalar @_ > 4 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $header, $prologue, $body ) = @_;
 
-  $prologue .= <<"_ACEOF";
+    $prologue .= <<"_ACEOF";
     #include <$header>
 _ACEOF
-  my $conftest = $self->lang_build_program( $prologue, $body );
+    my $conftest = $self->lang_build_program( $prologue, $body );
 
-  my $have_header = $self->compile_if_else( $conftest );
-  $have_header;
+    $self->compile_if_else( $conftest, $options );
 }
 
-=head2 check_header
+=head2 check_header( $header, \%options? )
 
 This function is used to check if a specific header file is present in
 the system: if we detect it and if we can compile anything with that
@@ -1673,43 +2284,138 @@ The standard usage for this module is:
 This function will return a true value (1) on success, and a false value
 if the header is not present or not available for common usage.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+When a I<prologue> exists in the optional hash at end, it will be prepended
+to the tested header. If any of I<action_on_cache_true>,
+I<action_on_cache_false> is defined, both callbacks are passed to
+L</check_cached> as I<action_on_true> or I<action_on_false> to
+C<check_cached>, respectively.
+
 =cut
 
-sub check_header {
-  my $self = shift;
-  my $header = shift;
-  my $pre_inc = shift;
+sub check_header
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $header ) = @_;
+    $self = $self->_get_instance();
+    defined($header)   or return croak("No type to check for");
+    ref($header) eq "" or return croak("No type to check for");
+
+    return 0 unless $header;
+    my $cache_name = $self->_cache_name($header);
+    my $check_sub  = sub {
+        my $prologue = defined $options->{prologue} ? $options->{prologue} : "";
+
+        my $have_header = $self->_check_header(
+            $header,
+            $prologue,
+            "",
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
+        $self->define_var(
+            _have_header_define_name($header),
+            $have_header ? $have_header : undef,
+            "defined when $header is available"
+        );
+
+        $have_header;
+    };
 
-  return 0 unless $header;
-  my $cache_name = $self->_cache_name( $header );
-  my $check_sub = sub {
-    my $prologue  = "";
-    defined $pre_inc
-      and $prologue .= "$pre_inc\n";
+    $self->check_cached(
+        $cache_name,
+        "for $header",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
+}
 
-    my $have_header = $self->_check_header( $header, $prologue, "" );
-    $self->define_var( _have_header_define_name( $header ), $have_header ? $have_header : undef, "defined when $header is available" );
+=head2 check_headers
 
-    return $have_header;
-  };
+This function uses check_header to check if a set of include files exist
+in the system and can be included and compiled by the available compiler.
+Returns the name of the first header file found.
+
+Passes an optional \%options hash to each L</check_header> call.
+
+=cut
 
-  $self->check_cached( $cache_name, "for $header", $check_sub );
+sub check_headers
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+    $self->check_header( $_, $options ) and return $_ for (@_);
+    return;
 }
 
 =head2 check_all_headers
 
-This function checks each given header for usability.
+This function checks each given header for usability and returns true
+when each header can be used -- otherwise false.
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+Each of existing key/value pairs using I<prologue>, I<action_on_cache_true>
+or I<action_on_cache_false> as key are passed throuh to each call of
+L</check_header>.
+Given callbacks for I<action_on_header_true> or I<action_on_header_false> are
+called for each symbol checked using L</check_header> receiving the symbol as
+first argument.
 
 =cut
 
-sub check_all_headers {
-  my $self = shift->_get_instance();
-  @_ or return;
-  my $rc = 1;
-  foreach my $header (@_) {
-    $rc &= $self->check_header( $header );
-  }
-  $rc;
+sub check_all_headers
+{
+    my $options = {};
+    scalar @_ > 2 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+    @_ or return;
+
+    my %pass_options;
+    defined $options->{prologue}              and $pass_options{prologue}              = $options->{prologue};
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+
+    my $all_headers = 1;
+    foreach my $header (@_)
+    {
+        $all_headers &= $self->check_header(
+            $header,
+            {
+                %pass_options,
+                (
+                    $options->{action_on_header_true} && "CODE" eq ref $options->{action_on_header_true}
+                    ? ( action_on_true => sub { $options->{action_on_header_true}->($header) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_header_false} && "CODE" eq ref $options->{action_on_header_false}
+                    ? ( action_on_false => sub { $options->{action_on_header_false}->($header) } )
+                    : ()
+                ),
+            }
+        );
+    }
+
+          $all_headers
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
+
+    $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and !$all_headers
+      and $options->{action_on_false}->();
+
+    $all_headers;
 }
 
 =head2 check_stdc_headers
@@ -1721,31 +2427,41 @@ stdio.h and time.h.
 
 Returns a false value if it fails.
 
+Passes an optional \%options hash to each L</check_all_headers> call.
+
 =cut
 
-sub check_stdc_headers {
-  my $self = shift->_get_instance();
-  my $rc = 0;
-  if( $rc = $self->check_all_headers( qw(stdlib.h stdarg.h string.h float.h) ) ) {
-    $rc &= $self->check_all_headers( qw/assert.h ctype.h errno.h limits.h/ );
-    $rc &= $self->check_all_headers( qw/locale.h math.h setjmp.h signal.h/ );
-    $rc &= $self->check_all_headers( qw/stddef.h stdio.h time.h/ );
-  }
-  $rc and $self->define_var( "STDC_HEADERS", 1, "Define to 1 if you have the ANSI C header files." );
-  $rc;
+my @ansi_c_headers = qw(stdlib stdarg string float assert ctype errno limits locale math setjmp signal stddef stdio time);
+
+sub check_stdc_headers
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+
+    # XXX for C++ the map should look like "c${_}" ...
+    my @c_ansi_c_headers = map { "${_}.h" } @ansi_c_headers;
+    my $rc = $self->check_all_headers( @c_ansi_c_headers, $options );
+    $rc and $self->define_var( "STDC_HEADERS", 1, "Define to 1 if you have the ANSI C header files." );
+    $rc;
 }
 
 =head2 check_default_headers
 
-This function checks for some default headers, the std c89 haeders and
+This function checks for some default headers, the std c89 headers and
 sys/types.h, sys/stat.h, memory.h, strings.h, inttypes.h, stdint.h and unistd.h
 
+Passes an optional \%options hash to each L</check_all_headers> call.
+
 =cut
 
-sub check_default_headers {
-  my $self = shift->_get_instance();
-  my $rc = $self->check_stdc_headers() and $self->check_all_headers( qw(sys/types.h sys/stat.h memory.h strings.h inttypes.h stdint.h unistd.h) );
-  $rc;
+sub check_default_headers
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+    $self->check_stdc_headers($options)
+      and $self->check_all_headers( qw(sys/types.h sys/stat.h memory.h strings.h inttypes.h stdint.h unistd.h), $options );
 }
 
 =head2 check_dirent_header
@@ -1784,171 +2500,261 @@ type C<struct dirent>, not C<struct direct>, and would access the length
 of a directory entry name by passing a pointer to a C<struct dirent> to
 the C<NAMLEN> macro.
 
-This macro might be obsolescent, as all current systems with directory
+This method might be obsolescent, as all current systems with directory
 libraries have C<<E<lt>dirent.hE<gt>>>. Programs supporting only newer OS
-might not need touse this macro.
+might not need touse this method.
 
-=cut
-
-sub check_dirent_header {
-  my $self = shift->_get_instance();
-
-  my $cache_name = $self->_cache_name( "header_dirent" );
-  my $check_sub = sub {
-
-    my $have_dirent;
-    foreach my $header (qw(dirent.h sys/ndir.h sys/dir.h ndir.h)) {
-      $have_dirent = $self->_check_header( $header, "#include <sys/types.h>\n", "if ((DIR *) 0) { return 0; }" );
-      $self->define_var( _have_header_define_name( $header ), $have_dirent ? $have_dirent : undef, "defined when $header is available" );
-      $have_dirent and $have_dirent = $header and last;
-    }
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+Each of existing key/value pairs using I<prologue>, I<action_on_header_true>
+(as I<action_on_true> having the name of the tested header as first argument)
+or I<action_on_header_false> (as I<action_on_false> having the name of the
+tested header as first argument) as key are passed throuh to each call of
+L</_check_header>.
+Given callbacks for I<action_on_cache_true> or I<action_on_cache_false> are
+passed to the call of L</check_cached>.
 
-    $have_dirent;
-  };
+=cut
 
+sub check_dirent_header
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+
+    my %pass_options;
+    defined $options->{prologue} and $pass_options{prologue} = $options->{prologue};
+
+    my $cache_name = $self->_cache_name("header_dirent");
+    my $check_sub  = sub {
+        my $have_dirent;
+        foreach my $header (qw(dirent.h sys/ndir.h sys/dir.h ndir.h))
+        {
+            $have_dirent = $self->_check_header(
+                $header,
+                "#include <sys/types.h>\n",
+                "if ((DIR *) 0) { return 0; }",
+                {
+                    %pass_options,
+                    (
+                        $options->{action_on_header_true} && "CODE" eq ref $options->{action_on_header_true}
+                        ? ( action_on_true => sub { $options->{action_on_header_true}->($header) } )
+                        : ()
+                    ),
+                    (
+                        $options->{action_on_header_false} && "CODE" eq ref $options->{action_on_header_false}
+                        ? ( action_on_false => sub { $options->{action_on_header_false}->($header) } )
+                        : ()
+                    ),
+                }
+            );
+            $self->define_var(
+                _have_header_define_name($header),
+                $have_dirent ? $have_dirent : undef,
+                "defined when $header is available"
+            );
+            $have_dirent and $have_dirent = $header and last;
+        }
+
+              $have_dirent
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !$have_dirent
+          and $options->{action_on_false}->();
+
+        $have_dirent;
+    };
 
-  $self->check_cached( $cache_name, "for header defining DIR *", $check_sub );
-}
+    my $dirent_header = $self->check_cached(
+        $cache_name,
+        "for header defining DIR *",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on__true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on__false => $options->{action_on_cache_false} ) : () ),
+        }
+    );
 
-sub _have_lib_define_name {
-  my $lib = $_[0];
-  my $have_name = "HAVE_LIB" . uc($lib);
-  $have_name =~ tr/_A-Za-z0-9/_/c;
-  return $have_name;
+    $dirent_header;
 }
 
-=head2 _check_perl_api_program
+=head2 _check_perlapi_program
 
 This method provides the program source which is suitable to do basic
 compile/link tests to prove perl development environment.
 
 =cut
 
-sub _check_perl_api_program {
-  my $self = shift;
+sub _check_perlapi_program
+{
+    my $self = shift;
 
-  my $includes = $self->_default_includes_with_perl();
-  my $perl_check_body = <<'EOB';
+    my $includes        = $self->_default_includes_with_perl();
+    my $perl_check_body = <<'EOB';
   I32 rc;
   SV *foo = newSVpv("Perl rocks", 11);
   rc = SvCUR(foo);
 EOB
-  $self->lang_build_program( $includes, $perl_check_body );
+    $self->lang_build_program( $includes, $perl_check_body );
 }
 
-=head2 _check_compile_perl_api
+=head2 _check_compile_perlapi
 
 This method can be used from other checks to prove whether we have a perl
 development environment or not (perl.h, reasonable basic checks - types, etc.)
 
 =cut
 
-sub _check_compile_perl_api {
-  my $self = shift;
+sub _check_compile_perlapi
+{
+    my $self = shift;
 
-  my $conftest = $self->_check_perl_api_program();
-  $self->compile_if_else($conftest);
+    my $conftest = $self->_check_perlapi_program();
+    $self->compile_if_else($conftest);
 }
 
-=head2 check_compile_perl_api
+=head2 check_compile_perlapi
 
 This method can be used from other checks to prove whether we have a perl
 development environment or not (perl.h, reasonable basic checks - types, etc.)
 
 =cut
 
-sub check_compile_perl_api {
-  my $self = shift->_get_instance;
-  my $cache_name = $self->_cache_name(qw(compile perl api));
+sub check_compile_perlapi
+{
+    my $self       = shift->_get_instance;
+    my $cache_name = $self->_cache_name(qw(compile perlapi));
 
-  $self->check_cached( $cache_name,
-    "whether perl api is accessible",
-    sub { $self->_check_compile_perl_api } );
+    $self->check_cached( $cache_name, "whether perlapi is accessible", sub { $self->_check_compile_perlapi } );
 }
 
-=head2 _check_link_perl_api
-
-This method can be used from other checks to prove whether we have a perl
-development environment including a suitable libperl or not (perl.h,
-reasonable basic checks - types, etc.)
+=head2 check_compile_perlapi_or_die
 
-Caller must ensure that the linker flags are set appropriate (C<-lperl>
-or similar).
+Dies when not being able to compile using the Perl API
 
 =cut
 
-sub _check_link_perl_api {
-  my $self = shift;
+sub check_compile_perlapi_or_die
+{
+    my $self = shift;
+    $self->check_compile_perlapi(@_) or $self->msg_error("Cannot use Perl API - giving up");
+}
 
-  my $conftest = $self->_check_perl_api_program();
-  my @save_libs = @{$self->{extra_libs}};
-  my @save_extra_link_flags = @{$self->{extra_link_flags}};
+=head2 check_linkable_xs_so
 
-  push @{$self->{extra_link_flags}}, "-L" . File::Spec->catdir($Config{installarchlib}, "CORE");
-  push @{$self->{extra_libs}}, "perl";
-  if($Config{perllibs}) {
-    foreach my $perllib (split(" ", $Config{perllibs})) {
-      $perllib =~ m/^\-l(\w+)$/ and push @{$self->{extra_libs}}, "$1" and next;
-      push @{$self->{extra_link_flags}}, $perllib;
-    }
-  }
+Checks whether a dynamic loadable object containing an XS module can be
+linked or not. Due the nature of the beast, this test currently always
+succeed.
 
-  my $have_libperl = $self->link_if_else( $conftest );
+=cut
+
+sub check_linkable_xs_so { 1 }
 
-  $self->{extra_libs} = [ @save_libs ];
-  $self->{extra_link_flags} = [ @save_extra_link_flags ];
+=head2 check_linkable_xs_so_or_die
 
-  $have_libperl;
+Dies when L</check_linkable_xs_so> fails.
+
+=cut
+
+sub check_linkable_xs_so_or_die
+{
+    my $self = shift;
+    $self->check_linkable_xs_so(@_) or $self->msg_error("Cannot link XS dynamic loadable - giving up");
 }
 
-=head2 check_link_perl_api
+=head2 check_loadable_xs_so
 
-This method can be used from other checks to prove whether we have a perl
-development environment or not (perl.h, libperl.la, reasonable basic
-checks - types, etc.)
+Checks whether a dynamic loadable object containing an XS module can be
+loaded or not. Due the nature of the beast, this test currently always
+succeed.
 
 =cut
 
-sub check_link_perl_api {
-  my $self = shift->_get_instance;
-  my $cache_name = $self->_cache_name(qw(link perl api));
+sub check_loadable_xs_so { 1 }
+
+=head2 check_loadable_xs_so_or_die
+
+Dies when L</check_loadable_xs_so> fails.
 
-  $self->check_cached( $cache_name,
-    "whether perl api is linkable",
-    sub { $self->_check_link_perl_api } );
+=cut
+
+sub check_loadable_xs_so_or_die
+{
+    my $self = shift;
+    $self->check_loadable_xs_so(@_) or $self->msg_error("Cannot load XS dynamic loadable - giving up");
 }
 
-=head2 check_lm( [ action-if-found ], [ action-if-not-found ] )
+=head2 _check_link_perlapi
 
-This method is used to check if some common C<math.h> functions are
-available, and if C<-lm> is needed. Returns the empty string if no
-library is needed, or the "-lm" string if libm is needed.
+This method can be used from other checks to prove whether we have a perl
+development environment including a suitable libperl or not (perl.h,
+reasonable basic checks - types, etc.)
 
-Actions are only called at the end of the list of tests. If one fails,
-I<action-if-not-found> is run. Otherwise, I<action-if-found> is run.
+Caller must ensure that the linker flags are set appropriate (C<-lperl>
+or similar).
 
 =cut
 
-sub check_lm {
-  my ($self, $aif, $ainf) = @_;
-  ref($self) or $self = $self->_get_instance();
+sub _check_link_perlapi
+{
+    my $self = shift;
+
+    my $conftest              = $self->_check_perlapi_program();
+    my @save_libs             = @{ $self->{extra_libs} };
+    my @save_extra_link_flags = @{ $self->{extra_link_flags} };
+
+    my $libperl = $Config{libperl};
+    $libperl =~ s/^lib//;
+    $libperl =~ s/\.[^\.]*$//;
+
+    push @{ $self->{extra_link_flags} }, "-L" . File::Spec->catdir( $Config{installarchlib}, "CORE" );
+    push @{ $self->{extra_libs} }, "$libperl";
+    if ( $Config{perllibs} )
+    {
+        foreach my $perllib ( split( " ", $Config{perllibs} ) )
+        {
+            $perllib =~ m/^\-l(\w+)$/ and push @{ $self->{extra_libs} }, "$1" and next;
+            push @{ $self->{extra_link_flags} }, $perllib;
+        }
+    }
 
-  my $fail = 0;
-  my $required = "";
-  for my $func (qw(log2 pow log10 log exp sqrt)) {
-    my $ans = $self->search_libs( $func, ['m'] );
+    my $have_libperl = $self->link_if_else($conftest);
 
-    $ans or $fail = 1;
-    ($ans ne "none required") and $required = $ans;
-  }
+    $have_libperl or $self->{extra_libs}       = [@save_libs];
+    $have_libperl or $self->{extra_link_flags} = [@save_extra_link_flags];
+
+    $have_libperl;
+}
+
+=head2 check_link_perlapi
 
-  if ($fail) { $ainf && $ainf->() }
-  else       { $aif  && $aif->() }
+This method can be used from other checks to prove whether we have a perl
+development environment or not (perl.h, libperl.la, reasonable basic
+checks - types, etc.)
+
+=cut
+
+sub check_link_perlapi
+{
+    my $self       = shift->_get_instance;
+    my $cache_name = $self->_cache_name(qw(link perlapi));
+
+    $self->check_cached( $cache_name, "whether perlapi is linkable", sub { $self->_check_link_perlapi } );
+}
 
-  $required;
+sub _have_lib_define_name
+{
+    my $lib       = $_[0];
+    my $have_name = "HAVE_LIB" . uc($lib);
+    $have_name =~ tr/_A-Za-z0-9/_/c;
+    return $have_name;
 }
 
-=head2 check_lib( lib, func, [ action-if-found ], [ action-if-not-found ], [ @other-libs ] )
+=head2 check_lib( lib, func, @other-libs?, \%options? )
 
 This function is used to check if a specific library includes some
 function. Call it with the library name (without the lib portion), and
@@ -1958,10 +2764,9 @@ the name of the function you want to test:
 
 It returns 1 if the function exist, 0 otherwise.
 
-I<action-if-found> and I<action-if-not-found> can be CODE references
-whereby the default action in case of function found is to define
-the HAVE_LIBlibrary (all in capitals) preprocessor macro with 1 and
-add $lib to the list of libraries to link.
+In case of function found, the HAVE_LIBlibrary (all in capitals)
+preprocessor macro is defined with 1 and $lib together with @other_libs
+are added to the list of libraries to link with.
 
 If linking with library results in unresolved symbols that would be
 resolved by linking with additional libraries, give those libraries
@@ -1972,55 +2777,66 @@ The other-libraries argument should be limited to cases where it is
 desirable to test for one library in the presence of another that
 is not already in LIBS. 
 
-It's recommended to use L<search_libs> instead of check_lib these days.
+This method caches its result in the C<ac_cv_lib_>lib_func variable.
 
-=cut
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+If any of I<action_on_cache_true>, I<action_on_cache_false> is defined,
+both callbacks are passed to L</check_cached> as I<action_on_true> or
+I<action_on_false> to C<check_cached>, respectively.
 
-sub check_lib {
-  my ( $self, $lib, $func, $action_if_found, $action_if_not_found, @other_libs ) = @_;
-  ref($self) or $self = $self->_get_instance();
+It's recommended to use L<search_libs> instead of check_lib these days.
 
-  return 0 unless $lib;
-  return 0 unless $func;
+=cut
 
-  scalar( @other_libs ) == 1 and ref( $other_libs[0] ) eq "ARRAY"
-    and @other_libs = @{ $other_libs[0] };
+sub check_lib
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+    my ( $lib, $func, @other_libs ) = @_;
 
-  my $cache_name = $self->_cache_name( "lib", $lib, $func );
-  my $check_sub = sub {
-    my $conftest = $self->lang_call( "", $func );
+    return 0 unless $lib and $func;
 
-    my @save_libs = @{$self->{extra_libs}};
-    push( @{$self->{extra_libs}}, $lib, @other_libs );
-    my $have_lib = $self->link_if_else( $conftest );
-    $self->{extra_libs} = [ @save_libs ];
+    scalar(@other_libs) == 1
+      and ref( $other_libs[0] ) eq "ARRAY"
+      and @other_libs = @{ $other_libs[0] };
 
-    if( $have_lib ) {
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-      else {
-	$self->define_var( _have_lib_define_name( $lib ), $have_lib,
-			   "defined when library $lib is available" );
-	push( @{$self->{extra_libs}}, $lib );
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
-      else {
-	$self->define_var( _have_lib_define_name( $lib ), undef,
-			   "defined when library $lib is available" );
-      }
-    }
-    $have_lib;
-  };
+    my $cache_name = $self->_cache_name( "lib", $lib, $func );
+    my $check_sub = sub {
+        my $conftest = $self->lang_call( "", $func );
+
+        my @save_libs = @{ $self->{extra_libs} };
+        push( @{ $self->{extra_libs} }, $lib, @other_libs );
+        my $have_lib = $self->link_if_else(
+            $conftest,
+            {
+                ( $options->{action_on_true}  ? ( action_on_true  => $options->{action_on_true} )  : () ),
+                ( $options->{action_on_false} ? ( action_on_false => $options->{action_on_false} ) : () )
+            }
+        );
+        $self->{extra_libs} = [@save_libs];
+
+        $have_lib
+          and $self->define_var( _have_lib_define_name($lib), $have_lib, "defined when library $lib is available" )
+          and push( @{ $self->{extra_libs} }, $lib, @other_libs );
+        $have_lib
+          or $self->define_var( _have_lib_define_name($lib), undef, "defined when library $lib is available" );
+        $have_lib;
+    };
 
-  $self->check_cached( $cache_name, "for $func in -l$lib", $check_sub );
+    $self->check_cached(
+        $cache_name,
+        "for $func in -l$lib",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
 }
 
-=head2 search_libs( function, search-libs, [action-if-found], [action-if-not-found], [other-libs] )
+=head2 search_libs( function, search-libs, @other-libs?, \%options? )
 
 Search for a library defining function if it's not already available.
 This equates to calling
@@ -2032,9 +2848,7 @@ first with no libraries, then for each library listed in search-libs.
 I<search-libs> must be specified as an array reference to avoid
 confusion in argument order.
 
-Prepend -llibrary to LIBS for the first library found to contain function,
-and run I<action-if-found>. If the function is not found, run
-I<action-if-not-found>.
+Prepend -llibrary to LIBS for the first library found to contain function.
 
 If linking with library results in unresolved symbols that would be
 resolved by linking with additional libraries, give those libraries as
@@ -2047,53 +2861,187 @@ as "none required" if function is already available, as C<0> if no
 library containing function was found, otherwise as the -llibrary option
 that needs to be prepended to LIBS.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+If any of I<action_on_cache_true>, I<action_on_cache_false> is defined,
+both callbacks are passed to L</check_cached> as I<action_on_true> or
+I<action_on_false> to C<check_cached>, respectively.  Given callbacks
+for I<action_on_lib_true> or I<action_on_lib_false> are called for
+each library checked using L</link_if_else> receiving the library as
+first argument and all C<@other_libs> subsequently.
+
 =cut
 
-sub search_libs {
-  my ( $self, $func, $libs, $action_if_found, $action_if_not_found, @other_libs ) = @_;
-  ref($self) or $self = $self->_get_instance();
+sub search_libs
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+    my ( $func, $libs, @other_libs ) = @_;
+
+    ( defined($libs) and "ARRAY" eq ref($libs) and scalar( @{$libs} ) > 0 )
+      or return 0;    # XXX would prefer croak
+    return 0 unless $func;
+
+    scalar(@other_libs) == 1
+      and ref( $other_libs[0] ) eq "ARRAY"
+      and @other_libs = @{ $other_libs[0] };
 
-  ( defined( $libs ) and "ARRAY" eq ref( $libs ) and scalar( @{$libs} ) > 0 )
-    or return 0; # XXX would prefer croak
-  return 0 unless $func;
+    my $cache_name = $self->_cache_name( "search", $func );
+    my $check_sub = sub {
+        my $conftest = $self->lang_call( "", $func );
+
+        my @save_libs = @{ $self->{extra_libs} };
+        my $have_lib  = 0;
+        foreach my $libstest ( undef, @$libs )
+        {
+            # XXX would local work on array refs? can we omit @save_libs?
+            $self->{extra_libs} = [@save_libs];
+            defined($libstest) and unshift( @{ $self->{extra_libs} }, $libstest, @other_libs );
+            $self->link_if_else(
+                $conftest,
+                {
+                    (
+                        $options->{action_on_lib_true} && "CODE" eq ref $options->{action_on_lib_true}
+                        ? ( action_on_true => sub { $options->{action_on_lib_true}->( $libstest, @other_libs, @_ ) } )
+                        : ()
+                    ),
+                    (
+                        $options->{action_on_lib_false} && "CODE" eq ref $options->{action_on_lib_false}
+                        ? ( action_on_false => sub { $options->{action_on_lib_false}->( $libstest, @other_libs, @_ ) } )
+                        : ()
+                    ),
+                }
+              )
+              and ( $have_lib = defined($libstest) ? $libstest : "none required" )
+              and last;
+        }
+        $self->{extra_libs} = [@save_libs];
+
+        $have_lib eq "none required" or unshift( @{ $self->{extra_libs} }, $have_lib );
+
+              $have_lib
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !$have_lib
+          and $options->{action_on_false}->();
+
+        $have_lib;
+    };
 
-  scalar( @other_libs ) == 1 and ref( $other_libs[0] ) eq "ARRAY"
-    and @other_libs = @{ $other_libs[0] };
+    return $self->check_cached(
+        $cache_name,
+        "for library containing $func",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
+}
 
-  my $cache_name = $self->_cache_name( "search", $func );
-  my $check_sub = sub {
+sub _check_lm_funcs { qw(log2 pow log10 log exp sqrt) }
 
-    my $conftest = $self->lang_call( "", $func );
+=head2 check_lm( \%options? )
 
-    my @save_libs = @{$self->{extra_libs}};
-    my $have_lib = 0;
-    foreach my $libstest ( undef, @$libs ) {
-      # XXX would local work on array refs? can we omit @save_libs?
-      $self->{extra_libs} = [ @save_libs ];
-      defined( $libstest ) and unshift( @{$self->{extra_libs}}, $libstest, @other_libs );
-      $self->link_if_else( $conftest ) and ( $have_lib = defined( $libstest ) ? $libstest : "none required" ) and last;
-    }
-    $self->{extra_libs} = [ @save_libs ];
-    if( $have_lib ) {
-      $have_lib eq "none required" or unshift( @{$self->{extra_libs}}, $have_lib );
+This method is used to check if some common C<math.h> functions are
+available, and if C<-lm> is needed. Returns the empty string if no
+library is needed, or the "-lm" string if libm is needed.
 
-      if( defined( $action_if_found ) and "CODE" eq ref( $action_if_found ) ) {
-	&{$action_if_found}();
-      }
-    }
-    else {
-      if( defined( $action_if_not_found ) and "CODE" eq ref( $action_if_not_found ) ) {
-	&{$action_if_not_found}();
-      }
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+Each of existing key/value pairs using I<action_on_func_true> (as
+I<action_on_true> having the name of the tested functions as first argument),
+I<action_on_func_false> (as I<action_on_false> having the name of the tested
+functions as first argument), I<action_on_func_lib_true> (as
+I<action_on_lib_true> having the name of the tested functions as first
+argument), I<action_on_func_lib_false> (as I<action_on_lib_false> having
+the name of the tested functions as first argument) as key are passed
+throuh to each call of L</search_libs>.
+Given callbacks for I<action_on_lib_true>, I<action_on_lib_false>,
+I<action_on_cache_true> or I<action_on_cache_false> are passed to the
+call of L</search_libs>.
+
+B<Note> that I<action_on_lib_true> and I<action_on_func_lib_true> or
+I<action_on_lib_false> and I<action_on_func_lib_false> cannot be used
+at the same time, respectively.
+
+=cut
+
+sub check_lm
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance();
+
+    defined $options->{action_on_lib_true}
+      and defined $options->{action_on_func_lib_true}
+      and croak("action_on_lib_true and action_on_func_lib_true cannot be used together");
+    defined $options->{action_on_lib_false}
+      and defined $options->{action_on_func_lib_false}
+      and croak("action_on_lib_false and action_on_func_lib_false cannot be used together");
+
+    my %pass_options;
+    defined $options->{action_on_cache_true}  and $pass_options{action_on_cache_true}  = $options->{action_on_cache_true};
+    defined $options->{action_on_cache_false} and $pass_options{action_on_cache_false} = $options->{action_on_cache_false};
+    defined $options->{action_on_lib_true}    and $pass_options{action_on_lib_true}    = $options->{action_on_lib_true};
+    defined $options->{action_on_lib_false}   and $pass_options{action_on_lib_false}   = $options->{action_on_lib_false};
+
+    my $fail       = 0;
+    my $required   = "";
+    my @math_funcs = $self->_check_lm_funcs;
+    for my $func (@math_funcs)
+    {
+        my $ans = $self->search_libs(
+            $func,
+            ['m'],
+            {
+                %pass_options,
+                (
+                    $options->{action_on_func_true} && "CODE" eq ref $options->{action_on_func_true}
+                    ? ( action_on_true => sub { $options->{action_on_func_true}->( $func, @_ ) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_func_false} && "CODE" eq ref $options->{action_on_func_false}
+                    ? ( action_on_false => sub { $options->{action_on_func_false}->( $func, @_ ) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_func_lib_true} && "CODE" eq ref $options->{action_on_func_lib_true}
+                    ? ( action_on_lib_true => sub { $options->{action_on_func_lib_true}->( $func, @_ ) } )
+                    : ()
+                ),
+                (
+                    $options->{action_on_func_lib_false} && "CODE" eq ref $options->{action_on_func_lib_false}
+                    ? ( action_on_lib_false => sub { $options->{action_on_func_lib_false}->( $func, @_ ) } )
+                    : ()
+                ),
+            },
+        );
+
+        $ans or $fail = 1;
+        $ans ne "none required" and $required = $ans;
     }
 
-    return $have_lib;
-  };
+         !$fail
+      and $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
+
+          $fail
+      and $options->{action_on_false}
+      and ref $options->{action_on_false} eq "CODE"
+      and $options->{action_on_false}->();
 
-  return $self->check_cached( $cache_name, "for library containing $func", $check_sub );
+    $required;
 }
 
-=head2 pkg_config_package_flags($package, [action-if-found], [action-if-not-found])
+=head2 pkg_config_package_flags($package, \%options?)
 
 Search for pkg-config flags for package as specified. The flags which are
 extracted are C<--cflags> and C<--libs>. The extracted flags are appended
@@ -2102,53 +3050,89 @@ to the global C<extra_compile_flags> and C<extra_link_flags>, respectively.
 Call it with the package you're looking for and optional callback whether
 found or not.
 
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
+If any of I<action_on_cache_true>, I<action_on_cache_false> is defined,
+both callbacks are passed to L</check_cached> as I<action_on_true> or
+I<action_on_false> to L</check_cached>, respectively.
+
 =cut
 
 my $_pkg_config_prog;
 
-sub _pkg_config_flag {
-  defined $_pkg_config_prog or croak("pkg_config_prog required");
-  my @pkg_config_args = @_;
-  my ( $stdout, $stderr, $exit ) =
-    capture { system( $_pkg_config_prog, @pkg_config_args ); };
-  chomp $stdout;
-  0 == $exit and return $stdout;
-  return;
-}
-
-sub pkg_config_package_flags {
-  my ( $self, $package, $action_if_found, $action_if_not_found ) = @_;
-  $self = $self->_get_instance();
-  (my $pkgpfx = $package) =~ s/^(\w+).*?$/$1/;
-  my $cache_name = $self->_cache_name( "pkg", $pkgpfx );
-  defined $_pkg_config_prog or $_pkg_config_prog = $self->check_prog_pkg_config;
-  my $check_sub = sub {
-    my ( @pkg_cflags, @pkg_libs );
-
-    (my $ENV_CFLAGS = $package) =~ s/^(\w+).*?$/$1_CFLAGS/;
-    my $CFLAGS = defined $ENV{$ENV_CFLAGS} ? $ENV{$ENV_CFLAGS}
-					   : _pkg_config_flag($package, "--cflags");
-    $CFLAGS and @pkg_cflags = (
-      map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; }
-      split( m/\n/, $CFLAGS )
-    ) and push @{ $self->{extra_preprocess_flags} }, @pkg_cflags;
-
-    (my $ENV_LIBS = $package) =~ s/^(\w+).*?$/$1_LIBS/;
-    # do not separate between libs and extra (for now) - they come with -l prepended
-    my $LIBS = defined $ENV{$ENV_LIBS} ? $ENV{$ENV_LIBS}
-				       : _pkg_config_flag($package, "--libs");
-    $LIBS and @pkg_libs = (
-      map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; }
-      split( m/\n/, $LIBS )
-    ) and push @{ $self->{extra_link_flags} }, @pkg_libs;
-
-    join(" ", @pkg_cflags, @pkg_libs);
-  };
-
-  $self->check_cached( $cache_name, "for pkg-config package of $package", $check_sub );
-}
-
-=head2 _check_pureperl_build_wanted
+sub _pkg_config_flag
+{
+    defined $_pkg_config_prog or croak("pkg_config_prog required");
+    my @pkg_config_args = @_;
+    my ( $stdout, $stderr, $exit ) =
+      capture { system( $_pkg_config_prog, @pkg_config_args ); };
+    chomp $stdout;
+    0 == $exit and return $stdout;
+    return;
+}
+
+sub pkg_config_package_flags
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my ( $self, $package ) = @_;
+    $self = $self->_get_instance();
+
+    ( my $pkgpfx = $package ) =~ s/^(\w+).*?$/$1/;
+    my $cache_name = $self->_cache_name( "pkg", $pkgpfx );
+
+    defined $_pkg_config_prog or $_pkg_config_prog = $self->check_prog_pkg_config;
+    my $check_sub = sub {
+        my ( @pkg_cflags, @pkg_libs );
+
+        ( my $ENV_CFLAGS = $package ) =~ s/^(\w+).*?$/$1_CFLAGS/;
+        my $CFLAGS =
+          defined $ENV{$ENV_CFLAGS}
+          ? $ENV{$ENV_CFLAGS}
+          : _pkg_config_flag( $package, "--cflags" );
+        $CFLAGS and @pkg_cflags = (
+            map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; }
+              split( m/\n/, $CFLAGS )
+        ) and push @{ $self->{extra_preprocess_flags} }, @pkg_cflags;
+
+        ( my $ENV_LIBS = $package ) =~ s/^(\w+).*?$/$1_LIBS/;
+        # do not separate between libs and extra (for now) - they come with -l prepended
+        my $LIBS =
+          defined $ENV{$ENV_LIBS}
+          ? $ENV{$ENV_LIBS}
+          : _pkg_config_flag( $package, "--libs" );
+        $LIBS and @pkg_libs = (
+            map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; Text::ParseWords::shellwords $_; }
+              split( m/\n/, $LIBS )
+        ) and push @{ $self->{extra_link_flags} }, @pkg_libs;
+
+        my $pkg_config_flags = join( " ", @pkg_cflags, @pkg_libs );
+
+              $pkg_config_flags
+          and $options->{action_on_true}
+          and ref $options->{action_on_true} eq "CODE"
+          and $options->{action_on_true}->();
+
+        $options->{action_on_false}
+          and ref $options->{action_on_false} eq "CODE"
+          and !$pkg_config_flags
+          and $options->{action_on_false}->();
+
+        $pkg_config_flags;
+    };
+
+    $self->check_cached(
+        $cache_name,
+        "for pkg-config package of $package",
+        $check_sub,
+        {
+            ( $options->{action_on_cache_true}  ? ( action_on_true  => $options->{action_on_cache_true} )  : () ),
+            ( $options->{action_on_cache_false} ? ( action_on_false => $options->{action_on_cache_false} ) : () )
+        }
+    );
+}
+
+=head2 _check_mm_pureperl_build_wanted
 
 This method proves the C<_argv> attribute and (when set) the C<PERL_MM_OPT>
 whether they contain I<PUREPERL_ONLY=(0|1)> or not. The attribute C<_force_xs>
@@ -2157,38 +3141,42 @@ is called with I<PUREPERL_ONLY=0>.
 
 =cut
 
-sub _check_mm_pureperl_build_wanted {
-  my $self = shift->_get_instance;
+sub _check_mm_pureperl_build_wanted
+{
+    my $self = shift->_get_instance;
 
-  defined $ENV{PERL_MM_OPT} and my @env_args = split " ", $ENV{PERL_MM_OPT};
+    defined $ENV{PERL_MM_OPT} and my @env_args = split " ", $ENV{PERL_MM_OPT};
 
-  foreach my $arg ( @{$self->{_argv}}, @env_args ) {
-    $arg =~ m/^PUREPERL_ONLY=(.*)$/ and return int($1);
-  }
+    foreach my $arg ( @{ $self->{_argv} }, @env_args )
+    {
+        $arg =~ m/^PUREPERL_ONLY=(.*)$/ and return int($1);
+    }
 
-  0;
+    0;
 }
 
-=head2 _check_pureperl_build_wanted
+=head2 _check_mb_pureperl_build_wanted
 
 This method proves the C<_argv> attribute and (when set) the C<PERL_MB_OPT>
 whether they contain I<--pureperl-only> or not.
 
 =cut
 
-sub _check_mb_pureperl_build_wanted {
-  my $self = shift->_get_instance;
+sub _check_mb_pureperl_build_wanted
+{
+    my $self = shift->_get_instance;
 
-  defined $ENV{PERL_MB_OPT} and my @env_args = split " ", $ENV{PERL_MB_OPT};
+    defined $ENV{PERL_MB_OPT} and my @env_args = split " ", $ENV{PERL_MB_OPT};
 
-  foreach my $arg ( @{$self->{_argv}}, @env_args ) {
-    $arg eq "--pureperl-only" and return 1;
-  }
+    foreach my $arg ( @{ $self->{_argv} }, @env_args )
+    {
+        $arg eq "--pureperl-only" and return 1;
+    }
 
-  0;
+    0;
 }
 
-=head2 _check_pureperl_build_wanted
+=head2 _check_pureperl_required
 
 This method calls C<_check_mm_pureperl_build_wanted> when running under
 L<ExtUtils::MakeMaker> (C<Makefile.PL>) or C<_check_mb_pureperl_build_wanted>
@@ -2199,80 +3187,99 @@ simply 0 is returned.
 
 =cut
 
-sub _check_pureperl_build_wanted {
-  $0 =~ m/Makefile\.PL$/i and goto \&_check_mm_pureperl_build_wanted;
-  $0 =~ m/Build\.PL$/i and goto \&_check_mb_pureperl_build_wanted;
+sub _check_pureperl_required
+{
+    my $self = shift;
+    $0 =~ m/Makefile\.PL$/i and return $self->_check_mm_pureperl_build_wanted(@_);
+    $0 =~ m/Build\.PL$/i    and return $self->_check_mb_pureperl_build_wanted(@_);
 
-  0;
+    0;
 }
 
-=head2 check_pureperl_build_wanted
+=head2 check_pureperl_required
 
 This check method proves whether a pureperl build is wanted or not by
-cached-checking C<< $self->_check_pureperl_build_wanted >>. The result
-might lead to further checks, eg. L</_check_compile_perl_api>.
+cached-checking C<< $self->_check_pureperl_required >>.
 
 =cut
 
-sub check_pureperl_build_wanted {
-  my $self = shift->_get_instance;
-  my $cache_name = $self->_cache_name(qw(pureperl only wanted));
-  $self->check_cached( $cache_name,
-    "whether pureperl shall be forced",
-    sub { $self->_check_pureperl_build_wanted } );
+sub check_pureperl_required
+{
+    my $self       = shift->_get_instance;
+    my $cache_name = $self->_cache_name(qw(pureperl required));
+    $self->check_cached( $cache_name, "whether pureperl is required", sub { $self->_check_pureperl_required } );
 }
 
-=head2 check_sane_xs
+=head2 check_produce_xs_build
 
-This routine checks whether XS can be sanely used. Therefore it does
+This routine checks whether XS can be produced. Therefore it does
 following checks in given order:
 
 =over 4
 
 =item *
 
-check pureperl environment variables or command line arguments and disable
-XS when pure perl is wanted in any way
+check pureperl environment variables (L</check_pureperl_required>) or
+command line arguments and return false when pure perl is requested
 
 =item *
 
-check whether a compiler is available (C<check_cc>) and disable XS if none found
+check whether a compiler is available (L</check_valid_compilers>) and
+return false if none found
 
 =item *
 
 check whether a test program accessing Perl API can be compiled and
 die with error if not
 
-=item *
+=back
 
-when C<ExtensivePerlAPI> is enabled, check wether perl extensions can
-be linked or die with error otherwise
+When all checks passed successfully, return a true value.
 
-=item *
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
 
-I<TODO> check whether a trivial XS can be loaded and die hard on error
+=cut
 
-=back
+sub check_produce_xs_build
+{
+    my $options = {};
+    scalar @_ > 1 and ref $_[-1] eq "HASH" and $options = pop @_;
+    my $self = shift->_get_instance;
+    $self->check_pureperl_required() and return _on_return_callback_helper( 0, $options, "action_on_false" );
+    $self->check_valid_compilers( $_[0] || [qw(C)] ) or return _on_return_callback_helper( 0, $options, "action_on_false" );
+    # XXX necessary check for $Config{useshrlib}? (need to dicuss with eg. TuX, 99% likely return 0)
+    $self->check_compile_perlapi_or_die();
 
-When all checks passed successfully, return a true value.
+    $options->{action_on_true}
+      and ref $options->{action_on_true} eq "CODE"
+      and $options->{action_on_true}->();
+
+    return 1;
+}
+
+=head2 check_produce_loadable_xs_build
+
+This routine proves whether XS should be built and it's possible to create
+a dynamic linked object which can be loaded using Perl's Dynaloader.
+
+The extension over L</check_produce_xs_build> can be avoided by adding the
+C<notest_loadable_xs> to C<$ENV{PERL5_AC_OPTS}>.
+
+If the very last parameter contains a hash reference, C<CODE> references
+to I<action_on_true> or I<action_on_false> are executed, respectively.
 
 =cut
 
-sub check_sane_xs {
-  my $self = shift->_get_instance;
-  my $pp = $self->check_pureperl_build_wanted();
-  $pp and return 0;
-  $self->check_cc or return 0;
-  # XXX necessary check for $Config{useshrlib}?
-  $self->check_compile_perl_api() or return $self->msg_error("Cannot use Perl API - giving up");
-  if( $self->{c_ac_flags}->{ExtensivePerlAPI} ) {
-    $self->check_compile_perl_api() or return $self->msg_error("Cannot link Perl API - giving up");
-    # XXX add a reasonable check compiling and trying to load an XS module
-  }
-  return 1;
+sub check_produce_loadable_xs_build
+{
+    my $self = shift->_get_instance;
+    $self->check_produce_xs_build(@_)
+      and !$self->{c_ac_flags}->{notest_loadable_xs}
+      and $self->check_linkable_xs_so_or_die
+      and $self->check_loadable_xs_so_or_die;
 }
 
-
 #
 #
 # Auxiliary funcs
@@ -2289,78 +3296,103 @@ Call once at very begin of C<Makefile.PL> or C<Build.PL>:
 
 =cut
 
-sub _set_argv {
-  my ( $self, @argv ) = @_;
-  $self = $self->_get_instance;
-  $self->{_argv} = \@argv;
-  return;
+sub _set_argv
+{
+    my ( $self, @argv ) = @_;
+    $self = $self->_get_instance;
+    $self->{_argv} = \@argv;
+    return;
 }
 
-sub _sanitize {
-  # This is hard coded, and maybe a little stupid...
-  my $x = shift;
-  $x =~ s/ //g;
-  $x =~ s/\///g;
-  $x =~ s/\\//g;
-  $x;
+sub _sanitize
+{
+    # This is hard coded, and maybe a little stupid...
+    my $x = shift;
+    $x =~ s/ //g;
+    $x =~ s/\///g;
+    $x =~ s/\\//g;
+    $x;
 }
 
-sub _get_instance {
-  ref $_[0] and return $_[0];
-  defined $glob_instance or $glob_instance = $_[0]->new();
-  $glob_instance;
+sub _get_instance
+{
+    ref $_[0] and return $_[0];
+    defined $glob_instance or $glob_instance = $_[0]->new();
+    $glob_instance;
 }
 
-sub _get_builder {
-  my $self = $_[0]->_get_instance();
-  defined( $self->{lang_supported}->{ $self->{lang} } ) or croak( "Unsupported compile language \"" . $self->{lang} . "\"" );
+sub _get_builder
+{
+    my $self = $_[0]->_get_instance();
 
-  my $builder = $self->{lang_supported}->{ $self->{lang} }->new();
+    ref $self->{lang_supported}->{ $self->{lang} } eq "CODE" and $self->{lang_supported}->{ $self->{lang} }->($self);
+    defined( $self->{lang_supported}->{ $self->{lang} } ) or croak( "Unsupported compile language \"" . $self->{lang} . "\"" );
 
-  ## XXX - Temporarily. Will try to send upstream
-  if ($self->{lang} eq "C") {
-      $builder->{config}{ccflags} =~ s/-arch \S+//g;
-      $builder->{config}{lddlflags} =~ s/-arch \S+//g;
-      $builder->{config}{ldflags} =~ s/-arch \S+//g;
-  }
-  $builder;
+    my $builder = $self->{lang_supported}->{ $self->{lang} }->new();
+
+    ## XXX - Temporarily. Will try to send upstream
+    if ( $self->{lang} eq "C" )
+    {
+        $builder->{config}{ccflags} =~ s/-arch \S+//g;
+        $builder->{config}{lddlflags} =~ s/-arch \S+//g;
+        $builder->{config}{ldflags} =~ s/-arch \S+//g;
+    }
+    $builder;
 }
 
-sub _set_language {
-  my $self = shift->_get_instance();
-  my ($lang, $impl) = @_;
+sub _set_language
+{
+    my $self = shift->_get_instance();
+    my ( $lang, $impl ) = @_;
 
-  defined( $lang ) or croak( "Missing language" );
+    defined($lang) or croak("Missing language");
 
-  defined( $impl ) and defined( $self->{lang_supported}->{$lang} )
-    and $impl ne $self->{lang_supported}->{$lang}
-    and croak( "Language implementor ($impl) doesn't match exisiting one (" . $self->{lang_supported}->{$lang} . ")" );
+          defined($impl)
+      and defined( $self->{lang_supported}->{$lang} )
+      and $impl ne $self->{lang_supported}->{$lang}
+      and croak( "Language implementor ($impl) doesn't match exisiting one (" . $self->{lang_supported}->{$lang} . ")" );
 
-  defined( $impl ) and !defined( $self->{lang_supported}->{$lang} )
-    and $self->{lang_supported}->{$lang} = $impl;
+    defined($impl)
+      and !defined( $self->{lang_supported}->{$lang} )
+      and $self->{lang_supported}->{$lang} = $impl;
 
-  defined( $self->{lang_supported}->{$lang} ) or croak( "Unsupported language \"$lang\"" );
+    ref $self->{lang_supported}->{$lang} eq "CODE" and $self->{lang_supported}->{$lang}->($self);
+    defined( $self->{lang_supported}->{$lang} ) or croak("Unsupported language \"$lang\"");
 
-  defined( $self->{extra_compile_flags}->{$lang} ) or $self->{extra_compile_flags}->{$lang} = [];
+    defined( $self->{extra_compile_flags}->{$lang} ) or $self->{extra_compile_flags}->{$lang} = [];
 
-  $self->{lang} = $lang;
+    $self->{lang} = $lang;
 
-  return;
+    return;
 }
 
-sub _fill_defines {
-  my ($self, $src, $action_if_true, $action_if_false) = @_;
-  ref $self or $self = $self->_get_instance();
+sub _on_return_callback_helper
+{
+    my $callback = pop @_;
+    my $options  = pop @_;
+    $options->{$callback}
+      and ref $options->{$callback} eq "CODE"
+      and $options->{$callback}->();
+    @_ and wantarray and return @_;
+    1 == scalar @_ and return $_[0];
+    return;
+}
 
-  my $conftest = "";
-  while( my ($defname, $defcnt) = each( %{ $self->{defines} } ) ) {
-    $defcnt->[0] or next;
-    defined $defcnt->[1] and $conftest .= "/* " . $defcnt->[1] . " */\n";
-    $conftest .= join( " ", "#define", $defname, $defcnt->[0] ) . "\n";
-  }
-  $conftest .= "/* end of conftest.h */\n";
+sub _fill_defines
+{
+    my ( $self, $src, $action_if_true, $action_if_false ) = @_;
+    ref $self or $self = $self->_get_instance();
+
+    my $conftest = "";
+    while ( my ( $defname, $defcnt ) = each( %{ $self->{defines} } ) )
+    {
+        $defcnt->[0] or next;
+        defined $defcnt->[1] and $conftest .= "/* " . $defcnt->[1] . " */\n";
+        $conftest .= join( " ", "#define", $defname, $defcnt->[0] ) . "\n";
+    }
+    $conftest .= "/* end of conftest.h */\n";
 
-  $conftest;
+    $conftest;
 }
 
 #
@@ -2444,7 +3476,6 @@ my $_default_includes = <<"_ACEOF";
 #endif
 _ACEOF
 
-
 sub _default_includes { $_default_includes }
 
 sub _default_main { $_[0]->_build_main("") }
@@ -2458,11 +3489,11 @@ my $_main_tpl = <<"_ACEOF";
   }
 _ACEOF
 
-
-sub _build_main {
-  my $self = shift->_get_instance();
-  my $body = shift || "";
-  sprintf($_main_tpl, $body);
+sub _build_main
+{
+    my $self = shift->_get_instance();
+    my $body = shift || "";
+    sprintf( $_main_tpl, $body );
 }
 
 =head2 _default_includes_with_perl
@@ -2481,53 +3512,62 @@ my $_include_perl = <<"_ACEOF";
 #include <XSUB.h> /* for perl context in threaded perls */
 _ACEOF
 
-sub _default_includes_with_perl {
-  join( "\n", $_[0]->_default_includes, $_include_perl );
+sub _default_includes_with_perl
+{
+    join( "\n", $_[0]->_default_includes, $_include_perl );
 }
 
 sub _cache_prefix { "ac" }
 
-sub _cache_name {
-  my ($self, @names) = @_;
-  my $cache_name = join( "_", $self->_cache_prefix(), "cv", @names );
-     $cache_name =~ tr/_A-Za-z0-9/_/c;
-  $cache_name;
+sub _cache_name
+{
+    my ( $self, @names ) = @_;
+    my $cache_name = join( "_", $self->_cache_prefix(), "cv", @names );
+    $cache_name =~ tr/_A-Za-z0-9/_/c;
+    $cache_name;
 }
 
-sub _get_log_fh {
-  my $self = $_[0]->_get_instance();
-  unless( defined( $self->{logfh} ) ) {
-    my $open_mode = defined $self->{logfile_mode} ? $self->{logfile_mode} : ">";
-    open( my $fh, $open_mode, $self->{logfile} ) or croak "Could not open file $self->{logfile}: $!";
-    $self->{logfh} = [ $fh ];
-  }
+sub _get_log_fh
+{
+    my $self = $_[0]->_get_instance();
+    unless ( defined( $self->{logfh} ) )
+    {
+        my $open_mode = defined $self->{logfile_mode} ? $self->{logfile_mode} : ">";
+        open( my $fh, $open_mode, $self->{logfile} ) or croak "Could not open file $self->{logfile}: $!";
+        $self->{logfh} = [$fh];
+    }
 
-  $self->{logfh};
+    $self->{logfh};
 }
 
-sub _add_log_entry {
-  my ($self, @logentries) = @_;
-  ref($self) or $self = $self->_get_instance();
-  $self->_get_log_fh();
-  foreach my $logentry (@logentries) {
-    foreach my $fh (@{$self->{logfh}}) {
-      print {$fh} "$logentry";
+sub _add_log_entry
+{
+    my ( $self, @logentries ) = @_;
+    ref($self) or $self = $self->_get_instance();
+    $self->_get_log_fh();
+    foreach my $logentry (@logentries)
+    {
+        foreach my $fh ( @{ $self->{logfh} } )
+        {
+            print {$fh} "$logentry";
+        }
     }
-  }
 
-  return;
+    return;
 }
 
-sub _add_log_lines {
-  my ($self, @logentries) = @_;
-  ref($self) or $self = $self->_get_instance();
-  $self->_get_log_fh();
-  my $logmsg = join("\n", @logentries) . "\n";
-  foreach my $fh (@{$self->{logfh}}) {
-    print {$fh} $logmsg;
-  }
+sub _add_log_lines
+{
+    my ( $self, @logentries ) = @_;
+    ref($self) or $self = $self->_get_instance();
+    $self->_get_log_fh();
+    my $logmsg = join( "\n", @logentries ) . "\n";
+    foreach my $fh ( @{ $self->{logfh} } )
+    {
+        print {$fh} $logmsg;
+    }
 
-  return;
+    return;
 }
 
 =head2 add_log_fh
@@ -2536,17 +3576,20 @@ Push new file handles at end of log-handles to allow tee-ing log-output
 
 =cut
 
-sub add_log_fh {
-  my ($self, @newh) = @_;
-  $self->_get_log_fh();
-SKIP_DUP:
-  foreach my $fh (@newh) {
-    foreach my $eh (@{$self->{logfh}}) {
-      $fh == $eh and next SKIP_DUP;
+sub add_log_fh
+{
+    my ( $self, @newh ) = @_;
+    $self->_get_log_fh();
+  SKIP_DUP:
+    foreach my $fh (@newh)
+    {
+        foreach my $eh ( @{ $self->{logfh} } )
+        {
+            $fh == $eh and next SKIP_DUP;
+        }
+        push @{ $self->{logfh} }, $fh;
     }
-    push @{$self->{logfh}}, $fh;
-  }
-  return;
+    return;
 }
 
 =head2 delete_log_fh
@@ -2557,37 +3600,43 @@ is removed. Use with caution.
 
 =cut
 
-sub delete_log_fh {
-  my ($self, @xh) = @_;
-  $self->_get_log_fh();
-SKIP_DUP:
-  foreach my $fh (@xh) {
-    foreach my $ih (0 .. $#{$self->{logfh}}) {
-      $fh == $self->{logfh}->[$ih] or next;
-      splice @{$self->{logfh}}, $ih, 1;
-      last;
+sub delete_log_fh
+{
+    my ( $self, @xh ) = @_;
+    $self->_get_log_fh();
+  SKIP_DUP:
+    foreach my $fh (@xh)
+    {
+        foreach my $ih ( 0 .. $#{ $self->{logfh} } )
+        {
+            $fh == $self->{logfh}->[$ih] or next;
+            splice @{ $self->{logfh} }, $ih, 1;
+            last;
+        }
     }
-  }
-  return;
+    return;
 }
 
-sub _cache_type_name  {
-  my ($self, @names) = @_;
-  $self->_cache_name( map { $_ =~ tr/*/p/; $_ } @names );
+sub _cache_type_name
+{
+    my ( $self, @names ) = @_;
+    $self->_cache_name( map { $_ =~ tr/*/p/; $_ } @names );
 }
 
-sub _get_extra_compiler_flags {
-  my $self = shift->_get_instance();
-  my @ppflags = @{$self->{extra_preprocess_flags}};
-  my @cflags = @{$self->{extra_compile_flags}->{ $self->{lang} }};
-  join( " ", @ppflags, @cflags );
+sub _get_extra_compiler_flags
+{
+    my $self    = shift->_get_instance();
+    my @ppflags = @{ $self->{extra_preprocess_flags} };
+    my @cflags  = @{ $self->{extra_compile_flags}->{ $self->{lang} } };
+    join( " ", @ppflags, @cflags );
 }
 
-sub _get_extra_linker_flags {
-  my $self = shift->_get_instance();
-  my @libs = @{$self->{extra_libs}};
-  my @ldflags = @{$self->{extra_link_flags}};
-  join( " ", @ldflags, map { "-l$_" } @libs );
+sub _get_extra_linker_flags
+{
+    my $self    = shift->_get_instance();
+    my @libs    = @{ $self->{extra_libs} };
+    my @ldflags = @{ $self->{extra_link_flags} };
+    join( " ", @ldflags, map { "-l$_" } @libs );
 }
 
 =head1 AUTHOR
@@ -2640,4 +3689,4 @@ ExtUtils::CBuilder(3)
 
 =cut
 
-1; # End of Config::AutoConf
+1;    # End of Config::AutoConf
diff --git a/t/00.load.t b/t/00.load.t
index ac364bc..72c77cb 100644
--- a/t/00.load.t
+++ b/t/00.load.t
@@ -2,6 +2,7 @@
 
 use Test::More tests => 1;
 
-BEGIN {
-  use_ok( 'Config::AutoConf' ) or BAIL_OUT("Can't load Config::AutoConf");
+BEGIN
+{
+    use_ok('Config::AutoConf') or BAIL_OUT("Can't load Config::AutoConf");
 }
diff --git a/t/01.checkprog.t b/t/01.checkprog.t
index 14b3df1..0ab0cad 100644
--- a/t/01.checkprog.t
+++ b/t/01.checkprog.t
@@ -16,94 +16,103 @@ ok( !Config::AutoConf->check_prog("hopingnobodyhasthiscommand"), "Don't find ''h
 like( Config::AutoConf->check_progs( "___perl___", "__perl__", "_perl_", "perl" ), qr/perl(?:\.exe)?$/i, "Find perl only" );
 is( Config::AutoConf->check_progs( "___perl___", "__perl__", "_perl_" ), undef, "Find no _xn surrounded perl" );
 
-SCOPE: {
-  my $ac = Config::AutoConf->new(); # avoid cache influences tests below
-  local $ENV{AWK} = "/somewhere/over/the/rainbow";
-  my $awk = $ac->check_prog_awk;
-  is($awk, $ENV{AWK}, "\$ENV{AWK} honored");
-
-  local $ENV{SED} = "/somewhere/over/the/rainbow";
-  my $sed = $ac->check_prog_sed;
-  is($sed, $ENV{SED}, "\$ENV{SED} honored");
-
-  local $ENV{EGREP} = "/somewhere/over/the/rainbow";
-  my $egrep = $ac->check_prog_egrep;
-  is($egrep, $ENV{EGREP}, "\$ENV{EGREP} honored");
-
-  local $ENV{YACC} = "/somewhere/over/the/rainbow";
-  my $yacc = $ac->check_prog_yacc;
-  is($yacc, $ENV{YACC}, "\$ENV{YACC} honored");
+SCOPE:
+{
+    my $ac = Config::AutoConf->new();    # avoid cache influences tests below
+    local $ENV{AWK} = "/somewhere/over/the/rainbow";
+    my $awk = $ac->check_prog_awk;
+    is( $awk, $ENV{AWK}, "\$ENV{AWK} honored" );
+
+    local $ENV{SED} = "/somewhere/over/the/rainbow";
+    my $sed = $ac->check_prog_sed;
+    is( $sed, $ENV{SED}, "\$ENV{SED} honored" );
+
+    local $ENV{EGREP} = "/somewhere/over/the/rainbow";
+    my $egrep = $ac->check_prog_egrep;
+    is( $egrep, $ENV{EGREP}, "\$ENV{EGREP} honored" );
+
+    local $ENV{YACC} = "/somewhere/over/the/rainbow";
+    my $yacc = $ac->check_prog_yacc;
+    is( $yacc, $ENV{YACC}, "\$ENV{YACC} honored" );
 }
 
-SCOPE: {
-  my $ac = Config::AutoConf->new(); # avoid cache influences tests below
-  local $ENV{ac_cv_prog_AWK} = "/somewhere/over/the/rainbow";
-  my $awk = $ac->check_prog_awk;
-  is($awk, $ENV{ac_cv_prog_AWK}, "\$ENV{ac_cv_prog_AWK} honored");
+SCOPE:
+{
+    my $ac = Config::AutoConf->new();    # avoid cache influences tests below
+    local $ENV{ac_cv_prog_AWK} = "/somewhere/over/the/rainbow";
+    my $awk = $ac->check_prog_awk;
+    is( $awk, $ENV{ac_cv_prog_AWK}, "\$ENV{ac_cv_prog_AWK} honored" );
 
-  local $ENV{ac_cv_prog_SED} = "/somewhere/over/the/rainbow";
-  my $sed = $ac->check_prog_sed;
-  is($sed, $ENV{ac_cv_prog_SED}, "\$ENV{ac_cv_prog_SED} honored");
+    local $ENV{ac_cv_prog_SED} = "/somewhere/over/the/rainbow";
+    my $sed = $ac->check_prog_sed;
+    is( $sed, $ENV{ac_cv_prog_SED}, "\$ENV{ac_cv_prog_SED} honored" );
 
-  local $ENV{ac_cv_prog_EGREP} = "/somewhere/over/the/rainbow";
-  my $egrep = $ac->check_prog_egrep;
-  is($egrep, $ENV{ac_cv_prog_EGREP}, "\$ENV{ac_cv_prog_EGREP} honored");
+    local $ENV{ac_cv_prog_EGREP} = "/somewhere/over/the/rainbow";
+    my $egrep = $ac->check_prog_egrep;
+    is( $egrep, $ENV{ac_cv_prog_EGREP}, "\$ENV{ac_cv_prog_EGREP} honored" );
 
-  local $ENV{ac_cv_prog_YACC} = "/somewhere/over/the/rainbow";
-  my $yacc = $ac->check_prog_yacc;
-  is($yacc, $ENV{ac_cv_prog_YACC}, "\$ENV{ac_cv_prog_YACC} honored");
+    local $ENV{ac_cv_prog_YACC} = "/somewhere/over/the/rainbow";
+    my $yacc = $ac->check_prog_yacc;
+    is( $yacc, $ENV{ac_cv_prog_YACC}, "\$ENV{ac_cv_prog_YACC} honored" );
 }
 
 diag("Check for some progs to get an overview about world outside");
 
-sub _is_x {
-  $^O =~ m/MSWin32/i and return $_[0] =~ m/\.(?:exe|com|bat|cmd)$/;
-  return -x $_[0];
+sub _is_x
+{
+    $^O =~ m/MSWin32/i and return $_[0] =~ m/\.(?:exe|com|bat|cmd)$/;
+    return -x $_[0];
 }
 
-SKIP: {
-  my $awk = Config::AutoConf->check_prog_awk;
-  $awk or skip "No awk", 1;
-  my $awk_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $awk )[0];
-  ok( _is_x($awk_bin), "$awk_bin is executable" );
-  diag("Found AWK as $awk");
+SKIP:
+{
+    my $awk = Config::AutoConf->check_prog_awk;
+    $awk or skip "No awk", 1;
+    my $awk_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $awk )[0];
+    ok( _is_x($awk_bin), "$awk_bin is executable" );
+    diag("Found AWK as $awk");
 }
 
-SKIP: {
-  my $sed = Config::AutoConf->check_prog_sed;
-  $sed or skip "No sed", 1;
-  my $sed_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $sed )[0];
-  ok( _is_x($sed_bin), "$sed_bin is executable" );
-  diag("Found SED as $sed");
+SKIP:
+{
+    my $sed = Config::AutoConf->check_prog_sed;
+    $sed or skip "No sed", 1;
+    my $sed_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $sed )[0];
+    ok( _is_x($sed_bin), "$sed_bin is executable" );
+    diag("Found SED as $sed");
 }
 
-SKIP: {
-  my $grep = Config::AutoConf->check_prog_egrep;
-  $grep or skip "No egrep", 1;
-  my $grep_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $grep )[0];
-  ok( _is_x($grep_bin), "$grep_bin is executable" );
-  diag("Found EGREP as $grep");
+SKIP:
+{
+    my $grep = Config::AutoConf->check_prog_egrep;
+    $grep or skip "No egrep", 1;
+    my $grep_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $grep )[0];
+    ok( _is_x($grep_bin), "$grep_bin is executable" );
+    diag("Found EGREP as $grep");
 }
 
-SKIP: {
-  my $yacc = Config::AutoConf->check_prog_yacc;
-  $yacc or skip "No yacc", 1;
-  my $yacc_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $yacc )[0];
-  ok( _is_x($yacc_bin), "$yacc is executable" );
-  diag("Found YACC as $yacc");
+SKIP:
+{
+    my $yacc = Config::AutoConf->check_prog_yacc;
+    $yacc or skip "No yacc", 1;
+    my $yacc_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $yacc )[0];
+    ok( _is_x($yacc_bin), "$yacc is executable" );
+    diag("Found YACC as $yacc");
 }
 
-SKIP: {
-  my $lex = Config::AutoConf->check_prog_lex;
-  $lex or skip "No lex", 1;
-  my $lex_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $lex )[0];
-  ok( _is_x($lex_bin), "$lex is executable" );
-  diag("Found LEX as $lex");
+SKIP:
+{
+    my $lex = Config::AutoConf->check_prog_lex;
+    $lex or skip "No lex", 1;
+    my $lex_bin = ( map { $_ =~ s/^\s+//; $_ =~ s/\s+$//; $_ } Text::ParseWords::shellwords $lex )[0];
+    ok( _is_x($lex_bin), "$lex is executable" );
+    diag("Found LEX as $lex");
 }
 
-SKIP: {
-  my $pkg_config = Config::AutoConf->check_prog_pkg_config;
-  $pkg_config or skip "No pkg-config", 1;
-  ok( _is_x($pkg_config), "$pkg_config is executable" );
-  diag("Found PKG-CONFIG as $pkg_config");
+SKIP:
+{
+    my $pkg_config = Config::AutoConf->check_prog_pkg_config;
+    $pkg_config or skip "No pkg-config", 1;
+    ok( _is_x($pkg_config), "$pkg_config is executable" );
+    diag("Found PKG-CONFIG as $pkg_config");
 }
diff --git a/t/02.compile.t b/t/02.compile.t
index ebb168f..1c0037e 100644
--- a/t/02.compile.t
+++ b/t/02.compile.t
@@ -7,134 +7,137 @@ use Test::More;
 
 use Config::AutoConf;
 
-END {
-  foreach my $f (<config*.*>) {
-    -e $f and unlink $f;
-  }
+END
+{
+    foreach my $f (<config*.*>)
+    {
+        -e $f and unlink $f;
+    }
 }
 
 ## OK, we really hope people have sdtio.h around
-ok(Config::AutoConf->check_header("stdio.h")) or plan skip_all => "No working compile environment";
-ok(!Config::AutoConf->check_header("astupidheaderfile.h"));
-is(Config::AutoConf->check_headers("astupidheaderfile.h", "stdio.h"), "stdio.h");
+ok( Config::AutoConf->check_header("stdio.h") ) or plan skip_all => "No working compile environment";
+ok( !Config::AutoConf->check_header("astupidheaderfile.h") );
+is( Config::AutoConf->check_headers( "astupidheaderfile.h", "stdio.h" ), "stdio.h" );
 
 # check several headers at once
 my $ac = Config::AutoConf->new( logfile => "config2.log" );
 eval { $ac->check_default_headers(); };
-ok( !$@, "check_default_headers" ) or diag( $@ );
+ok( !$@, "check_default_headers" ) or diag($@);
 ## we should find at least a stdio.h ...
-note( "Checking for cache value " . $ac->_cache_name( "stdio.h" ) );
-ok( $ac->cache_val( $ac->_cache_name( "stdio.h" ) ), "found stdio.h" );
+note( "Checking for cache value " . $ac->_cache_name("stdio.h") );
+ok( $ac->cache_val( $ac->_cache_name("stdio.h") ), "found stdio.h" );
 
 # some complex header tests for wide OS support
 eval { $ac->check_dirent_header(); };
-ok( !$@, "check_dirent_header" ) or diag( $@ );
+ok( !$@, "check_dirent_header" ) or diag($@);
 
 # check predeclared symbol
 # as we test a perl module, we expect perl.h available and suitable
 my $include_perl = "#include <EXTERN.h>\n#include <perl.h>";
 
-SKIP: {
+SKIP:
+{
     skip "Constants not defined on this Perl version", 2 if $] <= 5.01000;
 
-    ok $ac->check_decl( "PERL_VERSION_STRING", undef, undef, $include_perl ),
-      "PERL_VERSION_STRING declared";
+    ok $ac->check_decl( "PERL_VERSION_STRING", { prologue => $include_perl } ), "PERL_VERSION_STRING declared";
 
-    ok $ac->check_decls( [qw(PERL_API_REVISION PERL_API_VERSION PERL_API_SUBVERSION)],
-                         undef, undef, $include_perl ),
-                           "PERL_API_* declared";
+    ok $ac->check_decls(
+        [qw(PERL_API_REVISION PERL_API_VERSION PERL_API_SUBVERSION)],
+        { prologue => $ac->_default_includes_with_perl }
+      ),
+      "PERL_API_* declared";
 }
 
-ok $ac->check_decl( "perl_parse(PerlInterpreter *, XSINIT_t , int , char** , char** )",
-                    undef, undef, $include_perl ),
+ok $ac->check_decl( "perl_parse(PerlInterpreter *, XSINIT_t , int , char** , char** )", { prologue => $include_perl } ),
   "perl_parse() declared";
 
 # check declared types
-ok $ac->check_type( "I32", undef, undef, $include_perl ),
-  "I32 is valid type";
+ok $ac->check_type( "I32", { prologue => $include_perl } ), "I32 is valid type";
 
-ok $ac->check_types( ["SV *", "AV *", "HV *" ], undef, undef, $include_perl ),
-  "[SAH]V * are valid types" ;
+ok $ac->check_types( [ "SV *", "AV *", "HV *" ], { prologue => $include_perl } ), "[SAH]V * are valid types";
 
 # check size of perl types
-my $typesize = $ac->check_sizeof_type( "I32", undef, undef, $include_perl );
-ok $typesize, "I32 has size of " . ($typesize ? $typesize : "n/a") . " bytes";
+my $typesize = $ac->check_sizeof_type( "I32", { prologue => $include_perl } );
+ok $typesize, "I32 has size of " . ( $typesize ? $typesize : "n/a" ) . " bytes";
 
-ok $ac->check_sizeof_types( ["I32", "SV *", "AV", "HV *", "SV.sv_refcnt" ], undef, undef, $include_perl ),
-  "Could determined sizes for I32, SV *, AV, HV *, SV.sv_refcnt" ;
+ok $ac->check_sizeof_types( [ "I32", "SV *", "AV", "HV *", "SV.sv_refcnt" ], { prologue => $include_perl } ),
+  "Could determined sizes for I32, SV *, AV, HV *, SV.sv_refcnt";
 
-my $compute = $ac->compute_int( "-sizeof(I32)", undef, $include_perl );
-cmp_ok( $compute, "==", 0-$typesize, "Compute (-sizeof(I32))" );
+my $compute = $ac->compute_int( "-sizeof(I32)", { prologue => $include_perl } );
+cmp_ok( $compute, "==", 0 - $typesize, "Compute (-sizeof(I32))" );
 
 # check perl data structure members
-ok $ac->check_member( "struct av.sv_any", undef, undef, $include_perl ),
-  "have struct av.sv_any member";
+ok $ac->check_member( "struct av.sv_any", { prologue => $include_perl } ), "have struct av.sv_any member";
 
-ok $ac->check_members( ["struct hv.sv_any", "struct STRUCT_SV.sv_any"],
-                       undef, undef, $include_perl ),
+ok $ac->check_members( [ "struct hv.sv_any", "struct STRUCT_SV.sv_any" ], { prologue => $include_perl } ),
   "have struct hv.sv_any and struct STRUCT_SV.sv_any members";
 
 # check aligning
-ok $ac->check_alignof_type( "I32", undef, undef, $include_perl ),
-  "Align of I32";
-ok $ac->check_alignof_type( "SV.sv_refcnt", undef, undef, $include_perl ),
-  "Align of SV.sv_refcnt";
-ok $ac->check_alignof_types( ["I32", "U32", "AV", "HV *", "SV.sv_refcnt" ], undef, undef, $include_perl ),
-  "Could determined sizes for I32, U32, AV, HV *, SV.sv_refcnt" ;
+ok $ac->check_alignof_type( "I32",          { prologue => $include_perl } ), "Align of I32";
+ok $ac->check_alignof_type( "SV.sv_refcnt", { prologue => $include_perl } ), "Align of SV.sv_refcnt";
+ok $ac->check_alignof_types( [ "I32", "U32", "AV", "HV *", "SV.sv_refcnt" ], { prologue => $include_perl } ),
+  "Could determined sizes for I32, U32, AV, HV *, SV.sv_refcnt";
 
 Config::AutoConf->write_config_h();
 ok( -f "config.h", "default config.h created" );
 my $fsize;
-ok( $fsize = (stat("config.h"))[7], "config.h contains content" );
+ok( $fsize = ( stat("config.h") )[7], "config.h contains content" );
 $ac->write_config_h();
 ok( -f "config.h", "default config.h created" );
-cmp_ok( (stat("config.h"))[7], ">", $fsize, "2nd config.h is bigger than first (more checks made)" );
+cmp_ok( ( stat("config.h") )[7], ">", $fsize, "2nd config.h is bigger than first (more checks made)" );
 
-my ($fh, $fbuf, $dbuf);
+my ( $fh, $fbuf, $dbuf );
 open( $fh, "<", "config.h" );
 { local $/; $fbuf = <$fh>; }
-close( $fh );
+close($fh);
 
-if ($] < 5.008) {
-  require IO::String;
-  $fh = IO::String->new($dbuf);
+if ( $] < 5.008 )
+{
+    require IO::String;
+    $fh = IO::String->new($dbuf);
 }
-else {
-  open( $fh, "+>", \$dbuf );
+else
+{
+    open( $fh, "+>", \$dbuf );
 }
-$ac->write_config_h( $fh );
-close( $fh );
+$ac->write_config_h($fh);
+close($fh);
 $fh = undef;
 
 cmp_ok( $dbuf, "eq", $fbuf, "file and direct write computes equal" );
 
-TODO: {
-  -f "META.yml" or $ENV{AUTOMATED_TESTING} = 1;
-  local $TODO = "Quick fix: TODO - analyse diag later" unless $ENV{AUTOMATED_TESTING};
-  my @old_logfh;
-  $dbuf = "";
-
-  if ($] < 5.008) {
-    $fh = IO::String->new($dbuf);
-  }
-  else {
-    open( $fh, "+>", \$dbuf );
-  }
-  @old_logfh = @{$ac->{logfh}};
-  $ac->add_log_fh($fh);
-  cmp_ok(scalar @{$ac->{logfh}}, "==", 2, "Successfully added 2nd loghandle");
-
-  ok( $ac->check_compile_perl_api(), "Could compile perl extensions" ) or diag($dbuf);
-  scalar @old_logfh and $ac->delete_log_fh( $fh );
-  scalar @old_logfh and is_deeply(\@old_logfh, $ac->{logfh}, "add_log_fh/delete_log_fh");
-  defined $fh and close($fh);
-  $fh = undef;
+TODO:
+{
+    -f "META.yml" or $ENV{AUTOMATED_TESTING} = 1;
+    local $TODO = "Quick fix: TODO - analyse diag later" unless $ENV{AUTOMATED_TESTING};
+    my @old_logfh;
+    $dbuf = "";
+
+    if ( $] < 5.008 )
+    {
+        $fh = IO::String->new($dbuf);
+    }
+    else
+    {
+        open( $fh, "+>", \$dbuf );
+    }
+    @old_logfh = @{ $ac->{logfh} };
+    $ac->add_log_fh($fh);
+    cmp_ok( scalar @{ $ac->{logfh} }, "==", 2, "Successfully added 2nd loghandle" );
+
+    ok( $ac->check_compile_perlapi(), "Could compile perl extensions" ) or diag($dbuf);
+    scalar @old_logfh and $ac->delete_log_fh($fh);
+    scalar @old_logfh and is_deeply( \@old_logfh, $ac->{logfh}, "add_log_fh/delete_log_fh" );
+    defined $fh       and close($fh);
+    $fh = undef;
 }
 
-SCOPE: {
-  local $ENV{ac_cv_insane_h} = "/usr/include/insane.h";
-  my $insane_h = $ac->check_header("insane.h");
-  is($insane_h, $ENV{ac_cv_insane_h}, "Cache override for header files work");
+SCOPE:
+{
+    local $ENV{ac_cv_insane_h} = "/usr/include/insane.h";
+    my $insane_h = $ac->check_header("insane.h");
+    is( $insane_h, $ENV{ac_cv_insane_h}, "Cache override for header files work" );
 }
 
 done_testing;
diff --git a/t/03.link.t b/t/03.link.t
index 6f8cb44..852723a 100644
--- a/t/03.link.t
+++ b/t/03.link.t
@@ -4,55 +4,107 @@ use strict;
 use warnings;
 
 use Test::More;
-
 use Config::AutoConf;
 
-END {
-  foreach my $f (<config*.*>) {
-    -e $f and unlink $f;
-  }
+END
+{
+    foreach my $f (<config*.*>)
+    {
+        -e $f and unlink $f;
+    }
 }
 
-my ($ac_1, $ac_2);
+my $ac_1;
 
 ok( $ac_1 = Config::AutoConf->new( logfile => "config3.log" ), "Instantiating Config::AutoConf for check_lib() tests" );
-ok( $ac_2 = Config::AutoConf->new( logfile => "config4.log" ), "Instantiating Config::AutoConf for search_libs() tests" );
-
 ok( $ac_1->check_header("stdio.h") ) or plan skip_all => "No working compile environment";
 
-TODO: {
+ok( $ac_1->check_func("printf"), "Every system should have a printf" );
+my $set_me;
+$ac_1->check_func(
+    "scanf",
+    {
+        action_on_true  => sub { $set_me = 1 },
+        action_on_false => sub { $set_me = 0 }
+    }
+);
+ok( defined $set_me, "Having scanf or not, but now we know" );
+ok( $ac_1->check_funcs( [qw(sprintf sscanf)] ), "Every system should have sprintf and sscanf" );
+
+TODO:
+{
     local $TODO = "It seems some Windows machine doesn't have -lm" if $^O eq "MSWin32";
 
     ## OK, we really hope people have -lm around
-    ok(!$ac_1->check_lib("m", "foobar"), "foobar() not in -lm");
-    ok($ac_1->check_lib("m", "atan"), "atan() in -lm");
+    ok( !$ac_1->check_lib( "m", "foobar" ), "foobar() not in -lm" );
+    ok( $ac_1->check_lib( "m", "atan" ), "atan() in -lm" );
 
-    my $where_atan;
+    my ( $where_atan, $ac_2 );
+    ok( $ac_2 = Config::AutoConf->new( logfile => "config4.log" ), "Instantiating Config::AutoConf for search_libs() tests" );
     ok( $where_atan = $ac_2->search_libs( "atan", [qw(m)] ), "searching lib for atan()" );
     isnt( $where_atan, 0, "library for atan() found (or none required)" );
+}
+
+my ( $ac_3, %math_funcs );
+ok( $ac_3 = Config::AutoConf->new( logfile => "config4_2.log" ), "Instantiating Config::AutoConf for check_lm() tests" );
+$ac_3->check_lm(
+    {
+        action_on_func_lib_true  => sub { my ( $func, $lib, @extra ) = @_; $math_funcs{$func} = $lib },
+        action_on_func_lib_false => sub { my ( $func, $lib, @extra ) = @_; $math_funcs{$func} = 0 },
+    }
+);
+is_deeply(
+    [ sort keys %math_funcs ],
+    [ sort $ac_3->_check_lm_funcs ],
+    "Math functions (" . join( ", ", $ac_3->_check_lm_funcs ) . ") tested for -lm"
+);
+
+eval
+{
+    $ac_3->check_lm(
+        {
+            action_on_lib_true      => sub { },
+            action_on_func_lib_true => sub { },
+        }
+    );
+};
+ok( $@, "action_on_lib_true and action_on_func_lib_true cannot be used together" );
+
+eval
+{
+    $ac_3->check_lm(
+        {
+            action_on_lib_false      => sub { },
+            action_on_func_lib_false => sub { },
+        }
+    );
 };
+ok( $@, "action_on_lib_false and action_on_func_lib_false cannot be used together" );
+
+TODO:
+{
+    -f "META.yml" or $ENV{AUTOMATED_TESTING} = 1;
+    local $TODO = "Quick fix: TODO - analyse diag later" unless $ENV{AUTOMATED_TESTING};
+    my ( $fh, $fbuf, $dbuf, @old_logfh );
+    $dbuf = "";
 
-TODO: {
-  -f "META.yml" or $ENV{AUTOMATED_TESTING} = 1;
-  local $TODO = "Quick fix: TODO - analyse diag later" unless $ENV{AUTOMATED_TESTING};
-  my ($fh, $fbuf, $dbuf, @old_logfh);
-  $dbuf = "";
-
-  if ($] < 5.008) {
-    require IO::String;
-    $fh = IO::String->new($dbuf);
-  }
-  else {
-    open( $fh, "+>", \$dbuf );
-  }
-  @old_logfh = @{$ac_1->{logfh}};
-  $ac_1->add_log_fh($fh);
-  cmp_ok(scalar @{$ac_1->{logfh}}, "==", 2, "Successfully added 2nd loghandle");
-  ok( $ac_1->_check_link_perl_api(), "Could link perl extensions" ) or diag($dbuf);
-  scalar @old_logfh and $ac_1->delete_log_fh( $fh );
-  scalar @old_logfh and is_deeply(\@old_logfh, $ac_1->{logfh}, "add_log_fh/delete_log_fh");
-  defined $fh and close($fh);
-  $fh = undef;
+    if ( $] < 5.008 )
+    {
+        require IO::String;
+        $fh = IO::String->new($dbuf);
+    }
+    else
+    {
+        open( $fh, "+>", \$dbuf );
+    }
+    @old_logfh = @{ $ac_1->{logfh} };
+    $ac_1->add_log_fh($fh);
+    cmp_ok( scalar @{ $ac_1->{logfh} }, "==", 2, "Successfully added 2nd loghandle" );
+    ok( $ac_1->check_link_perlapi(), "Could link perl extensions" ) or diag($dbuf);
+    scalar @old_logfh and $ac_1->delete_log_fh($fh);
+    scalar @old_logfh and is_deeply( \@old_logfh, $ac_1->{logfh}, "add_log_fh/delete_log_fh" );
+    defined $fh       and close($fh);
+    $fh = undef;
 }
 
 done_testing;
diff --git a/t/05.settings.t b/t/05.settings.t
deleted file mode 100644
index f79b1f7..0000000
--- a/t/05.settings.t
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- cperl -*-
-
-use strict;
-use warnings;
-
-use Test::More tests => 9;
-
-use Config::AutoConf;
-
-use Cwd qw(abs_path);
-use File::Basename qw(dirname);
-use File::Spec;
-
-END {
-  foreach my $f (<config*.*>) {
-    -e $f and unlink $f;
-  }
-}
-
-my $pkg_config = Config::AutoConf->check_prog_pkg_config;
-
-SKIP: {
-  $pkg_config or skip "No pkg-config", 1;
-  local $ENV{PKG_CONFIG_PATH} = File::Spec->catdir( dirname(abs_path($0)), "testdata" );
-  my $ac = Config::AutoConf->new(logfile => "config5.log");
-  my $foo_flags = $ac->pkg_config_package_flags("foo");
-  is($foo_flags, "-I/base/path/include/foo-0 -L/base/path/lib/foo -lfoo", "pkg-config flags for 'foo'");
-}
-
-SCOPE: {
-  # this section intensionally works without pkg-config binary
-  local $ENV{bar_CFLAGS} = "-Ibar";
-  local $ENV{bar_LIBS} = "-lbar";
-  my $ac = Config::AutoConf->new(logfile => "config5.log", logfile_mode => ">>");
-  my $bar_flags = $ac->pkg_config_package_flags("bar>2");
-  is($bar_flags, "-Ibar -lbar", "pkg-config flags for 'bar>2'");
-  my $cache_name = $ac->_cache_name(qw/pkg bar/);
-  ok($ac->{cache}->{$cache_name}, "cache entry for 'bar>2' computed correctly");
-}
-
-SCOPE: {
-  local $ENV{PERL_MM_OPT} = "PUREPERL_ONLY=0";
-  local $0 = "Makefile.PL";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  ok(!$ac->check_pureperl_build_wanted(), "PERL_MM_OPT=\"PUREPERL_ONLY=0\" Makefile.PL");
-}
-
-SCOPE: {
-  local $ENV{PERL_MM_OPT} = "PUREPERL_ONLY=1";
-  local $0 = "Makefile.PL";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  ok($ac->check_pureperl_build_wanted(), "PERL_MM_OPT=\"PUREPERL_ONLY=1\" Makefile.PL");
-}
-
-SCOPE: {
-  local $0 = "Makefile.PL";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  $ac->_set_argv("PUREPERL_ONLY=0");
-  ok(!$ac->check_pureperl_build_wanted(), "Makefile.PL PUREPERL_ONLY=0");
-}
-
-SCOPE: {
-  local $0 = "Makefile.PL";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  $ac->_set_argv("PUREPERL_ONLY=1");
-  ok($ac->check_pureperl_build_wanted(), "Makefile.PL PUREPERL_ONLY=1");
-}
-
-SCOPE: {
-  local $0 = "Build.PL";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  $ac->_set_argv("--pureperl-only");
-  ok($ac->check_pureperl_build_wanted(), "Build.PL --pureperl-only");
-}
-
-SCOPE: {
-  local $0 = "Build.PL";
-  local $ENV{PERL_MB_OPT} = "--pureperl-only";
-  my $ac = Config::AutoConf->new(logfile => "config6.log", logfile_mode => ">>");
-  ok($ac->check_pureperl_build_wanted(), "PERL_MB_OPT=\"--pureperl-only\" ");
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-autoconf-perl.git



More information about the Pkg-perl-cvs-commits mailing list