File: Makefile.PL

package info (click to toggle)
libcrypt-twofish-perl 2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 96 kB
  • ctags: 61
  • sloc: ansic: 298; perl: 263; makefile: 15
file content (91 lines) | stat: -rw-r--r-- 2,177 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
# $Id: Makefile.PL,v 2.12 2001/05/21 17:38:01 ams Exp $
# Copyright 2001 Abhijit Menon-Sen <ams@wiw.org>

use Config;
use File::Spec;
use ExtUtils::MakeMaker;

($stdint = <<"TEST") =~ s/^\| {0,3}//gm;
|   #include <stdint.h>
|   int main(void) {
|       printf("%d%d", sizeof(uint16_t), sizeof(uint32_t));
|       return 0;
|   }
TEST
($inttypes = $stdint) =~ s/stdint/inttypes/;

print "Searching for uint*_t... ";

if (ftest($inttypes) eq "24") {
    print "inttypes.h";
    $def = "#include <inttypes.h>";
} elsif (ftest($stdint) eq "24") {
    print "stdint.h";
    $def = "#include <stdint.h>";
} else {
    print "no";
    foreach (qw(short int long)) {
        my $size = $Config{"${_}size"};
        $sixteen   ||= "unsigned $_" if ($size == 2);
        $thirtytwo ||= "unsigned $_" if ($size == 4);
    }
    $def = "typedef $sixteen uint16_t;\ntypedef $thirtytwo uint32_t;";
}

print "\n";

($text = <<"PLATFORM") =~ s/^\| {0,3}//gm;
|   /* Automatically generated by "perl Makefile.PL" */
|
|   #ifndef _PLATFORM_H_
|   #define _PLATFORM_H_
|
|   $def
|
|   #endif
PLATFORM

open(F, ">platform.h") || die "platform.h: $!\n";
print F $text;
close F;

sub MY::postamble { "tables.h: tab/tables.pl\n\tperl tab/tables.pl\n" }

WriteMakefile(
    NAME          => 'Crypt::Twofish',
    OBJECT        => 'Twofish.o _twofish.o',
    VERSION_FROM  => 'Twofish.pm',
    ABSTRACT_FROM => 'Twofish.pm',
    depend        => { '_twofish.c' => 'tables.h' }
);

# Compile and run a program to test for a particular feature.
sub ftest
{
    my $null = File::Spec->devnull;
    my $result = 0;

    open(F, ">ftest.c") || die "ftest.c: $!\n";
    print F $_[0];
    close F;

    unlink("ftest");
    open OLDERR, ">&STDERR" || die;
    open OLDOUT, ">&STDOUT" || die;
    open STDOUT, ">$null" || die;
    open STDERR, ">$null" || die;

    if (system("$Config{cc} $Config{ccflags} -o ftest ftest.c") == 0) {
        open STDOUT, ">&OLDOUT" || die;
        open (F, "./ftest |") && do {
            local $/;
            $result = <F>;
        };
    }

    open STDERR, ">&OLDERR" || die;
    open STDOUT, ">&OLDOUT" || die;
    unlink("ftest", "ftest.c");

    return $result;
}