3 use ExtUtils::MakeMaker qw(WriteMakefile WriteEmptyMakefile);
7 my $verbose = $ENV{IM_VERBOSE};
11 GetOptions("incpath=s", \@incpaths,
12 "libpath=s" => \@libpaths,
13 "verbose|v" => \$verbose);
19 my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
23 NAME => 'Imager::Font::FT2',
24 VERSION_FROM => 'FT2.pm',
25 OBJECT => 'FT2.o freetyp2.o',
26 clean => { FILES => 'testout' },
30 if ($BUILDING_IMAGER) {
32 unshift @INC, "../lib";
36 print "FreeType 2: building independently\n";
37 require Imager::ExtUtils;
38 push @inc, Imager::ExtUtils->includes;
39 $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
41 # Imager required configure through use
42 my @Imager_req = ( Imager => "0.77" );
43 if ($MM_ver >= 6.46) {
53 "Test::More" => "0.47",
57 homepage => "http://imager.perl.org/",
60 url => "http://imager.perl.org/svn/trunk/Imager-Font-FT2",
61 web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager-Font-FT2",
73 require Imager::Probe;
78 code => \&freetype2_probe_ftconfig,
80 sub { -e File::Spec->catfile($_[0], "freetype/ftbitmap.h") },
81 libbase => "freetype",
82 testcode => _ft2_test_code(),
83 testcodeheaders => [ "stdio.h", "string.h", "ft2build.h" ],
84 incpath => join($Config{path_sep}, @incpaths),
85 libpath => join($Config{path_sep}, @libpaths),
89 incsuffix => "freetype2",
92 incsuffix => "freetype",
97 my $probe_res = Imager::Probe->probe(\%probe);
99 push @inc, $probe_res->{INC};
100 $opts{LIBS} = $probe_res->{LIBS};
104 if ($MM_ver > 6.06) {
105 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
106 $opts{ABSTRACT} = 'FreeType 2 font driver for Imager';
109 WriteMakefile(%opts);
112 if ($BUILDING_IMAGER) {
113 WriteEmptyMakefile(%opts);
117 die "OS unsupported: FreeType 2 headers/libraries not found\n";
130 my @exe_suffix = $Config{_exe};
131 if ($^O eq 'MSWin32') {
132 push @exe_suffix, qw/.bat .cmd/;
135 for my $dir (File::Spec->path) {
136 for my $suffix (@exe_suffix) {
137 -x catfile($dir, "$name$suffix")
145 # probes for freetype2 by trying to run freetype-config
146 sub freetype2_probe_ftconfig {
149 is_exe('freetype-config') or return;
151 my $cflags = `freetype-config --cflags`
155 my $lflags = `freetype-config --libs`
159 # before 2.1.5 freetype-config --cflags could output
160 # the -I options in the wrong order, causing a conflict with
161 # freetype1.x installed with the same --prefix
164 # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
166 # - freetype 1.x headers are in prefix/include/freetype
167 my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
169 && $incdirs[1] eq "$incdirs[0]/freetype2"
170 && -e "$incdirs[0]/freetype/freetype.h"
171 && -e "$incdirs[0]/freetype/fterrid.h") {
172 print "** freetype-config provided -I options out of order, correcting\n"
174 $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
175 map "-I$_", reverse @incdirs);
178 print "$req->{name}: configured via freetype-config\n";