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
26 getenv(); # get environment variables
27 init(); # initialize global data
28 pathcheck(); # Check if directories exist
30 # Pick what libraries are used
35 if (exists $ENV{IM_ENABLE}) {
36 my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
37 for my $key (keys %formats) {
38 delete $formats{$key} unless $en{$key};
43 # Make sure there isn't a clash between the gif libraries.
46 for $frm(values %formats) {
47 $F_DEFINE .= ' -D'.$frm->{def};
48 $F_LIBS .= ' ' .$frm->{libfiles};
49 $F_OBJECT .= ' ' .$frm->{objfiles};
52 $F_INC = join(" ",map { (exists $definc{$_})?'':'-I'.$_ } @incs);
53 $F_LIBS = join(" ",map { '-L'.$_ } @libs).' '.$F_LIBS;
58 if ($^O eq 'hpux') { $OSLIBS .= ' -ldld'; }
59 if (defined $Config{'d_dlsymun'}) { $OSDEF .= ' -DDLSYMUN'; }
61 @objs = qw(Imager.o draw.o image.o io.o iolayer.o log.o
62 gaussian.o conv.o pnm.o raw.o feat.o font.o
63 filters.o dynaload.o stackmach.o datatypes.o
64 regmach.o trans2.o quant.o);
68 'VERSION_FROM' => 'Imager.pm',
69 'LIBS' => "$LFLAGS -lm $OSLIBS $F_LIBS",
70 'DEFINE' => "$F_DEFINE $EXTDEF $OSDEF $CFLAGS",
71 'INC' => "$DFLAGS $F_INC",
72 'OBJECT' => join(' ', @objs, $F_OBJECT)
75 if ($VERBOSE) { print Dumper(\%opts); }
76 mkdir('testout',0777); # since we cannot include it in the archive.
83 dyntest.(MYEXTLIB) : dynfilt/Makefile
84 cd dynfilt && $(MAKE) $(PASTHRU)
86 lib/Imager/Regops.pm : regmach.h regops.perl
87 $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
91 # manual configuration of helper libraries
96 Please answer the following questions about
97 which formats are avaliable on your computer
99 press <return> to continue
102 <STDIN>; # eat one return
104 for $frm(sort { $formats{$b}{order} <=> $formats{$a}{order} } keys %formats) {
106 if ($formats{$frm}{docs}) { print "\n",$formats{$frm}{docs},"\n\n"; }
107 print "Enable $frm support: ";
110 if ($gz =~ m/^(y|yes|n|no)/i) {
111 $gz=substr(lc($gz),0,1);
113 delete $formats{$frm};
120 # automatic configuration of helper libraries
123 for $frm(keys %formats) {
124 delete $formats{$frm} if !checkformat($frm);
130 if ($formats{'gif'} and $formats{'ungif'}) {
131 print "ungif and gif can not coexist - removing ungif support\n";
132 delete $formats{'ungif'};
135 for my $frm (grep $formats{$_}, qw(gif ungif)) {
136 push(@dirs, @{$formats{$frm}{incdir}}) if $formats{$frm}{incdir};
140 FILES: for my $dir (@dirs) {
141 my $h = "$dir/gif_lib.h";
142 open H, "< $h" or next;
144 if (/GIF_LIB_VERSION\s+"\s*version\s*(\d+)\.(\d+)/i) {
154 # we need the version in a #ifdefable form
156 $F_DEFINE .= "-DIM_GIFMAJOR=$major -DIM_GIFMINOR=$minor";
163 # print "checking path $path\n";
164 if ( !opendir(DH,$path) ) {
165 warn "Cannot open dir $path: $!\n";
168 my @l=grep { $chk->($_) } readdir(DH);
171 return map $path, @l;
177 my $libchk=$formats{$frm}{'libcheck'};
178 my $incchk=$formats{$frm}{'inccheck'};
182 push(@l, gd($lp,$libchk));
187 push(@i, gd($ip,$incchk));
190 printf("%10s: includes %s - libraries %s\n",$frm,(@i?'found':'not found'),(@l?'found':'not found'));
191 $formats{$frm}{incdir} = \@i;
192 $formats{$frm}{libdir} = \@l;
193 return scalar(@i && @l);
202 print " Include paths:\n";
203 for (@incs) { print $_,"\n"; }
205 @incs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed."),0) } @incs;
208 print "\nLibrary paths:\n";
209 for (@incs) { print $_,"\n"; }
211 @libs=grep { -d $_ && -r _ && -x _ or ( print(" $_ doesnt exist or is unaccessible - removed."),0) } @libs;
216 # Format data initialization
218 # format definition is:
220 # default include path
221 # files needed for include (boolean perl code)
224 # files needed for link (boolean perl code)
225 # object files needed for the format
230 @definc{'/usr/include'}=();
231 @incs=(qw(/usr/include /usr/local/include /usr/include/freetype /usr/local/include/freetype), split /:/, $INCPATH );
232 @libs=(split(/ /, $Config{'libpth'}), split(/:/, $LIBPATH) );
233 if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
234 push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
235 push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
241 inccheck=>sub { $_[0] eq 'jpeglib.h' },
242 libcheck=>sub { $_[0] eq 'libjpeg.a' or $_ eq "libjpeg.$lext" },
246 In order to use jpeg with this module you need to have libjpeg
247 installed on your computer}
253 inccheck=>sub { $_[0] eq 'tiffio.h' },
254 libcheck=>sub { $_[0] eq 'libtiff.a' or $_ eq "libtiff.$lext" },
258 In order to use tiff with this module you need to have libtiff
259 installed on your computer}
265 inccheck=>sub { $_[0] eq 'png.h' },
266 libcheck=>sub { $_[0] eq "libpng$aext" or $_[0] eq "libpng.$lext" },
267 libfiles=>'-lpng -lz',
270 Png stands for Portable Network Graphics and is intended as
271 a replacement for gif on the web. It is patent free and
272 is recommended by the w3c, you need libpng to use these formats}
278 inccheck=>sub { $_[0] eq 'gif_lib.h' },
279 libcheck=>sub { $_[0] eq 'libgif.a' or $_[0] eq "libgif.$lext" },
283 gif is the de facto standard for webgraphics at the moment,
284 it does have some patent problems. If you have giflib and
285 are not in violation with the unisys patent you should use
286 this instead of the 'ungif' option. Note that they cannot
287 be in use at the same time}
293 inccheck=>sub { $_[0] eq 'gif_lib.h' },
294 libcheck=>sub { $_[0] eq 'libungif.a' or $_[0] eq "libungif.$lext" },
298 gif is the de facto standard for webgraphics at the moment,
299 it does have some patent problems. If you have libungif and
300 want to create images free from LZW patented compression you
301 should use this option instead of the 'gif' option}
304 $formats{'T1-fonts'}={
307 inccheck=>sub { $_[0] eq 't1lib.h' },
308 libcheck=>sub { $_[0] eq 'libt1.a' or $_[0] eq "libt1.$lext" },
312 postscript t1 fonts are scalable fonts. They can include
313 ligatures and kerning information and generally yield good
314 visual quality. We depend on libt1 to rasterize the fonts
318 $formats{'TT-fonts'}={
321 inccheck=>sub { $_[0] eq 'freetype.h' },
322 libcheck=>sub { $_[0] eq 'libttf.a' or $_[0] eq "libttf.$lext" },
326 Truetype fonts are scalable fonts. They can include
327 kerning and hinting information and generally yield good
328 visual quality esp on low resultions. The freetype library is
329 used to rasterize for us. The only drawback is that there
330 are alot of badly designed fonts out there.}
333 for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/ /mg; }
340 defined($V) ? $V : "";
344 # Get information from environment variables
356 $DFLAGS) = map { gen $_ } qw(IM_VERBOSE
366 if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
368 if ($NOLOG) { print "Logging not compiled into module\n"; }
369 else { $EXTDEF.=' -DIMAGER_LOG'; }
372 $EXTDEF.=' -DIMAGER_DEBUG_MALLOC';
373 print "Malloc debugging enabled\n";