3 use ExtUtils::MakeMaker;
8 use ExtUtils::Manifest qw(maniread);
10 use vars qw(%formats $VERBOSE $INCPATH $LIBPATH $NOLOG $DEBUG_MALLOC $MANUAL $CFLAGS $LFLAGS $DFLAGS);
14 # EU::MM runs Makefile.PL all in the same process, so sub-modules will
16 our $BUILDING_IMAGER = 1;
18 # used to display a summary after we've probed the world
22 # IM_INCPATH colon seperated list of paths to extra include paths
23 # IM_LIBPATH colon seperated list of paths to extra library paths
25 # IM_VERBOSE turns on verbose mode for the library finding and such
26 # IM_MANUAL to manually select which libraries are used and which not
27 # IM_ENABLE to programmatically select which libraries are used
29 # IM_NOLOG if true logging will not be compiled into the module
30 # IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
31 # do not use IM_DEBUG_MALLOC in production - this slows
32 # everything down by alot
33 # IM_CFLAGS Extra flags to pass to the compiler
34 # IM_LFLAGS Extra flags to pass to the linker
35 # IM_DFLAGS Extra flags to pass to the preprocessor
37 my $KEEP_FILES = $ENV{IMAGER_KEEP_FILES};
39 getenv(); # get environment variables
41 my $lext=$Config{'so'}; # Get extensions of libraries
42 my $aext=$Config{'_a'};
44 my $help; # display help if set
45 my @enable; # list of drivers to enable
46 my @disable; # or list of drivers to disable
47 my @incpaths; # places to look for headers
48 my @libpaths; # places to look for libraries
49 my $coverage; # build for coverage testing
50 my $assert; # build with assertions
51 GetOptions("help" => \$help,
52 "enable=s" => \@enable,
53 "disable=s" => \@disable,
54 "incpath=s", \@incpaths,
55 "libpath=s" => \@libpaths,
56 "verbose|v" => \$VERBOSE,
58 'coverage' => \$coverage,
59 "assert|a" => \$assert);
63 if ($ENV{AUTOMATED_TESTING}) {
68 print "Verbose mode\n";
70 import Data::Dumper qw(Dumper);
79 if ($NOLOG) { print "Logging not compiled into module\n"; }
81 push @defines, [ IMAGER_LOG => 1, "Logging system" ];
85 push @defines, [ IM_ASSERT => 1, "im_assert() are effective" ];
89 push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
90 print "Malloc debugging enabled\n";
93 if (@enable && @disable) {
94 print STDERR "Only --enable or --disable can be used, not both, try --help\n";
100 my @incs; # all the places to look for headers
101 my @libs; # all the places to look for libraries
103 init(); # initialize global data
104 pathcheck(); # Check if directories exist
106 if (exists $ENV{IM_ENABLE}) {
107 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
108 for my $key (keys %formats) {
109 delete $formats{$key} unless $en{$key};
113 my %en = map { $_ => 1 } map { split /,/ } @enable;
114 for my $key (keys %formats) {
115 delete $formats{$key} unless $en{$key};
119 delete @formats{map { split /,/ } @disable};
122 # Pick what libraries are used
133 for my $frmkey (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
134 my $frm = $formats{$frmkey};
135 push @defines, [ $frm->{def}, 1, "$frmkey available" ];
136 $F_OBJECT .= ' ' .$frm->{objfiles};
137 if ($frm->{cflags}) {
138 $lib_cflags .= ' ' .$frm->{cflags};
139 ++$definc{$_} for map { /^-I(.*)$/ ? ($1) : () }
140 grep /^-I./, split ' ', $frm->{cflags};
142 if ($frm->{lflags}) {
143 $lib_lflags .= ' ' . $frm->{lflags};
146 $F_LIBS .= ' ' .$frm->{libfiles};
151 my $F_INC = join ' ', map "-I$_", map / / ? qq{"$_"} : $_,
152 grep !$definc{$_}, @incs;
153 $F_LIBS = join(' ',map "-L$_", map / / ? qq{"$_"} : $_,
154 grep !$deflib{$_}++, @libs) . $F_LIBS;
157 my $OSDEF = "-DOS_$^O";
159 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
160 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
162 my @objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
163 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o combine.o
164 filters.o dynaload.o stackmach.o datatypes.o
165 regmach.o trans2.o quant.o error.o convert.o
166 map.o tags.o palimg.o maskimg.o img8.o img16.o rotate.o
167 bmp.o tga.o color.o fills.o imgdouble.o limits.o hlines.o
168 imext.o scale.o rubthru.o render.o paste.o compose.o flip.o);
172 'VERSION_FROM' => 'Imager.pm',
173 'LIBS' => "$LFLAGS -lm $lib_lflags $OSLIBS $F_LIBS",
174 'DEFINE' => "$OSDEF $CFLAGS",
175 'INC' => "$lib_cflags $DFLAGS $F_INC",
176 'OBJECT' => join(' ', @objs, $F_OBJECT),
177 clean => { FILES=>'testout rubthru.c scale.c conv.c filters.c gaussian.c render.c rubthru.c' },
179 PREREQ_PM => { 'Test::More' => 0.47 },
183 if ($Config{gccversion}) {
184 push @ARGV, 'OPTIMIZE=-ftest-coverage -fprofile-arcs';
185 #$opts{dynamic_lib} = { OTHERLDFLAGS => '-ftest-coverage -fprofile-arcs' };
188 die "Don't know the coverage C flags for your compiler\n";
192 # eval to prevent warnings about versions with _ in them
193 my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
194 if ($MM_ver > 6.06) {
195 $opts{AUTHOR} = 'Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson';
196 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
199 if ($MM_ver >= 6.46) {
204 "Parse::RecDescent" => 0
222 homepage => "http://imager.perl.org/",
223 repository => "git://git.imager.perl.org/imager.git",
224 bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
229 make_imconfig(\@defines);
231 if ($VERBOSE) { print Dumper(\%opts); }
232 mkdir('testout',0777); # since we cannot include it in the archive.
234 -d "probe" and rmdir "probe";
236 WriteMakefile(%opts);
240 for my $name (sort { lc $a cmp lc $b } keys %IMAGER_LIBS) {
241 if ($IMAGER_LIBS{$name}) {
250 print "Libraries found:\n" if @good;
251 print " $_\n" for @good;
252 print "Libraries *not* found:\n" if @bad;
253 print " $_\n" for @bad;
260 my $perl = $self->{PERLRUN} ? '$(PERLRUN)' : '$(PERL)';
263 my @ims = grep /\.im$/, keys %$mani;
265 dyntest.$(MYEXTLIB) : dynfilt/Makefile
266 cd dynfilt && $(MAKE) $(PASTHRU)
268 lib/Imager/Regops.pm : regmach.h regops.perl
269 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
271 imconfig.h : Makefile.PL
272 $(ECHO) "imconfig.h out-of-date with respect to $?"
273 $(PERLRUN) Makefile.PL
274 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
276 lib/Imager/APIRef.pod : \$(C_FILES) \$(H_FILES) apidocs.perl
277 $perl apidocs.perl lib/Imager/APIRef.pod
279 !.join('', map _im_rule($perl, $_), @ims)
284 my ($perl, $im) = @_;
286 (my $c = $im) =~ s/\.im$/.c/;
289 $c: $im lib/Imager/Preprocess.pm
290 $perl -Ilib -MImager::Preprocess -epreprocess $im $c
296 # manual configuration of helper libraries
301 Please answer the following questions about
302 which formats are avaliable on your computer
304 press <return> to continue
307 <STDIN>; # eat one return
309 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
311 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
312 print "Enable $frm support: ";
315 if ($gz =~ m/^(y|yes|n|no)/i) {
316 $gz=substr(lc($gz),0,1);
318 delete $formats{$frm};
325 # automatic configuration of helper libraries
328 print "Automatic probing:\n" if $VERBOSE;
329 for my $frm (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
330 delete $formats{$frm} if !checkformat($frm);
336 # if ($formats{'gif'} and $formats{'ungif'}) {
337 # print "ungif and gif can not coexist - removing ungif support\n";
338 # delete $formats{'ungif'};
341 # for my $frm (qw(gif ungif)) {
342 # checkformat($frm) if ($MANUAL and $formats{$frm});
346 # for my $frm (grep $formats{$_}, qw(gif ungif)) {
347 # push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
351 # FILES: for my $dir (@dirs) {
352 # my $h = "$dir/gif_lib.h";
353 # open H, "< $h" or next;
355 # if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
365 # # we need the version in a #ifdefable form
367 # push @defines, [ IM_GIFMAJOR => $major, "Parsed giflib version" ];
368 # push @defines, [ IM_GIFMINOR => $minor ];
369 # push @defines, [ IM_NO_SET_GIF_VERSION => 1, "Disable EGifSetGifVersion" ]
370 # if $no_gif_set_version;
377 # print "checking path $path\n";
378 if ( !opendir(DH,$path) ) {
379 warn "Cannot open dir $path: $!\n";
382 my @l=grep { $chk->($_) } readdir(DH);
385 return map $path, @l;
389 my ($format, $frm) = @_;
391 my $lib_check=$formats{$frm}{'libcheck'};
392 my $inc_check=$formats{$frm}{'inccheck'};
397 push(@l, grep_directory($lp,$lib_check));
402 push(@i, $ip) if $inc_check->($ip,$frm);
405 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
406 $formats{$frm}{incdir} = \@i;
407 $formats{$frm}{libdir} = \@l;
408 return 1 if scalar(@i && @l);
411 printf("%10s: not available\n", $frm);
420 print " checkformat($frm)\n" if $VERBOSE;
422 my $format = $formats{$frm};
425 if (my $code = $format->{'code'}) {
426 if (ref $code eq 'ARRAY') {
427 push @probes, @$code;
433 push @probes, \&_probe_default;
435 print " Calling probe function\n" if $VERBOSE;
437 for my $func (@probes) {
438 if ($func->($format, $frm)) {
446 if ($format->{postcheck}) {
447 print " Calling postcheck function\n" if $VERBOSE;
448 $format->{postcheck}->($format, $frm)
459 print " Include paths:\n";
460 for (@incs) { print $_,"\n"; }
462 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
465 print "\nLibrary paths:\n";
466 for (@libs) { print $_,"\n"; }
468 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
473 # Format data initialization
475 # format definition is:
477 # default include path
478 # files needed for include (boolean perl code)
481 # files needed for link (boolean perl code)
482 # object files needed for the format
487 my @definc = qw(/usr/include);
488 @definc{@definc}=(1) x @definc;
491 split(/\Q$Config{path_sep}/, $INCPATH),
492 map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths
494 if ($Config{locincpth}) {
495 push @incs, grep -d, split ' ', $Config{locincpth};
497 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
498 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
500 if ($Config{incpath}) {
501 push @incs, grep -d, split /\Q$Config{path_sep}/, $Config{incpath};
505 /usr/include/freetype2
506 /usr/local/include/freetype2
507 /usr/local/include/freetype1/freetype
508 /usr/include /usr/local/include /usr/include/freetype
509 /usr/local/include/freetype);
510 if ($Config{ccflags}) {
511 my @hidden = map { /^-I(.*)$/ ? ($1) : () } split ' ', $Config{ccflags};
513 @definc{@hidden} = (1) x @hidden;
516 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
517 map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths );
518 if ($Config{loclibpth}) {
519 push @libs, grep -d, split ' ', $Config{loclibpth};
522 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
523 push @libs, grep -d, split / /, $Config{libspath} if $Config{libspath};
524 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
525 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
527 if ($^O eq 'cygwin') {
528 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
529 push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api';
531 if ($Config{ldflags}) {
532 # some builds of perl put -Ldir into ldflags without putting it in
533 # loclibpth, let's extract them
534 my @hidden = grep -d, map { /^-L(.*)$/ ? ($1) : () }
535 split ' ', $Config{ldflags};
537 # don't mark them as seen - EU::MM will remove any libraries
538 # it can't find and it doesn't look for -L in ldflags
539 #@deflib{@hidden} = @hidden;
541 push @libs, grep -d, qw(/usr/local/lib);
545 # def=>'HAVE_LIBJPEG',
546 # inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
547 # libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
548 # libfiles=>'-ljpeg',
549 # objfiles=>'jpeg.o',
551 # In order to use jpeg with this module you need to have libjpeg
552 # installed on your computer}
557 # def=>'HAVE_LIBTIFF',
558 # inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
559 # libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
560 # libfiles=>'-ltiff',
561 # objfiles=>'tiff.o',
563 # In order to use tiff with this module you need to have libtiff
564 # installed on your computer},
565 # postcheck => \&postcheck_tiff,
570 # def=>'HAVE_LIBPNG',
571 # inccheck=>sub { -e catfile($_[0], 'png.h') },
572 # libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
573 # libfiles=>$^O eq 'MSWin32' ? '-lpng -lzlib' : '-lpng -lz',
576 # Png stands for Portable Network Graphics and is intended as
577 # a replacement for gif on the web. It is patent free and
578 # is recommended by the w3c, you need libpng to use these formats},
579 # code => \&png_probe,
584 # def=>'HAVE_LIBGIF',
585 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
586 # libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
590 # gif is the de facto standard for webgraphics at the moment,
591 # it does have some patent problems. If you have giflib and
592 # are not in violation with the unisys patent you should use
593 # this instead of the 'ungif' option. Note that they cannot
594 # be in use at the same time}
597 # $formats{'ungif'}={
599 # def=>'HAVE_LIBGIF',
600 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
601 # libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
602 # libfiles=>'-lungif',
605 # gif is the de facto standard for webgraphics at the moment,
606 # it does have some patent problems. If you have libungif and
607 # want to create images free from LZW patented compression you
608 # should use this option instead of the 'gif' option}
611 # $formats{'T1-fonts'}={
614 # inccheck=>sub { -e catfile($_[0], 't1lib.h') },
615 # libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
619 # postscript t1 fonts are scalable fonts. They can include
620 # ligatures and kerning information and generally yield good
621 # visual quality. We depend on libt1 to rasterize the fonts
622 # for use in images.}
625 $formats{'TT-fonts'}=
629 inccheck=>sub { -e catfile($_[0], 'freetype.h')
630 && !-e catfile($_[0], 'fterrors.h') },
631 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
634 code => \&freetype1_probe,
636 Truetype fonts are scalable fonts. They can include
637 kerning and hinting information and generally yield good
638 visual quality esp on low resultions. The freetype library is
639 used to rasterize for us. The only drawback is that there
640 are alot of badly designed fonts out there.}
642 # $formats{'w32'} = {
645 # inccheck=>sub { -e catfile($_[0], 'windows.h') },
646 # libcheck=>sub { lc $_[0] eq 'gdi32.lib'
647 # || lc $_[0] eq 'libgdi32.a' },
648 # libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
649 # objfiles=>'win32.o',
651 # Uses the Win32 GDI for rendering text.
653 # This currently only works on under normal Win32 and cygwin.
656 # $formats{'freetype2'} =
660 # # we always use a probe function
661 # #inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
662 # #libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
663 # libfiles=>'-lfreetype',
664 # objfiles=>'freetyp2.o',
666 # Freetype 2 supports both Truetype and Type 1 fonts, both of which are
667 # scalable. It also supports a variety of other fonts.
671 # \&freetype2_probe_ftconfig,
672 # \&freetype2_probe_scan
677 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
684 defined($V) ? $V : "";
688 # Get information from environment variables
700 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
712 # populate the environment so that sub-modules get the same info
714 $ENV{IM_VERBOSE} = 1 if $VERBOSE;
715 $ENV{IM_INCPATH} = join $Config{path_sep}, @incpaths if @incpaths;
716 $ENV{IM_LIBPATH} = join $Config{path_sep}, @libpaths if @libpaths;
722 open CONFIG, "> imconfig.h"
723 or die "Cannot create imconfig.h: $!\n";
725 /* This file is automatically generated by Makefile.PL.
726 Don't edit this file, since any changes will be lost */
728 #ifndef IMAGER_IMCONFIG_H
729 #define IMAGER_IMCONFIG_H
731 for my $define (@$defines) {
733 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
735 print CONFIG "#define $define->[0] $define->[1]\n";
737 print CONFIG "\n#endif\n";
741 # # use pkg-config to probe for libraries
742 # # works around the junk that pkg-config dumps on FreeBSD
746 # is_exe('pkg-config') or return;
748 # my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null';
750 # !system("pkg-config $pkg --exists $redir");
753 # probes for freetype1 by scanning @incs for the includes and
754 # @libs for the libs. This is done separately because freetype's headers
755 # are stored in a freetype or freetype1 directory under PREFIX/include.
757 # we could find the files with the existing mechanism, but it won't set
758 # -I flags correctly.
760 # This could be extended to freetype2 too, but freetype-config catches
762 sub freetype1_probe {
763 my ($frm, $frmkey) = @_;
767 for my $inc (@incs) {
768 for my $subdir (qw/freetype freetype1/) {
769 my $path = File::Spec->catfile($inc, $subdir, 'freetype.h');
771 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
774 $found_inc = File::Spec->catdir($inc, $subdir);
781 for my $lib (@libs) {
782 my $a_path = File::Spec->catfile($lib, "libttf$aext");
783 my $l_path = File::Spec->catfile($lib, "libttf.$lext");
784 if (-e $a_path || -e $l_path) {
790 return unless $found_inc && $found_lib;
791 printf("%10s: includes %s - libraries %s\n", $frmkey,
792 ($found_inc ? 'found' : 'not found'),
793 ($found_lib ? 'found' : 'not found'));
795 $frm->{cflags} = "-I$found_inc";
796 $frm->{libfiles} = "-lttf";
801 # probes for freetype2 by trying to run freetype-config
802 # sub freetype2_probe_ftconfig {
803 # my ($frm, $frmkey) = @_;
805 # is_exe('freetype-config') or return;
807 # my $cflags = `freetype-config --cflags`
811 # my $lflags = `freetype-config --libs`
815 # # before 2.1.5 freetype-config --cflags could output
816 # # the -I options in the wrong order, causing a conflict with
817 # # freetype1.x installed with the same --prefix
820 # # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
822 # # - freetype 1.x headers are in prefix/include/freetype
823 # my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
825 # && $incdirs[1] eq "$incdirs[0]/freetype2"
826 # && -e "$incdirs[0]/freetype/freetype.h"
827 # && -e "$incdirs[0]/freetype/fterrid.h") {
828 # print "** freetype-config provided -I options out of order, correcting\n"
830 # $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
831 # map "-I$_", reverse @incdirs);
833 # $frm->{cflags} = $cflags;
834 # $frm->{lflags} = $lflags;
836 # printf "%10s: configured via freetype-config\n", $frmkey;
841 # attempt to probe for freetype2 by scanning directories
842 # we can't use the normal scan since we need to find the directory
843 # containing most of the includes
844 # sub freetype2_probe_scan {
845 # my ($frm, $frmkey) = @_;
850 # for my $inc (@incs) {
851 # my $path = File::Spec->catfile($inc, 'ft2build.h');
854 # # try to find what it's including
856 # open FT2BUILD, "< $path"
858 # while (<FT2BUILD>) {
859 # if (m!^\s*\#\s*include\s+<([\w/.]+)>!
860 # || m!^\s*\#\s*include\s+"([\w/.]+)"!) {
868 # # non-Unix installs put this directly under the same directory in
870 # if (-e File::Spec->catfile($inc, $ftheader)) {
874 # for my $subdir (qw/freetype2 freetype/) {
875 # $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
879 # $found_inc2 = File::Spec->catdir($inc, $subdir);
886 # for my $lib (@libs) {
887 # my $a_path = File::Spec->catfile($lib, "libfreetype$aext");
888 # my $l_path = File::Spec->catfile($lib, "libfreetype.$lext");
889 # if (-e $a_path || -e $l_path) {
895 # printf("%10s: includes %s - libraries %s\n", $frmkey,
896 # ($found_inc ? 'found' : 'not found'),
897 # ($found_lib ? 'found' : 'not found'));
899 # return unless $found_inc && $found_lib;
901 # $frm->{cflags} = _make_I($found_inc);
902 # $frm->{cflags} .= " " . _make_I($found_inc2) if $found_inc2;
903 # $frm->{libfiles} = "-lfreetype";
914 $inc_dir =~ / / ? qq!-I"$inc_dir"! : "-I$inc_dir";
917 # probes for libpng via pkg-config
919 # my ($frm, $frmkey) = @_;
921 # is_exe('pkg-config') or return;
924 # for my $check_conf (qw(libpng libpng12 libpng10)) {
925 # if (_pkg_probe($check_conf)) {
926 # $config = $check_conf;
932 # my $cflags = `pkg-config $config --cflags`
935 # my $lflags = `pkg-config $config --libs`
940 # $frm->{cflags} = $cflags;
941 # $frm->{lflags} = $lflags;
943 # printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
949 return File::Spec->catfile(@_);
955 # my @exe_suffix = $Config{_exe};
956 # if ($^O eq 'MSWin32') {
957 # push @exe_suffix, qw/.bat .cmd/;
960 # for my $dir (File::Spec->path) {
961 # for my $suffix (@exe_suffix) {
962 # -x catfile($dir, "$name$suffix")
972 Usage: $0 [--enable feature1,feature2,...] [other options]
973 $0 [--disable feature1,feature2,...] [other options]
975 Possible feature names are:
976 T1-fonts TT-fonts freetype2
979 Verbose library probing (or set IM_VERBOSE in the environment)
981 Disable logging (or set IM_NOLOG in the environment)
983 Add to the include search path
985 Add to the library search path
987 Build for coverage testing.
989 Build with assertions active.
995 # generate the PM MM argument
996 # I'd prefer to modify the public version, but there doesn't seem to be
997 # a public API to do that
1000 my $instbase = '$(INST_LIBDIR)';
1002 # first the basics, .pm and .pod files
1003 $pm{"Imager.pm"} = "$instbase/Imager.pm";
1005 my $mani = maniread();
1007 for my $filename (keys %$mani) {
1008 if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) {
1009 (my $work = $filename) =~ s/^lib//;
1010 $pm{$filename} = $instbase . $work;
1015 $pm{typemap} = $instbase . '/Imager/typemap';
1017 # and the core headers
1018 for my $filename (keys %$mani) {
1019 if ($filename =~ /^\w+\.h$/) {
1020 $pm{$filename} = $instbase . '/Imager/include/' . $filename;
1024 # and the generated header
1025 $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h';
1034 if ($path =~ m!^~[/\\]!) {
1035 defined $home or $home = $ENV{HOME};
1036 if (!defined $home && $^O eq 'MSWin32'
1037 && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) {
1038 $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH};
1040 unless (defined $home) {
1041 $home = eval { (getpwuid($<))[7] };
1043 defined $home or die "You supplied $path, but I can't find your home directory\n";
1045 $path = File::Spec->catdir($home, $path);
1051 # sub postcheck_tiff {
1052 # my ($format, $frm) = @_;
1054 # -d "probe" or mkdir "probe";
1056 # my $tiffver_name = "probe/tiffver.txt";
1059 # if ($Config{cc} =~ /\b(cl|bcc)\b/) {
1066 # # setup LD_RUN_PATH to match link time
1067 # my $lopts = join " " , map("-L$_", @{$format->{libdir}}), " -ltiff";
1068 # my ($extra, $bs_load, $ld_load, $ld_run_path) =
1069 # ExtUtils::Liblist->ext($lopts, $VERBOSE);
1070 # local $ENV{LD_RUN_PATH};
1072 # if ($ld_run_path) {
1073 # print "Setting LD_RUN_PATH=$ld_run_path for TIFF probe\n" if $VERBOSE;
1074 # $ENV{LD_RUN_PATH} = $ld_run_path;
1081 # debug => $VERBOSE,
1082 # incpath => $format->{incdir},
1083 # libpath => $format->{libdir},
1085 # header => [ qw(stdio.h tiffio.h) ],
1086 # function => <<FUNCTION,
1088 # const char *vers = TIFFGetVersion();
1089 # FILE *f = fopen("$tiffver_name", "wb");
1102 # unless ($good && -s $tiffver_name
1103 # && open(VERS, "< $tiffver_name")) {
1104 # unlink $tiffver_name unless $KEEP_FILES;
1106 # **tiff: cannot determine libtiff version number
1112 # # version file seems to be there, load it up
1113 # my $ver_str = do { local $/; <VERS> };
1115 # unlink $tiffver_name unless $KEEP_FILES;
1117 # my ($version) = $ver_str =~ /(\d+\.\d+\.\d+)/;
1119 # if ($version eq '3.9.0') {
1121 # **tiff: libtiff 3.9.0 introduced a serious bug, please install 3.9.1
1130 # This isn't a module, but some broken tools, like
1131 # Module::Depends::Instrusive insist on treating it like one.
1133 # http://rt.cpan.org/Public/Bug/Display.html?id=21229