aboutsummaryrefslogtreecommitdiff
path: root/Perl/Makefile.PL
blob: 699b594a34b7faf472d4f40066558e0c1250fc0d (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use 5.006;
use Tk;
use Tk::Config;
use ExtUtils::MakeMaker;
use strict;

my $TkLibDir = $Tk::library;
my $platform = $Tk::platform;

my $VERSION = CONF_VERS;


if (!$TkLibDir)
{
    print stderr "==================================================================\n";
    print stderr "Could not find the Perl/Tk (pTk) library.\n";
    print stderr "Please, install first Perl/Tk interface before installing Tk::Zinc\n";
    print stderr "==================================================================\n";
    die;
}


print "Configuring version $VERSION for $platform platform...\n";
print "Using $TkLibDir as Tk library...\n";

my @GENERIC_C = ('Track.c', 'Tabular.c', 'Reticle.c', 'Map.c', 'Rectangle.c', 'Arc.c', 'Curve.c',
		 'Item.c', 'PostScript.c', 'MapInfo.c', 'Attrs.c', 'Draw.c', 'Geo.c', 'List.c',
		 'perfos.c', 'Transfo.c', 'Group.c', 'Icon.c', 'Text.c', 'Image.c', 'Color.c',
		 'Field.c', 'Triangles.c', 'Window.c', 'tkZinc.c', 'Zinc.c');

my @LIBTESS_C = ('dict.c', 'geom.c', 'memalloc.c', 'mesh.c', 'normal.c', 'priorityq.c',
		 'render.c', 'sweep.c', 'tess.c', 'tessmono.c');

my @OM_C = ('OverlapMan.c');

my @WIN_C = ('WinPort.c');

my @C;

push @C, @LIBTESS_C, @GENERIC_C ;

if ($platform =~ /win/i)
{
    push @C, @WIN_C;
}

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
	      'AUTHOR'          => 'Patrick Lecoanet <lecoanet@cena.fr>',
	      'NAME'		=> 'Tk::Zinc',
	      'VERSION'	        => $VERSION,
	      'PREREQ_PM'	=> {Tk => 8.0},
	      'LIBS'		=> ['-L/usr/X11R6/lib -lXext -lX11 -lGL -lpthread -L.'], 
	      'DEFINE'		=> &get_flags,
	      'INC'		=> "-I. -I$TkLibDir -I$TkLibDir/pTk",
	      'C'               => [@C],
	      'XS_VERSION'      => $Tk::Config::VERSION,
	      'XS'              => {'Zinc.sx' => 'Zinc.c'},
	      'linkext'         => {LINKTYPE => 'dynamic'},
	      'depend'          => {'Zinc.o' => '$(O_FILES) Zinc.o'},
	      'LDFROM' => '$(O_FILES)',
	      );

sub get_flags
{
    my %DEF_FLAGS = ('GL'        => 1,
		     'SHAPE'     => 1,
		     'GL_DAMAGE' => 1,
		     'OM'        => 1
		     );
    
    foreach my $arg (@ARGV)
    {
	print "$arg ....\n";
	my ($name, $value) = split(/[=]+/, $arg);
	if ($name =~ /(with-gl)/i)
	{
	    if ($value =~ /no/i)
	    {
		$DEF_FLAGS{'GL'} = 0;
		$DEF_FLAGS{'GL_DAMAGE'} = 0;
	    }
	}
	elsif ($name =~ /(with-om)/i)
	{
	    if ($value =~ /no/i)
	    {
		$DEF_FLAGS{'OM'} = 0;
	    }
	}
	elsif ($name =~ /(with-shape)/i)
	{
	    if ($value =~ /no/i)
	    {
		$DEF_FLAGS{'SHAPE'} = 0;
	    }
	}
    }
    
    my $defines = '-DPTK';
    print "Configuring with:\n    ";
    foreach my $flag (keys %DEF_FLAGS)
    {
	print "$flag=$DEF_FLAGS{$flag} ";
	if ($DEF_FLAGS{$flag})
	{
	    $defines = $defines . " " . "-D$flag";
	    if ($flag eq 'OM') {
		push @C, @OM_C
	    }
	}
    }
    print "\n";
    return $defines;
}