]> git.imager.perl.org - imager.git/blob - T1/Makefile.PL
Changes updates
[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 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 my @inc;
29 if ($BUILDING_IMAGER) {
30   push @inc, "-I..";
31   unshift @INC, "../lib";
32 }
33 else {
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
41   my @Imager_req = ( Imager => "0.95" );
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 => "git://git.imager.perl.org/imager.git",
58         bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
59        },
60       };
61     $opts{PREREQ_PM} =
62       {
63        @Imager_req,
64        XSLoader => 0,
65       };
66   }
67 }
68
69 require Imager::Probe;
70
71 my %probe =
72   (
73    name => "T1Lib",
74    inccheck =>
75    sub { -e File::Spec->catfile($_[0], "t1lib.h") },
76    libbase => "t1",
77    testcode => _t1_test_code(),
78    testcodeheaders => [ "stdio.h", "string.h", "t1lib.h" ],
79    incpath => \@incpaths,
80    libpath => \@libpaths,
81    verbose => $verbose,
82   );
83
84 my $probe_res = Imager::Probe->probe(\%probe);
85 if ($probe_res) {
86   $IMAGER_LIBS{T1} = 1;
87
88   push @inc, $probe_res->{INC};
89   $opts{LIBS} = $probe_res->{LIBS};
90   $opts{DEFINE} = $probe_res->{DEFINE};
91   $opts{INC} = "@inc";
92
93   if ($MM_ver > 6.06) {
94     $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>';
95     $opts{ABSTRACT} = 'T1Lib font driver for Imager';
96   }
97   
98   WriteMakefile(%opts);
99 }
100 else {
101   $IMAGER_LIBS{T1} = 0;
102
103   if ($BUILDING_IMAGER) {
104     ExtUtils::MakeMaker::WriteEmptyMakefile(%opts);
105   }
106   else {
107     # fail in good way
108     die "OS unsupported: T1Lib headers/libraries not found\n";
109   }
110 }
111
112 sub _t1_test_code {
113   return <<'CODE';
114 int font_id;
115 if (T1_InitLib(IGNORE_CONFIGFILE|IGNORE_FONTDATABASE) == NULL) {
116   fprintf(stderr, "T1Lib: Cannot initialize\n");
117   return 1;
118 }
119 T1_CloseLib();
120 return 0;
121 CODE
122 }
123