2 use ExtUtils::MakeMaker;
6 $lext=$Config{'so'}; # Get extensions of libraries
9 # IM_INCPATH colon seperated list of paths to extra include paths
10 # IM_LIBPATH colon seperated list of paths to extra library paths
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
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
25 getenv(); # get environment variables
26 init(); # initialize global data
27 pathcheck(); # Check if directories exist
29 # Pick what libraries are used
34 if (exists $ENV{IM_ENABLE}) {
35 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
36 for my $key (keys %formats) {
37 delete $formats{$key} unless $en{$key};
42 # Make sure there isn't a clash between the gif libraries.
45 for $frm(values %formats) {
46 $F_DEFINE .= ' -D'.$frm->{def};
47 $F_LIBS .= ' ' .$frm->{libfiles};
48 $F_OBJECT .= ' ' .$frm->{objfiles};
51 $F_INC = join(" ",map { (exists $definc{$_})?'':'-I'.$_ } @incs);
52 $F_LIBS = join(" ",map { '-L'.$_ } @libs).' '.$F_LIBS;
57 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
58 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
60 @objs = qw(Imager.o draw.o image.o io.o iolayer.o log.o
61 gaussian.o conv.o pnm.o raw.o feat.o font.o
62 filters.o dynaload.o stackmach.o datatypes.o
63 regmach.o trans2.o quant.o);
67 'VERSION_FROM' => 'Imager.pm',
68 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS",
69 'DEFINE' => "$F_DEFINE $EXTDEF $OSDEF $CFLAGS",
70 'INC' => "$DFLAGS $F_INC",
71 'OBJECT' => join(' ', @objs, $F_OBJECT)
74 if ($VERBOSE) { print Dumper(\%opts); }
75 mkdir('testout',0777); # since we cannot include it in the archive.
82 dyntest.(MYEXTLIB) : dynfilt/Makefile
83 cd dynfilt && $(MAKE) $(PASTHRU)
85 lib/Imager/Regops.pm : regmach.h regops.perl
86 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
90 # manual configuration of helper libraries
95 Please answer the following questions about
96 which formats are avaliable on your computer
98 press <return> to continue
101 <STDIN>; # eat one return
103 for $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
105 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
106 print "Enable $frm support: ";
109 if ($gz =~ m/^(y|yes|n|no)/i) {
110 $gz=substr(lc($gz),0,1);
112 delete $formats{$frm};
119 # automatic configuration of helper libraries
122 for $frm(keys %formats) {
123 delete $formats{$frm} if !checkformat($frm);
129 if ($formats{'gif'} and $formats{'ungif'}) {
130 print "ungif and gif can not coexist - removing ungif support\n";
131 delete $formats{'ungif'};
134 for my $frm (grep $formats{$_}, qw(gif ungif)) {
135 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
139 FILES: for my $dir (@dirs) {
140 my $h = "$dir/gif_lib.h";
141 open H, "< $h" or next;
143 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
153 # we need the version in a #ifdefable form
155 $F_DEFINE .= "-DIM_GIFMAJOR=$major -DIM_GIFMINOR=$minor";
162 # print "checking path $path\n";
163 if ( !opendir(DH,$path) ) {
164 warn "Cannot open dir $path: $!\n";
167 my @l=grep { $chk->($_) } readdir(DH);
170 return map $path, @l;
176 my $libchk=$formats{$frm}{'libcheck'};
177 my $incchk=$formats{$frm}{'inccheck'};
181 push(@l, gd($lp,$libchk));
186 push(@i, gd($ip,$incchk));
189 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
190 $formats{$frm}{incdir} = \@i;
191 $formats{$frm}{libdir} = \@l;
192 return scalar(@i && @l);
201 print " Include paths:\n";
202 for (@incs) { print $_,"\n"; }
204 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed."),0) } @incs;
207 print "\nLibrary paths:\n";
208 for (@incs) { print $_,"\n"; }
210 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed."),0) } @libs;
215 # Format data initialization
217 # format definition is:
219 # default include path
220 # files needed for include (boolean perl code)
223 # files needed for link (boolean perl code)
224 # object files needed for the format
229 @definc{'/usr/include'}=();
230 @incs=(qw(/usr/include /usr/local/include /usr/include/freetype /usr/local/include/freetype), split /:/, $INCPATH );
231 @libs=(split(/ /, $Config{'libpth'}), split(/:/, $LIBPATH) );
236 inccheck=>sub { $_[0] eq 'jpeglib.h' },
237 libcheck=>sub { $_[0] eq 'libjpeg.a' or $_ eq "libjpeg.$lext" },
241 In order to use jpeg with this module you need to have libjpeg
242 installed on your computer}
248 inccheck=>sub { $_[0] eq 'tiffio.h' },
249 libcheck=>sub { $_[0] eq 'libtiff.a' or $_ eq "libtiff.$lext" },
253 In order to use tiff with this module you need to have libtiff
254 installed on your computer}
260 inccheck=>sub { $_[0] eq 'png.h' },
261 libcheck=>sub { $_[0] eq 'libpng.a' or $_[0] eq "libpng.$lext" },
262 libfiles=>'-lpng -lz',
265 Png stands for Portable Network Graphics and is intended as
266 a replacement for gif on the web. It is patent free and
267 is recommended by the w3c, you need libpng to use these formats}
273 inccheck=>sub { $_[0] eq 'gif_lib.h' },
274 libcheck=>sub { $_[0] eq 'libgif.a' or $_[0] eq "libgif.$lext" },
278 gif is the de facto standard for webgraphics at the moment,
279 it does have some patent problems. If you have giflib and
280 are not in violation with the unisys patent you should use
281 this instead of the 'ungif' option. Note that they cannot
282 be in use at the same time}
288 inccheck=>sub { $_[0] eq 'gif_lib.h' },
289 libcheck=>sub { $_[0] eq 'libungif.a' or $_[0] eq "libungif.$lext" },
293 gif is the de facto standard for webgraphics at the moment,
294 it does have some patent problems. If you have libungif and
295 want to create images free from LZW patented compression you
296 should use this option instead of the 'gif' option}
299 $formats{'T1-fonts'}={
302 inccheck=>sub { $_[0] eq 't1lib.h' },
303 libcheck=>sub { $_[0] eq 'libt1.a' or $_[0] eq "libt1.$lext" },
307 postscript t1 fonts are scalable fonts. They can include
308 ligatures and kerning information and generally yield good
309 visual quality. We depend on libt1 to rasterize the fonts
313 $formats{'TT-fonts'}={
316 inccheck=>sub { $_[0] eq 'freetype.h' },
317 libcheck=>sub { $_[0] eq 'libttf.a' or $_[0] eq "libttf.$lext" },
321 Truetype fonts are scalable fonts. They can include
322 kerning and hinting information and generally yield good
323 visual quality esp on low resultions. The freetype library is
324 used to rasterize for us. The only drawback is that there
325 are alot of badly designed fonts out there.}
328 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
335 defined($V) ? $V : "";
339 # Get information from environment variables
351 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
361 if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
363 if ($NOLOG) { print "Logging not compiled into module\n"; }
364 else { $EXTDEF.=' -DIMAGER_LOG'; }
367 $EXTDEF.=' -DIMAGER_DEBUG_MALLOC';
368 print "Malloc debugging enabled\n";