1use ExtUtils::MakeMaker;
2use Config;
3
4sub configure {
5    $ENV{'CC'} # If a compiler is not specified on the command line then
6      or $ENV{'CC'} = $Config{'cc'}; # use the one with which perl was built
7
8    system("./configure") == 0 or
9      die "Error in configuring the Authen::PAM module.\n";
10
11    # returns a reference to anonymous hash which is then interpreted as
12    # additional options to the WriteMakeFile
13    $options = require "pam.cfg";
14
15    if ( $Config{'osname'} eq 'solaris' && $Config{'osvers'} eq '2.6') {
16      print "Adding a workaround for a bug in the Solaris 2.6 pam library\n";
17      ${$options}{'DEFINE'} .= ' -DSTATIC_CONV_FUNC ';
18    }
19
20    foreach (@ARGV) {
21      if (/^-D.+/) {
22	print "Adding a definition '$_' from the command line\n";
23	$options->{DEFINE} .= " $_ " ;
24      }
25    }
26
27    return $options;
28}
29
30sub MY::postamble {
31    my $TARG = MM->catfile('d','PAM.pm');
32qq!$TARG: Makefile
33\techo '#This is a dummy file so CPAN will find a VERSION' > $TARG
34\techo 'package Authen::PAM;' >> $TARG
35\techo '\$\$VERSION = "\$(VERSION)";' >>$TARG
36\techo '#This is to make sure require will return an error' >>$TARG
37\techo '0;' >>$TARG
38\techo '__END__' >>$TARG
39\techo '' >>$TARG
40\tperl -ne 'print if /^=\\w/ ... /^=cut/' PAM.pm.in >>$TARG
41
42!
43}
44
45
46WriteMakefile(
47    'NAME'	=> 'Authen::PAM',
48    'VERSION_FROM' => 'PAM.pm',
49    'LIBS'	=> ['-lpam'],
50    'INC'       => '-I.',          # Needed for PAM_config.h
51    'CONFIGURE' => \&configure,
52    'PREREQ_PM' => { POSIX => 0 }, # module dependenices
53    'dist'      => {
54        COMPRESS => 'gzip -9f',
55        SUFFIX => 'gz',
56        DIST_DEFAULT => 'd/PAM.pm tardist'
57    },
58    'clean'     => { FILES => "PAM.pm" },
59    'realclean' => { FILES => "config.* pam.cfg" }
60);
61
62