Skip to content

HTTPS clone URL

Subversion checkout URL

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