- !system("pkg-config $pkg --exists $redir");
-}
-
-# probes for freetype1 by scanning @incs for the includes and
-# @libs for the libs. This is done separately because freetype's headers
-# are stored in a freetype or freetype1 directory under PREFIX/include.
-#
-# we could find the files with the existing mechanism, but it won't set
-# -I flags correctly.
-#
-# This could be extended to freetype2 too, but freetype-config catches
-# that
-sub freetype1_probe {
- my ($frm, $frmkey) = @_;
-
- my $found_inc;
- INCS:
- for my $inc (@incs) {
- for my $subdir (qw/freetype freetype1/) {
- my $path = File::Spec->catfile($inc, $subdir, 'freetype.h');
- -e $path or next;
- $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
- -e $path and next;
-
- $found_inc = File::Spec->catdir($inc, $subdir);
- last INCS;
- }
- }
-
- my $found_lib;
- LIBS:
- for my $lib (@libs) {
- my $a_path = File::Spec->catfile($lib, "libttf$aext");
- my $l_path = File::Spec->catfile($lib, "libttf.$lext");
- if (-e $a_path || -e $l_path) {
- $found_lib = $lib;
- last LIBS;
- }
- }
-
- return unless $found_inc && $found_lib;
- printf("%10s: includes %s - libraries %s\n", $frmkey,
- ($found_inc ? 'found' : 'not found'),
- ($found_lib ? 'found' : 'not found'));
-
- $frm->{cflags} = "-I$found_inc";
- $frm->{libfiles} = "-lttf";
-
- return 1;
-}
-
-# probes for freetype2 by trying to run freetype-config
-sub freetype2_probe_ftconfig {
- my ($frm, $frmkey) = @_;
-
- is_exe('freetype-config') or return;
-
- my $cflags = `freetype-config --cflags`
- and !$? or return;
- chomp $cflags;
-
- my $lflags = `freetype-config --libs`
- and !$? or return;
- chomp $lflags;
-
- # before 2.1.5 freetype-config --cflags could output
- # the -I options in the wrong order, causing a conflict with
- # freetype1.x installed with the same --prefix
- #
- # can happen iff:
- # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
- # in that order
- # - freetype 1.x headers are in prefix/include/freetype
- my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
- if (@incdirs == 2
- && $incdirs[1] eq "$incdirs[0]/freetype2"
- && -e "$incdirs[0]/freetype/freetype.h"
- && -e "$incdirs[0]/freetype/fterrid.h") {
- print "** freetype-config provided -I options out of order, correcting\n"
- if $VERBOSE;
- $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
- map "-I$_", reverse @incdirs);