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