]> git.imager.perl.org - imager.git/blob - T1/Makefile.PL
add github action for CI on OS X
[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 if (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
57 my @inc;
58 if ($BUILDING_IMAGER) {
59   push @inc, "-I..";
60   unshift @INC, "../lib";
61 }
62 else {
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
70   my @Imager_req = ( Imager => "0.95" );
71   if (eval { ExtUtils::MakeMaker->VERSION('6.46'); 1 }) {
72     $opts{META_MERGE}{prereqs} =
73       {
74        configure =>
75        {
76         requires =>
77         {
78          @Imager_req,
79         },
80        },
81        build =>
82        {
83         requires =>
84         {
85          @Imager_req,
86          "Test::More" => "0.47",
87         }
88        },
89        runtime =>
90        {
91         requires =>
92         {
93          @Imager_req,
94         }
95        },
96        test =>
97        {
98         requires =>
99         {
100          "Test::More" => "0.47",
101         }
102        },
103       };
104     $opts{PREREQ_PM} =
105       {
106        @Imager_req,
107        XSLoader => 0,
108       };
109   }
110 }
111
112 require Imager::Probe;
113
114 my %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,
124    verbose => $verbose,
125   );
126
127 my $probe_res = Imager::Probe->probe(\%probe);
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 }