3
# Configure script for Net-SNMP and MSVC
4
# Written by Alex Burger
16
GetOptions ('config=s' => \$config,
18
'linktype=s' => \$linktype,
19
'destdir=s' => \$prefix,
20
'prefix=s' => \$prefix,
21
'with-ssl' => \$openssl,
28
perl Configure [<options>]
32
--config=[release | debug] Compile as release or with debug symbols
33
--with-sdk Link against MS Platform SDK
34
--linktype=[static | dynamic] Build static or dynamic (DLL)
35
--prefix=\"path\" Set INSTALL_BASE path (install path)
36
--destdir=\"path\" Same as --prefix
37
--with-ssl Link against OpenSSL
38
--help This help screen
47
$config = lc($config);
48
if (($config ne "debug") && ($config ne "release")) {
52
$linktype = lc($linktype);
53
if (($linktype ne "static") && ($linktype ne "dynamic")) {
61
# Make sure prefix only contains forward slashes
64
$prefixdos = "\"$prefix\"";
65
# Make sure prefixdos only contains backward slashes
66
$prefixdos =~ s/\//\\/g;
70
###############################################
72
# Create main Makefile
74
###############################################
76
my $makefile_out = "Makefile";
77
my $makefile_in = "Makefile.in";
79
open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_out\n";
80
open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_in\n";
82
print "creating $makefile_out\n";
94
s/^LINKTYPE=/LINKTYPE=$linktype/;
96
s/^PREFIX=/PREFIX=$prefix/;
97
s/^PREFIX_DOS=/PREFIX_DOS=$prefixdos/;
98
s/^SSL=.*/SSL=$openssl/;
100
print MAKE_OUT $_ . "\n";
104
###############################################
106
# Create Makefiles for applications from
108
# (except for snmpnetstat)
110
###############################################
130
foreach my $progName (@programs) {
132
my $makefile_out = "$progName\\Makefile";
133
my $makefile_in = "Makefile-apps.in";
135
my $outdir = $config;
136
my $intdir = $config;
138
open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_out\n";
139
open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_in\n";
141
print "creating $makefile_out\n";
147
s/^LINKTYPE=/LINKTYPE=$linktype/;
148
s/^PROGNAME=/PROGNAME=$progName/;
149
s/^CFG=/CFG=$config/;
150
s/^OUTDIR=/OUTDIR=.\\$outdir/;
151
s/^INTDIR=/INTDIR=.\\$intdir/;
152
s/^SSL=.*/SSL=$openssl/;
154
print MAKE_OUT $_ . "\n";
158
###############################################
160
# Create Makefiles for snmpnetstat from
161
# snmpnetstat\Makefile.in
163
###############################################
168
foreach my $progName (@programs) {
170
my $makefile_out = "$progName\\Makefile";
171
my $makefile_in = "$progName\\Makefile.in";
173
my $outdir = $config;
174
my $intdir = $config;
176
open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_out\n";
177
open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_in\n";
179
print "creating $makefile_out\n";
185
s/^LINKTYPE=/LINKTYPE=$linktype/;
186
s/^PROGNAME=/PROGNAME=$progName/;
187
s/^CFG=/CFG=$config/;
188
s/^OUTDIR=/OUTDIR=.\\$outdir/;
189
s/^INTDIR=/INTDIR=.\\$intdir/;
190
s/^SSL=.*/SSL=$openssl/;
192
print MAKE_OUT $_ . "\n";
197
###############################################
199
# Create Makefiles for libraries
200
# from name\Makefile.in
202
###############################################
209
push (@programs, "netsnmpmibssdk");
212
push (@programs, "netsnmpmibs");
215
if ($linktype eq "dynamic") {
216
push (@programs, "libsnmp_dll");
219
push (@programs, "libsnmp");
222
foreach my $progName (@programs) {
224
my $makefile_out = "$progName\\Makefile";
225
my $makefile_in = "$progName\\Makefile.in";
227
my $outdir = $config;
228
my $intdir = $config;
230
open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_out\n";
231
open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_in\n";
233
print "creating $makefile_out\n";
239
s/^PROGNAME=/PROGNAME=$progName/;
240
s/^CFG=/CFG=$config/;
241
s/^OUTDIR=/OUTDIR=.\\$outdir/;
242
s/^INTDIR=/INTDIR=.\\$intdir/;
243
s/^SSL=.*/SSL=$openssl/;
245
print MAKE_OUT $_ . "\n";
249
###############################################
251
# Create Makefiles for daemons
252
# from name\Makefile.in
254
###############################################
260
push (@programs, "snmpdsdk");
263
push (@programs, "snmpd");
266
foreach my $progName (@programs) {
268
my $makefile_out = "$progName\\Makefile";
269
my $makefile_in = "$progName\\Makefile.in";
271
my $outdir = $config;
272
my $intdir = $config;
274
open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_out\n";
275
open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_in\n";
277
print "creating $makefile_out\n";
283
s/^LINKTYPE=/LINKTYPE=$linktype/;
284
s/^PROGNAME=/PROGNAME=$progName/;
285
s/^CFG=/CFG=$config/;
286
s/^OUTDIR=/OUTDIR=.\\$outdir/;
287
s/^INTDIR=/INTDIR=.\\$intdir/;
288
s/^SSL=.*/SSL=$openssl/;
290
print MAKE_OUT $_ . "\n";
294
###############################################
296
# Create net-snmp-config.h
298
###############################################
300
my $file_out = "net-snmp\\net-snmp-config.h";
301
my $file_in = "net-snmp\\net-snmp-config.h.in";
303
open (FILE_OUT, ">$file_out") || die "Can't Open $file_out\n";
304
open (FILE_IN, "<$file_in") || die "Can't Open $file_in\n";
306
print "creating $file_out\n";
313
s/^#define INSTALL_BASE.*/#define INSTALL_BASE \"$prefix\"/;
315
if ($linktype eq "dynamic") {
316
s/^#undef NETSNMP_USE_DLL.*/#define NETSNMP_USE_DLL 1/;
319
s/^#undef USE_OPENSSL.*/#define USE_OPENSSL 1/;
322
print FILE_OUT $_ . "\n";
327
---------------------------------------------------------
328
Net-SNMP configuration summary:
329
---------------------------------------------------------
333
print " Config type: $config\n";
334
print " SDK: " . ($sdk == 1 ? "enabled" : "disabled") . "\n";
335
print " Link type: $linktype\n";
336
print " Prefix / Destdir: " . ($prefix ne "" ? $prefix : "(default)") . "\n";
337
print " OpenSSL: " . ($openssl == 1 ? "enabled" : "disabled") . "\n";
339
if ($ENV{INCLUDE} eq "") {
340
print "\n\nVisual Studio environment not detected. Please run VCVARS32.BAT before\n";
341
print "running nmake\n\n";