AFS

 view release on metacpan or  search on metacpan

src/Makefile.PL  view on Meta::CPAN

# RCS-Id: "@(#)$RCS-Id: src/Makefile.PL 09f1168 Mon Jan 7 08:10:19 2013 +0100 Norbert E Gruener$"
#
# © 2001-2012 Norbert E. Gruener <nog@MPA-Garching.MPG.de>
#
# This library is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#------------------------------------------------------------------------------
use strict;
use English;

use lib qw(./inc);

use ExtUtils::MakeMaker;
use Config;
use Cwd;
use version 0.77; # get latest bug-fixes and API

my $dir = getcwd;
if ($dir !~ /src$/) { die "Ooops, the Makefile.PL is not sitting in the proper directory\n";}

my $libs;
my $p_flag = '';

if ($Config{usethreads}) {
    # use the threaded version of the AFS libraries for threaded Perl...
    $libs = join (" ", qw(
                          -lbos
                          -lvolser
                          -lvldb
                          -lcmd
                          -lusd
                          -laudit
                          -lc -lafsauthent -lc
                          -lc -lafsrpc -lc
                          -lutil
                         )
                 );
    $p_flag = '-DAFS_PTHREAD_ENV';
}
else {
    # use the unthreaded version of the AFS libraries for unthreaded Perl...
    $libs = join (" ", qw(
                          -lkauth
                          -lprot
                          -lbos
                          -lrx
                          -lvolser
                          -lvldb

                          -lcmd
                          -lubik
                          -lauth

                          -lrxkad
                          -lrxstat
                          -lrx

                          -lsys
                          -ldes
                          -llwp
                          -lcom_err
                          -lutil
                          -lusd
                          -laudit
                         )
                 );
}

# give me the path to the AFS system libraries
# used to build the AFS extension module
my $guess_path;
if    (-r "/usr/local/include/afs/afs.h") { $guess_path = '/usr/local'; }
elsif (-r "/usr/afsws/include/afs/afs.h") { $guess_path = '/usr/afsws'; }
elsif (-r "/usr/include/afs/afs.h")       { $guess_path = '/usr'; }
else                                      { $guess_path = 'unknown'; }

my $AFSPath = $ENV{AFSPATH} || $guess_path;
my $msg = "\nPath to the AFS installation (libraries, binaries, \n"
        . "header files) to be used for this installation? \t ";
$AFSPath = prompt($msg, $AFSPath);
$AFSPath =~ s\/$\\;
if ($AFSPath eq 'unknown') {
    warn "Most probabley you have not installed the AFS system libraries \n";
    if ($ENV{AUTOMATED_TESTING}) { exit 0; }
    die "Script terminated ...\n";
}

# determine the alpha_sys value
my $alpha_sys = 'unknown';
if ($ENV{AFS_SYSNAME}) {
    $alpha_sys = $ENV{AFS_SYSNAME};
}
elsif (-e "$AFSPath/bin/fs") {
    my $fs_sysname = `$AFSPath/bin/fs sysname 2>&1`;
    if ($fs_sysname =~ s/Current sysname is:? //) {
        $fs_sysname =~ s/list? //;
        $fs_sysname =~ /(\w+)/;
        $alpha_sys  = $1;
    }
    else {
        warn "Unknown value for your AFS sysname value: $fs_sysname \n";
        if ($ENV{AUTOMATED_TESTING}) { exit 0; }
        die "Script terminated ...\n";
    }
}
else {
    warn "Could not find the AFS binary 'fs' at $AFSPath/bin \n";
    if ($ENV{AUTOMATED_TESTING}) { exit 0; }
    die "Script terminated ...\n";
}

if ($alpha_sys eq 'unknown') {
    warn "Could not determine the AFS sysname value for your system \n" .
         "But you should never reach this place \n";
    if ($ENV{AUTOMATED_TESTING}) { exit 0; }
    die "Script terminated ...\n";
}

# find out the AFS version of the AFS system libraries
open FILE, ">fotav.c";
print FILE <<'EOF';

src/Makefile.PL  view on Meta::CPAN

