File: Makefile.PL

package info (click to toggle)
libgssapi-perl 0.22-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 180 kB
  • ctags: 35
  • sloc: perl: 706; makefile: 53
file content (249 lines) | stat: -rw-r--r-- 7,733 bytes parent folder | download
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
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/: }
		<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";
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) {
	die 'not found!';
    } else {
      print "\n\n $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 {
      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 ( is_heimdal($krb5cmd) ) {
       push @EXTRADEFINES,  '-DHEIMDAL';
       #print $LINE, ' Setting Heimdal Defines';
    }
    #
    # Reading this at configuration Time is boring
    #
    #else {
    #   print $LINE, ' Setting MIT defines';
    #}
}


#--------------------------------------------------------------
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 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);
}
#-------------------------------------------------