-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile.PL
More file actions
249 lines (204 loc) · 6.37 KB
/
Makefile.PL
File metadata and controls
249 lines (204 loc) · 6.37 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
use strict;
use 5.009000; # need Newx in XS
use ExtUtils::MakeMaker;
use Getopt::Std;
use File::Spec;
use Config;
my $DEFAULT_IZ_LIB_DIR = "../izC/lib";
my $DEFAULT_IZ_INC_DIR = "../izC/include";
our $opt_L = $ENV{IZ_LIB_DIR} || $DEFAULT_IZ_LIB_DIR;
our $opt_I = $ENV{IZ_INC_DIR} || $DEFAULT_IZ_INC_DIR;
getopts('L:I:');
#
# determine paths
#
sub get_izlib_name {
my $ext = $Config{'so'};
if ($ext =~ /^dll$/i) { # windows?
return "iz.$ext";
}
return "libiz.$ext";
}
sub show_how_to_path_set {
print "*** iZ-C not found. ***\n";
my $libname = get_izlib_name;
print "iz.h and $libname are needed to build this module.\n";
print "Specify -I<header_dir> and -L<lib_dir> correctly";
print " or set environ variables IZ_INC_DIR and IZ_LIB_DIR.\n";
print "default:\n";
print " header_dir: $DEFAULT_IZ_INC_DIR\n";
print " lib_dir: $DEFAULT_IZ_LIB_DIR\n";
exit 2;
}
sub get_iz_lib_dir {
my @dirs = ($opt_L,
'/usr/local/lib', '/usr/lib',
"$ENV{HOME}/lib",
"$ENV{HOME}/izC", "$ENV{HOME}/izC/lib");
my $libname = get_izlib_name;
for my $d (@dirs) {
my $libiz = File::Spec->catfile($d, $libname);
if (length($d) > 0 && -d $d && -f $libiz) {
print "library: $libiz\n";
return $d;
}
}
show_how_to_path_set;
}
sub get_iz_inc_dir {
my @dirs = ($opt_I,
'/usr/local/include', '/usr/include',
"$ENV{HOME}/include",
"$ENV{HOME}/izC", "$ENV{HOME}/izC/include");
for my $d (@dirs) {
my $izh = File::Spec->catfile($d, "iz.h");
if (length($d) > 0 && -d $d && -f $izh) {
print "header: $izh\n";
return $d;
}
}
show_how_to_path_set;
}
my $iz_lib_dir = get_iz_lib_dir;
my $iz_inc_dir = get_iz_inc_dir;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Algorithm::CP::IZ',
VERSION_FROM => 'lib/Algorithm/CP/IZ.pm', # finds $VERSION, requires EU::MM from perl >= 5.5
PREREQ_PM => { UNIVERSAL => 0, "Scalar::Util" => 0,}, # e.g., Module::Name => 1.1
ABSTRACT_FROM => 'lib/Algorithm/CP/IZ.pm', # retrieve abstract from module
AUTHOR => 'Toshimitsu FUJIWARA <tttfjw at gmail.com>',
LICENSE => 'artistic_2',
#Value must be from legacy list of licenses here
#http://search.cpan.org/perldoc?Module%3A%3ABuild%3A%3AAPI
LIBS => ["-L$iz_lib_dir -liz"], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
INC => "-I$iz_inc_dir", # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
clean => {FILES => "cs_reif2.inc cs_vadd.inc cs_vmul.inc cs_vsub.inc"},
);
if (eval {require ExtUtils::Constant; 1}) {
# If you edit these definitions to change the constants used by this module,
# you will need to use the generated const-c.inc and const-xs.inc
# files to replace their "fallback" counterparts before distributing your
# changes.
my @names = (
qw(
CS_ERR_NONE
CS_ERR_GETVALUE
CS_ERR_OVERFLOW
CS_ERR_NO_MEMORY
CS_VALUE_SELECTOR_MIN_TO_MAX
CS_VALUE_SELECTOR_MAX_TO_MIN
CS_VALUE_SELECTOR_LOWER_AND_UPPER
CS_VALUE_SELECTOR_UPPER_AND_LOWER
CS_VALUE_SELECTOR_MEDIAN_AND_REST
CS_VALUE_SELECTION_EQ
CS_VALUE_SELECTION_NEQ
CS_VALUE_SELECTION_LE
CS_VALUE_SELECTION_LT
CS_VALUE_SELECTION_GE
CS_VALUE_SELECTION_GT
IZ_VERSION_MAJOR
IZ_VERSION_MINOR
IZ_VERSION_PATCH
));
ExtUtils::Constant::WriteConstants(
NAME => 'Algorithm::CP::IZ',
NAMES => \@names,
DEFAULT_TYPE => 'IV',
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc',
);
}
else {
use File::Copy;
use File::Spec;
foreach my $file ('const-c.inc', 'const-xs.inc') {
my $fallback = File::Spec->catfile('fallback', $file);
copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
}
}
# VAdd
unless (-f "cs_vadd.inc") {
open (my $fh, ">", "cs_vadd.inc") or die "cs_vadd.inc: cannot create: $!";
for my $i (3..10) {
print $fh "void*\n";
print $fh "cs_VAdd$i(";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ")\n";
print $fh map { " void* vint$_\n" } (1..$i);
print $fh "CODE:\n";
print $fh " RETVAL = cs_VAdd($i, ";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ");\n";
print $fh "OUTPUT:\n";
print $fh " RETVAL\n\n";
}
close($fh);
}
# VMul
unless (-f "cs_vmul.inc") {
open (my $fh, ">", "cs_vmul.inc") or die "cs_vmul.inc: cannot create: $!";
for my $i (3..10) {
print $fh "void*\n";
print $fh "cs_VMul$i(";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ")\n";
print $fh map { " void* vint$_\n" } (1..$i);
print $fh "CODE:\n";
print $fh " RETVAL = cs_VMul($i, ";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ");\n";
print $fh "OUTPUT:\n";
print $fh " RETVAL\n\n";
}
close($fh);
}
# VSub
unless (-f "cs_vsub.inc") {
open (my $fh, ">", "cs_vsub.inc") or die "cs_vsub.inc: cannot create: $!";
for my $i (3..10) {
print $fh "void*\n";
print $fh "cs_VSub$i(";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ")\n";
print $fh map { " void* vint$_\n" } (1..$i);
print $fh "CODE:\n";
print $fh " RETVAL = cs_VSub($i, ";
print $fh join(", ", map { "vint$_" } (1..$i));
print $fh ");\n";
print $fh "OUTPUT:\n";
print $fh " RETVAL\n\n";
}
close($fh);
}
# Reif*
unless (-f "cs_reif2.inc") {
open (my $fh, ">", "cs_reif2.inc") or die "cs_reif2.inc: cannot create: $!";
my @names = qw(Eq Neq Lt Le Gt Ge);
for my $name (@names) {
print $fh "void*\n";
print $fh "cs_Reif$name(vint1, vint2)\n";
print $fh " void* vint1\n";
print $fh " void* vint2\n";
print $fh "CODE:\n";
print $fh " RETVAL = cs_Reif$name(vint1, vint2);\n";
print $fh "OUTPUT:\n";
print $fh " RETVAL\n\n";
}
my @names2 = map { uc $_ } @names;
for my $name (@names2) {
print $fh "void*\n";
print $fh "cs_Reif$name(vint, val)\n";
print $fh " void* vint\n";
print $fh " int val\n";
print $fh "CODE:\n";
print $fh " RETVAL = cs_Reif$name(vint, val);\n";
print $fh "OUTPUT:\n";
print $fh " RETVAL\n\n";
}
close($fh);
}