3
# Build script for Net-SNMP and MSVC
4
# Written by Alex Burger - alex_b@users.sourceforge.net
7
my $openssl = "disabled";
9
my $default_install_base = "c:/usr";
10
my $install_base = $default_install_base;
11
my $install = "enabled";
12
my $perl = "disabled";
13
my $perl_install = "disabled";
14
my $logging = "enabled";
15
my $debug = "disabled";
17
# Prepend win32\ if running from main directory
18
my $current_pwd = `%COMSPEC% /c cd`;
20
if (! ($current_pwd =~ /\\win32$/)) {
22
$current_pwd = `%COMSPEC% /c cd`;
26
if (! (-d $ENV{MSVCDir})) {
27
print "\nPlease run VCVARS32.BAT first to set up the Visual Studio build\n" .
33
# Set PATH environment variable so Perl make tests can locate the DLL
34
$ENV{MIBDIRS}="$current_pwd\\bin;$ENV{MIBDIRS}";
36
# Set MIBDIRS environment variable so Perl make tests can locate the mibs
37
my $temp_mibdir = "$current_pwd/../mibs";
38
$temp_mibdir =~ s/\\/\//g;
39
$ENV{MIBDIRS}=$temp_mibdir;
41
# Set SNMPCONFPATH environment variable so Perl conf.t test can locate
42
# the configuration files.
43
# See the note about environment variables in the Win32 section of
44
# perl/SNMP/README for details on why this is needed.
45
$ENV{SNMPCONFPATH}=t;$ENV{SNMPCONFPATH};
48
print "\n\nNet-SNMP build and install options\n";
49
print "==================================\n\n";
50
print "1. OpenSSL support: " . $openssl. "\n";
51
print "2. Platform SDK support: " . $sdk . "\n";
53
print "3. Install path: " . $install_base . "\n";
54
print "4. Install after build: " . $install . "\n";
56
print "5. Perl modules: " . $perl . "\n";
57
print "6. Install perl modules: " . $perl_install . "\n";
59
print "7. Quiet build (logged): " . $logging . "\n";
60
print "8. Debug mode: " . $debug . "\n";
61
print "\nF. Finished - start build\n";
62
print "Q. Quit - abort build\n\n";
63
print "Select option to set / toggle: ";
67
if ($openssl eq "enabled") {
68
$openssl = "disabled";
74
elsif ($option eq "2") {
75
if ($sdk eq "enabled") {
82
elsif ($option eq "3") {
83
print "Please enter the new install path [$default_install_base]: ";
84
chomp ($install_base = <>);
85
if ($install_base eq "") {
86
$install_base = $default_install_base;
88
$install_base =~ s/\\/\//g;
90
elsif ($option eq "4") {
91
if ($install eq "enabled") {
92
$install = "disabled";
98
elsif ($option eq "5") {
99
if ($perl eq "enabled") {
106
elsif ($option eq "6") {
107
if ($perl_install eq "enabled") {
108
$perl_install = "disabled";
111
$perl_install = "enabled";
114
elsif ($option eq "7") {
115
if ($logging eq "enabled") {
116
$logging = "disabled";
119
$logging = "enabled";
122
elsif ($option eq "8") {
123
if ($debug eq "enabled") {
130
elsif (lc($option) eq "f") {
133
elsif (lc($option) eq "q") {
138
$openssl = ($openssl eq "enabled" ? "--with-ssl" : "" );
139
$sdk = ($sdk eq "enabled" ? "--with-sdk" : "" );
140
$debug = ($debug eq "enabled" ? "--config=debug" : "--config=release" );
142
print "\nBuilding...\n";
144
if ($logging eq "enabled") {
145
print "\nCreating *.out log files.\n\n";
148
if ($logging eq "enabled") {
149
print "Deleting old log files...\n";
150
system("del *.out > NUL: 2>&1");
152
# Delete net-snmp-config.h from main include folder just in case it was created by a Cygwin or MinGW build
153
system("del ..\\include\\net-snmp\\net-snmp-config.h > NUL: 2>&1");
155
print "Running Configure...\n";
156
system("perl Configure $openssl $sdk $debug --linktype=static --prefix=\"$install_base\" > configure.out 2>&1") == 0 || die "Build error (see configure.out)";
158
print "Cleaning...\n";
159
system("nmake /nologo clean > clean.out 2>&1") == 0 || die "Build error (see clean.out)";
161
print "Building main package...\n";
162
system("nmake /nologo > make.out 2>&1") == 0 || die "Build error (see make.out)";
164
if ($perl eq "enabled") {
165
print "Running Configure for DLL...\n";
166
system("perl Configure $openssl $sdk $debug --linktype=dynamic --prefix=\"$install_base\" > perlconfigure.out 2>&1") == 0 || die "Build error (see perlconfigure.out)";
168
print "Cleaning libraries...\n";
169
system("nmake /nologo libs_clean >> clean.out 2>&1") == 0 || die "Build error (see clean.out)";
171
print "Building DLL libraries...\n";
172
system("nmake /nologo libs > dll.out 2>&1") == 0 || die "Build error (see dll.out)";
174
print "Cleaning Perl....\n";
175
system("nmake /nologo perl_clean >> clean.out 2>&1"); # If already cleaned, Makefile is gone so don't worry about errors!
177
print "Building Perl modules...\n";
178
system("nmake /nologo perl > perlmake.out 2>&1") == 0 || die "Build error (see perlmake.out)";
180
print "Testing Perl modules...\n";
181
system("nmake /nologo perl_test > perltest.out 2>&1"); # Don't die if all the tests don't pass..
183
if ($perl_install eq "enabled") {
184
print "Installing Perl modules...\n";
185
system("nmake /nologo perl_install > perlinstall.out 2>&1") == 0 || die "Build error (see perlinstall.out)";
188
print "\nSee perltest.out for Perl test results\n";
192
if ($install eq "enabled") {
193
print "Installing main package...\n";
194
system("nmake /nologo install > install.out 2>&1") == 0 || die "Build error (see install.out)";
197
print "Type nmake install to install the package to $install_base\n";
200
if ($perl_install eq "disabled" && $perl eq "enabled") {
201
print "Type nmake perl_install to install the Perl modules\n";
207
# Delete net-snmp-config.h from main include folder just in case it was created by a Cygwin or MinGW build
208
system("del ..\\include\\net-snmp\\net-snmp-config.h > NUL: 2>&1");
210
system("perl Configure $openssl $sdk $debug --linktype=static --prefix=\"$install_base\"") == 0 || die "Build error (see above)";
211
system("nmake /nologo clean") == 0 || die "Build error (see above)";
212
system("nmake /nologo") == 0 || die "Build error (see above)";
214
if ($perl eq "enabled") {
215
system("perl Configure $openssl $sdk $debug --linktype=dynamic --prefix=\"$install_base\"") == 0 || die "Build error (see above)";
216
system("nmake /nologo libs_clean") == 0 || die "Build error (see above)";
217
system("nmake /nologo libs") == 0 || die "Build error (see above)";
219
system("nmake /nologo perl_clean"); # If already cleaned, Makefile is gone so don't worry about errors!
220
system("nmake /nologo perl") == 0 || die "Build error (see above)";
221
system("nmake /nologo perl_test"); # Don't die if all the tests don't pass..
223
if ($perl_install eq "enabled") {
224
print "Installing Perl modules...\n";
225
system("nmake /nologo perl_install") == 0 || die "Build error (see above)";
230
if ($install eq "enabled") {
231
print "Installing main package...\n";
232
system("nmake /nologo install") == 0 || die "Build error (see above)";
235
print "Type nmake install to install the package to $install_base\n";
238
if ($perl_install eq "disabled" && $perl eq "enabled") {
239
print "Type nmake perl_install to install the Perl modules\n";