File: Makefile.PL

package info (click to toggle)
libtext-qrcode-perl 0.01-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 304 kB
  • sloc: perl: 1,682; makefile: 2
file content (99 lines) | stat: -rw-r--r-- 2,519 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
use strict;
use warnings;
use inc::Module::Install;
use File::Copy;

name                'Text-QRCode';
author              'Yoshiki Kurihara <kurihara at cpan.org>';
all_from            'lib/Text/QRCode.pm',

cc_inc_paths '.';
can_cc or die 'This module requires a C compiler';

auto_install;
WriteAll;

sub MY::post_constants {
    my $define = eval { test_libqrencode() };
    if ( $@ ) {
        warn $@;
        exit 0; # tell cpan testers that this is not a failure
    }
    return <<"POST_CONST";
CCFLAGS += $define
LDDLFLAGS += -lqrencode
LDFLAGS += -lqrencode
POST_CONST
}

sub test_libqrencode {
    my $compile_cmd
        = 'cc -I/usr/local/include -I/usr/include -L/usr/lib -L/usr/local/lib -lqrencode';
    my $libqrencode_url
        = 'http://megaui.net/fukuchi/works/qrencode/index.en.html';
    my $version;
    my $fh;
    my %define_of = (
        '1.0.2' => '-DUNDER_LIBQRENCODE_1_0_2',
        '2.0.0' => '-DOVER_LIBQRENCODE_2_0_0',
    );

    open $fh, '>', 'test_libqrencode.c';
    print $fh <<'EOT';
#include <stdio.h>
#include "qrencode.h"

int main(int argc, char **argv)
{
    QRcode *code;
    return 0;
}
EOT
    ;
    close $fh;

    system("$compile_cmd -o test_libqrencode test_libqrencode.c >/dev/null 2>&1") == 0
        or do {
            unlink for qw( test_libqrencode test_libqrencode.c );
            die "*** You must install libqrencode.\n*** See $libqrencode_url";
        };

    open $fh, '>', 'test_libqrencode1.0.2.c';
    print $fh <<'EOT';
#include <stdio.h>
#include "qrencode.h"

int main(int argc, char **argv)
{
    QRcode *code;
    code = (QRcode *)QRcode_encodeStringCase("foo", 1, QR_ECLEVEL_L);
    return 0;
}
EOT
    ;
    system("$compile_cmd -o test_libqrencode1.0.2 test_libqrencode1.0.2.c >/dev/null 2>&1") == 0
        and $version = "1.0.2";

    open $fh, '>', 'test_libqrencode2.0.0.c';
    print $fh <<'EOT';
#include <stdio.h>
#include "qrencode.h"

int main(int argc, char **argv)
{
    QRcode *code;
    code = (QRcode *)QRcode_encodeString8bit("foo", 1, QR_ECLEVEL_L);
    return 0;
}
EOT
    ;
    system("$compile_cmd -o test_libqrencode2.0.0 test_libqrencode2.0.0.c >/dev/null 2>&1") == 0
        and $version = "2.0.0";

    unlink for qw( test_libqrencode test_libqrencode.c
                   test_libqrencode1.0.2 test_libqrencode1.0.2.c
                   test_libqrencode2.0.0 test_libqrencode2.0.0.c );

    die "*** Unknown error occured in libqrencode version check process." unless $version;
    return $define_of{ $version };
}