aboutsummaryrefslogtreecommitdiff
path: root/Makefile.PL
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile.PL')
-rw-r--r--Makefile.PL94
1 files changed, 94 insertions, 0 deletions
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..bebc206
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,94 @@
+# this code has been developped by Somanos Sar from CENA
+# $Id$
+
+use 5.00404;
+use Cwd;
+use Config;
+use File::Basename;
+
+
+BEGIN
+{
+ my $IsWin32 = ($^O eq 'MSWin32' || $Config{'ccflags'} =~ /-D_?WIN32_?/);
+}
+
+my %opt = parse_opt();
+
+# Libraries
+my $tkConfig = $opt{'--tkConfig'};
+my $tclConfig = $opt{'--tclConfig'};
+
+$tkConfig = gess_libs('tkConfig.sh') if (!($tkConfig and -d $tkConfig));
+$tclConfig = gess_libs('tclConfig.sh') if (!($tclConfig and -d $tclConfig));
+
+my $gl_lib = gess_libs('libGL.so');
+if ($gl_lib)
+{
+ $gl_lib = 'yes';
+}
+else
+{
+ $gl_lib = 'yes';
+}
+
+# Directories
+my $prefix = $Config{'prefix'};
+$prefix = $opt{'--prefix'} if ($opt{'--prefix'});
+
+
+#############################################
+# SUBROUTINES
+#############################################
+
+# Try to guess which library are to be use for tk and tcl
+sub gess_libs
+{
+ my $lib_name = shift;
+ print "No $lib_name specified!!! Trying to find it by myself (may be long)...\n";
+
+ my @libs = split(/[ \t]+/, $Config{'libpth'});
+ foreach my $lib (@libs)
+ {
+ my @configs = `find /usr/lib -name $lib_name`;
+ if (@configs)
+ {
+ print "Using $configs[0]\n";
+ $configs[0] = dirname($configs[0]);
+ return $configs[0];
+ }
+ }
+ return undef;
+}
+
+# Parse option from command line
+sub parse_opt
+{
+ my $args = join(/_IFS_/, @ARGV);
+ my @tokens = split(/_IFS_/, $args);
+ my %options;
+
+ foreach my $token (@tokens)
+ {
+ my ($key, $value) = split(/[ =]+/, $token);
+ $options{$key} = $value;
+ }
+ return %options;
+}
+
+
+
+#print "$tkConfig $tclConfig $prefix $gl_lib // $opt{'--tkConfig'} $opt{'--tclConfig'}\n";
+
+my @args = ("./configure",
+ "--enable-ptk=yes",
+ "--enable-gl=yes",
+ "--enable-gl=$gl_lib",
+ "--enable-shared=yes",
+ "--with-tk=$tkConfig",
+ "--with-tcl=$tclConfig",
+ "--prefix=$prefix",
+ "INSTALL_PERL=\"yes\""
+ );
+print "\nConfiguring with... ", join (' ', @args), "\n";
+
+system (@args);