2 use ExtUtils::MakeMaker;
6 $lext=$Config{'so'}; # Get extensions of libraries
10 # IM_INCPATH colon seperated list of paths to extra include paths
11 # IM_LIBPATH colon seperated list of paths to extra library paths
13 # IM_VERBOSE turns on verbose mode for the library finding and such
14 # IM_MANUAL to manually select which libraries are used and which not
15 # IM_ENABLE to programmatically select which libraries are used
17 # IM_NOLOG if true logging will not be compiled into the module
18 # IM_DEBUG_MALLOC if true malloc debbuging will be compiled into the module
19 # do not use IM_DEBUG_MALLOC in production - this slows
20 # everything down by alot
21 # IM_CFLAGS Extra flags to pass to the compiler
22 # IM_LFLAGS Extra flags to pass to the linker
23 # IM_DFLAGS Extra flags to pass to the preprocessor
24 # IM_SUPPRESS_PROMPT Suppress the prompt asking about gif support
27 getenv(); # get environment variables
28 init(); # initialize global data
29 pathcheck(); # Check if directories exist
31 # Pick what libraries are used
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};
44 # Make sure there isn't a clash between the gif libraries.
47 for $frm(values %formats) {
48 $F_DEFINE .= ' -D'.$frm->{def};
49 $F_LIBS .= ' ' .$frm->{libfiles};
50 $F_OBJECT .= ' ' .$frm->{objfiles};
53 $F_INC = join(" ",map { (exists $definc{$_})?'':'-I'.$_ } @incs);
54 $F_LIBS = join(" ",map { '-L'.$_ } @libs).' '.$F_LIBS;
59 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
60 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
62 @objs = qw(Imager.o draw.o polygon.o image.o io.o iolayer.o
63 log.o gaussian.o conv.o pnm.o raw.o feat.o font.o
64 filters.o dynaload.o stackmach.o datatypes.o
65 regmach.o trans2.o quant.o error.o convert.o
66 map.o tags.o palimg.o maskimg.o img16.o rotate.o
67 bmp.o tga.o rgb.o color.o fills.o imgdouble.o);
71 'VERSION_FROM' => 'Imager.pm',
72 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS",
73 'DEFINE' => "$F_DEFINE $EXTDEF $OSDEF $CFLAGS",
74 'INC' => "$DFLAGS $F_INC",
75 'OBJECT' => join(' ', @objs, $F_OBJECT),
76 clean => { FILES=>'testout' },
80 $opts{AUTHOR} = 'Arnar M. Hrafnkelsson, addi@umich.edu';
81 $opts{ABSTRACT} = 'Perl extension for Generating 24 bit Images';
84 if ($VERBOSE) { print Dumper(\%opts); }
85 mkdir('testout',0777); # since we cannot include it in the archive.
93 dyntest.$(MYEXTLIB) : dynfilt/Makefile
94 cd dynfilt && $(MAKE) $(PASTHRU)
96 lib/Imager/Regops.pm : regmach.h regops.perl
97 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
101 # manual configuration of helper libraries
106 Please answer the following questions about
107 which formats are avaliable on your computer
109 press <return> to continue
112 <STDIN>; # eat one return
114 for $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
116 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
117 print "Enable $frm support: ";
120 if ($gz =~ m/^(y|yes|n|no)/i) {
121 $gz=substr(lc($gz),0,1);
123 delete $formats{$frm};
130 # automatic configuration of helper libraries
133 for $frm(keys %formats) {
134 delete $formats{$frm} if !checkformat($frm);
140 if ($formats{'gif'} and $formats{'ungif'}) {
141 print "ungif and gif can not coexist - removing ungif support\n";
142 delete $formats{'ungif'};
146 if (($formats{'gif'} or $formats{'ungif'}) && !$ENV{IM_SUPPRESS_PROMPT}) {
149 You have libgif or libungif installed. They are both known to have
150 bugs. Imager can crash or display other strange behaviour after
151 reading or writing gif images. Some of the gif tests can even fail
152 since they stress some parts of the buggy code.
154 Do you want to remove gif support? [Y/n]
159 delete $formats{'gif'};
160 delete $formats{'ungif'};
165 for my $frm (qw(gif ungif)) {
166 checkformat($frm) if ($MANUAL and $formats{$frm});
170 for my $frm (grep $formats{$_}, qw(gif ungif)) {
171 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
175 FILES: for my $dir (@dirs) {
176 my $h = "$dir/gif_lib.h";
177 open H, "< $h" or next;
179 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
189 # we need the version in a #ifdefable form
191 $F_DEFINE .= "-DIM_GIFMAJOR=$major -DIM_GIFMINOR=$minor";
198 # print "checking path $path\n";
199 if ( !opendir(DH,$path) ) {
200 warn "Cannot open dir $path: $!\n";
203 my @l=grep { $chk->($_) } readdir(DH);
206 return map $path, @l;
212 my $libchk=$formats{$frm}{'libcheck'};
213 my $incchk=$formats{$frm}{'inccheck'};
217 push(@l, gd($lp,$libchk));
222 push(@i, gd($ip,$incchk));
225 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
226 $formats{$frm}{incdir} = \@i;
227 $formats{$frm}{libdir} = \@l;
228 return scalar(@i && @l);
237 print " Include paths:\n";
238 for (@incs) { print $_,"\n"; }
240 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @incs;
243 print "\nLibrary paths:\n";
244 for (@incs) { print $_,"\n"; }
246 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
251 # Format data initialization
253 # format definition is:
255 # default include path
256 # files needed for include (boolean perl code)
259 # files needed for link (boolean perl code)
260 # object files needed for the format
265 @definc{'/usr/include'}=();
266 @incs=(split(/\Q$Config{path_sep}/, $INCPATH),
267 qw(/sw/include /usr/include/freetype2 /usr/local/include/freetype2
268 /usr/include /usr/local/include /usr/include/freetype
269 /usr/local/include/freetype));
270 @libs=(split(/\Q$Config{path_sep}/,$LIBPATH),
271 qw(/sw/lib), split(/ /, $Config{'libpth'}));
272 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
273 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
274 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
276 if ($^O eq 'cygwin') {
277 push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
278 push(@incs, '/usr/include/w32api') if -d '/usr/lib/w32api';
284 inccheck=>sub { $_[0] eq 'jpeglib.h' },
285 libcheck=>sub { $_[0] eq "libjpeg$aext" or $_ eq "libjpeg.$lext" },
289 In order to use jpeg with this module you need to have libjpeg
290 installed on your computer}
296 inccheck=>sub { $_[0] eq 'tiffio.h' },
297 libcheck=>sub { $_[0] eq "libtiff$aext" or $_ eq "libtiff.$lext" },
301 In order to use tiff with this module you need to have libtiff
302 installed on your computer}
308 inccheck=>sub { $_[0] eq 'png.h' },
309 libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
310 libfiles=>'-lpng -lz',
313 Png stands for Portable Network Graphics and is intended as
314 a replacement for gif on the web. It is patent free and
315 is recommended by the w3c, you need libpng to use these formats}
321 inccheck=>sub { $_[0] eq 'gif_lib.h' },
322 libcheck=>sub { $_[0] eq "libgif$aext" or $_[0] eq "libgif.$lext" },
326 gif is the de facto standard for webgraphics at the moment,
327 it does have some patent problems. If you have giflib and
328 are not in violation with the unisys patent you should use
329 this instead of the 'ungif' option. Note that they cannot
330 be in use at the same time}
336 inccheck=>sub { $_[0] eq 'gif_lib.h' },
337 libcheck=>sub { $_[0] eq "libungif$aext" or $_[0] eq "libungif.$lext" },
341 gif is the de facto standard for webgraphics at the moment,
342 it does have some patent problems. If you have libungif and
343 want to create images free from LZW patented compression you
344 should use this option instead of the 'gif' option}
347 $formats{'T1-fonts'}={
350 inccheck=>sub { $_[0] eq 't1lib.h' },
351 libcheck=>sub { $_[0] eq "libt1$aext" or $_[0] eq "libt1.$lext" },
355 postscript t1 fonts are scalable fonts. They can include
356 ligatures and kerning information and generally yield good
357 visual quality. We depend on libt1 to rasterize the fonts
361 $formats{'TT-fonts'}={
364 inccheck=>sub { $_[0] eq 'freetype.h' },
365 libcheck=>sub { $_[0] eq "libttf$aext" or $_[0] eq "libttf.$lext" },
369 Truetype fonts are scalable fonts. They can include
370 kerning and hinting information and generally yield good
371 visual quality esp on low resultions. The freetype library is
372 used to rasterize for us. The only drawback is that there
373 are alot of badly designed fonts out there.}
378 inccheck=>sub { lc $_[0] eq 'windows.h' },
379 libcheck=>sub { lc $_[0] eq 'gdi32.lib'
380 || lc $_[0] eq 'libgdi32.a' },
381 libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
384 Uses the Win32 GDI for rendering text.
386 This currently only works on under normal Win32 and cygwin.
389 $formats{'freetype2'} = {
392 inccheck=>sub { lc $_[0] eq 'ft2build.h' },
393 libcheck=>sub { $_[0] eq "libfreetype$aext" or $_[0] eq "libfreetype.$lext" },
394 libfiles=>'-lfreetype',
395 objfiles=>'freetyp2.o',
397 Freetype 2 supports both Truetype and Type 1 fonts, both of which are
402 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
409 defined($V) ? $V : "";
413 # Get information from environment variables
425 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
435 if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
437 if ($NOLOG) { print "Logging not compiled into module\n"; }
438 else { $EXTDEF.=' -DIMAGER_LOG'; }
441 $EXTDEF.=' -DIMAGER_DEBUG_MALLOC';
442 print "Malloc debugging enabled\n";