~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to win32/build.pl

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-13 12:06:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040913120621-g952ntonlleihcvm
Tags: upstream-5.1.1
ImportĀ upstreamĀ versionĀ 5.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
3
# Build script for Net-SNMP and MSVC
 
4
# Written by Alex Burger - alex_b@users.sourceforge.net
 
5
# March 12th, 2004
 
6
#
 
7
my $openssl = "disabled";
 
8
my $sdk = "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";
 
16
 
 
17
# Prepend win32\ if running from main directory
 
18
my $current_pwd = `%COMSPEC% /c cd`;
 
19
chomp $current_pwd;
 
20
if (! ($current_pwd =~ /\\win32$/)) {
 
21
  chdir ("win32");
 
22
  $current_pwd = `%COMSPEC% /c cd`;
 
23
  chomp $current_pwd;
 
24
}
 
25
 
 
26
if (! (-d $ENV{MSVCDir})) {
 
27
  print "\nPlease run VCVARS32.BAT first to set up the Visual Studio build\n" .
 
28
        "environment.\n\n";
 
29
  system("pause");
 
30
  exit;
 
31
}
 
32
 
 
33
# Set PATH environment variable so Perl make tests can locate the DLL
 
34
$ENV{MIBDIRS}="$current_pwd\\bin;$ENV{MIBDIRS}";
 
35
 
 
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;
 
40
 
 
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};
 
46
 
 
47
while (1) {
 
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";
 
52
  print "\n";
 
53
  print "3. Install path:         " . $install_base . "\n";
 
54
  print "4. Install after build:  " . $install . "\n";
 
55
  print "\n";
 
56
  print "5. Perl modules:         " . $perl . "\n";
 
57
  print "6. Install perl modules: " . $perl_install . "\n";
 
58
  print "\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: ";
 
64
 
 
65
  chomp ($option = <>);
 
66
  if ($option eq "1") {
 
67
    if ($openssl eq "enabled") {
 
68
      $openssl = "disabled";
 
69
    }
 
70
    else {
 
71
      $openssl = "enabled";
 
72
    }
 
73
  }
 
74
  elsif ($option eq "2") {
 
75
    if ($sdk eq "enabled") {
 
76
      $sdk = "disabled";
 
77
    }
 
78
    else {
 
79
      $sdk = "enabled";
 
80
    }
 
81
  }
 
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;
 
87
    }
 
88
    $install_base =~ s/\\/\//g;
 
89
  }
 
90
  elsif ($option eq "4") {
 
91
    if ($install eq "enabled") {
 
92
      $install = "disabled";
 
93
    }
 
94
    else {
 
95
      $install = "enabled";
 
96
    }
 
97
  }
 
98
  elsif ($option eq "5") {
 
99
    if ($perl eq "enabled") {
 
100
      $perl = "disabled";
 
101
    }
 
102
    else {
 
103
      $perl = "enabled";
 
104
    }
 
105
  }
 
106
  elsif ($option eq "6") {
 
107
    if ($perl_install eq "enabled") {
 
108
      $perl_install = "disabled";
 
109
    }
 
110
    else {
 
111
      $perl_install = "enabled";
 
112
    }
 
113
  }
 
114
  elsif ($option eq "7") {
 
115
    if ($logging eq "enabled") {
 
116
      $logging = "disabled";
 
117
    }
 
118
    else {
 
119
      $logging = "enabled";
 
120
    }
 
121
  }
 
122
  elsif ($option eq "8") {
 
123
    if ($debug eq "enabled") {
 
124
      $debug = "disabled";
 
125
    }
 
126
    else {
 
127
      $debug = "enabled";
 
128
    }
 
129
  }
 
130
  elsif (lc($option) eq "f") {
 
131
    last;
 
132
  }
 
133
  elsif (lc($option) eq "q") {
 
134
    exit;
 
135
  }
 
136
}
 
137
 
 
138
$openssl = ($openssl eq "enabled" ? "--with-ssl" : "" );
 
139
$sdk = ($sdk eq "enabled" ? "--with-sdk" : "" );
 
140
$debug = ($debug eq "enabled" ? "--config=debug" : "--config=release" );
 
141
 
 
142
print "\nBuilding...\n";
 
143
 
 
144
if ($logging eq "enabled") {
 
145
  print "\nCreating *.out log files.\n\n";
 
146
}
 
147
 
 
148
if ($logging eq "enabled") {
 
149
  print "Deleting old log files...\n";
 
150
  system("del *.out > NUL: 2>&1");
 
151
 
 
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");
 
154
  
 
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)";
 
157
 
 
158
  print "Cleaning...\n";
 
159
  system("nmake /nologo clean > clean.out 2>&1") == 0 || die "Build error (see clean.out)";
 
160
 
 
161
  print "Building main package...\n";
 
162
  system("nmake /nologo > make.out 2>&1") == 0 || die "Build error (see make.out)";
 
163
 
 
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)";
 
167
 
 
168
    print "Cleaning libraries...\n";
 
169
    system("nmake /nologo libs_clean >> clean.out 2>&1") == 0 || die "Build error (see clean.out)";
 
170
 
 
171
    print "Building DLL libraries...\n";
 
172
    system("nmake /nologo libs > dll.out 2>&1") == 0 || die "Build error (see dll.out)";
 
173
   
 
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!
 
176
 
 
177
    print "Building Perl modules...\n";
 
178
    system("nmake /nologo perl > perlmake.out 2>&1") == 0 || die "Build error (see perlmake.out)";
 
179
 
 
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..
 
182
  
 
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)";
 
186
    }
 
187
      
 
188
    print "\nSee perltest.out for Perl test results\n";
 
189
  }
 
190
 
 
191
  print "\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)";
 
195
  }
 
196
  else {
 
197
    print "Type nmake install to install the package to $install_base\n";
 
198
  }
 
199
  
 
200
  if ($perl_install eq "disabled" && $perl eq "enabled") {
 
201
    print "Type nmake perl_install to install the Perl modules\n";
 
202
  }
 
203
}
 
204
else {
 
205
  system("del *.out");
 
206
 
 
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");
 
209
 
 
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)";
 
213
  
 
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)";
 
218
    
 
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..
 
222
    
 
223
    if ($perl_install eq "enabled") {      
 
224
      print "Installing Perl modules...\n";
 
225
      system("nmake /nologo perl_install") == 0 || die "Build error (see above)";
 
226
    }
 
227
  }
 
228
 
 
229
  print "\n";
 
230
  if ($install eq "enabled") {
 
231
    print "Installing main package...\n";
 
232
    system("nmake /nologo install") == 0 || die "Build error (see above)";
 
233
  }
 
234
  else {
 
235
    print "Type nmake install to install the package to $install_base\n";
 
236
  }
 
237
  
 
238
  if ($perl_install eq "disabled" && $perl eq "enabled") {
 
239
    print "Type nmake perl_install to install the Perl modules\n";
 
240
  }
 
241
}
 
242
 
 
243
print "\nDone!\n";
 
244