fix typo
[imager.git] / Makefile.PL
CommitLineData
ea9e6c3f 1#!perl -w
02d1d628
AMH
2use ExtUtils::MakeMaker;
3use Cwd;
4use Config;
07ea6c21 5use File::Spec;
37959076 6use Getopt::Long;
02d1d628 7
02d1d628
AMH
8#
9# IM_INCPATH colon seperated list of paths to extra include paths
10# IM_LIBPATH colon seperated list of paths to extra library paths
11#
12# IM_VERBOSE turns on verbose mode for the library finding and such
13# IM_MANUAL to manually select which libraries are used and which not
14# IM_ENABLE to programmatically select which libraries are used
15# and which are not
16# IM_NOLOG if true logging will not be compiled into the module
17# IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
18# do not use IM_DEBUG_MALLOC in production - this slows
19# everything down by alot
20# IM_CFLAGS Extra flags to pass to the compiler
21# IM_LFLAGS Extra flags to pass to the linker
22# IM_DFLAGS Extra flags to pass to the preprocessor
f4dbac50 23# IM_SUPPRESS_PROMPT Suppress the prompt asking about gif support
02d1d628 24
37959076
TC
25my $help;
26my @enable;
27my @disable;
28my @incpaths;
29my @libpaths;
30my $noprobe;
31GetOptions("help" => \$help,
32 "enable=s" => \@enable,
33 "disable=s" => \@disable,
34 "incpath=s", \@incpaths,
35 "libpath=s" => \@libpaths,
36 "noprobe" => \$noprobe);
37
38if ($help) {
39 usage();
40}
41
42if (@enable && @disable) {
43 print STDERR "Only --enable or --disable can be used, not both, try --help\n";
44 exit 1;
45}
02d1d628
AMH
46
47getenv(); # get environment variables
48init(); # initialize global data
49pathcheck(); # Check if directories exist
50
37959076
TC
51if (exists $ENV{IM_ENABLE}) {
52 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
53 for my $key (keys %formats) {
54 delete $formats{$key} unless $en{$key};
55 }
56}
57if (@enable) {
58 my %en = map { $_ => 1 } map { split /,/ } @enable;
59 for my $key (keys %formats) {
60 delete $formats{$key} unless $en{$key};
61 }
62}
63elsif (@disable) {
64 delete @formats{map { split /,/ } @disable};
65}
66
e11d297f
TC
67my @defines;
68
02d1d628
AMH
69# Pick what libraries are used
70if ($MANUAL) {
71 manual();
72} else {
73 automatic();
02d1d628
AMH
74}
75
76# Make sure there isn't a clash between the gif libraries.
77gifcheck();
78
07ea6c21 79my $lib_cflags = '';
80c15fc7
TC
80my $F_LIBS = '';
81my $F_OBJECT = '';
e11d297f
TC
82for my $frmkey (keys %formats) {
83 my $frm = $formats{$frmkey};
84 push @defines, [ $frm->{def}, 1, "$frmkey available" ];
02d1d628
AMH
85 $F_LIBS .= ' ' .$frm->{libfiles};
86 $F_OBJECT .= ' ' .$frm->{objfiles};
07ea6c21 87 $lib_cflags .= ' ' .$frm->{cflags} if $frm->{cflags};
02d1d628
AMH
88}
89
ea9e6c3f
TC
90$F_INC = join ' ', map "-I$_", map / / ? qq{"$_"} : $_,
91 grep !exists $definc{$_}, @incs;
92$F_LIBS = join(' ',map "-L$_", map / / ? qq{"$_"} : $_, @libs) . $F_LIBS;
02d1d628
AMH
93
94$OSLIBS = '';
95$OSDEF = "-DOS_$^O";
96
97if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
98if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
99
9982a307
AMH
100@objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
101 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o
02d1d628 102 filters.o dynaload.o stackmach.o datatypes.o
2df3535a 103 regmach.o trans2.o quant.o error.o convert.o
261f91c5 104 map.o tags.o palimg.o maskimg.o img16.o rotate.o
77157728 105 bmp.o tga.o rgb.o color.o fills.o imgdouble.o limits.o);
02d1d628
AMH
106
107%opts=(
108 'NAME' => 'Imager',
109 'VERSION_FROM' => 'Imager.pm',
110 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS",
e11d297f 111 'DEFINE' => "$OSDEF $CFLAGS",
07ea6c21 112 'INC' => "$lib_cflags $DFLAGS $F_INC",
de2b8bae 113 'OBJECT' => join(' ', @objs, $F_OBJECT),
8746dc75 114 clean => { FILES=>'testout meta.tmp' },
02d1d628
AMH
115 );
116
29316bdb
TC
117if ($ExtUtils::MakeMaker::VERSION > 6.06) {
118 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson';
ca508100
TC
119 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
120}
121
e11d297f
TC
122make_imconfig(\@defines);
123
02d1d628
AMH
124if ($VERBOSE) { print Dumper(\%opts); }
125mkdir('testout',0777); # since we cannot include it in the archive.
126WriteMakefile(%opts);
4dce694d 127
02d1d628
AMH
128exit;
129
130
131sub MY::postamble {
132'
faa9b3e7 133dyntest.$(MYEXTLIB) : dynfilt/Makefile
02d1d628
AMH
134 cd dynfilt && $(MAKE) $(PASTHRU)
135
136lib/Imager/Regops.pm : regmach.h regops.perl
137 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
e11d297f
TC
138
139imconfig.h: Makefile.PL
140 $(ECHO) "imconfig.h out-of-date with respect to $?"
141 $(PERLRUN) Makefile.PL
142 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
02d1d628
AMH
143';
144}
145
55932d2a
TC
146sub MY::metafile {
147 my ($self) = @_;
148
149 my $meta = <<YAML;
150--- #YAML:1.0
151name: Imager
152version: $self->{VERSION}
153version_from: $self->{VERSION_FROM}
154author: $self->{AUTHOR}
155abstract: $self->{ABSTRACT}
156installdirs: $self->{INSTALLDIRS}
157recommends:
158 Parse::RecDescent: 0
159license: perl
160dynamic_config: 1
161distribution_type: module
162generated_by: Imager version $self->{VERSION}
163YAML
24099689
TC
164 open META, "> meta.tmp" or die "Cannot create meta.tmp: $!";
165 print META $meta;
166 close META;
55932d2a 167
24099689 168 return sprintf "metafile :\n\t\$(CP) meta.tmp META.yml\n";
55932d2a
TC
169}
170
02d1d628
AMH
171# manual configuration of helper libraries
172
173sub manual {
174 print <<EOF;
175
176 Please answer the following questions about
177 which formats are avaliable on your computer
178
179press <return> to continue
180EOF
181
182 <STDIN>; # eat one return
183
2646b26c 184 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
02d1d628
AMH
185 SWX:
186 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
187 print "Enable $frm support: ";
09fd3468 188 $gz = <STDIN>;
02d1d628
AMH
189 chomp($gz);
190 if ($gz =~ m/^(y|yes|n|no)/i) {
191 $gz=substr(lc($gz),0,1);
192 if ($gz eq 'n') {
193 delete $formats{$frm};
194 }
195 } else { goto SWX; }
196 }
197}
198
199
200# automatic configuration of helper libraries
201
202sub automatic {
203 for $frm(keys %formats) {
204 delete $formats{$frm} if !checkformat($frm);
205 }
206}
207
208
209sub gifcheck {
5f5fe73e 210 if ($formats{'gif'} and $formats{'ungif'}) {
02d1d628
AMH
211 print "ungif and gif can not coexist - removing ungif support\n";
212 delete $formats{'ungif'};
213 }
5f5fe73e
AMH
214
215 RETR:
f4dbac50 216 if (($formats{'gif'} or $formats{'ungif'}) && !$ENV{IM_SUPPRESS_PROMPT}) {
5f5fe73e
AMH
217 print <<EOFF;
218
219You have libgif or libungif installed. They are both known to have
220bugs. Imager can crash or display other strange behaviour after
221reading or writing gif images. Some of the gif tests can even fail
222since they stress some parts of the buggy code.
223
f1967c11
TC
224libungif 4.1.2 and later is safe. giflib 4.1.3 needs at least one
225patch to have all the bugs fixed, see README for details.
226
227Of course it's possible your operating system distributor has patched
228all of these problems and you have nothing to worry about.
0b836ff8 229
5f5fe73e
AMH
230Do you want to remove gif support? [Y/n]
231EOFF
232 my $resp = <STDIN>;
233 chomp($resp);
234 if ($resp ne "n") {
235 delete $formats{'gif'};
236 delete $formats{'ungif'};
09fd3468 237 return;
5f5fe73e
AMH
238 }
239 }
09fd3468
AMH
240
241 for my $frm (qw(gif ungif)) {
242 checkformat($frm) if ($MANUAL and $formats{$frm});
243 }
244
02d1d628
AMH
245 my @dirs;
246 for my $frm (grep $formats{$_}, qw(gif ungif)) {
247 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
248 }
249 my $minor = 0;
250 my $major = 0;
251 FILES: for my $dir (@dirs) {
252 my $h = "$dir/gif_lib.h";
253 open H, "< $h" or next;
254 while (<H>) {
255 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
256 $major = $1;
257 $minor = $2;
258 close H;
259 last FILES;
260 }
261 }
262 close H;
263 }
264
265 # we need the version in a #ifdefable form
4dce694d 266
e11d297f
TC
267 push @defines, [ IM_GIFMAJOR, $major, "Parsed giflib version" ];
268 push @defines, [ IM_GIFMINOR, $minor ];
02d1d628
AMH
269}
270
271
272sub gd {
273 my($path,$chk)=@_;
274
275# print "checking path $path\n";
276 if ( !opendir(DH,$path) ) {
277 warn "Cannot open dir $path: $!\n";
278 return;
279 }
280 my @l=grep { $chk->($_) } readdir(DH);
281 # print @l;
282 close(DH);
283 return map $path, @l;
284}
285
286
287sub checkformat {
288 my $frm=shift;
37959076 289
07ea6c21 290 my $code = $formats{$frm}{'code'};
37959076 291 if ($code && !$noprobe) {
07ea6c21
TC
292 return 1 if $code->($formats{$frm}, $frm);
293 }
294
02d1d628
AMH
295 my $libchk=$formats{$frm}{'libcheck'};
296 my $incchk=$formats{$frm}{'inccheck'};
297
298 my @l;
299 for my $lp (@libs) {
300 push(@l, gd($lp,$libchk));
301 }
302
303 my @i;
304 for my $ip (@incs) {
f8e9bc07 305 push(@i, $ip) if $incchk->($ip,$frm);
02d1d628
AMH
306 }
307
308 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
309 $formats{$frm}{incdir} = \@i;
310 $formats{$frm}{libdir} = \@l;
311 return scalar(@i && @l);
312}
313
314
02d1d628
AMH
315sub pathcheck {
316 if ($VERBOSE) {
317 print "pathcheck\n";
318 print " Include paths:\n";
319 for (@incs) { print $_,"\n"; }
320 }
3a6bb91b 321 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
02d1d628
AMH
322
323 if ($VERBOSE) {
324 print "\nLibrary paths:\n";
325 for (@incs) { print $_,"\n"; }
326 }
3a6bb91b 327 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
02d1d628
AMH
328 print "\ndone.\n";
329}
330
331
332# Format data initialization
333
334# format definition is:
335# defines needed
336# default include path
337# files needed for include (boolean perl code)
338# default lib path
339# libs needed
340# files needed for link (boolean perl code)
341# object files needed for the format
342
343
344sub init {
345
346 @definc{'/usr/include'}=();
37959076
TC
347 @incs=(split(/\Q$Config{path_sep}/, $INCPATH),
348 map { split /\Q$Config{path_sep}/} @incpaths );
2646b26c 349 if ($Config{locincpth}) {
6552acfe 350 push @incs, grep -d, split ' ', $Config{locincpth};
2646b26c 351 }
88a763e2
TC
352 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
353 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
2646b26c 354 }
6552acfe 355 push @incs, grep -d,
2646b26c
TC
356 qw(/sw/include
357 /usr/include/freetype2
358 /usr/local/include/freetype2
359 /usr/local/include/freetype1/freetype
37959076 360 /usr/include /usr/local/include /usr/include/freetype
2646b26c
TC
361 /usr/local/include/freetype);
362
37959076
TC
363 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
364 map { split /\Q$Config{path_sep}/} @libpaths );
2646b26c 365 if ($Config{loclibpth}) {
6552acfe 366 push @libs, grep -d, split ' ', $Config{loclibpth};
2646b26c 367 }
6552acfe 368 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
2646b26c 369 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
88a763e2
TC
370 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
371 }
faa9b3e7
TC
372 if ($^O eq 'cygwin') {
373 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
374 push(@incs, '/usr/include/w32api') if -d '/usr/lib/w32api';
375 }
02d1d628 376
2646b26c
TC
377 my $lext=$Config{'so'}; # Get extensions of libraries
378 my $aext=$Config{'_a'};
379
02d1d628
AMH
380 $formats{'jpeg'}={
381 order=>'21',
382 def=>'HAVE_LIBJPEG',
f8e9bc07 383 inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
50ee6f9c 384 libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
02d1d628
AMH
385 libfiles=>'-ljpeg',
386 objfiles=>'jpeg.o',
387 docs=>q{
388 In order to use jpeg with this module you need to have libjpeg
389 installed on your computer}
390 };
391
392 $formats{'tiff'}={
393 order=>'23',
394 def=>'HAVE_LIBTIFF',
f8e9bc07 395 inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
76c8a0a4 396 libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
02d1d628
AMH
397 libfiles=>'-ltiff',
398 objfiles=>'tiff.o',
399 docs=>q{
400 In order to use tiff with this module you need to have libtiff
401 installed on your computer}
402 };
403
404 $formats{'png'}={
405 order=>'22',
406 def=>'HAVE_LIBPNG',
f8e9bc07 407 inccheck=>sub { -e catfile($_[0], 'png.h') },
88a763e2 408 libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
02d1d628
AMH
409 libfiles=>'-lpng -lz',
410 objfiles=>'png.o',
411 docs=>q{
412 Png stands for Portable Network Graphics and is intended as
413 a replacement for gif on the web. It is patent free and
07ea6c21
TC
414 is recommended by the w3c, you need libpng to use these formats},
415 code => \&png_probe,
02d1d628
AMH
416 };
417
418 $formats{'gif'}={
419 order=>'20',
420 def=>'HAVE_LIBGIF',
f8e9bc07 421 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
e02451e0 422 libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
02d1d628
AMH
423 libfiles=>'-lgif',
424 objfiles=>'gif.o',
425 docs=>q{
426 gif is the de facto standard for webgraphics at the moment,
427 it does have some patent problems. If you have giflib and
428 are not in violation with the unisys patent you should use
429 this instead of the 'ungif' option. Note that they cannot
430 be in use at the same time}
431 };
432
433 $formats{'ungif'}={
434 order=>'21',
435 def=>'HAVE_LIBGIF',
f8e9bc07 436 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
e02451e0 437 libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
02d1d628
AMH
438 libfiles=>'-lungif',
439 objfiles=>'gif.o',
440 docs=>q{
441 gif is the de facto standard for webgraphics at the moment,
442 it does have some patent problems. If you have libungif and
443 want to create images free from LZW patented compression you
444 should use this option instead of the 'gif' option}
445 };
446
447 $formats{'T1-fonts'}={
448 order=>'30',
449 def=>'HAVE_LIBT1',
f8e9bc07 450 inccheck=>sub { -e catfile($_[0], 't1lib.h') },
faa9b3e7 451 libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
02d1d628
AMH
452 libfiles=>'-lt1',
453 objfiles=>'',
454 docs=>q{
455 postscript t1 fonts are scalable fonts. They can include
456 ligatures and kerning information and generally yield good
457 visual quality. We depend on libt1 to rasterize the fonts
458 for use in images.}
459 };
460
f8e9bc07
TC
461 $formats{'TT-fonts'}=
462 {
463 order=>'31',
464 def=>'HAVE_LIBTT',
465 inccheck=>sub { -e catfile($_[0], 'freetype.h')
466 && !-e catfile($_[0], 'fterrors.h') },
467 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
468 libfiles=>'-lttf',
469 objfiles=>'',
470 docs=>q{
471Truetype fonts are scalable fonts. They can include
472kerning and hinting information and generally yield good
473visual quality esp on low resultions. The freetype library is
474used to rasterize for us. The only drawback is that there
475are alot of badly designed fonts out there.}
02d1d628 476 };
faa9b3e7
TC
477 $formats{'w32'} = {
478 order=>40,
479 def=>'HAVE_WIN32',
f8e9bc07 480 inccheck=>sub { -e catfile($_[0], 'windows.h') },
faa9b3e7
TC
481 libcheck=>sub { lc $_[0] eq 'gdi32.lib'
482 || lc $_[0] eq 'libgdi32.a' },
483 libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
484 objfiles=>'win32.o',
485 docs => <<DOCS
486Uses the Win32 GDI for rendering text.
487
488This currently only works on under normal Win32 and cygwin.
489DOCS
490 };
491 $formats{'freetype2'} = {
492 order=>'29',
493 def=>'HAVE_FT2',
f8e9bc07 494 inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
faa9b3e7
TC
495 libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
496 libfiles=>'-lfreetype',
497 objfiles=>'freetyp2.o',
07ea6c21 498 docs=><<DOCS,
faa9b3e7 499Freetype 2 supports both Truetype and Type 1 fonts, both of which are
f8e9bc07 500scalable. It also supports a variety of other fonts.
faa9b3e7 501DOCS
07ea6c21 502 code => \&freetype2_probe,
faa9b3e7 503 };
02d1d628
AMH
504 # Make fix indent
505 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
506}
507
508
509
510sub gen {
511 my $V = $ENV{$_[0]};
512 defined($V) ? $V : "";
513}
514
515
516# Get information from environment variables
517
518sub getenv {
519
520 ($VERBOSE,
521 $INCPATH,
522 $LIBPATH,
523 $NOLOG,
524 $DEBUG_MALLOC,
525 $MANUAL,
526 $CFLAGS,
527 $LFLAGS,
528 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
529 IM_INCPATH
530 IM_LIBPATH
531 IM_NOLOG
532 IM_DEBUG_MALLOC
533 IM_MANUAL
534 IM_CFLAGS
535 IM_LFLAGS
536 IM_DFLAGS);
537
538 if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
539
540 if ($NOLOG) { print "Logging not compiled into module\n"; }
e11d297f
TC
541 else {
542 push @defines, [ IMAGER_LOG => 1, "Logging system" ];
543 }
02d1d628
AMH
544
545 if ($DEBUG_MALLOC) {
e11d297f 546 push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
02d1d628
AMH
547 print "Malloc debugging enabled\n";
548 }
549
550}
07ea6c21 551
e11d297f
TC
552sub make_imconfig {
553 my ($defines) = @_;
554
555 open CONFIG, "> imconfig.h"
556 or die "Cannot create imconfig.h: $!\n";
557 print CONFIG <<EOS;
558/* This file is automatically generated by Makefile.PL.
559 Don't edit this file, since any changes will be lost */
560
561#ifndef IMAGER_IMCONFIG_H
562#define IMAGER_IMCONFIG_H
563EOS
564 for my $define (@$defines) {
565 if ($define->[2]) {
566 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
567 }
568 print CONFIG "#define $define->[0] $define->[1]\n";
569 }
570 print CONFIG "\n#endif\n";
571 close CONFIG;
572}
573
dbc33d8a
TC
574# use pkg-config to probe for libraries
575# works around the junk that pkg-config dumps on FreeBSD
576sub _pkg_probe {
577 my ($pkg) = @_;
578
579 is_exe('pkg-config') or return;
580
581 my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null';
582
583 !system("pkg-config $pkg --exists $redir");
584}
585
07ea6c21
TC
586# probes for freetype2 by trying to run freetype-config
587sub freetype2_probe {
588 my ($frm, $frmkey) = @_;
589
590 is_exe('freetype-config') or return;
591
592 my $cflags = `freetype-config --cflags`
593 and !$? or return;
594 chomp $cflags;
595
596 $frm->{cflags} = $cflags;
597 my $lflags = `freetype-config --libs`
598 and !$? or return;
599 chomp $lflags;
600 $frm->{libfiles} = $lflags;
601
602 printf "%10s: configured via freetype-config\n", $frmkey;
603
604 return 1;
605}
606
607# probes for libpng via pkg-config
608sub png_probe {
609 my ($frm, $frmkey) = @_;
610
611 is_exe('pkg-config') or return;
612
07ea6c21
TC
613 my $config;
614 for my $check_conf (qw(libpng libpng12 libpng10)) {
dbc33d8a 615 if (_pkg_probe($check_conf)) {
07ea6c21
TC
616 $config = $check_conf;
617 last;
618 }
619 }
620 $config or return;
621
dbc33d8a
TC
622 my $cflags = `pkg-config $config --cflags`
623 and !$? or return;
624
07ea6c21
TC
625 my $lflags = `pkg-config $config --libs`
626 and !$? or return;
627
628 chomp $cflags;
629 chomp $lflags;
630 $frm->{cflags} = $cflags;
631 $frm->{libfiles} = $lflags;
632
633 printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
634
635 return 1;
636}
637
638sub catfile {
639 return File::Spec->catfile(@_);
640}
641
642sub is_exe {
643 my ($name) = @_;
644
645 for my $dir (File::Spec->path) {
646 -x catfile($dir, "$name$Config{_exe}")
647 and return 1;
648 }
649
650 return;
651}
37959076
TC
652
653sub usage {
654 print STDERR <<EOS;
655Usage: $0 [--enable feature1,feature2,...] [--incpath ...] [--libpath ...]
656 $0 [--disable feature1,feature2,...] [--incpath ...] [--libpath ...]
657 $0 --help
658Possible feature names are:
659 png gif ungif jpeg tiff T1-fonts TT-fonts freetype2
660EOS
661 exit 1;
662
663}