libbase => "freetype",
testcode => _ft2_test_code(),
testcodeheaders => [ "stdio.h", "string.h", "ft2build.h" ],
+ testcodeprologue => _ft2_test_code_prologue(),
incpath => join($Config{path_sep}, @incpaths),
libpath => join($Config{path_sep}, @libpaths),
alternatives =>
sub _ft2_test_code {
return <<'CODE';
+FT_Library library = 0;
+FT_Face face = 0;
+FT_Error error;
+error = FT_Init_FreeType(&library);
+if (error) {
+ fprintf(stderr, "FreeType 2: cannot initialize library: %d\n", error);
+ return 1;
+}
+error = FT_New_Face(library, "fontfiles/dodge.ttf", 0, &face);
+if (error) {
+ fprintf(stderr, "FreeType 2: cannot load font: %d\n", error);
+ return 1;
+}
return 0;
CODE
}
+sub _ft2_test_code_prologue {
+ return <<'CODE';
+#include FT_FREETYPE_H
+
+CODE
+}
+
sub is_exe {
my ($name) = @_;
=back
+If you need to perform know more than "does it link?" you can provide
+code to be compiled and run:
+
+=over
+
+=item function
+
+the body of the <main()> function. If not provided C<return 0;> is
+used.
+
+=item prologue
+
+code to insert between the C<#include> of the headers and the
+definition of main.
+
+=back
+
=head2 check_lib_or_exit
This behaves exactly the same as C<assert_lib()> except that instead of
'assertlibXXXXXXXX', SUFFIX => '.c'
);
print $ch qq{#include <$_>\n} foreach (@headers);
+ print $ch "\n$args{prologue}\n" if $args{prologue};
print $ch "int main(void) { ".($args{function} || 'return 0;')." }\n";
close($ch);
for my $link_cfg ( @link_cfgs ) {
INC => $result->{INC},
header => $req->{testcodeheaders},
function => $req->{testcode},
+ prologue => $req->{testcodeprologue},
);
unless ($good) {
print "$req->{name}: Test code failed: $@";
=item *
+C<testcodeprologue> - C code to insert between the headers and the
+main function.
+
+=item *
+
C<incpath> - C<$Config{path_sep}> separated list of header file
directories to check.