Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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