aboutsummaryrefslogtreecommitdiff
path: root/Makefile.PL
blob: bebc2067079f61508194e5347e3093d97aab4fe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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);