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 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 <tony@imager.perl.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/",
225 url => "git://git.imager.perl.org/imager.git",
226 web => "http://git.imager.perl.org/imager.git",
231 web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
232 mailto => 'bug-Imager@rt.cpan.org',
238 make_imconfig(\@defines);
240 if ($VERBOSE) { print Dumper(\%opts); }
241 mkdir('testout',0777); # since we cannot include it in the archive.
243 -d "probe" and rmdir "probe";
245 WriteMakefile(%opts);
249 for my $name (sort { lc $a cmp lc $b } keys %IMAGER_LIBS) {
250 if ($IMAGER_LIBS{$name}) {
259 print "Libraries found:\n" if @good;
260 print " $_\n" for @good;
261 print "Libraries *not* found:\n" if @bad;
262 print " $_\n" for @bad;
269 my $perl = $self->{PERLRUN} ? '$(PERLRUN)' : '$(PERL)';
272 my @ims = grep /\.im$/, keys %$mani;
274 dyntest.$(MYEXTLIB) : dynfilt/Makefile
275 cd dynfilt && $(MAKE) $(PASTHRU)
277 lib/Imager/Regops.pm : regmach.h regops.perl
278 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
280 imconfig.h : Makefile.PL
281 $(ECHO) "imconfig.h out-of-date with respect to $?"
282 $(PERLRUN) Makefile.PL
283 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
285 lib/Imager/APIRef.pod : \$(C_FILES) \$(H_FILES) apidocs.perl
286 $perl apidocs.perl lib/Imager/APIRef.pod
288 !.join('', map _im_rule($perl, $_), @ims)
293 my ($perl, $im) = @_;
295 (my $c = $im) =~ s/\.im$/.c/;
298 $c: $im lib/Imager/Preprocess.pm
299 $perl -Ilib -MImager::Preprocess -epreprocess $im $c
305 # manual configuration of helper libraries
310 Please answer the following questions about
311 which formats are avaliable on your computer
313 press <return> to continue
316 <STDIN>; # eat one return
318 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
320 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
321 print "Enable $frm support: ";
324 if ($gz =~ m/^(y|yes|n|no)/i) {
325 $gz=substr(lc($gz),0,1);
327 delete $formats{$frm};
334 # automatic configuration of helper libraries
337 print "Automatic probing:\n" if $VERBOSE;
338 for my $frm (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
339 delete $formats{$frm} if !checkformat($frm);
345 # if ($formats{'gif'} and $formats{'ungif'}) {
346 # print "ungif and gif can not coexist - removing ungif support\n";
347 # delete $formats{'ungif'};
350 # for my $frm (qw(gif ungif)) {
351 # checkformat($frm) if ($MANUAL and $formats{$frm});
355 # for my $frm (grep $formats{$_}, qw(gif ungif)) {
356 # push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
360 # FILES: for my $dir (@dirs) {
361 # my $h = "$dir/gif_lib.h";
362 # open H, "< $h" or next;
364 # if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
374 # # we need the version in a #ifdefable form
376 # push @defines, [ IM_GIFMAJOR => $major, "Parsed giflib version" ];
377 # push @defines, [ IM_GIFMINOR => $minor ];
378 # push @defines, [ IM_NO_SET_GIF_VERSION => 1, "Disable EGifSetGifVersion" ]
379 # if $no_gif_set_version;
386 # print "checking path $path\n";
387 if ( !opendir(DH,$path) ) {
388 warn "Cannot open dir $path: $!\n";
391 my @l=grep { $chk->($_) } readdir(DH);
394 return map $path, @l;
398 my ($format, $frm) = @_;
400 my $lib_check=$formats{$frm}{'libcheck'};
401 my $inc_check=$formats{$frm}{'inccheck'};
406 push(@l, grep_directory($lp,$lib_check));
411 push(@i, $ip) if $inc_check->($ip,$frm);
414 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
415 $formats{$frm}{incdir} = \@i;
416 $formats{$frm}{libdir} = \@l;
417 return 1 if scalar(@i && @l);
420 printf("%10s: not available\n", $frm);
429 print " checkformat($frm)\n" if $VERBOSE;
431 my $format = $formats{$frm};
434 if (my $code = $format->{'code'}) {
435 if (ref $code eq 'ARRAY') {
436 push @probes, @$code;
442 push @probes, \&_probe_default;
444 print " Calling probe function\n" if $VERBOSE;
446 for my $func (@probes) {
447 if ($func->($format, $frm)) {
455 if ($format->{postcheck}) {
456 print " Calling postcheck function\n" if $VERBOSE;
457 $format->{postcheck}->($format, $frm)
468 print " Include paths:\n";
469 for (@incs) { print $_,"\n"; }
471 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
474 print "\nLibrary paths:\n";
475 for (@libs) { print $_,"\n"; }
477 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
482 # Format data initialization
484 # format definition is:
486 # default include path
487 # files needed for include (boolean perl code)
490 # files needed for link (boolean perl code)
491 # object files needed for the format
496 my @definc = qw(/usr/include);
497 @definc{@definc}=(1) x @definc;
500 split(/\Q$Config{path_sep}/, $INCPATH),
501 map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths
503 if ($Config{locincpth}) {
504 push @incs, grep -d, split ' ', $Config{locincpth};
506 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
507 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
509 if ($Config{incpath}) {
510 push @incs, grep -d, split /\Q$Config{path_sep}/, $Config{incpath};
514 /usr/include/freetype2
515 /usr/local/include/freetype2
516 /usr/local/include/freetype1/freetype
517 /usr/include /usr/local/include /usr/include/freetype
518 /usr/local/include/freetype);
519 if ($Config{ccflags}) {
520 my @hidden = map { /^-I(.*)$/ ? ($1) : () } split ' ', $Config{ccflags};
522 @definc{@hidden} = (1) x @hidden;
525 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
526 map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths );
527 if ($Config{loclibpth}) {
528 push @libs, grep -d, split ' ', $Config{loclibpth};
531 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
532 push @libs, grep -d, split / /, $Config{libspath} if $Config{libspath};
533 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
534 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
536 if ($^O eq 'cygwin') {
537 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
538 push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api';
540 if ($Config{ldflags}) {
541 # some builds of perl put -Ldir into ldflags without putting it in
542 # loclibpth, let's extract them
543 my @hidden = grep -d, map { /^-L(.*)$/ ? ($1) : () }
544 split ' ', $Config{ldflags};
546 # don't mark them as seen - EU::MM will remove any libraries
547 # it can't find and it doesn't look for -L in ldflags
548 #@deflib{@hidden} = @hidden;
550 push @libs, grep -d, qw(/usr/local/lib);
554 # def=>'HAVE_LIBJPEG',
555 # inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
556 # libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
557 # libfiles=>'-ljpeg',
558 # objfiles=>'jpeg.o',
560 # In order to use jpeg with this module you need to have libjpeg
561 # installed on your computer}
566 # def=>'HAVE_LIBTIFF',
567 # inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
568 # libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
569 # libfiles=>'-ltiff',
570 # objfiles=>'tiff.o',
572 # In order to use tiff with this module you need to have libtiff
573 # installed on your computer},
574 # postcheck => \&postcheck_tiff,
579 # def=>'HAVE_LIBPNG',
580 # inccheck=>sub { -e catfile($_[0], 'png.h') },
581 # libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
582 # libfiles=>$^O eq 'MSWin32' ? '-lpng -lzlib' : '-lpng -lz',
585 # Png stands for Portable Network Graphics and is intended as
586 # a replacement for gif on the web. It is patent free and
587 # is recommended by the w3c, you need libpng to use these formats},
588 # code => \&png_probe,
593 # def=>'HAVE_LIBGIF',
594 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
595 # libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
599 # gif is the de facto standard for webgraphics at the moment,
600 # it does have some patent problems. If you have giflib and
601 # are not in violation with the unisys patent you should use
602 # this instead of the 'ungif' option. Note that they cannot
603 # be in use at the same time}
606 # $formats{'ungif'}={
608 # def=>'HAVE_LIBGIF',
609 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
610 # libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
611 # libfiles=>'-lungif',
614 # gif is the de facto standard for webgraphics at the moment,
615 # it does have some patent problems. If you have libungif and
616 # want to create images free from LZW patented compression you
617 # should use this option instead of the 'gif' option}
620 # $formats{'T1-fonts'}={
623 # inccheck=>sub { -e catfile($_[0], 't1lib.h') },
624 # libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
628 # postscript t1 fonts are scalable fonts. They can include
629 # ligatures and kerning information and generally yield good
630 # visual quality. We depend on libt1 to rasterize the fonts
631 # for use in images.}
634 $formats{'TT-fonts'}=
638 inccheck=>sub { -e catfile($_[0], 'freetype.h')
639 && !-e catfile($_[0], 'fterrors.h') },
640 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
643 code => \&freetype1_probe,
645 Truetype fonts are scalable fonts. They can include
646 kerning and hinting information and generally yield good
647 visual quality esp on low resultions. The freetype library is
648 used to rasterize for us. The only drawback is that there
649 are alot of badly designed fonts out there.}
651 # $formats{'w32'} = {
654 # inccheck=>sub { -e catfile($_[0], 'windows.h') },
655 # libcheck=>sub { lc $_[0] eq 'gdi32.lib'
656 # || lc $_[0] eq 'libgdi32.a' },
657 # libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
658 # objfiles=>'win32.o',
660 # Uses the Win32 GDI for rendering text.
662 # This currently only works on under normal Win32 and cygwin.
665 # $formats{'freetype2'} =
669 # # we always use a probe function
670 # #inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
671 # #libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
672 # libfiles=>'-lfreetype',
673 # objfiles=>'freetyp2.o',
675 # Freetype 2 supports both Truetype and Type 1 fonts, both of which are
676 # scalable. It also supports a variety of other fonts.
680 # \&freetype2_probe_ftconfig,
681 # \&freetype2_probe_scan
686 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
693 defined($V) ? $V : "";
697 # Get information from environment variables
709 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
721 # populate the environment so that sub-modules get the same info
723 $ENV{IM_VERBOSE} = 1 if $VERBOSE;
724 $ENV{IM_INCPATH} = join $Config{path_sep}, @incpaths if @incpaths;
725 $ENV{IM_LIBPATH} = join $Config{path_sep}, @libpaths if @libpaths;
731 open CONFIG, "> imconfig.h"
732 or die "Cannot create imconfig.h: $!\n";
734 /* This file is automatically generated by Makefile.PL.
735 Don't edit this file, since any changes will be lost */
737 #ifndef IMAGER_IMCONFIG_H
738 #define IMAGER_IMCONFIG_H
740 for my $define (@$defines) {
742 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
744 print CONFIG "#define $define->[0] $define->[1]\n";
746 print CONFIG "\n#endif\n";
750 # # use pkg-config to probe for libraries
751 # # works around the junk that pkg-config dumps on FreeBSD
755 # is_exe('pkg-config') or return;
757 # my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null';
759 # !system("pkg-config $pkg --exists $redir");
762 # probes for freetype1 by scanning @incs for the includes and
763 # @libs for the libs. This is done separately because freetype's headers
764 # are stored in a freetype or freetype1 directory under PREFIX/include.
766 # we could find the files with the existing mechanism, but it won't set
767 # -I flags correctly.
769 # This could be extended to freetype2 too, but freetype-config catches
771 sub freetype1_probe {
772 my ($frm, $frmkey) = @_;
776 for my $inc (@incs) {
777 for my $subdir (qw/freetype freetype1/) {
778 my $path = File::Spec->catfile($inc, $subdir, 'freetype.h');
780 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
783 $found_inc = File::Spec->catdir($inc, $subdir);
790 for my $lib (@libs) {
791 my $a_path = File::Spec->catfile($lib, "libttf$aext");
792 my $l_path = File::Spec->catfile($lib, "libttf.$lext");
793 if (-e $a_path || -e $l_path) {
799 return unless $found_inc && $found_lib;
800 printf("%10s: includes %s - libraries %s\n", $frmkey,
801 ($found_inc ? 'found' : 'not found'),
802 ($found_lib ? 'found' : 'not found'));
804 $frm->{cflags} = "-I$found_inc";
805 $frm->{libfiles} = "-lttf";
810 # probes for freetype2 by trying to run freetype-config
811 # sub freetype2_probe_ftconfig {
812 # my ($frm, $frmkey) = @_;
814 # is_exe('freetype-config') or return;
816 # my $cflags = `freetype-config --cflags`
820 # my $lflags = `freetype-config --libs`
824 # # before 2.1.5 freetype-config --cflags could output
825 # # the -I options in the wrong order, causing a conflict with
826 # # freetype1.x installed with the same --prefix
829 # # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
831 # # - freetype 1.x headers are in prefix/include/freetype
832 # my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
834 # && $incdirs[1] eq "$incdirs[0]/freetype2"
835 # && -e "$incdirs[0]/freetype/freetype.h"
836 # && -e "$incdirs[0]/freetype/fterrid.h") {
837 # print "** freetype-config provided -I options out of order, correcting\n"
839 # $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
840 # map "-I$_", reverse @incdirs);
842 # $frm->{cflags} = $cflags;
843 # $frm->{lflags} = $lflags;
845 # printf "%10s: configured via freetype-config\n", $frmkey;
850 # attempt to probe for freetype2 by scanning directories
851 # we can't use the normal scan since we need to find the directory
852 # containing most of the includes
853 # sub freetype2_probe_scan {
854 # my ($frm, $frmkey) = @_;
859 # for my $inc (@incs) {
860 # my $path = File::Spec->catfile($inc, 'ft2build.h');
863 # # try to find what it's including
865 # open FT2BUILD, "< $path"
867 # while (<FT2BUILD>) {
868 # if (m!^\s*\#\s*include\s+<([\w/.]+)>!
869 # || m!^\s*\#\s*include\s+"([\w/.]+)"!) {
877 # # non-Unix installs put this directly under the same directory in
879 # if (-e File::Spec->catfile($inc, $ftheader)) {
883 # for my $subdir (qw/freetype2 freetype/) {
884 # $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
888 # $found_inc2 = File::Spec->catdir($inc, $subdir);
895 # for my $lib (@libs) {
896 # my $a_path = File::Spec->catfile($lib, "libfreetype$aext");
897 # my $l_path = File::Spec->catfile($lib, "libfreetype.$lext");
898 # if (-e $a_path || -e $l_path) {
904 # printf("%10s: includes %s - libraries %s\n", $frmkey,
905 # ($found_inc ? 'found' : 'not found'),
906 # ($found_lib ? 'found' : 'not found'));
908 # return unless $found_inc && $found_lib;
910 # $frm->{cflags} = _make_I($found_inc);
911 # $frm->{cflags} .= " " . _make_I($found_inc2) if $found_inc2;
912 # $frm->{libfiles} = "-lfreetype";
923 $inc_dir =~ / / ? qq!-I"$inc_dir"! : "-I$inc_dir";
926 # probes for libpng via pkg-config
928 # my ($frm, $frmkey) = @_;
930 # is_exe('pkg-config') or return;
933 # for my $check_conf (qw(libpng libpng12 libpng10)) {
934 # if (_pkg_probe($check_conf)) {
935 # $config = $check_conf;
941 # my $cflags = `pkg-config $config --cflags`
944 # my $lflags = `pkg-config $config --libs`
949 # $frm->{cflags} = $cflags;
950 # $frm->{lflags} = $lflags;
952 # printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
958 return File::Spec->catfile(@_);
964 # my @exe_suffix = $Config{_exe};
965 # if ($^O eq 'MSWin32') {
966 # push @exe_suffix, qw/.bat .cmd/;
969 # for my $dir (File::Spec->path) {
970 # for my $suffix (@exe_suffix) {
971 # -x catfile($dir, "$name$suffix")
981 Usage: $0 [--enable feature1,feature2,...] [other options]
982 $0 [--disable feature1,feature2,...] [other options]
984 Possible feature names are:
985 T1-fonts TT-fonts freetype2
988 Verbose library probing (or set IM_VERBOSE in the environment)
990 Disable logging (or set IM_NOLOG in the environment)
992 Add to the include search path
994 Add to the library search path
996 Build for coverage testing.
998 Build with assertions active.
1004 # generate the PM MM argument
1005 # I'd prefer to modify the public version, but there doesn't seem to be
1006 # a public API to do that
1009 my $instbase = '$(INST_LIBDIR)';
1011 # first the basics, .pm and .pod files
1012 $pm{"Imager.pm"} = "$instbase/Imager.pm";
1014 my $mani = maniread();
1016 for my $filename (keys %$mani) {
1017 if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) {
1018 (my $work = $filename) =~ s/^lib//;
1019 $pm{$filename} = $instbase . $work;
1024 $pm{typemap} = $instbase . '/Imager/typemap';
1026 # and the core headers
1027 for my $filename (keys %$mani) {
1028 if ($filename =~ /^\w+\.h$/) {
1029 $pm{$filename} = $instbase . '/Imager/include/' . $filename;
1033 # and the generated header
1034 $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h';
1043 if ($path =~ m!^~[/\\]!) {
1044 defined $home or $home = $ENV{HOME};
1045 if (!defined $home && $^O eq 'MSWin32'
1046 && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) {
1047 $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH};
1049 unless (defined $home) {
1050 $home = eval { (getpwuid($<))[7] };
1052 defined $home or die "You supplied $path, but I can't find your home directory\n";
1054 $path = File::Spec->catdir($home, $path);
1060 # sub postcheck_tiff {
1061 # my ($format, $frm) = @_;
1063 # -d "probe" or mkdir "probe";
1065 # my $tiffver_name = "probe/tiffver.txt";
1068 # if ($Config{cc} =~ /\b(cl|bcc)\b/) {
1075 # # setup LD_RUN_PATH to match link time
1076 # my $lopts = join " " , map("-L$_", @{$format->{libdir}}), " -ltiff";
1077 # my ($extra, $bs_load, $ld_load, $ld_run_path) =
1078 # ExtUtils::Liblist->ext($lopts, $VERBOSE);
1079 # local $ENV{LD_RUN_PATH};
1081 # if ($ld_run_path) {
1082 # print "Setting LD_RUN_PATH=$ld_run_path for TIFF probe\n" if $VERBOSE;
1083 # $ENV{LD_RUN_PATH} = $ld_run_path;
1090 # debug => $VERBOSE,
1091 # incpath => $format->{incdir},
1092 # libpath => $format->{libdir},
1094 # header => [ qw(stdio.h tiffio.h) ],
1095 # function => <<FUNCTION,
1097 # const char *vers = TIFFGetVersion();
1098 # FILE *f = fopen("$tiffver_name", "wb");
1111 # unless ($good && -s $tiffver_name
1112 # && open(VERS, "< $tiffver_name")) {
1113 # unlink $tiffver_name unless $KEEP_FILES;
1115 # **tiff: cannot determine libtiff version number
1121 # # version file seems to be there, load it up
1122 # my $ver_str = do { local $/; <VERS> };
1124 # unlink $tiffver_name unless $KEEP_FILES;
1126 # my ($version) = $ver_str =~ /(\d+\.\d+\.\d+)/;
1128 # if ($version eq '3.9.0') {
1130 # **tiff: libtiff 3.9.0 introduced a serious bug, please install 3.9.1
1139 # This isn't a module, but some broken tools, like
1140 # Module::Depends::Instrusive insist on treating it like one.
1142 # http://rt.cpan.org/Public/Bug/Display.html?id=21229