3 use ExtUtils::MakeMaker;
8 use ExtUtils::Manifest qw(maniread);
9 use vars qw(%formats $VERBOSE $INCPATH $LIBPATH $NOLOG $DEBUG_MALLOC $MANUAL $CFLAGS $LFLAGS $DFLAGS);
12 # IM_INCPATH colon seperated list of paths to extra include paths
13 # IM_LIBPATH colon seperated list of paths to extra library paths
15 # IM_VERBOSE turns on verbose mode for the library finding and such
16 # IM_MANUAL to manually select which libraries are used and which not
17 # IM_ENABLE to programmatically select which libraries are used
19 # IM_NOLOG if true logging will not be compiled into the module
20 # IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
21 # do not use IM_DEBUG_MALLOC in production - this slows
22 # everything down by alot
23 # IM_CFLAGS Extra flags to pass to the compiler
24 # IM_LFLAGS Extra flags to pass to the linker
25 # IM_DFLAGS Extra flags to pass to the preprocessor
26 # IM_SUPPRESS_PROMPT Suppress the prompt asking about gif support
28 getenv(); # get environment variables
30 my $lext=$Config{'so'}; # Get extensions of libraries
31 my $aext=$Config{'_a'};
33 my $help; # display help if set
34 my @enable; # list of drivers to enable
35 my @disable; # or list of drivers to disable
36 my @incpaths; # places to look for headers
37 my @libpaths; # places to look for libraries
38 my $noexif; # non-zero to disable EXIF parsing of JPEGs
39 my $no_gif_set_version; # disable calling EGifSetGifVersion
40 my $coverage; # build for coverage testing
41 GetOptions("help" => \$help,
42 "enable=s" => \@enable,
43 "disable=s" => \@disable,
44 "incpath=s", \@incpaths,
45 "libpath=s" => \@libpaths,
46 "verbose|v" => \$VERBOSE,
49 "nogifsetversion" => \$no_gif_set_version,
50 'coverage' => \$coverage);
53 print "Verbose mode\n";
55 import Data::Dumper qw(Dumper);
64 if ($NOLOG) { print "Logging not compiled into module\n"; }
66 push @defines, [ IMAGER_LOG => 1, "Logging system" ];
70 push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
71 print "Malloc debugging enabled\n";
74 if (@enable && @disable) {
75 print STDERR "Only --enable or --disable can be used, not both, try --help\n";
81 my @incs; # all the places to look for headers
82 my @libs; # all the places to look for libraries
84 init(); # initialize global data
85 pathcheck(); # Check if directories exist
87 if (exists $ENV{IM_ENABLE}) {
88 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
89 for my $key (keys %formats) {
90 delete $formats{$key} unless $en{$key};
94 my %en = map { $_ => 1 } map { split /,/ } @enable;
95 for my $key (keys %formats) {
96 delete $formats{$key} unless $en{$key};
100 delete @formats{map { split /,/ } @disable};
103 # Pick what libraries are used
110 # Make sure there isn't a clash between the gif libraries.
117 for my $frmkey (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
118 my $frm = $formats{$frmkey};
119 push @defines, [ $frm->{def}, 1, "$frmkey available" ];
120 $F_OBJECT .= ' ' .$frm->{objfiles};
121 if ($frm->{cflags}) {
122 $lib_cflags .= ' ' .$frm->{cflags};
123 ++$definc{$_} for map { /^-I(.*)$/ ? ($1) : () }
124 grep /^-I./, split ' ', $frm->{cflags};
126 if ($frm->{lflags}) {
127 $lib_lflags .= ' ' . $frm->{lflags};
130 $F_LIBS .= ' ' .$frm->{libfiles};
136 print "EXIF support enabled\n";
137 push @defines, [ 'IMEXIF_ENABLE', 1, "Enable experimental EXIF support" ];
138 $F_OBJECT .= ' imexif.o';
141 my $F_INC = join ' ', map "-I$_", map / / ? qq{"$_"} : $_,
142 grep !$definc{$_}, @incs;
143 $F_LIBS = join(' ',map "-L$_", map / / ? qq{"$_"} : $_,
144 grep !$deflib{$_}++, @libs) . $F_LIBS;
147 my $OSDEF = "-DOS_$^O";
149 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
150 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
152 my @objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
153 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o
154 filters.o dynaload.o stackmach.o datatypes.o
155 regmach.o trans2.o quant.o error.o convert.o
156 map.o tags.o palimg.o maskimg.o img16.o rotate.o
157 bmp.o tga.o color.o fills.o imgdouble.o limits.o hlines.o
158 imext.o scale.o rubthru.o render.o paste.o compose.o);
162 'VERSION_FROM' => 'Imager.pm',
163 'LIBS' => "$LFLAGS -lm $lib_lflags $OSLIBS $F_LIBS",
164 'DEFINE' => "$OSDEF $CFLAGS",
165 'INC' => "$lib_cflags $DFLAGS $F_INC",
166 'OBJECT' => join(' ', @objs, $F_OBJECT),
167 clean => { FILES=>'testout rubthru.c scale.c conv.c filters.c gaussian.c render.c rubthru.c' },
169 PREREQ_PM => { 'Test::More' => 0.47 },
173 if ($Config{gccversion}) {
174 push @ARGV, 'OPTIMIZE=-ftest-coverage -fprofile-arcs';
175 #$opts{dynamic_lib} = { OTHERLDFLAGS => '-ftest-coverage -fprofile-arcs' };
178 die "Don't know the coverage C flags for your compiler\n";
182 # eval to prevent warnings about versions with _ in them
183 my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
184 if ($MM_ver > 6.06) {
185 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson';
186 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
189 if ($MM_ver >= 6.46) {
194 "Parse::RecDescent" => 0
201 make_imconfig(\@defines);
203 if ($VERBOSE) { print Dumper(\%opts); }
204 mkdir('testout',0777); # since we cannot include it in the archive.
206 WriteMakefile(%opts);
213 my $perl = $self->{PERLRUN} ? '$(PERLRUN)' : '$(PERL)';
216 my @ims = grep /\.im$/, keys %$mani;
218 dyntest.$(MYEXTLIB) : dynfilt/Makefile
219 cd dynfilt && $(MAKE) $(PASTHRU)
221 lib/Imager/Regops.pm : regmach.h regops.perl
222 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
224 imconfig.h : Makefile.PL
225 $(ECHO) "imconfig.h out-of-date with respect to $?"
226 $(PERLRUN) Makefile.PL
227 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
229 lib/Imager/APIRef.pod : \$(C_FILES) apidocs.perl
230 $perl apidocs.perl lib/Imager/APIRef.pod
232 !.join('', map _im_rule($perl, $_), @ims)
237 my ($perl, $im) = @_;
239 (my $c = $im) =~ s/\.im$/.c/;
242 $c: $im lib/Imager/Preprocess.pm
243 $perl -Ilib -MImager::Preprocess -epreprocess $im $c
249 # manual configuration of helper libraries
254 Please answer the following questions about
255 which formats are avaliable on your computer
257 press <return> to continue
260 <STDIN>; # eat one return
262 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
264 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
265 print "Enable $frm support: ";
268 if ($gz =~ m/^(y|yes|n|no)/i) {
269 $gz=substr(lc($gz),0,1);
271 delete $formats{$frm};
278 # automatic configuration of helper libraries
281 print "Automatic probing:\n" if $VERBOSE;
282 for my $frm (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) {
283 delete $formats{$frm} if !checkformat($frm);
289 if ($formats{'gif'} and $formats{'ungif'}) {
290 print "ungif and gif can not coexist - removing ungif support\n";
291 delete $formats{'ungif'};
294 for my $frm (qw(gif ungif)) {
295 checkformat($frm) if ($MANUAL and $formats{$frm});
299 for my $frm (grep $formats{$_}, qw(gif ungif)) {
300 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
304 FILES: for my $dir (@dirs) {
305 my $h = "$dir/gif_lib.h";
306 open H, "< $h" or next;
308 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
318 # we need the version in a #ifdefable form
320 push @defines, [ IM_GIFMAJOR => $major, "Parsed giflib version" ];
321 push @defines, [ IM_GIFMINOR => $minor ];
322 push @defines, [ IM_NO_SET_GIF_VERSION => 1, "Disable EGifSetGifVersion" ]
323 if $no_gif_set_version;
330 # print "checking path $path\n";
331 if ( !opendir(DH,$path) ) {
332 warn "Cannot open dir $path: $!\n";
335 my @l=grep { $chk->($_) } readdir(DH);
338 return map $path, @l;
345 print " checkformat($frm)\n" if $VERBOSE;
347 my $probe_array = $formats{$frm}{'code'};
349 print " Calling probe function\n" if $VERBOSE;
350 if (ref $probe_array ne 'ARRAY') {
351 $probe_array = [ $probe_array ];
353 for my $func (@$probe_array) {
354 return 1 if $func->($formats{$frm}, $frm);
358 my $lib_check=$formats{$frm}{'libcheck'};
359 my $inc_check=$formats{$frm}{'inccheck'};
364 push(@l, grep_directory($lp,$lib_check));
369 push(@i, $ip) if $inc_check->($ip,$frm);
372 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
373 $formats{$frm}{incdir} = \@i;
374 $formats{$frm}{libdir} = \@l;
375 return 1 if scalar(@i && @l);
378 printf("%10s: not available\n", $frm);
388 print " Include paths:\n";
389 for (@incs) { print $_,"\n"; }
391 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
394 print "\nLibrary paths:\n";
395 for (@libs) { print $_,"\n"; }
397 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
402 # Format data initialization
404 # format definition is:
406 # default include path
407 # files needed for include (boolean perl code)
410 # files needed for link (boolean perl code)
411 # object files needed for the format
416 my @definc = qw(/usr/include);
417 @definc{@definc}=(1) x @definc;
420 split(/\Q$Config{path_sep}/, $INCPATH),
421 map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths
423 if ($Config{locincpth}) {
424 push @incs, grep -d, split ' ', $Config{locincpth};
426 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
427 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
429 if ($Config{incpath}) {
430 push @incs, grep -d, split /\Q$Config{path_sep}/, $Config{incpath};
434 /usr/include/freetype2
435 /usr/local/include/freetype2
436 /usr/local/include/freetype1/freetype
437 /usr/include /usr/local/include /usr/include/freetype
438 /usr/local/include/freetype);
439 if ($Config{ccflags}) {
440 my @hidden = map { /^-I(.*)$/ ? ($1) : () } split ' ', $Config{ccflags};
442 @definc{@hidden} = (1) x @hidden;
445 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
446 map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths );
447 if ($Config{loclibpth}) {
448 push @libs, grep -d, split ' ', $Config{loclibpth};
451 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
452 push @libs, grep -d, split / /, $Config{libspath} if $Config{libspath};
453 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
454 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
456 if ($^O eq 'cygwin') {
457 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
458 push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api';
460 if ($Config{ldflags}) {
461 # some builds of perl put -Ldir into ldflags without putting it in
462 # loclibpth, let's extract them
463 my @hidden = grep -d, map { /^-L(.*)$/ ? ($1) : () }
464 split ' ', $Config{ldflags};
466 # don't mark them as seen - EU::MM will remove any libraries
467 # it can't find and it doesn't look for -L in ldflags
468 #@deflib{@hidden} = @hidden;
470 push @libs, grep -d, qw(/usr/local/lib);
475 inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
476 libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
480 In order to use jpeg with this module you need to have libjpeg
481 installed on your computer}
487 inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
488 libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
492 In order to use tiff with this module you need to have libtiff
493 installed on your computer}
499 inccheck=>sub { -e catfile($_[0], 'png.h') },
500 libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
501 libfiles=>$^O eq 'MSWin32' ? '-lpng -lzlib' : '-lpng -lz',
504 Png stands for Portable Network Graphics and is intended as
505 a replacement for gif on the web. It is patent free and
506 is recommended by the w3c, you need libpng to use these formats},
513 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
514 libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
518 gif is the de facto standard for webgraphics at the moment,
519 it does have some patent problems. If you have giflib and
520 are not in violation with the unisys patent you should use
521 this instead of the 'ungif' option. Note that they cannot
522 be in use at the same time}
528 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
529 libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
533 gif is the de facto standard for webgraphics at the moment,
534 it does have some patent problems. If you have libungif and
535 want to create images free from LZW patented compression you
536 should use this option instead of the 'gif' option}
539 $formats{'T1-fonts'}={
542 inccheck=>sub { -e catfile($_[0], 't1lib.h') },
543 libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
547 postscript t1 fonts are scalable fonts. They can include
548 ligatures and kerning information and generally yield good
549 visual quality. We depend on libt1 to rasterize the fonts
553 $formats{'TT-fonts'}=
557 inccheck=>sub { -e catfile($_[0], 'freetype.h')
558 && !-e catfile($_[0], 'fterrors.h') },
559 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
562 code => \&freetype1_probe,
564 Truetype fonts are scalable fonts. They can include
565 kerning and hinting information and generally yield good
566 visual quality esp on low resultions. The freetype library is
567 used to rasterize for us. The only drawback is that there
568 are alot of badly designed fonts out there.}
573 inccheck=>sub { -e catfile($_[0], 'windows.h') },
574 libcheck=>sub { lc $_[0] eq 'gdi32.lib'
575 || lc $_[0] eq 'libgdi32.a' },
576 libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
579 Uses the Win32 GDI for rendering text.
581 This currently only works on under normal Win32 and cygwin.
584 $formats{'freetype2'} =
588 # we always use a probe function
589 #inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
590 #libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
591 libfiles=>'-lfreetype',
592 objfiles=>'freetyp2.o',
594 Freetype 2 supports both Truetype and Type 1 fonts, both of which are
595 scalable. It also supports a variety of other fonts.
599 \&freetype2_probe_ftconfig,
600 \&freetype2_probe_scan
605 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
612 defined($V) ? $V : "";
616 # Get information from environment variables
628 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
643 open CONFIG, "> imconfig.h"
644 or die "Cannot create imconfig.h: $!\n";
646 /* This file is automatically generated by Makefile.PL.
647 Don't edit this file, since any changes will be lost */
649 #ifndef IMAGER_IMCONFIG_H
650 #define IMAGER_IMCONFIG_H
652 for my $define (@$defines) {
654 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
656 print CONFIG "#define $define->[0] $define->[1]\n";
658 print CONFIG "\n#endif\n";
662 # use pkg-config to probe for libraries
663 # works around the junk that pkg-config dumps on FreeBSD
667 is_exe('pkg-config') or return;
669 my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null';
671 !system("pkg-config $pkg --exists $redir");
674 # probes for freetype1 by scanning @incs for the includes and
675 # @libs for the libs. This is done separately because freetype's headers
676 # are stored in a freetype or freetype1 directory under PREFIX/include.
678 # we could find the files with the existing mechanism, but it won't set
679 # -I flags correctly.
681 # This could be extended to freetype2 too, but freetype-config catches
683 sub freetype1_probe {
684 my ($frm, $frmkey) = @_;
688 for my $inc (@incs) {
689 for my $subdir (qw/freetype freetype1/) {
690 my $path = File::Spec->catfile($inc, $subdir, 'freetype.h');
692 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
695 $found_inc = File::Spec->catdir($inc, $subdir);
702 for my $lib (@libs) {
703 my $a_path = File::Spec->catfile($lib, "libttf$aext");
704 my $l_path = File::Spec->catfile($lib, "libttf.$lext");
705 if (-e $a_path || -e $l_path) {
711 return unless $found_inc && $found_lib;
712 printf("%10s: includes %s - libraries %s\n", $frmkey,
713 ($found_inc ? 'found' : 'not found'),
714 ($found_lib ? 'found' : 'not found'));
716 $frm->{cflags} = "-I$found_inc";
717 $frm->{libfiles} = "-lttf";
722 # probes for freetype2 by trying to run freetype-config
723 sub freetype2_probe_ftconfig {
724 my ($frm, $frmkey) = @_;
726 is_exe('freetype-config') or return;
728 my $cflags = `freetype-config --cflags`
732 my $lflags = `freetype-config --libs`
736 # before 2.1.5 freetype-config --cflags could output
737 # the -I options in the wrong order, causing a conflict with
738 # freetype1.x installed with the same --prefix
741 # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags
743 # - freetype 1.x headers are in prefix/include/freetype
744 my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags;
746 && $incdirs[1] eq "$incdirs[0]/freetype2"
747 && -e "$incdirs[0]/freetype/freetype.h"
748 && -e "$incdirs[0]/freetype/fterrid.h") {
749 print "** freetype-config provided -I options out of order, correcting\n"
751 $cflags = join(' ', grep(!/-I/, split ' ', $cflags),
752 map "-I$_", reverse @incdirs);
754 $frm->{cflags} = $cflags;
755 $frm->{lflags} = $lflags;
757 printf "%10s: configured via freetype-config\n", $frmkey;
762 # attempt to probe for freetype2 by scanning directories
763 # we can't use the normal scan since we need to find the directory
764 # containing most of the includes
765 sub freetype2_probe_scan {
766 my ($frm, $frmkey) = @_;
771 for my $inc (@incs) {
772 my $path = File::Spec->catfile($inc, 'ft2build.h');
775 # try to find what it's including
777 open FT2BUILD, "< $path"
780 if (m!^\s*\#\s*include\s+<([\w/.]+)>!
781 || m!^\s*\#\s*include\s+"([\w/.]+)"!) {
789 # non-Unix installs put this directly under the same directory in
791 if (-e File::Spec->catfile($inc, $ftheader)) {
795 for my $subdir (qw/freetype2 freetype/) {
796 $path = File::Spec->catfile($inc, $subdir, 'fterrors.h');
800 $found_inc2 = File::Spec->catdir($inc, $subdir);
807 for my $lib (@libs) {
808 my $a_path = File::Spec->catfile($lib, "libfreetype$aext");
809 my $l_path = File::Spec->catfile($lib, "libfreetype.$lext");
810 if (-e $a_path || -e $l_path) {
816 printf("%10s: includes %s - libraries %s\n", $frmkey,
817 ($found_inc ? 'found' : 'not found'),
818 ($found_lib ? 'found' : 'not found'));
820 return unless $found_inc && $found_lib;
822 $frm->{cflags} = _make_I($found_inc);
823 $frm->{cflags} .= " " . _make_I($found_inc2) if $found_inc2;
824 $frm->{libfiles} = "-lfreetype";
835 $inc_dir =~ / / ? qq!-I"$inc_dir"! : "-I$inc_dir";
838 # probes for libpng via pkg-config
840 my ($frm, $frmkey) = @_;
842 is_exe('pkg-config') or return;
845 for my $check_conf (qw(libpng libpng12 libpng10)) {
846 if (_pkg_probe($check_conf)) {
847 $config = $check_conf;
853 my $cflags = `pkg-config $config --cflags`
856 my $lflags = `pkg-config $config --libs`
861 $frm->{cflags} = $cflags;
862 $frm->{lflags} = $lflags;
864 printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
870 return File::Spec->catfile(@_);
876 my @exe_suffix = $Config{_exe};
877 if ($^O eq 'MSWin32') {
878 push @exe_suffix, qw/.bat .cmd/;
881 for my $dir (File::Spec->path) {
882 for my $suffix (@exe_suffix) {
883 -x catfile($dir, "$name$suffix")
893 Usage: $0 [--enable feature1,feature2,...] [other options]
894 $0 [--disable feature1,feature2,...] [other options]
896 Possible feature names are:
897 png gif ungif jpeg tiff T1-fonts TT-fonts freetype2
900 Verbose library probing (or set IM_VERBOSE in the environment)
902 Disable logging (or set IM_NOLOG in the environment)
904 Add to the include search path
906 Add to the library search path
912 # generate the PM MM argument
913 # I'd prefer to modify the public version, but there doesn't seem to be
914 # a public API to do that
917 my $instbase = '$(INST_LIBDIR)';
919 # first the basics, .pm and .pod files
920 $pm{"Imager.pm"} = "$instbase/Imager.pm";
922 my $mani = maniread();
924 for my $filename (keys %$mani) {
925 if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) {
926 (my $work = $filename) =~ s/^lib//;
927 $pm{$filename} = $instbase . $work;
932 $pm{typemap} = $instbase . '/Imager/typemap';
934 # and the core headers
935 for my $filename (keys %$mani) {
936 if ($filename =~ /^\w+\.h$/) {
937 $pm{$filename} = $instbase . '/Imager/include/' . $filename;
941 # and the generated header
942 $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h';
951 if ($path =~ m!^~[/\\]!) {
952 defined $home or $home = $ENV{HOME};
953 if (!defined $home && $^O eq 'MSWin32'
954 && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) {
955 $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH};
957 unless (defined $home) {
958 $home = eval { (getpwuid($<))[7] };
960 defined $home or die "You supplied $path, but I can't find your home directory\n";
962 $path = File::Spec->catdir($home, $path);
968 # This isn't a module, but some broken tools, like
969 # Module::Depends::Instrusive insist on treating it like one.
971 # http://rt.cpan.org/Public/Bug/Display.html?id=21229