use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. use strict; use Config; use Getopt::Long; my %options; my @whichcand = qw(/bin/which /usr/bin/which); my $LINE = "\n\n----------------------------------------------------------\n"; &GetOptions(\%options , "gssapiimpl=s", "help", "gssapi_libs=s", "gssapi_inc=s", "gssapi_lddlflags=s"); open(MANIFEST, "MANIFEST") or die "$0: Unable to open MANIFEST: $!"; my $otherxs = join " ", map { substr($_, 0, -1) } grep { m:^xs/: } ; close(MANIFEST); if ($options{'help'}){ print < # if ( @{$otherparm} > 0 ) { my $lddflagstring = join ' ', $Config{lddlflags}, @{$otherparm}; if ( $Config{lddlflags} ) { print $LINE, ' Adding from your Perlinstallation ($Config{lddlflags}) to LDDLFLAGS', "\n\n ", $Config{lddlflags}; } print $LINE, " Bypassing to LDDLFLAGS \n\n $lddflagstring"; push @LDDLFLAGS, 'LDDLFLAGS', $lddflagstring ; } #-------------------------------------- push @GSSLIBS, join ' ', @{$gsslibs}; } #--------------------------------------------------------------- $incconf = krb5_cflags( $krb5cmd ); unless ( $incconf ) { # # krb5-conf does not respond -I/usr/include # on Fedora and RHL. # Thanks to Dax Kelson # $incconf = '-I/usr/include'; } #--------------------------------------------------------------- if ( is_heimdal($krb5cmd) ) { push @EXTRADEFINES, '-DHEIMDAL'; } if ( is_mit_1_2($krb5cmd) ) { # # activate Workaround to support # MIT Kerberos 1.2.x # (constants in old lowercase-style) # push @EXTRADEFINES, '-DMITKERB12'; } } #-------------------------------------------------------------- print "$LINE Adding own DEFINEs \n\n @EXTRADEFINES" if( scalar(@EXTRADEFINES) ); print "$LINE Using LIBS\n\n @GSSLIBS", "$LINE Using INC includeconfiguration\n\n $incconf", $LINE; #-------------------------------------------------------------- WriteMakefile( LIBS => join (' ', @GSSLIBS), 'NAME' => 'GSSAPI', 'VERSION_FROM' => 'GSSAPI.pm', # 'CCFLAGS' => '-Wall', 'PREREQ_PM' => { 'Test::More' => 0 }, @LDDLFLAGS, 'DEFINE' => join (' ', @EXTRADEFINES), 'INC' => $incconf, 'macro' => { OTHER_XS => $otherxs }, 'depend' => { 'GSSAPI.c' => '$(OTHER_XS)' } ); #-------------------------------------------------------------- #------------------------------------------------- sub find_which_command { foreach (@whichcand) { return $_ if ( -e $_); } return undef; } #------------------------------------------------- sub find_krb5config_cmd { my ($expl_path) = @_; my $r = undef; unless ($expl_path) { #my $whichcmd = find_which_command() || die 'cannot locate which command'; $r = `which krb5-config 2>/dev/null`; chomp $r; } else { my $supposed = join '/', $expl_path, 'bin', 'krb5-config'; if ( -e $supposed ) { $r = $supposed ; } } return $r; } #------------------------------------------------- sub krb5_libconfig { my ($cfgcmd) = @_; $cfgcmd || die 'no $cfgcmd '; return `$cfgcmd --libs gssapi`; } #------------------------------------------------- #------------------------------------------------- sub krb5_cflags { my ($cfgcmd) = @_; $cfgcmd || die 'no $cfgcmd '; return `$cfgcmd --cflags gssapi`; } #------------------------------------------------- sub krb5_version { my ($cfgcmd) = @_; $cfgcmd || die 'no $cfgcmd '; return `$cfgcmd --version`; } #------------------------------------------------- #------------------------------------------------- sub is_heimdal { my ($cfgcmd) = @_; my $r = undef; my @vinfo = krb5_version( $cfgcmd ); FOUND: { foreach ( @vinfo) { if ( m/eimdal/) { $r = 1; last FOUND; } } } return $r; } #------------------------------------------------- sub is_mit_1_2 { my ($cfgcmd) = @_; my $r = undef; my @vinfo = krb5_version( $cfgcmd ); FOUND: { foreach ( @vinfo) { if ( m/Kerberos 5 release 1\.2/) { $r = 1; last FOUND; } } } return $r; } #------------------------------------------------- sub find_libs_in_krb5config_string { my ( $confstringstring ) = @_; my (@libs, @others); foreach ( split ' ', $confstringstring ) { if ( m/(-(Wl,-R|[LlR])[^ ]*)/) { push @libs, $1 } else { push @others, $_; } } return (\@libs, \@others); } #-------------------------------------------------