| 1 |
#!perl -w |
| 2 |
use strict; |
| 3 |
use ExtUtils::MakeMaker; |
| 4 |
use Getopt::Long; |
| 5 |
use Config; |
| 6 |
|
| 7 |
my $verbose = $ENV{IM_VERBOSE}; |
| 8 |
my @libpaths; |
| 9 |
my @incpaths; |
| 10 |
|
| 11 |
GetOptions("incpath=s", \@incpaths, |
| 12 |
"libpath=s" => \@libpaths, |
| 13 |
"verbose|v" => \$verbose); |
| 14 |
|
| 15 |
our $BUILDING_IMAGER; |
| 16 |
our %IMAGER_LIBS; |
| 17 |
|
| 18 |
my $MM_ver = eval $ExtUtils::MakeMaker::VERSION; |
| 19 |
|
| 20 |
my %opts = |
| 21 |
( |
| 22 |
NAME => 'Imager::Font::T1', |
| 23 |
VERSION_FROM => 'T1.pm', |
| 24 |
OBJECT => 'T1.o imt1.o', |
| 25 |
clean => { FILES => 'testout' }, |
| 26 |
); |
| 27 |
|
| 28 |
if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) { |
| 29 |
$opts{LICENSE} = "perl_5"; |
| 30 |
$opts{AUTHOR} = 'Tony Cook <[email protected]>'; |
| 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://github.com/tonycoz/imager.git", |
| 46 |
web => "https://github.com/tonycoz/imager.git", |
| 47 |
}, |
| 48 |
bugtracker => |
| 49 |
{ |
| 50 |
web => "https://github.com/tonycoz/imager/issues", |
| 51 |
}, |
| 52 |
}, |
| 53 |
}; |
| 54 |
} |
| 55 |
|
| 56 |
my @inc; |
| 57 |
if ($BUILDING_IMAGER) { |
| 58 |
push @inc, "-I.."; |
| 59 |
unshift @INC, "../lib"; |
| 60 |
} |
| 61 |
else { |
| 62 |
unshift @INC, "inc"; |
| 63 |
print "T1Lib: building independently\n"; |
| 64 |
require Imager::ExtUtils; |
| 65 |
push @inc, Imager::ExtUtils->includes; |
| 66 |
$opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ]; |
| 67 |
|
| 68 |
# Imager required configure through use |
| 69 |
my @Imager_req = ( Imager => "0.95" ); |
| 70 |
if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) { |
| 71 |
$opts{META_MERGE}{prereqs} = |
| 72 |
{ |
| 73 |
configure => |
| 74 |
{ |
| 75 |
requires => |
| 76 |
{ |
| 77 |
@Imager_req, |
| 78 |
}, |
| 79 |
}, |
| 80 |
build => |
| 81 |
{ |
| 82 |
requires => |
| 83 |
{ |
| 84 |
@Imager_req, |
| 85 |
"Test::More" => "0.47", |
| 86 |
} |
| 87 |
}, |
| 88 |
runtime => |
| 89 |
{ |
| 90 |
requires => |
| 91 |
{ |
| 92 |
@Imager_req, |
| 93 |
} |
| 94 |
}, |
| 95 |
test => |
| 96 |
{ |
| 97 |
requires => |
| 98 |
{ |
| 99 |
"Test::More" => "0.47", |
| 100 |
} |
| 101 |
}, |
| 102 |
}; |
| 103 |
$opts{PREREQ_PM} = |
| 104 |
{ |
| 105 |
@Imager_req, |
| 106 |
XSLoader => 0, |
| 107 |
}; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
require Imager::Probe; |
| 112 |
|
| 113 |
my %probe = |
| 114 |
( |
| 115 |
name => "T1Lib", |
| 116 |
inccheck => |
| 117 |
sub { -e File::Spec->catfile($_[0], "t1lib.h") }, |
| 118 |
libbase => "t1", |
| 119 |
testcode => _t1_test_code(), |
| 120 |
testcodeheaders => [ "stdio.h", "string.h", "t1lib.h" ], |
| 121 |
incpath => \@incpaths, |
| 122 |
libpath => \@libpaths, |
| 123 |
verbose => $verbose, |
| 124 |
); |
| 125 |
|
| 126 |
my $probe_res = Imager::Probe->probe(\%probe); |
| •127 |
undef $probe_res; # we don't want to build the T1 lib, cf. #638762 |
| 128 |
if ($probe_res) { |
| 129 |
$IMAGER_LIBS{T1} = 1; |
| 130 |
|
| 131 |
push @inc, $probe_res->{INC}; |
| 132 |
$opts{LIBS} = $probe_res->{LIBS}; |
| 133 |
$opts{DEFINE} = $probe_res->{DEFINE}; |
| 134 |
$opts{INC} = "@inc"; |
| 135 |
|
| 136 |
WriteMakefile(%opts); |
| 137 |
} |
| 138 |
else { |
| 139 |
$IMAGER_LIBS{T1} = 0; |
| 140 |
|
| 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 |
|
| 150 |
sub _t1_test_code { |
| 151 |
return <<'CODE'; |
| 152 |
int font_id; |
| 153 |
if (T1_InitLib(IGNORE_CONFIGFILE|IGNORE_FONTDATABASE) == NULL) { |
| 154 |
fprintf(stderr, "T1Lib: Cannot initialize\n"); |
| 155 |
return 1; |
| 156 |
} |
| 157 |
T1_CloseLib(); |
| 158 |
return 0; |
| 159 |
CODE |
| 160 |
} |