Commit | Line | Data |
---|---|---|
ea9e6c3f | 1 | #!perl -w |
714cf158 | 2 | use strict; |
02d1d628 AMH |
3 | use ExtUtils::MakeMaker; |
4 | use Cwd; | |
5 | use Config; | |
07ea6c21 | 6 | use File::Spec; |
37959076 | 7 | use Getopt::Long; |
92bda632 | 8 | use ExtUtils::Manifest qw(maniread); |
10b85929 | 9 | use ExtUtils::Liblist; |
714cf158 | 10 | use vars qw(%formats $VERBOSE $INCPATH $LIBPATH $NOLOG $DEBUG_MALLOC $MANUAL $CFLAGS $LFLAGS $DFLAGS); |
812ae05c TC |
11 | use lib 'inc'; |
12 | use Devel::CheckLib; | |
02d1d628 | 13 | |
1d7e3124 TC |
14 | # EU::MM runs Makefile.PL all in the same process, so sub-modules will |
15 | # see this | |
16 | our $BUILDING_IMAGER = 1; | |
17 | ||
02d1d628 AMH |
18 | # |
19 | # IM_INCPATH colon seperated list of paths to extra include paths | |
20 | # IM_LIBPATH colon seperated list of paths to extra library paths | |
21 | # | |
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 | |
25 | # and which are not | |
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 | |
33 | ||
812ae05c TC |
34 | my $KEEP_FILES = $ENV{IMAGER_KEEP_FILES}; |
35 | ||
855c5808 TC |
36 | getenv(); # get environment variables |
37 | ||
714cf158 TC |
38 | my $lext=$Config{'so'}; # Get extensions of libraries |
39 | my $aext=$Config{'_a'}; | |
40 | ||
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 | |
1ef586b1 | 46 | my $coverage; # build for coverage testing |
b3afeed5 | 47 | my $assert; # build with assertions |
37959076 TC |
48 | GetOptions("help" => \$help, |
49 | "enable=s" => \@enable, | |
50 | "disable=s" => \@disable, | |
51 | "incpath=s", \@incpaths, | |
52 | "libpath=s" => \@libpaths, | |
274cd32b | 53 | "verbose|v" => \$VERBOSE, |
f7450478 | 54 | "nolog" => \$NOLOG, |
b3afeed5 TC |
55 | 'coverage' => \$coverage, |
56 | "assert|a" => \$assert); | |
57 | ||
1d7e3124 TC |
58 | setenv(); |
59 | ||
b3afeed5 TC |
60 | if ($ENV{AUTOMATED_TESTING}) { |
61 | $assert = 1; | |
62 | } | |
855c5808 TC |
63 | |
64 | if ($VERBOSE) { | |
65 | print "Verbose mode\n"; | |
66 | require Data::Dumper; | |
67 | import Data::Dumper qw(Dumper); | |
68 | } | |
37959076 TC |
69 | |
70 | if ($help) { | |
71 | usage(); | |
72 | } | |
73 | ||
f7450478 TC |
74 | my @defines; |
75 | ||
274cd32b TC |
76 | if ($NOLOG) { print "Logging not compiled into module\n"; } |
77 | else { | |
78 | push @defines, [ IMAGER_LOG => 1, "Logging system" ]; | |
79 | } | |
80 | ||
b3afeed5 TC |
81 | if ($assert) { |
82 | push @defines, [ IM_ASSERT => 1, "im_assert() are effective" ]; | |
83 | } | |
84 | ||
274cd32b TC |
85 | if ($DEBUG_MALLOC) { |
86 | push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ]; | |
87 | print "Malloc debugging enabled\n"; | |
88 | } | |
89 | ||
37959076 TC |
90 | if (@enable && @disable) { |
91 | print STDERR "Only --enable or --disable can be used, not both, try --help\n"; | |
92 | exit 1; | |
93 | } | |
02d1d628 | 94 | |
714cf158 TC |
95 | my %definc; |
96 | my %deflib; | |
97 | my @incs; # all the places to look for headers | |
98 | my @libs; # all the places to look for libraries | |
99 | ||
02d1d628 AMH |
100 | init(); # initialize global data |
101 | pathcheck(); # Check if directories exist | |
102 | ||
37959076 TC |
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}; | |
107 | } | |
108 | } | |
109 | if (@enable) { | |
110 | my %en = map { $_ => 1 } map { split /,/ } @enable; | |
111 | for my $key (keys %formats) { | |
112 | delete $formats{$key} unless $en{$key}; | |
113 | } | |
114 | } | |
115 | elsif (@disable) { | |
116 | delete @formats{map { split /,/ } @disable}; | |
117 | } | |
118 | ||
02d1d628 AMH |
119 | # Pick what libraries are used |
120 | if ($MANUAL) { | |
121 | manual(); | |
122 | } else { | |
123 | automatic(); | |
02d1d628 AMH |
124 | } |
125 | ||
07ea6c21 | 126 | my $lib_cflags = ''; |
a8395b42 | 127 | my $lib_lflags = ''; |
80c15fc7 TC |
128 | my $F_LIBS = ''; |
129 | my $F_OBJECT = ''; | |
714cf158 | 130 | for my $frmkey (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) { |
e11d297f TC |
131 | my $frm = $formats{$frmkey}; |
132 | push @defines, [ $frm->{def}, 1, "$frmkey available" ]; | |
02d1d628 | 133 | $F_OBJECT .= ' ' .$frm->{objfiles}; |
714cf158 TC |
134 | if ($frm->{cflags}) { |
135 | $lib_cflags .= ' ' .$frm->{cflags}; | |
136 | ++$definc{$_} for map { /^-I(.*)$/ ? ($1) : () } | |
137 | grep /^-I./, split ' ', $frm->{cflags}; | |
138 | } | |
a8395b42 TC |
139 | if ($frm->{lflags}) { |
140 | $lib_lflags .= ' ' . $frm->{lflags}; | |
141 | } | |
142 | else { | |
143 | $F_LIBS .= ' ' .$frm->{libfiles}; | |
144 | } | |
145 | ||
02d1d628 | 146 | } |
714cf158 | 147 | |
714cf158 TC |
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; | |
02d1d628 | 152 | |
714cf158 TC |
153 | my $OSLIBS = ''; |
154 | my $OSDEF = "-DOS_$^O"; | |
02d1d628 AMH |
155 | |
156 | if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; } | |
157 | if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; } | |
158 | ||
714cf158 TC |
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 | |
d5477d3d | 164 | bmp.o tga.o color.o fills.o imgdouble.o limits.o hlines.o |
e41cfe8f | 165 | imext.o scale.o rubthru.o render.o paste.o compose.o flip.o); |
92bda632 | 166 | |
714cf158 TC |
167 | my %opts=( |
168 | 'NAME' => 'Imager', | |
169 | 'VERSION_FROM' => 'Imager.pm', | |
a8395b42 | 170 | 'LIBS' => "$LFLAGS -lm $lib_lflags $OSLIBS $F_LIBS", |
714cf158 TC |
171 | 'DEFINE' => "$OSDEF $CFLAGS", |
172 | 'INC' => "$lib_cflags $DFLAGS $F_INC", | |
173 | 'OBJECT' => join(' ', @objs, $F_OBJECT), | |
f45b774f | 174 | clean => { FILES=>'testout rubthru.c scale.c conv.c filters.c gaussian.c render.c rubthru.c' }, |
714cf158 | 175 | PM => gen_PM(), |
867acf5b | 176 | PREREQ_PM => { 'Test::More' => 0.47 }, |
714cf158 | 177 | ); |
02d1d628 | 178 | |
1ef586b1 TC |
179 | if ($coverage) { |
180 | if ($Config{gccversion}) { | |
181 | push @ARGV, 'OPTIMIZE=-ftest-coverage -fprofile-arcs'; | |
182 | #$opts{dynamic_lib} = { OTHERLDFLAGS => '-ftest-coverage -fprofile-arcs' }; | |
183 | } | |
184 | else { | |
185 | die "Don't know the coverage C flags for your compiler\n"; | |
186 | } | |
187 | } | |
188 | ||
c52cbef2 TC |
189 | # eval to prevent warnings about versions with _ in them |
190 | my $MM_ver = eval $ExtUtils::MakeMaker::VERSION; | |
191 | if ($MM_ver > 6.06) { | |
29316bdb | 192 | $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson'; |
ca508100 TC |
193 | $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images'; |
194 | } | |
f45b774f TC |
195 | |
196 | if ($MM_ver >= 6.46) { | |
197 | $opts{META_MERGE} = | |
198 | { | |
199 | recommends => | |
200 | { | |
201 | "Parse::RecDescent" => 0 | |
202 | }, | |
203 | license => "perl", | |
204 | dynamic_config => 1, | |
43452432 TC |
205 | no_index => |
206 | { | |
207 | directory => | |
208 | [ | |
209 | "PNG", | |
ec6d8908 | 210 | "GIF", |
797a9f9c TC |
211 | "TIFF", |
212 | "JPEG", | |
bd7c1b36 | 213 | "W32", |
d7ca2089 | 214 | "FT2", |
43452432 TC |
215 | ], |
216 | }, | |
217 | resources => | |
218 | { | |
219 | homepage => "http://imager.perl.org/", | |
220 | repository => | |
221 | { | |
da405994 | 222 | url => "http://imager.perl.org/svn/trunk/Imager", |
43452432 TC |
223 | web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager", |
224 | type => "svn", | |
225 | }, | |
226 | bugtracker => | |
227 | { | |
228 | web => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Imager", | |
229 | mailto => 'bug-Imager@rt.cpan.org', | |
230 | }, | |
231 | }, | |
f45b774f | 232 | }; |
135d30e3 | 233 | } |
ca508100 | 234 | |
e11d297f TC |
235 | make_imconfig(\@defines); |
236 | ||
02d1d628 AMH |
237 | if ($VERBOSE) { print Dumper(\%opts); } |
238 | mkdir('testout',0777); # since we cannot include it in the archive. | |
135d30e3 | 239 | |
812ae05c TC |
240 | -d "probe" and rmdir "probe"; |
241 | ||
02d1d628 | 242 | WriteMakefile(%opts); |
4dce694d | 243 | |
02d1d628 AMH |
244 | exit; |
245 | ||
246 | ||
247 | sub MY::postamble { | |
5a7e62b6 TC |
248 | my $self = shift; |
249 | my $perl = $self->{PERLRUN} ? '$(PERLRUN)' : '$(PERL)'; | |
fe415ad2 TC |
250 | my $mani = maniread; |
251 | ||
252 | my @ims = grep /\.im$/, keys %$mani; | |
02d1d628 | 253 | ' |
faa9b3e7 | 254 | dyntest.$(MYEXTLIB) : dynfilt/Makefile |
02d1d628 AMH |
255 | cd dynfilt && $(MAKE) $(PASTHRU) |
256 | ||
257 | lib/Imager/Regops.pm : regmach.h regops.perl | |
258 | $(PERL) regops.perl regmach.h lib/Imager/Regops.pm | |
e11d297f | 259 | |
92bda632 | 260 | imconfig.h : Makefile.PL |
e11d297f TC |
261 | $(ECHO) "imconfig.h out-of-date with respect to $?" |
262 | $(PERLRUN) Makefile.PL | |
263 | $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <==" | |
5a7e62b6 | 264 | '.qq! |
6cfee9d1 | 265 | lib/Imager/APIRef.pod : \$(C_FILES) \$(H_FILES) apidocs.perl |
2a69ed21 | 266 | $perl apidocs.perl lib/Imager/APIRef.pod |
92bda632 | 267 | |
fe415ad2 TC |
268 | !.join('', map _im_rule($perl, $_), @ims) |
269 | ||
270 | } | |
271 | ||
272 | sub _im_rule { | |
273 | my ($perl, $im) = @_; | |
274 | ||
275 | (my $c = $im) =~ s/\.im$/.c/; | |
276 | return <<MAKE; | |
277 | ||
9b1ec2b8 TC |
278 | $c: $im lib/Imager/Preprocess.pm |
279 | $perl -Ilib -MImager::Preprocess -epreprocess $im $c | |
fe415ad2 TC |
280 | |
281 | MAKE | |
02d1d628 | 282 | |
55932d2a TC |
283 | } |
284 | ||
02d1d628 AMH |
285 | # manual configuration of helper libraries |
286 | ||
287 | sub manual { | |
288 | print <<EOF; | |
289 | ||
290 | Please answer the following questions about | |
291 | which formats are avaliable on your computer | |
292 | ||
293 | press <return> to continue | |
294 | EOF | |
295 | ||
296 | <STDIN>; # eat one return | |
297 | ||
2646b26c | 298 | for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) { |
02d1d628 AMH |
299 | SWX: |
300 | if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; } | |
301 | print "Enable $frm support: "; | |
714cf158 | 302 | my $gz = <STDIN>; |
02d1d628 AMH |
303 | chomp($gz); |
304 | if ($gz =~ m/^(y|yes|n|no)/i) { | |
305 | $gz=substr(lc($gz),0,1); | |
306 | if ($gz eq 'n') { | |
307 | delete $formats{$frm}; | |
308 | } | |
309 | } else { goto SWX; } | |
310 | } | |
311 | } | |
312 | ||
313 | ||
314 | # automatic configuration of helper libraries | |
315 | ||
316 | sub automatic { | |
714cf158 TC |
317 | print "Automatic probing:\n" if $VERBOSE; |
318 | for my $frm (sort { $formats{$a}{order} <=> $formats{$b}{order} } keys %formats) { | |
02d1d628 AMH |
319 | delete $formats{$frm} if !checkformat($frm); |
320 | } | |
321 | } | |
322 | ||
323 | ||
ec6d8908 TC |
324 | # sub gifcheck { |
325 | # if ($formats{'gif'} and $formats{'ungif'}) { | |
326 | # print "ungif and gif can not coexist - removing ungif support\n"; | |
327 | # delete $formats{'ungif'}; | |
328 | # } | |
5f5fe73e | 329 | |
ec6d8908 TC |
330 | # for my $frm (qw(gif ungif)) { |
331 | # checkformat($frm) if ($MANUAL and $formats{$frm}); | |
332 | # } | |
09fd3468 | 333 | |
ec6d8908 TC |
334 | # my @dirs; |
335 | # for my $frm (grep $formats{$_}, qw(gif ungif)) { | |
336 | # push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir}; | |
337 | # } | |
338 | # my $minor = 0; | |
339 | # my $major = 0; | |
340 | # FILES: for my $dir (@dirs) { | |
341 | # my $h = "$dir/gif_lib.h"; | |
342 | # open H, "< $h" or next; | |
343 | # while (<H>) { | |
344 | # if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) { | |
345 | # $major = $1; | |
346 | # $minor = $2; | |
347 | # close H; | |
348 | # last FILES; | |
349 | # } | |
350 | # } | |
351 | # close H; | |
352 | # } | |
02d1d628 | 353 | |
ec6d8908 | 354 | # # we need the version in a #ifdefable form |
4dce694d | 355 | |
ec6d8908 TC |
356 | # push @defines, [ IM_GIFMAJOR => $major, "Parsed giflib version" ]; |
357 | # push @defines, [ IM_GIFMINOR => $minor ]; | |
358 | # push @defines, [ IM_NO_SET_GIF_VERSION => 1, "Disable EGifSetGifVersion" ] | |
359 | # if $no_gif_set_version; | |
360 | # } | |
02d1d628 AMH |
361 | |
362 | ||
c6e870ae TC |
363 | sub grep_directory { |
364 | my($path, $chk)=@_; | |
02d1d628 AMH |
365 | |
366 | # print "checking path $path\n"; | |
367 | if ( !opendir(DH,$path) ) { | |
368 | warn "Cannot open dir $path: $!\n"; | |
369 | return; | |
370 | } | |
371 | my @l=grep { $chk->($_) } readdir(DH); | |
372 | # print @l; | |
373 | close(DH); | |
374 | return map $path, @l; | |
375 | } | |
376 | ||
812ae05c TC |
377 | sub _probe_default { |
378 | my ($format, $frm) = @_; | |
07ea6c21 | 379 | |
c6e870ae TC |
380 | my $lib_check=$formats{$frm}{'libcheck'}; |
381 | my $inc_check=$formats{$frm}{'inccheck'}; | |
02d1d628 | 382 | |
c6e870ae TC |
383 | if ($lib_check) { |
384 | my @l; | |
385 | for my $lp (@libs) { | |
386 | push(@l, grep_directory($lp,$lib_check)); | |
387 | } | |
388 | ||
389 | my @i; | |
390 | for my $ip (@incs) { | |
391 | push(@i, $ip) if $inc_check->($ip,$frm); | |
392 | } | |
393 | ||
394 | printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found')); | |
395 | $formats{$frm}{incdir} = \@i; | |
396 | $formats{$frm}{libdir} = \@l; | |
397 | return 1 if scalar(@i && @l); | |
02d1d628 | 398 | } |
c6e870ae TC |
399 | else { |
400 | printf("%10s: not available\n", $frm); | |
02d1d628 AMH |
401 | } |
402 | ||
c6e870ae | 403 | return 0; |
02d1d628 AMH |
404 | } |
405 | ||
812ae05c TC |
406 | sub checkformat { |
407 | my $frm=shift; | |
408 | ||
409 | print " checkformat($frm)\n" if $VERBOSE; | |
410 | ||
411 | my $format = $formats{$frm}; | |
412 | ||
413 | my @probes; | |
414 | if (my $code = $format->{'code'}) { | |
415 | if (ref $code eq 'ARRAY') { | |
416 | push @probes, @$code; | |
417 | } | |
418 | else { | |
419 | push @probes, $code; | |
420 | } | |
421 | } | |
422 | push @probes, \&_probe_default; | |
423 | ||
424 | print " Calling probe function\n" if $VERBOSE; | |
425 | my $found; | |
426 | for my $func (@probes) { | |
427 | if ($func->($format, $frm)) { | |
428 | ++$found; | |
429 | last; | |
430 | } | |
431 | } | |
432 | ||
433 | $found or return; | |
434 | ||
435 | if ($format->{postcheck}) { | |
436 | print " Calling postcheck function\n" if $VERBOSE; | |
437 | $format->{postcheck}->($format, $frm) | |
438 | or return; | |
439 | } | |
440 | ||
441 | return 1; | |
442 | } | |
443 | ||
02d1d628 | 444 | |
02d1d628 AMH |
445 | sub pathcheck { |
446 | if ($VERBOSE) { | |
447 | print "pathcheck\n"; | |
448 | print " Include paths:\n"; | |
449 | for (@incs) { print $_,"\n"; } | |
450 | } | |
3a6bb91b | 451 | @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs; |
02d1d628 AMH |
452 | |
453 | if ($VERBOSE) { | |
454 | print "\nLibrary paths:\n"; | |
855c5808 | 455 | for (@libs) { print $_,"\n"; } |
02d1d628 | 456 | } |
3a6bb91b | 457 | @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs; |
02d1d628 AMH |
458 | print "\ndone.\n"; |
459 | } | |
460 | ||
461 | ||
462 | # Format data initialization | |
463 | ||
464 | # format definition is: | |
465 | # defines needed | |
466 | # default include path | |
467 | # files needed for include (boolean perl code) | |
468 | # default lib path | |
469 | # libs needed | |
470 | # files needed for link (boolean perl code) | |
471 | # object files needed for the format | |
472 | ||
473 | ||
474 | sub init { | |
475 | ||
714cf158 TC |
476 | my @definc = qw(/usr/include); |
477 | @definc{@definc}=(1) x @definc; | |
d8e0c3ba TC |
478 | @incs= |
479 | ( | |
480 | split(/\Q$Config{path_sep}/, $INCPATH), | |
481 | map _tilde_expand($_), map { split /\Q$Config{path_sep}/ } @incpaths | |
482 | ); | |
2646b26c | 483 | if ($Config{locincpth}) { |
6552acfe | 484 | push @incs, grep -d, split ' ', $Config{locincpth}; |
2646b26c | 485 | } |
88a763e2 TC |
486 | if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) { |
487 | push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE}; | |
2646b26c | 488 | } |
16cf4610 TC |
489 | if ($Config{incpath}) { |
490 | push @incs, grep -d, split /\Q$Config{path_sep}/, $Config{incpath}; | |
491 | } | |
6552acfe | 492 | push @incs, grep -d, |
2646b26c TC |
493 | qw(/sw/include |
494 | /usr/include/freetype2 | |
495 | /usr/local/include/freetype2 | |
496 | /usr/local/include/freetype1/freetype | |
37959076 | 497 | /usr/include /usr/local/include /usr/include/freetype |
2646b26c | 498 | /usr/local/include/freetype); |
714cf158 TC |
499 | if ($Config{ccflags}) { |
500 | my @hidden = map { /^-I(.*)$/ ? ($1) : () } split ' ', $Config{ccflags}; | |
501 | push @incs, @hidden; | |
502 | @definc{@hidden} = (1) x @hidden; | |
503 | } | |
2646b26c | 504 | |
37959076 | 505 | @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH), |
d8e0c3ba | 506 | map _tilde_expand($_), map { split /\Q$Config{path_sep}/} @libpaths ); |
2646b26c | 507 | if ($Config{loclibpth}) { |
6552acfe | 508 | push @libs, grep -d, split ' ', $Config{loclibpth}; |
2646b26c | 509 | } |
714cf158 | 510 | |
6552acfe | 511 | push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'}); |
714cf158 | 512 | push @libs, grep -d, split / /, $Config{libspath} if $Config{libspath}; |
2646b26c | 513 | if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) { |
88a763e2 TC |
514 | push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB}; |
515 | } | |
faa9b3e7 TC |
516 | if ($^O eq 'cygwin') { |
517 | push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api'; | |
274cd32b | 518 | push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api'; |
faa9b3e7 | 519 | } |
714cf158 TC |
520 | if ($Config{ldflags}) { |
521 | # some builds of perl put -Ldir into ldflags without putting it in | |
522 | # loclibpth, let's extract them | |
523 | my @hidden = grep -d, map { /^-L(.*)$/ ? ($1) : () } | |
524 | split ' ', $Config{ldflags}; | |
525 | push @libs, @hidden; | |
526 | # don't mark them as seen - EU::MM will remove any libraries | |
527 | # it can't find and it doesn't look for -L in ldflags | |
528 | #@deflib{@hidden} = @hidden; | |
529 | } | |
ed28c9cc | 530 | push @libs, grep -d, qw(/usr/local/lib); |
2646b26c | 531 | |
797a9f9c TC |
532 | # $formats{'jpeg'}={ |
533 | # order=>'21', | |
534 | # def=>'HAVE_LIBJPEG', | |
535 | # inccheck=>sub { -e catfile($_[0], 'jpeglib.h') }, | |
536 | # libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" }, | |
537 | # libfiles=>'-ljpeg', | |
538 | # objfiles=>'jpeg.o', | |
539 | # docs=>q{ | |
540 | # In order to use jpeg with this module you need to have libjpeg | |
541 | # installed on your computer} | |
542 | # }; | |
02d1d628 | 543 | |
e5ee047b TC |
544 | # $formats{'tiff'}={ |
545 | # order=>'23', | |
546 | # def=>'HAVE_LIBTIFF', | |
547 | # inccheck=>sub { -e catfile($_[0], 'tiffio.h') }, | |
548 | # libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" }, | |
549 | # libfiles=>'-ltiff', | |
550 | # objfiles=>'tiff.o', | |
551 | # docs=>q{ | |
552 | # In order to use tiff with this module you need to have libtiff | |
553 | # installed on your computer}, | |
554 | # postcheck => \&postcheck_tiff, | |
555 | # }; | |
02d1d628 | 556 | |
1d7e3124 TC |
557 | # $formats{'png'}={ |
558 | # order=>'22', | |
559 | # def=>'HAVE_LIBPNG', | |
560 | # inccheck=>sub { -e catfile($_[0], 'png.h') }, | |
561 | # libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" }, | |
562 | # libfiles=>$^O eq 'MSWin32' ? '-lpng -lzlib' : '-lpng -lz', | |
563 | # objfiles=>'png.o', | |
564 | # docs=>q{ | |
565 | # Png stands for Portable Network Graphics and is intended as | |
566 | # a replacement for gif on the web. It is patent free and | |
567 | # is recommended by the w3c, you need libpng to use these formats}, | |
568 | # code => \&png_probe, | |
569 | # }; | |
02d1d628 | 570 | |
ec6d8908 TC |
571 | # $formats{'gif'}={ |
572 | # order=>'20', | |
573 | # def=>'HAVE_LIBGIF', | |
574 | # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') }, | |
575 | # libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" }, | |
576 | # libfiles=>'-lgif', | |
577 | # objfiles=>'gif.o', | |
578 | # docs=>q{ | |
579 | # gif is the de facto standard for webgraphics at the moment, | |
580 | # it does have some patent problems. If you have giflib and | |
581 | # are not in violation with the unisys patent you should use | |
582 | # this instead of the 'ungif' option. Note that they cannot | |
583 | # be in use at the same time} | |
584 | # }; | |
585 | ||
586 | # $formats{'ungif'}={ | |
587 | # order=>'21', | |
588 | # def=>'HAVE_LIBGIF', | |
589 | # inccheck=>sub { -e catfile($_[0], 'gif_lib.h') }, | |
590 | # libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" }, | |
591 | # libfiles=>'-lungif', | |
592 | # objfiles=>'gif.o', | |
593 | # docs=>q{ | |
594 | # gif is the de facto standard for webgraphics at the moment, | |
595 | # it does have some patent problems. If you have libungif and | |
596 | # want to create images free from LZW patented compression you | |
597 | # should use this option instead of the 'gif' option} | |
598 | # }; | |
02d1d628 AMH |
599 | |
600 | $formats{'T1-fonts'}={ | |
601 | order=>'30', | |
602 | def=>'HAVE_LIBT1', | |
f8e9bc07 | 603 | inccheck=>sub { -e catfile($_[0], 't1lib.h') }, |
faa9b3e7 | 604 | libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" }, |
02d1d628 AMH |
605 | libfiles=>'-lt1', |
606 | objfiles=>'', | |
607 | docs=>q{ | |
608 | postscript t1 fonts are scalable fonts. They can include | |
609 | ligatures and kerning information and generally yield good | |
610 | visual quality. We depend on libt1 to rasterize the fonts | |
611 | for use in images.} | |
612 | }; | |
613 | ||
f8e9bc07 TC |
614 | $formats{'TT-fonts'}= |
615 | { | |
616 | order=>'31', | |
617 | def=>'HAVE_LIBTT', | |
618 | inccheck=>sub { -e catfile($_[0], 'freetype.h') | |
619 | && !-e catfile($_[0], 'fterrors.h') }, | |
620 | libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" }, | |
621 | libfiles=>'-lttf', | |
622 | objfiles=>'', | |
714cf158 | 623 | code => \&freetype1_probe, |
f8e9bc07 TC |
624 | docs=>q{ |
625 | Truetype fonts are scalable fonts. They can include | |
626 | kerning and hinting information and generally yield good | |
627 | visual quality esp on low resultions. The freetype library is | |
628 | used to rasterize for us. The only drawback is that there | |
629 | are alot of badly designed fonts out there.} | |
02d1d628 | 630 | }; |
718b8c97 TC |
631 | # $formats{'w32'} = { |
632 | # order=>40, | |
633 | # def=>'HAVE_WIN32', | |
634 | # inccheck=>sub { -e catfile($_[0], 'windows.h') }, | |
635 | # libcheck=>sub { lc $_[0] eq 'gdi32.lib' | |
636 | # || lc $_[0] eq 'libgdi32.a' }, | |
637 | # libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '', | |
638 | # objfiles=>'win32.o', | |
639 | # docs => <<DOCS | |
640 | # Uses the Win32 GDI for rendering text. | |
641 | ||
642 | # This currently only works on under normal Win32 and cygwin. | |
643 | # DOCS | |
644 | # }; | |
50c75381 TC |
645 | # $formats{'freetype2'} = |
646 | # { | |
647 | # order=>'29', | |
648 | # def=>'HAVE_FT2', | |
649 | # # we always use a probe function | |
650 | # #inccheck=>sub { -e catfile($_[0], 'ft2build.h') }, | |
651 | # #libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" }, | |
652 | # libfiles=>'-lfreetype', | |
653 | # objfiles=>'freetyp2.o', | |
654 | # docs=><<DOCS, | |
655 | # Freetype 2 supports both Truetype and Type 1 fonts, both of which are | |
656 | # scalable. It also supports a variety of other fonts. | |
657 | # DOCS | |
658 | # code => | |
659 | # [ | |
660 | # \&freetype2_probe_ftconfig, | |
661 | # \&freetype2_probe_scan | |
662 | # ], | |
663 | # }; | |
f7450478 | 664 | |
02d1d628 AMH |
665 | # Make fix indent |
666 | for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; } | |
667 | } | |
668 | ||
669 | ||
670 | ||
671 | sub gen { | |
672 | my $V = $ENV{$_[0]}; | |
673 | defined($V) ? $V : ""; | |
674 | } | |
675 | ||
676 | ||
677 | # Get information from environment variables | |
678 | ||
679 | sub getenv { | |
680 | ||
681 | ($VERBOSE, | |
682 | $INCPATH, | |
683 | $LIBPATH, | |
684 | $NOLOG, | |
685 | $DEBUG_MALLOC, | |
686 | $MANUAL, | |
687 | $CFLAGS, | |
688 | $LFLAGS, | |
689 | $DFLAGS) = map { gen $_ } qw(IM_VERBOSE | |
690 | IM_INCPATH | |
691 | IM_LIBPATH | |
692 | IM_NOLOG | |
693 | IM_DEBUG_MALLOC | |
694 | IM_MANUAL | |
695 | IM_CFLAGS | |
696 | IM_LFLAGS | |
697 | IM_DFLAGS); | |
698 | ||
02d1d628 | 699 | } |
07ea6c21 | 700 | |
1d7e3124 TC |
701 | # populate the environment so that sub-modules get the same info |
702 | sub setenv { | |
703 | $ENV{IM_VERBOSE} = 1 if $VERBOSE; | |
704 | $ENV{IM_INCPATH} = join $Config{path_sep}, @incpaths if @incpaths; | |
705 | $ENV{IM_LIBPATH} = join $Config{path_sep}, @libpaths if @libpaths; | |
706 | } | |
707 | ||
e11d297f TC |
708 | sub make_imconfig { |
709 | my ($defines) = @_; | |
710 | ||
711 | open CONFIG, "> imconfig.h" | |
712 | or die "Cannot create imconfig.h: $!\n"; | |
713 | print CONFIG <<EOS; | |
714 | /* This file is automatically generated by Makefile.PL. | |
715 | Don't edit this file, since any changes will be lost */ | |
716 | ||
717 | #ifndef IMAGER_IMCONFIG_H | |
718 | #define IMAGER_IMCONFIG_H | |
719 | EOS | |
720 | for my $define (@$defines) { | |
721 | if ($define->[2]) { | |
722 | print CONFIG "\n/*\n $define->[2]\n*/\n\n"; | |
723 | } | |
724 | print CONFIG "#define $define->[0] $define->[1]\n"; | |
725 | } | |
726 | print CONFIG "\n#endif\n"; | |
727 | close CONFIG; | |
728 | } | |
729 | ||
50c75381 TC |
730 | # # use pkg-config to probe for libraries |
731 | # # works around the junk that pkg-config dumps on FreeBSD | |
732 | # sub _pkg_probe { | |
733 | # my ($pkg) = @_; | |
dbc33d8a | 734 | |
50c75381 | 735 | # is_exe('pkg-config') or return; |
dbc33d8a | 736 | |
50c75381 | 737 | # my $redir = $^O eq 'MSWin32' ? '' : '2>/dev/null'; |
dbc33d8a | 738 | |
50c75381 TC |
739 | # !system("pkg-config $pkg --exists $redir"); |
740 | # } | |
dbc33d8a | 741 | |
714cf158 TC |
742 | # probes for freetype1 by scanning @incs for the includes and |
743 | # @libs for the libs. This is done separately because freetype's headers | |
744 | # are stored in a freetype or freetype1 directory under PREFIX/include. | |
745 | # | |
746 | # we could find the files with the existing mechanism, but it won't set | |
747 | # -I flags correctly. | |
748 | # | |
749 | # This could be extended to freetype2 too, but freetype-config catches | |
750 | # that | |
751 | sub freetype1_probe { | |
752 | my ($frm, $frmkey) = @_; | |
753 | ||
754 | my $found_inc; | |
755 | INCS: | |
756 | for my $inc (@incs) { | |
757 | for my $subdir (qw/freetype freetype1/) { | |
758 | my $path = File::Spec->catfile($inc, $subdir, 'freetype.h'); | |
759 | -e $path or next; | |
760 | $path = File::Spec->catfile($inc, $subdir, 'fterrors.h'); | |
761 | -e $path and next; | |
762 | ||
763 | $found_inc = File::Spec->catdir($inc, $subdir); | |
764 | last INCS; | |
765 | } | |
766 | } | |
767 | ||
768 | my $found_lib; | |
769 | LIBS: | |
770 | for my $lib (@libs) { | |
771 | my $a_path = File::Spec->catfile($lib, "libttf$aext"); | |
772 | my $l_path = File::Spec->catfile($lib, "libttf.$lext"); | |
773 | if (-e $a_path || -e $l_path) { | |
774 | $found_lib = $lib; | |
775 | last LIBS; | |
776 | } | |
777 | } | |
778 | ||
89d37182 | 779 | return unless $found_inc && $found_lib; |
714cf158 TC |
780 | printf("%10s: includes %s - libraries %s\n", $frmkey, |
781 | ($found_inc ? 'found' : 'not found'), | |
782 | ($found_lib ? 'found' : 'not found')); | |
714cf158 TC |
783 | |
784 | $frm->{cflags} = "-I$found_inc"; | |
785 | $frm->{libfiles} = "-lttf"; | |
786 | ||
787 | return 1; | |
788 | } | |
789 | ||
07ea6c21 | 790 | # probes for freetype2 by trying to run freetype-config |
50c75381 TC |
791 | # sub freetype2_probe_ftconfig { |
792 | # my ($frm, $frmkey) = @_; | |
793 | ||
794 | # is_exe('freetype-config') or return; | |
795 | ||
796 | # my $cflags = `freetype-config --cflags` | |
797 | # and !$? or return; | |
798 | # chomp $cflags; | |
799 | ||
800 | # my $lflags = `freetype-config --libs` | |
801 | # and !$? or return; | |
802 | # chomp $lflags; | |
803 | ||
804 | # # before 2.1.5 freetype-config --cflags could output | |
805 | # # the -I options in the wrong order, causing a conflict with | |
806 | # # freetype1.x installed with the same --prefix | |
807 | # # | |
808 | # # can happen iff: | |
809 | # # - both -Iprefix/include and -Iprefix/include/freetype2 are in cflags | |
810 | # # in that order | |
811 | # # - freetype 1.x headers are in prefix/include/freetype | |
812 | # my @incdirs = map substr($_, 2), grep /^-I/, split ' ', $cflags; | |
813 | # if (@incdirs == 2 | |
814 | # && $incdirs[1] eq "$incdirs[0]/freetype2" | |
815 | # && -e "$incdirs[0]/freetype/freetype.h" | |
816 | # && -e "$incdirs[0]/freetype/fterrid.h") { | |
817 | # print "** freetype-config provided -I options out of order, correcting\n" | |
818 | # if $VERBOSE; | |
819 | # $cflags = join(' ', grep(!/-I/, split ' ', $cflags), | |
820 | # map "-I$_", reverse @incdirs); | |
821 | # } | |
822 | # $frm->{cflags} = $cflags; | |
823 | # $frm->{lflags} = $lflags; | |
07ea6c21 | 824 | |
50c75381 | 825 | # printf "%10s: configured via freetype-config\n", $frmkey; |
07ea6c21 | 826 | |
50c75381 TC |
827 | # return 1; |
828 | # } | |
07ea6c21 | 829 | |
c6e870ae TC |
830 | # attempt to probe for freetype2 by scanning directories |
831 | # we can't use the normal scan since we need to find the directory | |
832 | # containing most of the includes | |
50c75381 TC |
833 | # sub freetype2_probe_scan { |
834 | # my ($frm, $frmkey) = @_; | |
835 | ||
836 | # my $found_inc; | |
837 | # my $found_inc2; | |
838 | # INCS: | |
839 | # for my $inc (@incs) { | |
840 | # my $path = File::Spec->catfile($inc, 'ft2build.h'); | |
841 | # -e $path or next; | |
842 | ||
843 | # # try to find what it's including | |
844 | # my $ftheader; | |
845 | # open FT2BUILD, "< $path" | |
846 | # or next; | |
847 | # while (<FT2BUILD>) { | |
848 | # if (m!^\s*\#\s*include\s+<([\w/.]+)>! | |
849 | # || m!^\s*\#\s*include\s+"([\w/.]+)"!) { | |
850 | # $ftheader = $1; | |
851 | # last; | |
852 | # } | |
853 | # } | |
854 | # close FT2BUILD; | |
855 | # $ftheader | |
856 | # or next; | |
857 | # # non-Unix installs put this directly under the same directory in | |
858 | # # theory | |
859 | # if (-e File::Spec->catfile($inc, $ftheader)) { | |
860 | # $found_inc = $inc; | |
861 | # last INCS; | |
862 | # } | |
863 | # for my $subdir (qw/freetype2 freetype/) { | |
864 | # $path = File::Spec->catfile($inc, $subdir, 'fterrors.h'); | |
865 | # -e $path and next; | |
c6e870ae | 866 | |
50c75381 TC |
867 | # $found_inc = $inc; |
868 | # $found_inc2 = File::Spec->catdir($inc, $subdir); | |
869 | # last INCS; | |
870 | # } | |
871 | # } | |
c6e870ae | 872 | |
50c75381 TC |
873 | # my $found_lib; |
874 | # LIBS: | |
875 | # for my $lib (@libs) { | |
876 | # my $a_path = File::Spec->catfile($lib, "libfreetype$aext"); | |
877 | # my $l_path = File::Spec->catfile($lib, "libfreetype.$lext"); | |
878 | # if (-e $a_path || -e $l_path) { | |
879 | # $found_lib = $lib; | |
880 | # last LIBS; | |
881 | # } | |
882 | # } | |
c6e870ae | 883 | |
50c75381 TC |
884 | # printf("%10s: includes %s - libraries %s\n", $frmkey, |
885 | # ($found_inc ? 'found' : 'not found'), | |
886 | # ($found_lib ? 'found' : 'not found')); | |
c6e870ae | 887 | |
50c75381 | 888 | # return unless $found_inc && $found_lib; |
c6e870ae | 889 | |
50c75381 TC |
890 | # $frm->{cflags} = _make_I($found_inc); |
891 | # $frm->{cflags} .= " " . _make_I($found_inc2) if $found_inc2; | |
892 | # $frm->{libfiles} = "-lfreetype"; | |
c6e870ae | 893 | |
50c75381 TC |
894 | # return 1; |
895 | # } | |
c6e870ae | 896 | |
6c2b7cf1 TC |
897 | sub _make_I { |
898 | my ($inc_dir) = @_; | |
899 | ||
900 | $definc{$inc_dir} | |
e1fe2094 | 901 | and return ''; |
6c2b7cf1 TC |
902 | |
903 | $inc_dir =~ / / ? qq!-I"$inc_dir"! : "-I$inc_dir"; | |
904 | } | |
905 | ||
07ea6c21 | 906 | # probes for libpng via pkg-config |
50c75381 TC |
907 | # sub png_probe { |
908 | # my ($frm, $frmkey) = @_; | |
07ea6c21 | 909 | |
50c75381 | 910 | # is_exe('pkg-config') or return; |
07ea6c21 | 911 | |
50c75381 TC |
912 | # my $config; |
913 | # for my $check_conf (qw(libpng libpng12 libpng10)) { | |
914 | # if (_pkg_probe($check_conf)) { | |
915 | # $config = $check_conf; | |
916 | # last; | |
917 | # } | |
918 | # } | |
919 | # $config or return; | |
07ea6c21 | 920 | |
50c75381 TC |
921 | # my $cflags = `pkg-config $config --cflags` |
922 | # and !$? or return; | |
dbc33d8a | 923 | |
50c75381 TC |
924 | # my $lflags = `pkg-config $config --libs` |
925 | # and !$? or return; | |
07ea6c21 | 926 | |
50c75381 TC |
927 | # chomp $cflags; |
928 | # chomp $lflags; | |
929 | # $frm->{cflags} = $cflags; | |
930 | # $frm->{lflags} = $lflags; | |
07ea6c21 | 931 | |
50c75381 | 932 | # printf "%10s: configured via `pkg-config $config ...`\n", $frmkey; |
07ea6c21 | 933 | |
50c75381 TC |
934 | # return 1; |
935 | # } | |
07ea6c21 TC |
936 | |
937 | sub catfile { | |
938 | return File::Spec->catfile(@_); | |
939 | } | |
940 | ||
50c75381 TC |
941 | # sub is_exe { |
942 | # my ($name) = @_; | |
07ea6c21 | 943 | |
50c75381 TC |
944 | # my @exe_suffix = $Config{_exe}; |
945 | # if ($^O eq 'MSWin32') { | |
946 | # push @exe_suffix, qw/.bat .cmd/; | |
947 | # } | |
3e6d8b86 | 948 | |
50c75381 TC |
949 | # for my $dir (File::Spec->path) { |
950 | # for my $suffix (@exe_suffix) { | |
951 | # -x catfile($dir, "$name$suffix") | |
952 | # and return 1; | |
953 | # } | |
954 | # } | |
07ea6c21 | 955 | |
50c75381 TC |
956 | # return; |
957 | # } | |
37959076 TC |
958 | |
959 | sub usage { | |
960 | print STDERR <<EOS; | |
274cd32b TC |
961 | Usage: $0 [--enable feature1,feature2,...] [other options] |
962 | $0 [--disable feature1,feature2,...] [other options] | |
37959076 TC |
963 | $0 --help |
964 | Possible feature names are: | |
797a9f9c | 965 | T1-fonts TT-fonts freetype2 |
274cd32b TC |
966 | Other options: |
967 | --verbose | -v | |
968 | Verbose library probing (or set IM_VERBOSE in the environment) | |
969 | --nolog | |
970 | Disable logging (or set IM_NOLOG in the environment) | |
971 | --incpath dir | |
972 | Add to the include search path | |
973 | --libpath dir | |
974 | Add to the library search path | |
35a15603 TC |
975 | --coverage |
976 | Build for coverage testing. | |
977 | --assert | |
978 | Build with assertions active. | |
37959076 TC |
979 | EOS |
980 | exit 1; | |
981 | ||
982 | } | |
92bda632 TC |
983 | |
984 | # generate the PM MM argument | |
985 | # I'd prefer to modify the public version, but there doesn't seem to be | |
986 | # a public API to do that | |
987 | sub gen_PM { | |
988 | my %pm; | |
989 | my $instbase = '$(INST_LIBDIR)'; | |
990 | ||
991 | # first the basics, .pm and .pod files | |
992 | $pm{"Imager.pm"} = "$instbase/Imager.pm"; | |
993 | ||
994 | my $mani = maniread(); | |
995 | ||
996 | for my $filename (keys %$mani) { | |
997 | if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) { | |
998 | (my $work = $filename) =~ s/^lib//; | |
999 | $pm{$filename} = $instbase . $work; | |
1000 | } | |
1001 | } | |
1002 | ||
1003 | # need the typemap | |
1004 | $pm{typemap} = $instbase . '/Imager/typemap'; | |
1005 | ||
1006 | # and the core headers | |
1007 | for my $filename (keys %$mani) { | |
1008 | if ($filename =~ /^\w+\.h$/) { | |
1009 | $pm{$filename} = $instbase . '/Imager/include/' . $filename; | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | # and the generated header | |
1014 | $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h'; | |
1015 | ||
1016 | \%pm; | |
1017 | } | |
135d30e3 | 1018 | |
d8e0c3ba TC |
1019 | my $home; |
1020 | sub _tilde_expand { | |
1021 | my ($path) = @_; | |
1022 | ||
1023 | if ($path =~ m!^~[/\\]!) { | |
1024 | defined $home or $home = $ENV{HOME}; | |
1025 | if (!defined $home && $^O eq 'MSWin32' | |
1026 | && defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH}) { | |
1027 | $home = $ENV{HOMEDRIVE} . $ENV{HOMEPATH}; | |
1028 | } | |
1029 | unless (defined $home) { | |
1030 | $home = eval { (getpwuid($<))[7] }; | |
1031 | } | |
1032 | defined $home or die "You supplied $path, but I can't find your home directory\n"; | |
1033 | $path =~ s/^~//; | |
1034 | $path = File::Spec->catdir($home, $path); | |
1035 | } | |
1036 | ||
1037 | $path; | |
1038 | } | |
1039 | ||
e5ee047b TC |
1040 | # sub postcheck_tiff { |
1041 | # my ($format, $frm) = @_; | |
812ae05c | 1042 | |
e5ee047b | 1043 | # -d "probe" or mkdir "probe"; |
812ae05c | 1044 | |
e5ee047b | 1045 | # my $tiffver_name = "probe/tiffver.txt"; |
b8ea81ac | 1046 | |
e5ee047b TC |
1047 | # my $lib; |
1048 | # if ($Config{cc} =~ /\b(cl|bcc)\b/) { | |
1049 | # $lib = "libtiff"; | |
1050 | # } | |
1051 | # else { | |
1052 | # $lib = "tiff"; | |
1053 | # } | |
10b85929 | 1054 | |
e5ee047b TC |
1055 | # # setup LD_RUN_PATH to match link time |
1056 | # my $lopts = join " " , map("-L$_", @{$format->{libdir}}), " -ltiff"; | |
1057 | # my ($extra, $bs_load, $ld_load, $ld_run_path) = | |
1058 | # ExtUtils::Liblist->ext($lopts, $VERBOSE); | |
1059 | # local $ENV{LD_RUN_PATH}; | |
10b85929 | 1060 | |
e5ee047b TC |
1061 | # if ($ld_run_path) { |
1062 | # print "Setting LD_RUN_PATH=$ld_run_path for TIFF probe\n" if $VERBOSE; | |
1063 | # $ENV{LD_RUN_PATH} = $ld_run_path; | |
1064 | # } | |
812ae05c | 1065 | |
e5ee047b TC |
1066 | # my $good = |
1067 | # eval { | |
1068 | # assert_lib | |
1069 | # ( | |
1070 | # debug => $VERBOSE, | |
1071 | # incpath => $format->{incdir}, | |
1072 | # libpath => $format->{libdir}, | |
1073 | # lib => $lib, | |
1074 | # header => [ qw(stdio.h tiffio.h) ], | |
1075 | # function => <<FUNCTION, | |
1076 | # { | |
1077 | # const char *vers = TIFFGetVersion(); | |
1078 | # FILE *f = fopen("$tiffver_name", "wb"); | |
1079 | # if (!f) | |
1080 | # return 1; | |
1081 | # fputs(vers, f); | |
1082 | # if (fclose(f)) | |
1083 | # return 1; | |
1084 | # return 0; | |
1085 | # } | |
1086 | # FUNCTION | |
1087 | # ); | |
1088 | # 1; | |
1089 | # }; | |
1090 | ||
1091 | # unless ($good && -s $tiffver_name | |
1092 | # && open(VERS, "< $tiffver_name")) { | |
1093 | # unlink $tiffver_name unless $KEEP_FILES; | |
1094 | # print <<EOS; | |
1095 | # **tiff: cannot determine libtiff version number | |
1096 | # tiff: DISABLED | |
1097 | # EOS | |
1098 | # return; | |
1099 | # } | |
812ae05c | 1100 | |
e5ee047b TC |
1101 | # # version file seems to be there, load it up |
1102 | # my $ver_str = do { local $/; <VERS> }; | |
1103 | # close VERS; | |
1104 | # unlink $tiffver_name unless $KEEP_FILES; | |
812ae05c | 1105 | |
e5ee047b | 1106 | # my ($version) = $ver_str =~ /(\d+\.\d+\.\d+)/; |
812ae05c | 1107 | |
e5ee047b TC |
1108 | # if ($version eq '3.9.0') { |
1109 | # print <<EOS; | |
1110 | # **tiff: libtiff 3.9.0 introduced a serious bug, please install 3.9.1 | |
1111 | # tiff: DISABLED | |
1112 | # EOS | |
1113 | # return; | |
1114 | # } | |
812ae05c | 1115 | |
e5ee047b TC |
1116 | # return 1; |
1117 | # } | |
812ae05c | 1118 | |
678a9a65 TC |
1119 | # This isn't a module, but some broken tools, like |
1120 | # Module::Depends::Instrusive insist on treating it like one. | |
1121 | # | |
1122 | # http://rt.cpan.org/Public/Bug/Display.html?id=21229 | |
1123 | ||
1124 | 1; |