]> git.imager.perl.org - imager.git/blobdiff - Makefile.PL
- start of external Imager API access:
[imager.git] / Makefile.PL
index 0262e44b2196e764e91657dff6623d69a40503ce..e1334f0fab0b8ccc08f9b06a4f4a8c7b997e5e4b 100644 (file)
@@ -4,6 +4,9 @@ use Cwd;
 use Config;
 use File::Spec;
 use Getopt::Long;
+use vars qw(%Recommends);
+require "metafile.pl";
+use ExtUtils::Manifest qw(maniread);
 
 #
 # IM_INCPATH      colon seperated list of paths to extra include paths
@@ -22,29 +25,52 @@ use Getopt::Long;
 # IM_DFLAGS       Extra flags to pass to the preprocessor
 # IM_SUPPRESS_PROMPT  Suppress the prompt asking about gif support
 
+getenv();     # get environment variables
+
 my $help;
 my @enable;
 my @disable;
 my @incpaths;
 my @libpaths;
 my $noprobe;
+my $noexif;
 GetOptions("help" => \$help,
            "enable=s" => \@enable,
            "disable=s" => \@disable,
            "incpath=s", \@incpaths,
            "libpath=s" => \@libpaths,
-           "noprobe" => \$noprobe);
+           "noprobe" => \$noprobe,
+           "verbose|v" => \$VERBOSE,
+           "nolog" => \$NOLOG,
+          "noexif" => \$noexif);
+
+if ($VERBOSE) { 
+  print "Verbose mode\n"; 
+  require Data::Dumper; 
+  import Data::Dumper qw(Dumper);
+}
 
 if ($help) {
   usage();
 }
 
+my @defines;
+
+if ($NOLOG)   { print "Logging not compiled into module\n"; }
+else { 
+  push @defines, [ IMAGER_LOG => 1, "Logging system" ];
+}
+
+if ($DEBUG_MALLOC) {
+  push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
+  print "Malloc debugging enabled\n";
+}
+
 if (@enable && @disable) {
   print STDERR "Only --enable or --disable can be used, not both, try --help\n";
   exit 1;
 }
 
-getenv();     # get environment variables
 init();       # initialize global data
 pathcheck();  # Check if directories exist
 
@@ -64,8 +90,6 @@ elsif (@disable) {
   delete @formats{map { split /,/ } @disable};
 }
 
-my @defines;
-
 # Pick what libraries are used
 if ($MANUAL) {
   manual();
@@ -86,6 +110,11 @@ for my $frmkey (keys %formats) {
   $F_OBJECT .= ' '  .$frm->{objfiles};
   $lib_cflags   .= ' '  .$frm->{cflags} if $frm->{cflags};
 }
+unless ($noexif) {
+  print "EXIF support enabled\n";
+  push @defines, [ 'IMEXIF_ENABLE', 1, "Enable experimental EXIF support" ];
+  $F_OBJECT .= ' imexif.o';
+}
 
 $F_INC  = join ' ', map "-I$_", map / / ? qq{"$_"} : $_, 
   grep !exists $definc{$_}, @incs;
@@ -102,7 +131,11 @@ if (defined $Config{'d_dlsymun'}) { $OSDEF  .= ' -DDLSYMUN'; }
           filters.o dynaload.o stackmach.o datatypes.o
           regmach.o trans2.o quant.o error.o convert.o
           map.o tags.o palimg.o maskimg.o img16.o rotate.o
-           bmp.o tga.o rgb.o color.o fills.o imgdouble.o limits.o);
+           bmp.o tga.o rgb.o color.o fills.o imgdouble.o limits.o hlines.o
+           imext.o);
+
+$Recommends{Imager} =
+  { 'Parse::RecDescent' => 0 };
 
 %opts=(
        'NAME'         => 'Imager',
@@ -112,6 +145,7 @@ if (defined $Config{'d_dlsymun'}) { $OSDEF  .= ' -DDLSYMUN'; }
        'INC'          => "$lib_cflags $DFLAGS $F_INC",
        'OBJECT'       => join(' ', @objs, $F_OBJECT),
        clean          => { FILES=>'testout meta.tmp' },
+       PM             => gen_PM(),
       );
 
 if ($ExtUtils::MakeMaker::VERSION > 6.06) {
@@ -136,36 +170,16 @@ dyntest.$(MYEXTLIB) : dynfilt/Makefile
 lib/Imager/Regops.pm : regmach.h regops.perl
        $(PERL) regops.perl regmach.h lib/Imager/Regops.pm
 
-imconfig.h: Makefile.PL
+imconfig.h : Makefile.PL
        $(ECHO) "imconfig.h out-of-date with respect to $?"
        $(PERLRUN) Makefile.PL
        $(ECHO) "==> Your Makefile has been rebuilt - re-run your make command <=="
+
+lib/Imager/APIRef.pm : $(C_FILES) apidocs.perl
+       $(PERLRUN) apidocs.perl lib/Imager/APIRef.pm
+
 ';
-}
 
