]> git.imager.perl.org - imager.git/commitdiff
- Makefile.PL now accepts command-line options to set include and library
authorTony Cook <tony@develop=help.com>
Mon, 24 Jan 2005 10:26:25 +0000 (10:26 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 24 Jan 2005 10:26:25 +0000 (10:26 +0000)
  directories and to enable/disable drivers.

Changes
Makefile.PL

diff --git a/Changes b/Changes
index bd01209effe5ccc146553d3588df9b8c279e7304..b08e2abfcaaa7e22246776e0f39185568d3f7d24 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1000,6 +1000,8 @@ Revision history for Perl extension Imager.
   to consider it a valid FT1.x include directory.  We now check if it
   contains fterrors.h too, if it does, then it's from a FT2 installation
   and we ignore it.
+- Makefile.PL now accepts command-line options to set include and library
+  directories and to enable/disable drivers.
 
 =================================================================
 
index 9300764a93d45655bdcc3bc205b4ffd999ed7312..444842d44254432972805ab0ef20a59697168cf5 100644 (file)
@@ -3,6 +3,7 @@ use ExtUtils::MakeMaker;
 use Cwd;
 use Config;
 use File::Spec;
+use Getopt::Long;
 
 #
 # IM_INCPATH      colon seperated list of paths to extra include paths
@@ -21,11 +22,48 @@ use File::Spec;
 # IM_DFLAGS       Extra flags to pass to the preprocessor
 # IM_SUPPRESS_PROMPT  Suppress the prompt asking about gif support
 
+my $help;
+my @enable;
+my @disable;
+my @incpaths;
+my @libpaths;
+my $noprobe;
+GetOptions("help" => \$help,
+           "enable=s" => \@enable,
+           "disable=s" => \@disable,
+           "incpath=s", \@incpaths,
+           "libpath=s" => \@libpaths,
+           "noprobe" => \$noprobe);
+
+if ($help) {
+  usage();
+}
+
+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
 
+if (exists $ENV{IM_ENABLE}) {
+  my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
+  for my $key (keys %formats) {
+    delete $formats{$key} unless $en{$key};
+  }
+}
+if (@enable) {
+  my %en = map { $_ => 1 } map { split /,/ } @enable;
+  for my $key (keys %formats) {
+    delete $formats{$key} unless $en{$key};
+  }
+}
+elsif (@disable) {
+  delete @formats{map { split /,/ } @disable};
+}
+
 my @defines;
 
 # Pick what libraries are used
@@ -33,12 +71,6 @@ if ($MANUAL) {
   manual();
 } else {
   automatic();
-  if (exists $ENV{IM_ENABLE}) {
-    my %en = map { $_, 1 } split ' ', $ENV{IM_ENABLE};
-    for my $key (keys %formats) {
-      delete $formats{$key} unless $en{$key};
-    }
-  }
 }
 
 # Make sure there isn't a clash between the gif libraries.
@@ -230,9 +262,9 @@ sub gd {
 
 sub checkformat {
   my $frm=shift;
-
+  
   my $code = $formats{$frm}{'code'};
-  if ($code) {
+  if ($code && !$noprobe) {
     return 1 if $code->($formats{$frm}, $frm);
   }
 
@@ -256,8 +288,6 @@ sub checkformat {
 }
 
 
-
-
 sub pathcheck {
   if ($VERBOSE) {
     print "pathcheck\n";
@@ -290,7 +320,8 @@ sub pathcheck {
 sub init {
 
   @definc{'/usr/include'}=();
-  @incs=(split(/\Q$Config{path_sep}/, $INCPATH));
+  @incs=(split(/\Q$Config{path_sep}/, $INCPATH),
+        map { split /\Q$Config{path_sep}/} @incpaths );
   if ($Config{locincpth}) {
     push @incs, grep -d, split ' ', $Config{locincpth};
   }
@@ -302,10 +333,11 @@ sub init {
          /usr/include/freetype2
          /usr/local/include/freetype2
          /usr/local/include/freetype1/freetype
-         /usr/include /usr/local/include /usr/include/freetype 
+         /usr/include /usr/local/include /usr/include/freetype
          /usr/local/include/freetype);
 
-  @libs= split(/\Q$Config{path_sep}/,$LIBPATH);
+  @libs= ( split(/\Q$Config{path_sep}/,$LIBPATH),
+    map { split /\Q$Config{path_sep}/} @libpaths );
   if ($Config{loclibpth}) {
     push @libs, grep -d, split ' ', $Config{loclibpth};
   }
@@ -580,3 +612,15 @@ sub is_exe {
 
   return;
 }
+
+sub usage {
+  print STDERR <<EOS;
+Usage: $0 [--enable feature1,feature2,...] [--incpath ...] [--libpath ...]
+       $0 [--disable feature1,feature2,...] [--incpath ...] [--libpath ...]
+       $0 --help
+Possible feature names are:
+  png gif ungif jpeg tiff T1-fonts TT-fonts freetype2
+EOS
+  exit 1;
+
+}