update from the separate T1 distribution
[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
28my @inc;
29if ($BUILDING_IMAGER) {
30 push @inc, "-I..";
31 unshift @INC, "../lib";
32}
33else {
34 unshift @INC, "inc";
35 print "T1Lib: building independently\n";
36 require Imager::ExtUtils;
37 push @inc, Imager::ExtUtils->includes;
38 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
39
40 # Imager required configure through use
533bab3e 41 my @Imager_req = ( Imager => "0.81" );
a556912d
TC
42 if ($MM_ver >= 6.46) {
43 $opts{META_MERGE} =
44 {
45 configure_requires =>
46 {
47 @Imager_req,
48 },
49 build_requires =>
50 {
51 @Imager_req,
52 "Test::More" => "0.47",
53 },
54 resources =>
55 {
56 homepage => "http://imager.perl.org/",
57 repository =>
58 {
59 url => "git://git.imager.perl.org/imager-type1.git",
60 web => "http://git.imager.perl.org/imager-type1.git/",
61 type => "git",
62 },
63 },
64 };
65 $opts{PREREQ_PM} =
66 {
67 @Imager_req,
68 };
69 }
70}
71
72require Imager::Probe;
73
74my %probe =
75 (
76 name => "T1Lib",
77 inccheck =>
78 sub { -e File::Spec->catfile($_[0], "t1lib.h") },
79 libbase => "t1",
80 testcode => _t1_test_code(),
81 testcodeheaders => [ "stdio.h", "string.h", "t1lib.h" ],
82 incpath => \@incpaths,
83 libpath => \@libpaths,
84 );
85
86my $probe_res = Imager::Probe->probe(\%probe);
87if ($probe_res) {
d97c8dbd
TC
88 $IMAGER_LIBS{T1} = 1;
89
a556912d
TC
90 push @inc, $probe_res->{INC};
91 $opts{LIBS} = $probe_res->{LIBS};
92 $opts{DEFINE} = $probe_res->{DEFINE};
93 $opts{INC} = "@inc";
94
95 if ($MM_ver > 6.06) {
96 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
97 $opts{ABSTRACT} = 'T1Lib font driver for Imager';
98 }
99
100 WriteMakefile(%opts);
101}
102else {
d97c8dbd
TC
103 $IMAGER_LIBS{T1} = 0;
104
a556912d
TC
105 if ($BUILDING_IMAGER) {
106 ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
107 }
108 else {
109 # fail in good way
110 die "OS unsupported: T1Lib headers/libraries not found\n";
111 }
112}
113
114sub _t1_test_code {
115 return <<'CODE';
116int font_id;
117if (T1_InitLib(IGNORE_CONFIGFILE|IGNORE_FONTDATABASE) == NULL) {
118 fprintf(stderr, "T1Lib: Cannot initialize\n");
119 return 1;
120}
121T1_CloseLib();
122return 0;
123CODE
124}
125