-sub MY::metafile {
-  my ($self) = @_;
-
-  my $meta = <<YAML;
---- #YAML:1.0
-name: Imager
-version: $self->{VERSION}
-version_from: $self->{VERSION_FROM}
-author: $self->{AUTHOR}
-abstract: $self->{ABSTRACT}
-installdirs: $self->{INSTALLDIRS}
-recommends:
-  Parse::RecDescent: 0
-license: perl
-dynamic_config: 1
-distribution_type: module
-generated_by: Imager version $self->{VERSION}
-YAML
-  open META, "> meta.tmp" or die "Cannot create meta.tmp: $!";
-  print META $meta;
-  close META;
-  
-  return sprintf "metafile :\n\t\$(CP) meta.tmp META.yml\n";
 }
 
 # manual configuration of helper libraries
@@ -322,7 +336,7 @@ sub pathcheck {
 
   if ($VERBOSE) {
     print "\nLibrary paths:\n";
-    for (@incs) { print $_,"\n"; }
+    for (@libs) { print $_,"\n"; }
   }
   @libs=grep { -d $_ && -r _ && -x _ or ( print("  $_ doesnt exist or is unaccessible - removed.\n"),0) } @libs;
   print "\ndone.\n";
@@ -371,7 +385,7 @@ sub init {
   }
   if ($^O eq 'cygwin') {
     push(@libs, '/usr/lib/w32api') if -d '/usr/lib/w32api';
-    push(@incs, '/usr/include/w32api') if -d '/usr/lib/w32api';
+    push(@incs, '/usr/include/w32api') if -d '/usr/include/w32api';
   }
 
   my $lext=$Config{'so'};   # Get extensions of libraries
@@ -501,6 +515,7 @@ scalable.  It also supports a variety of other fonts.
 DOCS
                            code => \&freetype2_probe,
                           };
+
   # Make fix indent
   for (keys %formats) { $formats{$_}->{docs} =~ s/^\s+/  /mg; }
 }
@@ -535,18 +550,6 @@ sub getenv {
                                IM_LFLAGS
                                IM_DFLAGS);
 
-  if ($VERBOSE) { print "Verbose mode\n"; require Data::Dumper; import Data::Dumper qw(Dumper);}
-
-  if ($NOLOG)   { print "Logging not compiled into module\n"; }
-  else { 
-    push @defines, [ IMAGER_LOG => 1, "Logging system" ];
-  }
-
-  if ($DEBUG_MALLOC) {
-    push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
-    print "Malloc debugging enabled\n";
-  }
-
 }
 
 sub make_imconfig {
@@ -652,12 +655,58 @@ sub is_exe {
 
 sub usage {
   print STDERR <<EOS;
-Usage: $0 [--enable feature1,feature2,...] [--incpath ...] [--libpath ...]
-       $0 [--disable feature1,feature2,...] [--incpath ...] [--libpath ...]
+Usage: $0 [--enable feature1,feature2,...] [other options]
+       $0 [--disable feature1,feature2,...]  [other options]
        $0 --help
 Possible feature names are:
   png gif ungif jpeg tiff T1-fonts TT-fonts freetype2
+Other options:
+  --verbose | -v
+    Verbose library probing (or set IM_VERBOSE in the environment)
+  --nolog
+    Disable logging (or set IM_NOLOG in the environment)
+  --incpath dir
+    Add to the include search path
+  --libpath dir
+    Add to the library search path
+  --noprobe
+    Don't use pkg-config or freetype2-config to probe for freetype2 and libpng
 EOS
   exit 1;
 
 }
+
+# generate the PM MM argument
+# I'd prefer to modify the public version, but there doesn't seem to be 
+# a public API to do that
+sub gen_PM {
+  my %pm;
+  my $instbase = '$(INST_LIBDIR)';
+
+  # first the basics, .pm and .pod files
+  $pm{"Imager.pm"} = "$instbase/Imager.pm";
+
+  my $mani = maniread();
+
+  for my $filename (keys %$mani) {
+    if ($filename =~ m!^lib/! && $filename =~ /\.(pm|pod)$/) {
+      (my $work = $filename) =~ s/^lib//;
+      $pm{$filename} = $instbase . $work;
+    }
+  }
+
+  # need the typemap
+  $pm{typemap} = $instbase . '/Imager/typemap';
+
+  # and the core headers
+  for my $filename (keys %$mani) {
+    if ($filename =~ /^\w+\.h$/) {
+      $pm{$filename} = $instbase . '/Imager/include/' . $filename;
+    }
+  }
+
+  # and the generated header
+  $pm{"imconfig.h"} = $instbase . '/Imager/include/imconfig.h';
+
+  \%pm;
+}