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