1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
|
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 5.006; # builds on 5.005, but Slaven Rezic got strange testresults
use Config;
use Getopt::Long;
my %options;
my @whichcand = qw(/bin/which /usr/bin/which);
my @KRB5_CONFIG_TRIES = (
'/usr/kerberos/bin/krb5-config', # for use with CentOS, as suggested by Mark Hedges in https://rt.cpan.org/Ticket/Display.html?id=48732
'/usr/bin/krb5-config', # always worth a try ;-)
);
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/: }
<MANIFEST>;
close(MANIFEST);
if ($options{'help'}){
print <<HELP;
==================================================================
BUILDING HELP
==================================================================
Hello - you obviously need Help! :-)
This additional command line options are available
for adjusting:
(1) --gssapiimpl /bla/local/heimdal
This tells me where to look for your installed
GSSAPI installation MIT or Heimdal.
This must be the directory that contains
the ./bin/krb5_config utility.
(2) --gssapi_libs='-L/bla/local/mitkrb/lib -lgss_all'
The precise location of the libraries with -L and the libraries needed with -l.
(3) --gssapi_inc -I/bla/local/mitkrb/include
The exact location of the header files.
(4) --gssapi_lddlflags='-shared -Wl,--enable-new-dtags -Wl,-rpath -Wl/bla/local/mitkrb/lib'
Allows for any flags to be passed to the linker, for instance if WriteMakefile ignores
entries in LIBS.
Option (1) is preferred, use (2),(3) and (4) only if needed and you know what you
are doing. If any of (2),(3) or (4) is supplied, (1) will be ignored.
HELP
;
exit;
}
#-------------------------------------------------------------
print "\n Welcome to GSSAPI.pm setup! \n\n ($0 Version 0.03) \n";
print qq{\n run "perl Makefile.PL --help" to see further installation options\n};
#---------------------------------------------------------------
my @GSSLIBS = ();
my @LDDLFLAGS = ();
my $incconf = '';
my @EXTRADEFINES;
#---------------------------------------------------------------
if (exists $options{gssapi_libs} || exists $options{gssapi_inc} || exists $options{gssapi_lddlflags} ) {
if ($options{gssapi_libs}) {
push @GSSLIBS, $options{gssapi_libs}
} else {
die 'if options gssapi_inc or gssapi_lddlflags are provided, then gssapi_libs must be as well';
}
if ($options{gssapi_inc}) {
$incconf = $options{gssapi_inc}
} else {
die 'if options gssapi_libs or gssapi_lddlflags are provided, then gssapi_inc must be as well';
}
if ($options{gssapi_lddlflags}) {
if ( $Config{lddlflags} ) {
print "$LINE Adding from your Perlinstallation (\$Config{lddlflags}) to LDDLFLAGS \n",
$Config{lddlflags};
}
push @LDDLFLAGS, 'LDDLFLAGS',
join ' ', $Config{lddlflags}, $options{gssapi_lddlflags};
}
} else {
print $LINE, ' Searching krb5-config command... ';
my $krb5cmd = find_krb5config_cmd($options{'gssapiimpl'} );
unless ($krb5cmd) {
print 'NOT FOUND!';
print "\n\n seems this is a missing prerequirement.",
"\n The README file shipped with this module provides\n more information regarding prerequirements. \n\n";
exit 0; # send no automated FAIL testreport
} else {
print "\n\n using krb5-config command '$krb5cmd'.";
}
#---------------------------------------------
my $implementation = krb5_version( $krb5cmd );
print $LINE, " using GSSAPI implementation \n $implementation";
#---------------------------------------------
my $libconf = krb5_libconfig( $krb5cmd );
unless ($libconf) {
die "$krb5cmd does not respond libconf!";
} else {
if ($libconf =~ /Unknown/ && $implementation =~ /Solaris Kerberos/) {
$libconf = "-L/usr/lib -R/usr/lib -lgss";
}
my ($gsslibs, $otherparm) = find_libs_in_krb5config_string( $libconf );
#
# LIBS accepts only -L and -l flags and ignores others.
# but we need them at linktime!
# so all the output of krb5-config --libs gssapi
# has to be passed into LDDLFLAGS,
# und only -L and -l params to LIBS (to avoid warnings)
# <http://sourceforge.net/mailarchive/forum.php?thread_id=9655729&forum_id=47637>
#
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 <dax@gurulabs.com>
#
$incconf = '-I/usr/include';
}
if ($incconf =~ /Unknown/ && $implementation =~ /Solaris Kerberos/) {
$incconf = "-I/usr/include/kerberosv5";
push @EXTRADEFINES, '-DSEAM';
}
#---------------------------------------------------------------
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(
'AUTHOR' => 'Achim Grolms <perl@grolmsnet.de>',
'ABSTRACT_FROM' => 'GSSAPI.pm',
'LICENSE' => 'perl',
'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;
unless ( $r ) {
my $n = 1;
print "\n krb5-config NOT found in \$PATH... now doing some guesswork: \n";
foreach $r ( @KRB5_CONFIG_TRIES ) {
print "\n $n. trying $r ...";
if ( -e $r ) {
print 'found.';
return $r;
}
else {
print 'not found.';
}
$n++;
}
}
} 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/ && !m/Solaris Kerberos/) {
$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])[^ ]*)/) {
if ( m/(^-(Wl,-R|[LlR])[^ ]*)/) {
push @libs, $1
} else {
push @others, $_;
}
}
return (\@libs, \@others);
}
#-------------------------------------------------
|