Permalink
Browse files

- Makefile.PL now accepts command-line options to set include and lib…

…rary

  directories and to enable/disable drivers.
  • Loading branch information...
1 parent f8e9bc0 commit 37959076332dfe2b845746eddbbb43e260a57fa0 Tony Cook committed Jan 24, 2005
Showing with 59 additions and 13 deletions.
  1. +2 −0 Changes
  2. +57 −13 Makefile.PL
View
@@ -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.
=================================================================
View
@@ -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,24 +22,55 @@ 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
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;
+
+}

0 comments on commit 3795907

Please sign in to comment.