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
|
#!/usr/bin/perl
use strict;
sub version4cpan {
my $configure_in = "../configure.in";
$configure_in = $ARGV[0] if ($ARGV[0]);
open(FD, "<$configure_in") or die "Could not open file $configure_in";
my ($major, $minor, $patchlevel);
while (<FD>) {
if ($_ =~ /(MAJOR_VERSION)[ =][0-9]+/)
{
(undef, $major) = split(/[ =]+/, $_);
chomp $major;
}
elsif ($_ =~ /(MINOR_VERSION)[ =][0-9]+/)
{
(undef, $minor) = split(/[ =]+/, $_);
chomp $minor;
}
elsif ($_ =~ /(PATCHLEVEL)[ =][0-9]+/)
{
(undef, $patchlevel) = split(/[ =]+/ ,$_);
chomp $patchlevel;
}
}
close (FD);
return "$major.$minor$patchlevel";
}
sub filesubst {
my ($fileIn, $fileOut, $key, $val) = @_;
open(FDIN, "<$fileIn") or die "Could not open input file $fileIn";
open(FDOUT, ">$fileOut") or die "Could not open output file $fileOut";
while (<FDIN>) {
if (/$key/) {
s/$key/$val/g;
}
print FDOUT $_;
}
close(FDIN);
close(FDOUT);
}
my $version = version4cpan;
print "VERSION $version\n";
my $EXPORT_DIR="../export2cpan";
if (! -d $EXPORT_DIR) {
mkdir $EXPORT_DIR;
}
my $VERSION_DIR="$EXPORT_DIR/tk-zinc-$version";
if (! -d $VERSION_DIR) {
mkdir $VERSION_DIR;
}
else {
system "rm -rf $VERSION_DIR";
mkdir $VERSION_DIR;
}
my @files=('t', 'Zinc.xs', 'trace', 'demos',
'Zinc', 'ZincTrace');
foreach my $f (@files) {
system "cp -r $f $VERSION_DIR";
}
filesubst('Zinc.pm', "$VERSION_DIR/Zinc.pm", 'CONF_VERS', $version);
filesubst('Makefile.PL', "$VERSION_DIR/Makefile.PL", 'CONF_VERS', $version);
#system "echo $version > $VERSION_DIR/VERSION";
system "cp ../libtess/*.c $VERSION_DIR";
system "cp ../libtess/*.h $VERSION_DIR";
system "cp ../generic/*.c $VERSION_DIR";
system "cp ../generic/*.h $VERSION_DIR";
system "cp ../win/*.c $VERSION_DIR";
|