Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 627 lines (521 sloc) 16.858 kB
ea9e6c3 - the Win32 font driver now uses DEFAULT_CHARSET rather than
Tony Cook authored
1 #!perl -w
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
2 use ExtUtils::MakeMaker;
3 use Cwd;
4 use Config;
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
5 use File::Spec;
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
6 use Getopt::Long;
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
7
8 #
9 # IM_INCPATH colon seperated list of paths to extra include paths
10 # IM_LIBPATH colon seperated list of paths to extra library paths
11 #
12 # IM_VERBOSE turns on verbose mode for the library finding and such
13 # IM_MANUAL to manually select which libraries are used and which not
14 # IM_ENABLE to programmatically select which libraries are used
15 # and which are not
16 # IM_NOLOG if true logging will not be compiled into the module
17 # IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
18 # do not use IM_DEBUG_MALLOC in production - this slows
19 # everything down by alot
20 # IM_CFLAGS Extra flags to pass to the compiler
21 # IM_LFLAGS Extra flags to pass to the linker
22 # IM_DFLAGS Extra flags to pass to the preprocessor
f4dbac5 make it possible to run automated tests by adding the IM_SUPPRESS_PRO…
Tony Cook authored
23 # IM_SUPPRESS_PROMPT Suppress the prompt asking about gif support
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
24
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
25 my $help;
26 my @enable;
27 my @disable;
28 my @incpaths;
29 my @libpaths;
30 my $noprobe;
31 GetOptions("help" => \$help,
32 "enable=s" => \@enable,
33 "disable=s" => \@disable,
34 "incpath=s", \@incpaths,
35 "libpath=s" => \@libpaths,
36 "noprobe" => \$noprobe);
37
38 if ($help) {
39 usage();
40 }
41
42 if (@enable && @disable) {
43 print STDERR "Only --enable or --disable can be used, not both, try --help\n";
44 exit 1;
45 }
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
46
47 getenv(); # get environment variables
48 init(); # initialize global data
49 pathcheck(); # Check if directories exist
50
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
51 if (exists $ENV{IM_ENABLE}) {
52 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
53 for my $key (keys %formats) {
54 delete $formats{$key} unless $en{$key};
55 }
56 }
57 if (@enable) {
58 my %en = map { $_ => 1 } map { split /,/ } @enable;
59 for my $key (keys %formats) {
60 delete $formats{$key} unless $en{$key};
61 }
62 }
63 elsif (@disable) {
64 delete @formats{map { split /,/ } @disable};
65 }
66
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
67 my @defines;
68
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
69 # Pick what libraries are used
70 if ($MANUAL) {
71 manual();
72 } else {
73 automatic();
74 }
75
76 # Make sure there isn't a clash between the gif libraries.
77 gifcheck();
78
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
79 my $lib_cflags = '';
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
80 for my $frmkey (keys %formats) {
81 my $frm = $formats{$frmkey};
82 push @defines, [ $frm->{def}, 1, "$frmkey available" ];
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
83 $F_LIBS .= ' ' .$frm->{libfiles};
84 $F_OBJECT .= ' ' .$frm->{objfiles};
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
85 $lib_cflags .= ' ' .$frm->{cflags} if $frm->{cflags};
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
86 }
87
ea9e6c3 - the Win32 font driver now uses DEFAULT_CHARSET rather than
Tony Cook authored
88 $F_INC = join ' ', map "-I$_", map / / ? qq{"$_"} : $_,
89 grep !exists $definc{$_}, @incs;
90 $F_LIBS = join(' ',map "-L$_", map / / ? qq{"$_"} : $_, @libs) . $F_LIBS;
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
91
92 $OSLIBS = '';
93 $OSDEF = "-DOS_$^O";
94
95 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
96 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
97
9982a30 Finished antialiased polygon drawing routines.
Arnar Mar Hrafnkelsson authored
98 @objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
99 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
100 filters.o dynaload.o stackmach.o datatypes.o
2df3535 Added map.c which implements mapping images through tables.
Arnar Mar Hrafnkelsson authored
101 regmach.o trans2.o quant.o error.o convert.o
261f91c start of bmp support (just writing so far)
Tony Cook authored
102 map.o tags.o palimg.o maskimg.o img16.o rotate.o
737a830 Added read support for sgi .rgb files.
Arnar Mar Hrafnkelsson authored
103 bmp.o tga.o rgb.o color.o fills.o imgdouble.o);
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
104
105 %opts=(
106 'NAME' => 'Imager',
107 'VERSION_FROM' => 'Imager.pm',
108 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS",
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
109 'DEFINE' => "$OSDEF $CFLAGS",
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
110 'INC' => "$lib_cflags $DFLAGS $F_INC",
de2b8ba remove testout on make clean
Tony Cook authored
111 'OBJECT' => join(' ', @objs, $F_OBJECT),
112 clean => { FILES=>'testout' },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
113 );
114
29316bd - make the inclusion of NO_META dependent on the version of EU::MM.
Tony Cook authored
115 if ($ExtUtils::MakeMaker::VERSION > 6.06) {
116 $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>, Arnar M. Hrafnkelsson';
ca50810 add the extra attributes that PPDs want
Tony Cook authored
117 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
118 }
29316bd - make the inclusion of NO_META dependent on the version of EU::MM.
Tony Cook authored
119 if ($ExtUtils::MakeMaker::VERSION > 6.10) {
120 $opts{NO_META} = 1;
121 }
ca50810 add the extra attributes that PPDs want
Tony Cook authored
122
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
123 make_imconfig(\@defines);
124
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
125 if ($VERBOSE) { print Dumper(\%opts); }
126 mkdir('testout',0777); # since we cannot include it in the archive.
127 WriteMakefile(%opts);
4dce694 Made Makefile.PL run $Config{make} lib/Imager/Regops.pm so it exists
Arnar Mar Hrafnkelsson authored
128
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
129 exit;
130
131
132 sub MY::postamble {
133 '
faa9b3e Egads
Tony Cook authored
134 dyntest.$(MYEXTLIB) : dynfilt/Makefile
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
135 cd dynfilt && $(MAKE) $(PASTHRU)
136
137 lib/Imager/Regops.pm : regmach.h regops.perl
138 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
139
140 imconfig.h: Makefile.PL
141 $(ECHO) "imconfig.h out-of-date with respect to $?"
142 $(PERLRUN) Makefile.PL
143 $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
144 ';
145 }
146
147 # manual configuration of helper libraries
148
149 sub manual {
150 print <<EOF;
151
152 Please answer the following questions about
153 which formats are avaliable on your computer
154
155 press <return> to continue
156 EOF
157
158 <STDIN>; # eat one return
159
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
160 for my $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
161 SWX:
162 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
163 print "Enable $frm support: ";
09fd346 Fixed so that IM_MANUAL doesn't lose the giflib version check.
Arnar Mar Hrafnkelsson authored
164 $gz = <STDIN>;
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
165 chomp($gz);
166 if ($gz =~ m/^(y|yes|n|no)/i) {
167 $gz=substr(lc($gz),0,1);
168 if ($gz eq 'n') {
169 delete $formats{$frm};
170 }
171 } else { goto SWX; }
172 }
173 }
174
175
176 # automatic configuration of helper libraries
177
178 sub automatic {
179 for $frm(keys %formats) {
180 delete $formats{$frm} if !checkformat($frm);
181 }
182 }
183
184
185 sub gifcheck {
5f5fe73 Added mng to the TOOD, and added a warning to the Makefile.PL if gif/…
Arnar Mar Hrafnkelsson authored
186 if ($formats{'gif'} and $formats{'ungif'}) {
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
187 print "ungif and gif can not coexist - removing ungif support\n";
188 delete $formats{'ungif'};
189 }
5f5fe73 Added mng to the TOOD, and added a warning to the Makefile.PL if gif/…
Arnar Mar Hrafnkelsson authored
190
191 RETR:
f4dbac5 make it possible to run automated tests by adding the IM_SUPPRESS_PRO…
Tony Cook authored
192 if (($formats{'gif'} or $formats{'ungif'}) && !$ENV{IM_SUPPRESS_PROMPT}) {
5f5fe73 Added mng to the TOOD, and added a warning to the Makefile.PL if gif/…
Arnar Mar Hrafnkelsson authored
193 print <<EOFF;
194
195 You have libgif or libungif installed. They are both known to have
196 bugs. Imager can crash or display other strange behaviour after
197 reading or writing gif images. Some of the gif tests can even fail
198 since they stress some parts of the buggy code.
199
f1967c1 update information about giflib bugs
Tony Cook authored
200 libungif 4.1.2 and later is safe. giflib 4.1.3 needs at least one
201 patch to have all the bugs fixed, see README for details.
202
203 Of course it's possible your operating system distributor has patched
204 all of these problems and you have nothing to worry about.
0b836ff - more information on gif library versions in README and Makefile.PL
Tony Cook authored
205
5f5fe73 Added mng to the TOOD, and added a warning to the Makefile.PL if gif/…
Arnar Mar Hrafnkelsson authored
206 Do you want to remove gif support? [Y/n]
207 EOFF
208 my $resp = <STDIN>;
209 chomp($resp);
210 if ($resp ne "n") {
211 delete $formats{'gif'};
212 delete $formats{'ungif'};
09fd346 Fixed so that IM_MANUAL doesn't lose the giflib version check.
Arnar Mar Hrafnkelsson authored
213 return;
5f5fe73 Added mng to the TOOD, and added a warning to the Makefile.PL if gif/…
Arnar Mar Hrafnkelsson authored
214 }
215 }
09fd346 Fixed so that IM_MANUAL doesn't lose the giflib version check.
Arnar Mar Hrafnkelsson authored
216
217 for my $frm (qw(gif ungif)) {
218 checkformat($frm) if ($MANUAL and $formats{$frm});
219 }
220
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
221 my @dirs;
222 for my $frm (grep $formats{$_}, qw(gif ungif)) {
223 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
224 }
225 my $minor = 0;
226 my $major = 0;
227 FILES: for my $dir (@dirs) {
228 my $h = "$dir/gif_lib.h";
229 open H, "< $h" or next;
230 while (<H>) {
231 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
232 $major = $1;
233 $minor = $2;
234 close H;
235 last FILES;
236 }
237 }
238 close H;
239 }
240
241 # 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
242
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
243 push @defines, [ IM_GIFMAJOR, $major, "Parsed giflib version" ];
244 push @defines, [ IM_GIFMINOR, $minor ];
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
245 }
246
247
248 sub gd {
249 my($path,$chk)=@_;
250
251 # print "checking path $path\n";
252 if ( !opendir(DH,$path) ) {
253 warn "Cannot open dir $path: $!\n";
254 return;
255 }
256 my @l=grep { $chk->($_) } readdir(DH);
257 # print @l;
258 close(DH);
259 return map $path, @l;
260 }
261
262
263 sub checkformat {
264 my $frm=shift;
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
265
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
266 my $code = $formats{$frm}{'code'};
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
267 if ($code && !$noprobe) {
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
268 return 1 if $code->($formats{$frm}, $frm);
269 }
270
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
271 my $libchk=$formats{$frm}{'libcheck'};
272 my $incchk=$formats{$frm}{'inccheck'};
273
274 my @l;
275 for my $lp (@libs) {
276 push(@l, gd($lp,$libchk));
277 }
278
279 my @i;
280 for my $ip (@incs) {
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
281 push(@i, $ip) if $incchk->($ip,$frm);
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
282 }
283
284 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
285 $formats{$frm}{incdir} = \@i;
286 $formats{$frm}{libdir} = \@l;
287 return scalar(@i && @l);
288 }
289
290
291 sub pathcheck {
292 if ($VERBOSE) {
293 print "pathcheck\n";
294 print " Include paths:\n";
295 for (@incs) { print $_,"\n"; }
296 }
3a6bb91 All the little fixup changes for the 0.42 release.
Arnar Mar Hrafnkelsson authored
297 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
298
299 if ($VERBOSE) {
300 print "\nLibrary paths:\n";
301 for (@incs) { print $_,"\n"; }
302 }
3a6bb91 All the little fixup changes for the 0.42 release.
Arnar Mar Hrafnkelsson authored
303 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
304 print "\ndone.\n";
305 }
306
307
308 # Format data initialization
309
310 # format definition is:
311 # defines needed
312 # default include path
313 # files needed for include (boolean perl code)
314 # default lib path
315 # libs needed
316 # files needed for link (boolean perl code)
317 # object files needed for the format
318
319
320 sub init {
321
322 @definc{'/usr/include'}=();
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
323 @incs=(split(/\Q$Config{path_sep}/, $INCPATH),
324 map { split /\Q$Config{path_sep}/} @incpaths );
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
325 if ($Config{locincpth}) {
6552acf - avoid complaining about include/lib directories we pull from
Tony Cook authored
326 push @incs, grep -d, split ' ', $Config{locincpth};
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
327 }
88a763e libpng support for Win32
Tony Cook authored
328 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
329 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
330 }
6552acf - avoid complaining about include/lib directories we pull from
Tony Cook authored
331 push @incs, grep -d,
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
332 qw(/sw/include
333 /usr/include/freetype2
334 /usr/local/include/freetype2
335 /usr/local/include/freetype1/freetype
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
336 /usr/include /usr/local/include /usr/include/freetype
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
337 /usr/local/include/freetype);
338
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
339 @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
340 map { split /\Q$Config{path_sep}/} @libpaths );
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
341 if ($Config{loclibpth}) {
6552acf - avoid complaining about include/lib directories we pull from
Tony Cook authored
342 push @libs, grep -d, split ' ', $Config{loclibpth};
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
343 }
6552acf - avoid complaining about include/lib directories we pull from
Tony Cook authored
344 push @libs, grep -d, qw(/sw/lib), split(/ /, $Config{'libpth'});
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
345 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
88a763e libpng support for Win32
Tony Cook authored
346 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
347 }
faa9b3e Egads
Tony Cook authored
348 if ($^O eq 'cygwin') {
349 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
350 push(@incs, '/usr/include/w32api') if -d '/usr/lib/w32api';
351 }
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
352
2646b26 - Makefile.PL now checks the directories specified by $Config{locincpth}
Tony Cook authored
353 my $lext=$Config{'so'}; # Get extensions of libraries
354 my $aext=$Config{'_a'};
355
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
356 $formats{'jpeg'}={
357 order=>'21',
358 def=>'HAVE_LIBJPEG',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
359 inccheck=>sub { -e catfile($_[0], 'jpeglib.h') },
50ee6f9 Win32 jpeg support
Tony Cook authored
360 libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
361 libfiles=>'-ljpeg',
362 objfiles=>'jpeg.o',
363 docs=>q{
364 In order to use jpeg with this module you need to have libjpeg
365 installed on your computer}
366 };
367
368 $formats{'tiff'}={
369 order=>'23',
370 def=>'HAVE_LIBTIFF',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
371 inccheck=>sub { -e catfile($_[0], 'tiffio.h') },
76c8a0a Win32 handling for checking for libtiff
Tony Cook authored
372 libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
373 libfiles=>'-ltiff',
374 objfiles=>'tiff.o',
375 docs=>q{
376 In order to use tiff with this module you need to have libtiff
377 installed on your computer}
378 };
379
380 $formats{'png'}={
381 order=>'22',
382 def=>'HAVE_LIBPNG',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
383 inccheck=>sub { -e catfile($_[0], 'png.h') },
88a763e libpng support for Win32
Tony Cook authored
384 libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
385 libfiles=>'-lpng -lz',
386 objfiles=>'png.o',
387 docs=>q{
388 Png stands for Portable Network Graphics and is intended as
389 a replacement for gif on the web. It is patent free and
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
390 is recommended by the w3c, you need libpng to use these formats},
391 code => \&png_probe,
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
392 };
393
394 $formats{'gif'}={
395 order=>'20',
396 def=>'HAVE_LIBGIF',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
397 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
e02451e added low-level error handling module
Tony Cook authored
398 libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
399 libfiles=>'-lgif',
400 objfiles=>'gif.o',
401 docs=>q{
402 gif is the de facto standard for webgraphics at the moment,
403 it does have some patent problems. If you have giflib and
404 are not in violation with the unisys patent you should use
405 this instead of the 'ungif' option. Note that they cannot
406 be in use at the same time}
407 };
408
409 $formats{'ungif'}={
410 order=>'21',
411 def=>'HAVE_LIBGIF',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
412 inccheck=>sub { -e catfile($_[0], 'gif_lib.h') },
e02451e added low-level error handling module
Tony Cook authored
413 libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
414 libfiles=>'-lungif',
415 objfiles=>'gif.o',
416 docs=>q{
417 gif is the de facto standard for webgraphics at the moment,
418 it does have some patent problems. If you have libungif and
419 want to create images free from LZW patented compression you
420 should use this option instead of the 'gif' option}
421 };
422
423 $formats{'T1-fonts'}={
424 order=>'30',
425 def=>'HAVE_LIBT1',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
426 inccheck=>sub { -e catfile($_[0], 't1lib.h') },
faa9b3e Egads
Tony Cook authored
427 libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
428 libfiles=>'-lt1',
429 objfiles=>'',
430 docs=>q{
431 postscript t1 fonts are scalable fonts. They can include
432 ligatures and kerning information and generally yield good
433 visual quality. We depend on libt1 to rasterize the fonts
434 for use in images.}
435 };
436
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
437 $formats{'TT-fonts'}=
438 {
439 order=>'31',
440 def=>'HAVE_LIBTT',
441 inccheck=>sub { -e catfile($_[0], 'freetype.h')
442 && !-e catfile($_[0], 'fterrors.h') },
443 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
444 libfiles=>'-lttf',
445 objfiles=>'',
446 docs=>q{
447 Truetype fonts are scalable fonts. They can include
448 kerning and hinting information and generally yield good
449 visual quality esp on low resultions. The freetype library is
450 used to rasterize for us. The only drawback is that there
451 are alot of badly designed fonts out there.}
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
452 };
faa9b3e Egads
Tony Cook authored
453 $formats{'w32'} = {
454 order=>40,
455 def=>'HAVE_WIN32',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
456 inccheck=>sub { -e catfile($_[0], 'windows.h') },
faa9b3e Egads
Tony Cook authored
457 libcheck=>sub { lc $_[0] eq 'gdi32.lib'
458 || lc $_[0] eq 'libgdi32.a' },
459 libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
460 objfiles=>'win32.o',
461 docs => <<DOCS
462 Uses the Win32 GDI for rendering text.
463
464 This currently only works on under normal Win32 and cygwin.
465 DOCS
466 };
467 $formats{'freetype2'} = {
468 order=>'29',
469 def=>'HAVE_FT2',
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
470 inccheck=>sub { -e catfile($_[0], 'ft2build.h') },
faa9b3e Egads
Tony Cook authored
471 libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
472 libfiles=>'-lfreetype',
473 objfiles=>'freetyp2.o',
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
474 docs=><<DOCS,
faa9b3e Egads
Tony Cook authored
475 Freetype 2 supports both Truetype and Type 1 fonts, both of which are
f8e9bc0 - scanning for required include files is now down by directory rather
Tony Cook authored
476 scalable. It also supports a variety of other fonts.
faa9b3e Egads
Tony Cook authored
477 DOCS
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
478 code => \&freetype2_probe,
faa9b3e Egads
Tony Cook authored
479 };
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
480 # Make fix indent
481 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
482 }
483
484
485
486 sub gen {
487 my $V = $ENV{$_[0]};
488 defined($V) ? $V : "";
489 }
490
491
492 # Get information from environment variables
493
494 sub getenv {
495
496 ($VERBOSE,
497 $INCPATH,
498 $LIBPATH,
499 $NOLOG,
500 $DEBUG_MALLOC,
501 $MANUAL,
502 $CFLAGS,
503 $LFLAGS,
504 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
505 IM_INCPATH
506 IM_LIBPATH
507 IM_NOLOG
508 IM_DEBUG_MALLOC
509 IM_MANUAL
510 IM_CFLAGS
511 IM_LFLAGS
512 IM_DFLAGS);
513
514 if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
515
516 if ($NOLOG) { print "Logging not compiled into module\n"; }
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
517 else {
518 push @defines, [ IMAGER_LOG => 1, "Logging system" ];
519 }
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
520
521 if ($DEBUG_MALLOC) {
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
522 push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
02d1d62 Initial revision
Arnar Mar Hrafnkelsson authored
523 print "Malloc debugging enabled\n";
524 }
525
526 }
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
527
e11d297 - Makefile.PL now builds imconfig.h with #defines for libraries
Tony Cook authored
528 sub make_imconfig {
529 my ($defines) = @_;
530
531 open CONFIG, "> imconfig.h"
532 or die "Cannot create imconfig.h: $!\n";
533 print CONFIG <<EOS;
534 /* This file is automatically generated by Makefile.PL.
535 Don't edit this file, since any changes will be lost */
536
537 #ifndef IMAGER_IMCONFIG_H
538 #define IMAGER_IMCONFIG_H
539 EOS
540 for my $define (@$defines) {
541 if ($define->[2]) {
542 print CONFIG "\n/*\n $define->[2]\n*/\n\n";
543 }
544 print CONFIG "#define $define->[0] $define->[1]\n";
545 }
546 print CONFIG "\n#endif\n";
547 close CONFIG;
548 }
549
07ea6c2 - Makefile.PL now attempts to use freetype-config to configure freety…
Tony Cook authored
550 # probes for freetype2 by trying to run freetype-config
551 sub freetype2_probe {
552 my ($frm, $frmkey) = @_;
553
554 is_exe('freetype-config') or return;
555
556 my $cflags = `freetype-config --cflags`
557 and !$? or return;
558 chomp $cflags;
559
560 $frm->{cflags} = $cflags;
561 my $lflags = `freetype-config --libs`
562 and !$? or return;
563 chomp $lflags;
564 $frm->{libfiles} = $lflags;
565
566 printf "%10s: configured via freetype-config\n", $frmkey;
567
568 return 1;
569 }
570
571 # probes for libpng via pkg-config
572 sub png_probe {
573 my ($frm, $frmkey) = @_;
574
575 is_exe('pkg-config') or return;
576
577 my $cflags;
578 my $config;
579 for my $check_conf (qw(libpng libpng12 libpng10)) {
580 $cflags = `pkg-config $check_conf --cflags`;
581 if ($cflags && !$?) {
582 $config = $check_conf;
583 last;
584 }
585 }
586 $config or return;
587
588 my $lflags = `pkg-config $config --libs`
589 and !$? or return;
590
591 chomp $cflags;
592 chomp $lflags;
593 $frm->{cflags} = $cflags;
594 $frm->{libfiles} = $lflags;
595
596 printf "%10s: configured via `pkg-config $config ...`\n", $frmkey;
597
598 return 1;
599 }
600
601 sub catfile {
602 return File::Spec->catfile(@_);
603 }
604
605 sub is_exe {
606 my ($name) = @_;
607
608 for my $dir (File::Spec->path) {
609 -x catfile($dir, "$name$Config{_exe}")
610 and return 1;
611 }
612
613 return;
614 }
3795907 - Makefile.PL now accepts command-line options to set include and lib…
Tony Cook authored
615
616 sub usage {
617 print STDERR <<EOS;
618 Usage: $0 [--enable feature1,feature2,...] [--incpath ...] [--libpath ...]
619 $0 [--disable feature1,feature2,...] [--incpath ...] [--libpath ...]
620 $0 --help
621 Possible feature names are:
622 png gif ungif jpeg tiff T1-fonts TT-fonts freetype2
623 EOS
624 exit 1;
625
626 }
Something went wrong with that request. Please try again.