AFS

 view release on metacpan or  search on metacpan

src/Makefile.PL  view on Meta::CPAN

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';
#include <stdio.h>

int main(void)
{
  extern char *AFSVersion;
  printf(">%s<\n",AFSVersion);
}
EOF
close FILE;

system("$Config::Config{cc} fotav.c -L$AFSPath/lib -lubik");
if ($CHILD_ERROR) {
    unlink 'fotav.c';
    die "\nCould not compile test code to retrieve the version of AFS system libraries...\n";
}
my $version = `./a.out` || die "\nCould not run test code to retrieve the version of AFS system libraries...\n";



( run in 0.707 second using v1.01-cache-2.11-cpan-13bb782fe5a )