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