print "Your AFS system libraries are located at:  $AFSPath \n";
print "                  their major version is:  $m_version \n";
print "                  and their type is:       \"pthreaded\"\n" if ($Config{usethreads});
print "Your AFS system type seems to be:          $alpha_sys \n\n";
print "The Compile Flags are set to:              $a_flag \n";
print "                                           $d_flag \n";
print "                                           $e_flag \n";
print "                                           $p_flag\n\n";

# set the Makefile values
my $ccflags = $Config::Config{ccflags} || '';
my %MakefileArgs = (
    'NAME'         => 'AFS',
    'VERSION_FROM' => 'AFS.pm',
    'CCFLAGS'      => "-Wall $ccflags",
    'DEFINE'	   => "$d_flag $p_flag $a_flag $e_flag",
    'INC'          => $i_flag . "-I$AFSPath/include",
    'LIBS'         => [
                       "-L$AFSPath/lib -L$AFSPath/lib/afs "
                       . $libs
                      ],
    'realclean'    => {FILES => 'Makefile.bak lib'},
                   );

if ($Config{osname} =~ /aix/) {
    $MakefileArgs{LIBS}->[0] .= ' -ldl';
}
elsif ($Config{osname} =~ /irix/) {
   # just the default LIBS
}
elsif ($Config{osname} =~ /solaris/) {
    $MakefileArgs{DEFINE} .= ' -Dint32=afs_int32 -Duint32=afs_uint32' if $alpha_sys eq 'sun4x_56'; # From Peter@PSDT.com
    $MakefileArgs{LIBS}->[0] .= ' -lresolv -lsocket -lnsl -lintl -ldl';
    $MakefileArgs{CC} = 'gcc';
    #$MakefileArgs{LD} = 'gcc';
    $MakefileArgs{CCCDLFLAGS} = '-fPIC';
}
elsif ($Config{osname} =~ /linux/) {
    $MakefileArgs{LIBS}->[0] .= ' -lresolv';
}
# elsif ($Config{osname} =~ /dec_osf/) {
# # hier fehlt noch was !!!!!
# }
else {
    warn("System type '$Config{osname}' not yet tested with this Makefile.PL...\n\n"
         . "Using the default values, which may or may not work\n"
         . "If it is working, please inform the maintainer of this package.\n"
         . "Thank you.\n\n");
}

WriteMakefile(%MakefileArgs);

# change the library name of the AFS system library "util.a"
my $command = "\'s#-lutil#$AFSPath/lib/afs/util.a#\'";
system("perl -p -i.bak -e $command Makefile") unless -f "$AFSPath/lib/afs/libutil.a";

# change the library name of the AFS system library "vlib.a"
# my $command = "\'s#-lvlib#$AFSPath/lib/afs/vlib.a#\'";
# system("perl -p -i.bak -e $command Makefile") unless -f "$AFSPath/lib/afs/libvlib.a";

# change the library name of the AFS system library "libcom_err"
$command = "\'s#-lcom_err#$AFSPath/lib/afs/libcom_err.a#\'";
system("perl -p -i.bak -e $command Makefile");

# change the library name of the AFS system library "-lafsrpc"
if ($alpha_sys =~ /linux/ && $alpha_sys !~ /i386_linux2/) {
    $command = "\'s#-lc -lafsrpc -lc#$AFSPath/lib/libafsrpc_pic.a#g\'";
}
else {
    $command = "\'s#-lc -lafsrpc -lc#$AFSPath/lib/libafsrpc.a#g\'";
}
system("perl -p -i.bak -e $command Makefile");

# change the library name of the AFS system library "-lafsauthent"
if ($alpha_sys =~ /linux/ && $alpha_sys !~ /i386_linux2/) {
    $command = "\'s#-lc -lafsauthent -lc#$AFSPath/lib/libafsauthent_pic.a#g\'";
}
else {
    $command = "\'s#-lc -lafsauthent -lc#$AFSPath/lib/libafsauthent.a#g\'";
}
system("perl -p -i.bak -e $command Makefile");

# make changes to the typemap file if Perl < 5.6.0
$command = "\'s#T_UV#T_IV#\'";
system("perl -p -i.bak -e $command typemap") unless $] >= 5.006;



( run in 0.632 second using v1.01-cache-2.11-cpan-39bf76dae61 )