Configure
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:9k
- #!/usr/bin/perl
- #
- # Configure script for Net-SNMP and MSVC
- # Written by Alex Burger
- # March 5th, 2004
- #
- use Getopt::Long;
- my $config;
- my $sdk = 0;
- my $linktype;
- my $prefix;
- my $openssl = 0;
- my $b_ipv6 = 0;
- my $help = 0;
- GetOptions ('config=s' => $config,
- 'with-sdk' => $sdk,
- 'linktype=s' => $linktype,
- 'destdir=s' => $prefix,
- 'prefix=s' => $prefix,
- 'with-ssl' => $openssl,
- 'with-ipv6' => $b_ipv6,
- 'help' => $help);
- if ($help == 1)
- {
- $USAGE = qq/
- Usage:
- perl Configure [<options>]
-
- Options:
- --config=[release | debug] Compile as release or with debug symbols
- --with-sdk Link against MS Platform SDK
- --linktype=[static | dynamic] Build static or dynamic (DLL)
- --prefix="path" Set INSTALL_BASE path (install path)
- --destdir="path" Same as --prefix
- --with-ssl Link against OpenSSL
- --with-ipv6 Build in IPv6 transports
- --help This help screen
- /;
- print $USAGE;
- exit(0);
- }
-
- $config = lc($config);
- if (($config ne "debug") && ($config ne "release")) {
- $config = "release";
- }
- $linktype = lc($linktype);
- if (($linktype ne "static") && ($linktype ne "dynamic")) {
- $linktype = "static";
- }
- if ($prefix eq "") {
- $prefix = "c:/usr";
- }
- # Make sure prefix only contains forward slashes
- $prefix =~ s/\///g;
- $prefixdos = ""$prefix"";
- # Make sure prefixdos only contains backward slashes
- $prefixdos =~ s///\/g;
- print "nn";
- ###############################################
- #
- # Create main Makefile
- #
- ###############################################
- {
- my $makefile_out = "Makefile";
- my $makefile_in = "Makefile.in";
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
-
- while (<MAKE_IN>)
- {
- chomp;
- if ($sdk == 1) {
- s/^SDK=/SDK=true/;
- }
- else {
- s/^SDK=/SDK=false/;
- }
-
- s/^LINKTYPE=/LINKTYPE=$linktype/;
- s/^CFG=/CFG=$config/;
- s/^PREFIX=/PREFIX=$prefix/;
- s/^PREFIX_DOS=/PREFIX_DOS=$prefixdos/;
- s/^SSL=.*/SSL=$openssl/;
- print MAKE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create Makefiles for applications from
- # Makefile-apps.in
- # (except for snmpnetstat)
- #
- ###############################################
- my @programs = qw
- /encode_keychange
- snmpbulkget
- snmpbulkwalk
- snmpdelta
- snmpdf
- snmpget
- snmpgetnext
- snmpset
- snmpstatus
- snmptable
- snmptest
- snmptranslate
- snmptrap
- snmpusm
- snmpvacm
- snmpwalk
- /;
- foreach my $progName (@programs) {
-
- my $makefile_out = "$progName\Makefile";
- my $makefile_in = "Makefile-apps.in";
- my $outdir = $config;
- my $intdir = $config;
-
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
-
- while (<MAKE_IN>)
- {
- chomp;
-
- s/^LINKTYPE=/LINKTYPE=$linktype/;
- s/^PROGNAME=/PROGNAME=$progName/;
- s/^CFG=/CFG=$config/;
- s/^OUTDIR=/OUTDIR=.\$outdir/;
- s/^INTDIR=/INTDIR=.\$intdir/;
- s/^SSL=.*/SSL=$openssl/;
- print MAKE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create Makefiles for snmpnetstat from
- # snmpnetstatMakefile.in
- #
- ###############################################
- my @programs = qw
- /snmpnetstat
- /;
- foreach my $progName (@programs) {
-
- my $makefile_out = "$progName\Makefile";
- my $makefile_in = "$progName\Makefile.in";
- my $outdir = $config;
- my $intdir = $config;
-
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
-
- while (<MAKE_IN>)
- {
- chomp;
- s/^LINKTYPE=/LINKTYPE=$linktype/;
- s/^PROGNAME=/PROGNAME=$progName/;
- s/^CFG=/CFG=$config/;
- s/^OUTDIR=/OUTDIR=.\$outdir/;
- s/^INTDIR=/INTDIR=.\$intdir/;
- s/^SSL=.*/SSL=$openssl/;
- print MAKE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create Makefiles for libraries
- # from nameMakefile.in
- #
- ###############################################
- my @programs = qw
- /libagent
- libhelpers
- libnetsnmptrapd
- /;
- if ($sdk == 1) {
- push (@programs, "netsnmpmibssdk");
- }
- else {
- push (@programs, "netsnmpmibs");
- }
- if ($linktype eq "dynamic") {
- push (@programs, "libsnmp_dll");
- }
- else {
- push (@programs, "libsnmp");
- }
- foreach my $progName (@programs) {
-
- my $makefile_out = "$progName\Makefile";
- my $makefile_in = "$progName\Makefile.in";
-
- my $outdir = $config;
- my $intdir = $config;
-
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
-
- while (<MAKE_IN>)
- {
- chomp;
-
- s/^PROGNAME=/PROGNAME=$progName/;
- s/^CFG=/CFG=$config/;
- s/^OUTDIR=/OUTDIR=.\$outdir/;
- s/^INTDIR=/INTDIR=.\$intdir/;
- s/^SSL=.*/SSL=$openssl/;
- print MAKE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create Makefiles for daemons
- # from nameMakefile.in
- #
- ###############################################
- my @programs = qw
- /snmptrapd
- /;
- if ($sdk == 1) {
- push (@programs, "snmpdsdk");
- }
- else {
- push (@programs, "snmpd");
- }
- foreach my $progName (@programs) {
-
- my $makefile_out = "$progName\Makefile";
- my $makefile_in = "$progName\Makefile.in";
-
- my $outdir = $config;
- my $intdir = $config;
-
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
-
- while (<MAKE_IN>)
- {
- chomp;
-
- s/^LINKTYPE=/LINKTYPE=$linktype/;
- s/^PROGNAME=/PROGNAME=$progName/;
- s/^CFG=/CFG=$config/;
- s/^OUTDIR=/OUTDIR=.\$outdir/;
- s/^INTDIR=/INTDIR=.\$intdir/;
- s/^SSL=.*/SSL=$openssl/;
- print MAKE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create Makefile for Perl scripts in local
- # from localMakefile.in
- #
- ###############################################
-
- my $makefile_out = "local\Makefile";
- my $makefile_in = "local\Makefile.in";
- my $outdir = $config;
- open (MAKE_OUT, ">$makefile_out") || die "Can't Open $makefile_outn";
- open (MAKE_IN, "<$makefile_in") || die "Can't Open $makefile_inn";
- print "creating $makefile_outn";
- while (<MAKE_IN>)
- {
- chomp;
-
- s/^OUTDIR=/OUTDIR=.\$outdir/;
- s/^PREFIX=/PREFIX=$prefix/;
- s/^PREFIX_DOS=/PREFIX_DOS=$prefixdos/;
-
- print MAKE_OUT $_ . "n";
- }
- ###############################################
- #
- # Create net-snmp-config.h
- #
- ###############################################
- {
- my $file_out = "net-snmp\net-snmp-config.h";
- my $file_in = "net-snmp\net-snmp-config.h.in";
- open (FILE_OUT, ">$file_out") || die "Can't Open $file_outn";
- open (FILE_IN, "<$file_in") || die "Can't Open $file_inn";
-
- print "creating $file_outn";
- while (<FILE_IN>)
- {
- chomp;
- if ($prefix ne "") {
- s/^#define INSTALL_BASE.*/#define INSTALL_BASE "$prefix"/;
- }
- if ($linktype eq "dynamic") {
- s/^.*#undef NETSNMP_USE_DLL.*/#define NETSNMP_USE_DLL 1/;
- }
- if ($sdk == 1) {
- s/^.*#undef HAVE_WIN32_PLATFORM_SDK.*/#define HAVE_WIN32_PLATFORM_SDK 1/;
- }
- if ($openssl == 1) {
- s/^.*#undef USE_OPENSSL.*/#define USE_OPENSSL 1/;
- }
- if ($b_ipv6 == 1) {
- s/^.*#undef INET6.*/#define INET6 1/;
- }
- print FILE_OUT $_ . "n";
- }
- }
- ###############################################
- #
- # Create libsnmp.def file for libsnmp_dll
- #
- ###############################################
- if ($linktype eq "dynamic")
- {
- my $file_out = "libsnmp_dll\libsnmp.def";
- my $file_in = "libsnmp_dll\libsnmp.def.in";
- open (FILE_OUT, ">$file_out") || die "Can't Open $file_outn";
- open (FILE_IN, "<$file_in") || die "Can't Open $file_inn";
-
- print "creating $file_outn";
- while (<FILE_IN>)
- {
- chomp;
- if ($b_ipv6 == "1") {
- s/^;ipv6//i;
- }
- print FILE_OUT $_ . "n";
- }
- }
- print qq/
- ---------------------------------------------------------
- Net-SNMP configuration summary:
- ---------------------------------------------------------
- /;
- print " Config type: $confign";
- print " SDK: " . ($sdk == 1 ? "enabled" : "disabled") . "n";
- print " Link type: $linktypen";
- print " Prefix / Destdir: " . ($prefix ne "" ? $prefix : "(default)") . "n";
- print " OpenSSL: " . ($openssl == 1 ? "enabled" : "disabled") . "n";
- print " IPv6 transport: " . ($b_ipv6 == 1 ? "enabled" : "disabled") . "n";
- if ($ENV{INCLUDE} eq "") {
- print "nnVisual Studio environment not detected. Please run VCVARS32.BAT beforen";
- print "running nmakenn";
- }