fix a fence post error validating a combing mode number
[imager.git] / T1 / Makefile.PL
CommitLineData
a556912d
TC
1#!perl -w
2use strict;
3use ExtUtils::MakeMaker;
4use Getopt::Long;
5use Config;
6
7my $verbose = $ENV{IM_VERBOSE};
8my @libpaths;
9my @incpaths;
10
11GetOptions("incpath=s", \@incpaths,
12 "libpath=s" => \@libpaths,
13 "verbose|v" => \$verbose);
14
15our $BUILDING_IMAGER;
d97c8dbd 16our %IMAGER_LIBS;
a556912d
TC
17
18my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
19
20my %opts =
21 (
22 NAME => 'Imager::Font::T1',
23 VERSION_FROM => 'T1.pm',
24 OBJECT => 'T1.o imt1.o',
25 clean => { FILES => 'testout' },
26 );
27
572d5255
TC
28if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
29 $opts{LICENSE} = "perl_5";
30 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
31 $opts{ABSTRACT} = 'T1Lib font driver for Imager';
32 $opts{META_MERGE} =
33 {
34 'meta-spec' =>
35 {
36 version => "2",
37 url => "https://metacpan.org/pod/CPAN::Meta::Spec",
38 },
39 resources =>
40 {
41 homepage => "http://imager.perl.org/",
42 repository =>
43 {
44 type => "git",
45 url => "git://git.imager.perl.org/imager.git",
46 web => "http://git.imager.perl.org/imager.git",
47 },
48 bugtracker =>
49 {
50 web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
51 mailto => 'bug-Imager@rt.cpan.org',
52 },
53 },
54 };
55}
56
a556912d
TC
57my @inc;
58if ($BUILDING_IMAGER) {
59 push @inc, "-I..";
60 unshift @INC, "../lib";
61}
62else {
63 unshift @INC, "inc";
64 print "T1Lib: building independently\n";
65 require Imager::ExtUtils;
66 push @inc, Imager::ExtUtils->includes;
67 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
68
69 # Imager required configure through use
5eac8456 70 my @Imager_req = ( Imager => "0.95" );
572d5255
TC
71 if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
72 $opts{META_MERGE}{prereqs} =
a556912d 73 {
572d5255 74 configure =>
a556912d 75 {
572d5255
TC
76 requires =>
77 {
78 @Imager_req,
79 },
a556912d 80 },
572d5255 81 build =>
a556912d 82 {
572d5255
TC
83 requires =>
84 {
85 @Imager_req,
86 "Test::More" => "0.47",
87 }
a556912d 88 },
572d5255 89 runtime =>
a556912d 90 {
572d5255
TC
91 requires =>
92 {
93 @Imager_req,
94 }
95 },
96 test =>
97 {
98 requires =>
99 {
100 "Test::More" => "0.47",
101 }
a556912d
TC
102 },
103 };
104 $opts{PREREQ_PM} =
105 {
106 @Imager_req,
a5919365 107 XSLoader => 0,
a556912d
TC
108 };
109 }
110}
111
112require Imager::Probe;
113
114my %probe =
115 (
116 name => "T1Lib",
117 inccheck =>
118 sub { -e File::Spec->catfile($_[0], "t1lib.h") },
119 libbase => "t1",
120 testcode => _t1_test_code(),
121 testcodeheaders => [ "stdio.h", "string.h", "t1lib.h" ],
122 incpath => \@incpaths,
123 libpath => \@libpaths,
0987aae1 124 verbose => $verbose,
a556912d
TC
125 );
126
127my $probe_res = Imager::Probe->probe(\%probe);
128if ($probe_res) {
d97c8dbd
TC
129 $IMAGER_LIBS{T1} = 1;
130
a556912d
TC
131 push @inc, $probe_res->{INC};
132 $opts{LIBS} = $probe_res->{LIBS};
133 $opts{DEFINE} = $probe_res->{DEFINE};
134 $opts{INC} = "@inc";
135
a556912d
TC
136 WriteMakefile(%opts);
137}
138else {
d97c8dbd
TC
139 $IMAGER_LIBS{T1} = 0;
140
a556912d
TC
141 if ($BUILDING_IMAGER) {
142 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
143 }
144 else {
145 # fail in good way
146 die "OS unsupported: T1Lib headers/libraries not found\n";
147 }
148}
149
150sub _t1_test_code {
151 return <<'CODE';
152int font_id;
153if (T1_InitLib(IGNORE_CONFIGFILE|IGNORE_FONTDATABASE) == NULL) {
154 fprintf(stderr, "T1Lib: Cannot initialize\n");
155 return 1;
156}
157T1_CloseLib();
158return 0;
159CODE
160}