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;
19 # IM_INCPATH colon seperated list of paths to extra include paths
20 # IM_LIBPATH colon seperated list of paths to extra library paths
22 # IM_VERBOSE turns on verbose mode for the library finding and such
23 # IM_MANUAL to manually select which libraries are used and which not
24 # IM_ENABLE to programmatically select which libraries are used
26 # IM_NOLOG if true logging will not be compiled into the module
27 # IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
28 # do not use IM_DEBUG_MALLOC in production - this slows
29 # everything down by alot
30 # IM_CFLAGS Extra flags to pass to the compiler
31 # IM_LFLAGS Extra flags to pass to the linker
32 # IM_DFLAGS Extra flags to pass to the preprocessor
34 my $KEEP_FILES = $ENV{IMAGER_KEEP_FILES};
36 getenv(); # get environment variables
38 my $lext=$Config{'so'}; # Get extensions of libraries
39 my $aext=$Config{'_a'};
41 my $help; # display help if set
42 my @enable; # list of drivers to enable
43 my @disable; # or list of drivers to disable
44 my @incpaths; # places to look for headers
45 my @libpaths; # places to look for libraries
46 my $coverage; # build for coverage testing
47 my $assert; # build with assertions
48 GetOptions("help" => \$help,
49 "enable=s" => \@enable,
50 "disable=s" => \@disable,
51 "incpath=s", \@incpaths,
52 "libpath=s" => \@libpaths,
53 "verbose|v" => \$VERBOSE,
55 'coverage' => \$coverage,
56 "assert|a" => \$assert);
60 if ($ENV{AUTOMATED_TESTING}) {
65 print "Verbose mode\n";
67 import Data::Dumper qw(Dumper);
76 if ($NOLOG) { print "Logging not compiled into module\n"; }
78 push @defines, [ IMAGER_LOG => 1, "Logging system" ];
82 push @defines, [ IM_ASSERT => 1, "im_assert() are effective" ];
86 push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
87 print "Malloc debugging enabled\n";
90 if (@enable && @disable) {
91 print STDERR "Only --enable or --disable can be used, not both, try --help\n";
97 my @incs; # all the places to look for headers
98 my @libs; # all the places to look for libraries
100 init(); # initialize global data
101 pathcheck(); # Check if directories exist
103 if (exists $ENV{IM_ENABLE}) {
104 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
105 for my $key (keys %formats) {
106 delete $formats{$key} unless $en{$key};
110 my %en = map { $_ => 1 } map { split /,/ } @enable;
111 for my $key (keys %formats) {
112 delete $formats{$key} unless $en{$key};
116 delete @formats{map { split /,/ } @disable};
119 # Pick what libraries are used
130 for my $frmkey (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
131 my $frm = $formats{$frmkey};
132 push @defines, [ $frm->{def}, 1, "$frmkey available" ];
133 $F_OBJECT .= ' ' .$frm->{objfiles};
134 if ($frm->{cflags}) {
135 $lib_cflags .= ' ' .$frm->{cflags};
136 ++$definc{$_} for map { /^-I(.*)$/ ? ($1) : () }
137 grep /^-I./, split ' ', $frm->{cflags};
139 if ($frm->{lflags}) {
140 $lib_lflags .= ' ' . $frm->{lflags};
143 $F_LIBS .= ' ' .$frm->{libfiles};
148 my $F_INC = join ' ', map "-I$_", map / / ? qq{"$_"} : $_,
149 grep !$definc{$_}, @incs;
150 $F_LIBS = join(' ',map "-L$_", map / / ? qq{"$_"} : $_,
151 grep !$deflib{$_}++, @libs) . $F_LIBS;
154 my $OSDEF = "-DOS_$^O";
156 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
157 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
159 my @objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
160 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o
161 filters.o dynaload.o stackmach.o datatypes.o
162 regmach.o trans2.o quant.o error.o convert.o
163 map.o tags.o palimg.o maskimg.o img16.o rotate.o
164 bmp.o tga.o color.o fills.o imgdouble.o limits.o hlines.o
165 imext.o scale.o rubthru.o render.o paste.o compose.o flip.o);
169 'VERSION_FROM' => 'Imager.pm',
170 'LIBS' => "$LFLAGS -lm $lib_lflags $OSLIBS $F_LIBS",
171 'DEFINE' => "$OSDEF $CFLAGS",
172 'INC' => "$lib_cflags $DFLAGS $F_INC",
173 'OBJECT' => join(' ', @objs, $F_OBJECT),
174 clean => { FILES=>'testout rubthru.c scale.c conv.c filters.c gaussian.c render.c rubthru.c' },
176 PREREQ_PM => { 'Test::More' => 0.47 },
180 if ($Config{gccversion}) {
181 push @ARGV, 'OPTIMIZE=-ftest-coverage -fprofile-arcs';
182 #$opts{dynamic_lib} = { OTHERLDFLAGS => '-ftest-coverage -fprofile-arcs' };
185 die "Don't know the coverage C flags for your compiler\n";
189 # eval to prevent warnings about versions with _ in them
190 my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
191 if ($MM_ver > 6.06) {
192 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson';
193 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
196 if ($MM_ver >= 6.46) {
201 "Parse::RecDescent" => 0
217 homepage => "http://imager.perl.org/",
220 url => "http://imager.perl.org/svn/trunk/Imager",
221 web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager",
226 web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager",
227 mailto => 'bug-Imager@rt.cpan.org',
233 make_imconfig(\@defines);
235 if ($VERBOSE) { print Dumper(\%opts); }
236 mkdir('testout',0777); # since we cannot include it in the archive.
238 -d "probe" and rmdir "probe";
240 WriteMakefile(%opts);
247 my $perl = $self->{PERLRUN} ? '$(PERLRUN)' : '$(PERL)';
250 my @ims = grep /\.im$/, keys %$mani;
252 dyntest.$(MYEXTLIB) : dynfilt/Makefile
253 cd dynfilt && $(MAKE) $(PASTHRU)
255 lib/Imager/Regops.pm : regmach.h regops.perl
256 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
258 imconfig.h : Makefile.PL
259 $(ECHO) "imconfig.h out-of-date with respect to $?"
260 $(PERLRUN) Makefile.PL
261 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
263 lib/Imager/APIRef.pod : \$(C_FILES) \$(H_FILES) apidocs.perl
264 $perl apidocs.perl lib/Imager/APIRef.pod
266 !.join('', map _im_rule($perl, $_), @ims)
271 my ($perl, $im) = @_;
273 (my $c = $im) =~ s/\.im$/.c/;
276 $c: $im lib/Imager/Preprocess.pm
277 $perl -Ilib -MImager::Preprocess -epreprocess $im $c
283 # manual configuration of helper libraries
288 Please answer the following questions about
289 which formats are avaliable on your computer
291 press <return> to continue
294 <STDIN>; # eat one return
296 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
298 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
299 print "Enable $frm support: ";
302 if ($gz =~ m/^(y|yes|n|no)/i) {
303 $gz=substr(lc($gz),0,1);
305 delete $formats{$frm};
312 # automatic configuration of helper libraries
315 print "Automatic probing:\n" if $VERBOSE;
316 for my $frm (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
317 delete $formats{$frm} if !checkformat($frm);
323 # if ($formats{'gif'} and $formats{'ungif'}) {
324 # print "ungif and gif can not coexist - removing ungif support\n";
325 # delete $formats{'ungif'};
328 # for my $frm (qw(gif ungif)) {
329 # checkformat($frm) if ($MANUAL and $formats{$frm});
333 # for my $frm (grep $formats{$_}, qw(gif ungif)) {
334 # push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
338 # FILES: for my $dir (@dirs) {
339 # my $h = "$dir/gif_lib.h";
340 # open H, "< $h" or next;
342 # if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
352 # # we need the version in a #ifdefable form
354 # push @defines, [ IM_GIFMAJOR => $major, "Parsed giflib version" ];
355 # push @defines, [ IM_GIFMINOR => $minor ];
356 # push @defines, [ IM_NO_SET_GIF_VERSION => 1, "Disable EGifSetGifVersion" ]
357 # if $no_gif_set_version;
364 # print "checking path $path\n";
365 if ( !opendir(DH,$path) ) {
366 warn "Cannot open dir $path: $!\n";
369 my @l=grep { $chk->($_) } readdir(DH);
372 return map $path, @l;
376 my ($format, $frm) = @_;
378 my $lib_check=$formats{$frm}{'libcheck'};
379 my $inc_check=$formats{$frm}{'inccheck'};
384 push(@l, grep_directory($lp,$lib_check));
389 push(@i, $ip) if $inc_check->($ip,$frm);
392 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
393 $formats{$frm}{incdir} = \@i;
394 $formats{$frm}{libdir} = \@l;
395 return 1 if scalar(@i && @l);
398 printf("%10s: not available\n", $frm);
407 print " checkformat($frm)\n" if $VERBOSE;
409 my $format = $formats{$frm};
412 if (my $code = $format->{'code'}) {
413 if (ref $code eq 'ARRAY') {
414 push @probes, @$code;
420 push @probes, \&_probe_default;
422 print " Calling probe function\n" if $VERBOSE;
424 for my $func (@probes) {
425 if ($func->($format, $frm)) {
433 if ($format->{postcheck}) {
434 print " Calling postcheck function\n" if $VERBOSE;
435 $format->{postcheck}->($format, $frm)
446 print " Include paths:\n";
447 for (@incs) { print $_,"\n"; }
449 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
452 print "\nLibrary paths:\n";
453 for (@libs) { print $_,"\n"; }
455 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
460 # Format data initialization
462 # format definition is:
464 # default include path
465 # files needed for include (boolean perl code)
468 # files needed for link (boolean perl code)
469 # object files needed for the format
474 my @definc = qw(/usr/include);
475 @definc{@definc}=(1) x @definc;
478 split(/\Q$Config{path_sep}/, $INCPATH),
479 map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths
481 if ($Config{locincpth}) {
482 push @incs, grep -d, split ' ', $Config{locincpth};
484 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
485 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
487 if ($Config{incpath}) {
488 push @incs, grep -d, split /\Q$Config{path_sep}/, $Config{incpath};
492 /usr/include/freetype2
493 /usr/local/include/freetype2
494 /usr/local/include/freetype1/freetype
495 /usr/include /usr/local/include /usr/include/freetype
496 /usr/local/include/freetype);
497 if ($Config{ccflags}) {
498 my @hidden = map { /^-I(.*)$/ ? ($1) : () } split ' ', $Config{ccflags};
500 @definc{@hidden} = (1) x @hidden;
503 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
504 map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths );
505 if ($Config{loclibpth}) {
506 push @libs, grep -d, split ' ', $Config{loclibpth};
509 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
510 push @libs, grep -d, split / /, $Config{libspath} if $Config{libspath};
511 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
512 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
514 if ($^O eq 'cygwin') {
515 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
516 push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api';
518 if ($Config{ldflags}) {
519 # some builds of perl put -Ldir into ldflags without putting it in
520 # loclibpth, let's extract them
521 my @hidden = grep -d, map { /^-L(.*)$/ ? ($1) : () }
522 split ' ', $Config{ldflags};
524 # don't mark them as seen - EU::MM will remove any libraries
525 # it can't find and it doesn't look for -L in ldflags
526 #@deflib{@hidden} = @hidden;
528 push @libs, grep -d, qw(/usr/local/lib);
532 # def=>'HAVE_LIBJPEG',
533 # inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
534 # libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
535 # libfiles=>'-ljpeg',
536 # objfiles=>'jpeg.o',
538 # In order to use jpeg with this module you need to have libjpeg
539 # installed on your computer}
544 # def=>'HAVE_LIBTIFF',
545 # inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
546 # libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
547 # libfiles=>'-ltiff',
548 # objfiles=>'tiff.o',
550 # In order to use tiff with this module you need to have libtiff
551 # installed on your computer},
552 # postcheck => \&postcheck_tiff,
557 # def=>'HAVE_LIBPNG',
558 # inccheck=>sub { -e catfile($_[0], 'png.h') },
559 # libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
560 # libfiles=>$^O eq 'MSWin32' ? '-lpng -lzlib' : '-lpng -lz',
563 # Png stands for Portable Network Graphics and is intended as
564 # a replacement for gif on the web. It is patent free and
565 # is recommended by the w3c, you need libpng to use these formats},
566 # code => \&png_probe,
571 # def=>'HAVE_LIBGIF',
572 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
573 # libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
577 # gif is the de facto standard for webgraphics at the moment,
578 # it does have some patent problems. If you have giflib and
579 # are not in violation with the unisys patent you should use
580 # this instead of the 'ungif' option. Note that they cannot
581 # be in use at the same time}
584 # $formats{'ungif'}={
586 # def=>'HAVE_LIBGIF',
587 # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
588 # libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
589 # libfiles=>'-lungif',
592 # gif is the de facto standard for webgraphics at the moment,
593 # it does have some patent problems. If you have libungif and
594 # want to create images free from LZW patented compression you
595 # should use this option instead of the 'gif' option}
598 $formats{'T1-fonts'}={
601 inccheck=>sub { -e catfile($_[0], 't1lib.h') },
602 libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
606 postscript t1 fonts are scalable fonts. They can include
607 ligatures and kerning information and generally yield good
608 visual quality. We depend on libt1 to rasterize the fonts
612 $formats{'TT-fonts'}=
616 inccheck=>sub { -e catfile($_[0], 'freetype.h')
617 && !-e catfile($_[0], 'fterrors.h') },
618 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
621 code => \&freetype1_probe,
623 Truetype fonts are scalable fonts. They can include
624 kerning and hinting information and generally yield good
625 visual quality esp on low resultions. The freetype library is
626 used to rasterize for us. The only drawback is that there
627 are alot of badly designed fonts out there.}
632 inccheck=>sub { -e catfile($_[0], 'windows.h') },
633 libcheck=>sub { lc $_[0] eq 'gdi32.lib'
634 || lc $_[0] eq 'libgdi32.a' },
635 libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
638 Uses the Win32 GDI for rendering text.
640 This currently only works on under normal Win32 and cygwin.
643 $formats{'freetype2'} =
647 # we always use a probe function
648 #inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
649 #libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
650 libfiles=>'-lfreetype',
651 objfiles=>'freetyp2.o',
653 Freetype 2 supports both Truetype and Type 1 fonts, both of which are
654 scalable. It also supports a variety of other fonts.
658 \&freetype2_probe_ftconfig,
659 \&freetype2_probe_scan
664 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
671 defined($V) ? $V : "";
675 # Get information from environment variables
687 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
699 # populate the environment so that sub-modules get the same info
701 $ENV{IM_VERBOSE} = 1 if $VERBOSE;
702 $ENV{IM_INCPATH} = join $Config{path_sep}, @incpaths if @incpaths;
703 $ENV{IM_LIBPATH} = join $Config{path_sep}, @libpaths if @libpaths;
709 open CONFIG, "> imconfig.h"
710 or die "Cannot create imconfig.h: $!\n";
712 /* This file is automatically generated by Makefile.PL.
713 Don't edit this file, since any changes will be lost */
715 #ifndef IMAGER_IMCONFIG_H
716 #define IMAGER_IMCONFIG_H
718 for my $define (@$defines) {
720 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
722 print CONFIG "#define $define->[0] $define->[1]\n";
724 print CONFIG "\n#endif\n";
728 # use pkg-config to probe for libraries
729 # works around the junk that pkg-config dumps on FreeBSD
733 is_exe('pkg-config') or return;
735 my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null';
737 !system("pkg-config $pkg --exists $redir");
740 # probes for freetype1 by scanning @incs for the includes and
741 # @libs for the libs. This is done separately because freetype's headers
742 # are stored in a freetype or freetype1 directory under PREFIX/include.
744 # we could find the files with the existing mechanism, but it won't set
745 # -I flags correctly.
747 # This could be extended to freetype2 too, but freetype-config catches
749 sub freetype1_probe {
750 my ($frm, $frmkey) = @_;
754 for my $inc (@incs) {
755 for my $subdir (qw/freetype freetype1/) {
756 my $path = File::Spec->catfile($inc, $subdir, 'freetype.h');
758 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
761 $found_inc = File::Spec->catdir($inc, $subdir);
768 for my $lib (@libs) {
769 my $a_path = File::Spec->catfile($lib, "libttf$aext");
770 my $l_path = File::Spec->catfile($lib, "libttf.$lext");
771 if (-e $a_path || -e $l_path) {
777 return unless $found_inc && $found_lib;
778 printf("%10s: includes %s - libraries %s\n", $frmkey,
779 ($found_inc ? 'found' : 'not found'),
780 ($found_lib ? 'found' : 'not found'));
782 $frm->{cflags} = "-I$found_inc";
783 $frm->{libfiles} = "-lttf";
788 # probes for freetype2 by trying to run freetype-config
789 sub freetype2_probe_ftconfig {
790 my ($frm, $frmkey) = @_;
792 is_exe('freetype-config') or return;
794 my $cflags = `freetype-config --cflags`
798 my $lflags = `freetype-config --libs`
802 # before 2.1.5 freetype-config --cflags could output
803 # the -I options in the wrong order, causing a conflict with
804 # freetype1.x installed with the same --prefix
807 # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
809 # - freetype 1.x headers are in prefix/include/freetype
810 my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
812 && $incdirs[1] eq "$incdirs[0]/freetype2"
813 && -e "$incdirs[0]/freetype/freetype.h"
814 && -e "$incdirs[0]/freetype/fterrid.h") {
815 print "** freetype-config provided -I options out of order, correcting\n"
817 $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
818 map "-I$_", reverse @incdirs);
820 $frm->{cflags} = $cflags;
821 $frm->{lflags} = $lflags;
823 printf "%10s: configured via freetype-config\n", $frmkey;
828 # attempt to probe for freetype2 by scanning directories
829 # we can't use the normal scan since we need to find the directory
830 # containing most of the includes
831 sub freetype2_probe_scan {
832 my ($frm, $frmkey) = @_;
837 for my $inc (@incs) {
838 my $path = File::Spec->catfile($inc, 'ft2build.h');
841 # try to find what it's including
843 open FT2BUILD, "< $path"
846 if (m!^\s*\#\s*include\s+<([\w/.]+)>!
847 || m!^\s*\#\s*include\s+"([\w/.]+)"!) {
855 # non-Unix installs put this directly under the same directory in
857 if (-e File::Spec->catfile($inc, $ftheader)) {
861 for my $subdir (qw/freetype2 freetype/) {
862 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
866 $found_inc2 = File::Spec->catdir($inc, $subdir);
873 for my $lib (@libs) {
874 my $a_path = File::Spec->catfile($lib, "libfreetype$aext");
875 my $l_path = File::Spec->catfile($lib, "libfreetype.$lext");
876 if (-e $a_path || -e $l_path) {
882 printf("%10s: includes %s - libraries %s\n", $frmkey,
883 ($found_inc ? 'found' : 'not found'),
884 ($found_lib ? 'found' : 'not found'));
886 return unless $found_inc && $found_lib;
888 $frm->{cflags} = _make_I($found_inc);
889 $frm->{cflags} .= " " . _make_I($found_inc2) if $found_inc2;
890 $frm->{libfiles} = "-lfreetype";
901 $inc_dir =~ / / ? qq!-I"$inc_dir"! : "-I$inc_dir";
904 # probes for libpng via pkg-config
906 my ($frm, $frmkey) = @_;
908 is_exe('pkg-config') or return;
911 for my $check_conf (qw(libpng libpng12 libpng10)) {
912 if (_pkg_probe($check_conf)) {
913 $config = $check_conf;
919 my $cflags = `pkg-config $config --cflags`
922 my $lflags = `pkg-config $config --libs`
927 $frm->{cflags} = $cflags;
928 $frm->{lflags} = $lflags;
930 printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
936 return File::Spec->catfile(@_);
942 my @exe_suffix = $Config{_exe};
943 if ($^O eq 'MSWin32') {
944 push @exe_suffix, qw/.bat .cmd/;
947 for my $dir (File::Spec->path) {
948 for my $suffix (@exe_suffix) {
949 -x catfile($dir, "$name$suffix")
959 Usage: $0 [--enable feature1,feature2,...] [other options]
960 $0 [--disable feature1,feature2,...] [other options]
962 Possible feature names are:
963 T1-fonts TT-fonts freetype2
966 Verbose library probing (or set IM_VERBOSE in the environment)
968 Disable logging (or set IM_NOLOG in the environment)
970 Add to the include search path
972 Add to the library search path
974 Build for coverage testing.
976 Build with assertions active.
982 # generate the PM MM argument
983 # I'd prefer to modify the public version, but there doesn't seem to be
984 # a public API to do that
987 my $instbase = '$(INST_LIBDIR)';
989 # first the basics, .pm and .pod files
990 $pm{"Imager.pm"} = "$instbase/Imager.pm";
992 my $mani = maniread();
994 for my $filename (keys %$mani) {
995 if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) {
996 (my $work = $filename) =~ s/^lib//;
997 $pm{$filename} = $instbase . $work;
1002 $pm{typemap} = $instbase . '/Imager/typemap';
1004 # and the core headers
1005 for my $filename (keys %$mani) {
1006 if ($filename =~ /^\w+\.h$/) {
1007 $pm{$filename} = $instbase . '/Imager/include/' . $filename;
1011 # and the generated header
1012 $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h';
1021 if ($path =~ m!^~[/\\]!) {
1022 defined $home or $home = $ENV{HOME};
1023 if (!defined $home && $^O eq 'MSWin32'
1024 && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) {
1025 $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH};
1027 unless (defined $home) {
1028 $home = eval { (getpwuid($<))[7] };
1030 defined $home or die "You supplied $path, but I can't find your home directory\n";
1032 $path = File::Spec->catdir($home, $path);
1038 # sub postcheck_tiff {
1039 # my ($format, $frm) = @_;
1041 # -d "probe" or mkdir "probe";
1043 # my $tiffver_name = "probe/tiffver.txt";
1046 # if ($Config{cc} =~ /\b(cl|bcc)\b/) {
1053 # # setup LD_RUN_PATH to match link time
1054 # my $lopts = join " " , map("-L$_", @{$format->{libdir}}), " -ltiff";
1055 # my ($extra, $bs_load, $ld_load, $ld_run_path) =
1056 # ExtUtils::Liblist->ext($lopts, $VERBOSE);
1057 # local $ENV{LD_RUN_PATH};
1059 # if ($ld_run_path) {
1060 # print "Setting LD_RUN_PATH=$ld_run_path for TIFF probe\n" if $VERBOSE;
1061 # $ENV{LD_RUN_PATH} = $ld_run_path;
1068 # debug => $VERBOSE,
1069 # incpath => $format->{incdir},
1070 # libpath => $format->{libdir},
1072 # header => [ qw(stdio.h tiffio.h) ],
1073 # function => <<FUNCTION,
1075 # const char *vers = TIFFGetVersion();
1076 # FILE *f = fopen("$tiffver_name", "wb");
1089 # unless ($good && -s $tiffver_name
1090 # && open(VERS, "< $tiffver_name")) {
1091 # unlink $tiffver_name unless $KEEP_FILES;
1093 # **tiff: cannot determine libtiff version number
1099 # # version file seems to be there, load it up
1100 # my $ver_str = do { local $/; <VERS> };
1102 # unlink $tiffver_name unless $KEEP_FILES;
1104 # my ($version) = $ver_str =~ /(\d+\.\d+\.\d+)/;
1106 # if ($version eq '3.9.0') {
1108 # **tiff: libtiff 3.9.0 introduced a serious bug, please install 3.9.1
1117 # This isn't a module, but some broken tools, like
1118 # Module::Depends::Instrusive insist on treating it like one.
1120 # http://rt.cpan.org/Public/Bug/Display.html?id=21229