]> git.puffer.fish Git - mirror/frr.git/commitdiff
Make vtysh work on NetBSD, and minor cleanups:
authorgdt <gdt>
Wed, 30 Jun 2004 14:25:12 +0000 (14:25 +0000)
committergdt <gdt>
Wed, 30 Jun 2004 14:25:12 +0000 (14:25 +0000)
  if --enable-vtysh, look for perl, and substitute into vtysh/extract.pl,
  rather than assuming perl is in /usr/bin

  Look for tputs in libtermcap and libcurses, in addition to
  previously-searched locations.  Follow GNU readlines search order.

  Clean up --enable-vtysh definition in configure.ac.

  Add vtysh/vtysh_cmds.c to CLEANFILES.  This is important if
  extract.pl fails, so that 'make clean && make' will regenerate
  vtysh_cmds.c rhather than using the old zero-length file.

ChangeLog
configure.ac
vtysh/ChangeLog
vtysh/Makefile.am
vtysh/extract.pl [deleted file]
vtysh/extract.pl.in [new file with mode: 0755]

index f46a54cd005f67a9c281b1f880eaca15743e89e3..ba5347140fac4347a55936cc3c224aad919089ec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-06-30  Greg Troxel  <gdt@poblano.ir.bbn.com>
+
+       * configure.ac: Look for perl, and substitute into vtysh/extract.pl.
+       Search for termcap functions more expansively (fixes vtysh compile
+       on NetBSD).  Clean up --enable-vtysh definition.
+
 2004-06-30  Greg Troxel  <gdt@poblano.ir.bbn.com>
 
        * update-autotools: Use -rf on autom4te.cache.
index 2129421225853169ebdfaeb7b49769cbf0f79f54..bd6b4ff80597cd4a3f76546ab0e1d43a8f5e7676 100755 (executable)
@@ -5,7 +5,7 @@
 ##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
 ##  Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
 ##
-## $Id: configure.ac,v 1.53 2004/06/20 21:00:27 hasso Exp $
+## $Id: configure.ac,v 1.54 2004/06/30 14:25:12 gdt Exp $
 AC_PREREQ(2.53)
 
 AC_INIT(quagga, 0.96.5, [http://bugzilla.quagga.net])
@@ -68,7 +68,7 @@ dnl ----------------------
 dnl Packages configuration
 dnl ----------------------
 AC_ARG_ENABLE(vtysh,
-[  --enable-vtysh,       Make integrated vty shell for Quagga])
+[  --enable-vtysh          include integrated vty shell for Quagga])
 AC_ARG_ENABLE(ipv6,
 [  --disable-ipv6          turn off IPv6 related features and daemons])
 AC_ARG_ENABLE(zebra,
@@ -286,10 +286,18 @@ dnl ---------------------
 case "${enable_vtysh}" in
   "yes") VTYSH="vtysh";
          AC_DEFINE(VTYSH,,VTY shell)
-        AC_CHECK_LIB(tinfo, tputs, , AC_CHECK_LIB(ncurses, tputs))
+        AC_PATH_PROG(PERL, perl)
+dnl     Vtysh uses libreadline, which looks for termcap functions at
+dnl     configure time.  We follow readline's search order.
+dnl     The required procedures are in libtermcap on NetBSD, in
+dnl     [TODO] on Linux, and in [TODO] on Solaris.
+        AC_CHECK_LIB(termcap, tputs, ,
+               AC_CHECK_LIB(tinfo, tputs, ,
+               AC_CHECK_LIB(curses, tputs, ,
+               AC_CHECK_LIB(ncurses, tputs))))
          AC_CHECK_LIB(readline, main)
          if test $ac_cv_lib_readline_main = no; then
-           AC_MSG_ERROR([vtysh needs libreadline but was not found on your system.])
+           AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])
          fi
         AC_CHECK_HEADER(readline/history.h)
         if test $ac_cv_header_readline_history_h = no;then
@@ -1106,8 +1114,10 @@ AC_OUTPUT(Makefile lib/Makefile zebra/Makefile ripd/Makefile
          ripngd/Makefile bgpd/Makefile ospfd/Makefile 
          ospf6d/Makefile isisd/Makefile vtysh/Makefile doc/Makefile 
          ospfclient/Makefile
+         vtysh/extract.pl
          redhat/Makefile redhat/quagga.spec
-         lib/version.h)
+         lib/version.h,
+         [chmod +x vtysh/extract.pl])
 
 echo "
 zebra configuration
index d439850cc9fa42c9a9f39199c2e4918c501f9b57..db9f8051a746e2d649b21956a28c50537731df1b 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-30  Greg Troxel  <gdt@poblano.ir.bbn.com>
+
+       * extract.pl.in: Rename from extract.pl, with @PERL@.
+
+       * Makefile.am: Add vtysh_cmds.c to CLEANFILES.
+
 2004-06-20 Hasso Tepper <hasso@estpak.ee>
 
        * extract.pl: Zebra daemon has access lists as well.
index 9118350ee704abe3b573eb8ee0727b432906c86c..fea0cb02f20d540cd86ef46ae2c95e40586635d7 100644 (file)
@@ -9,6 +9,7 @@ bin_PROGRAMS = vtysh
 
 vtysh_SOURCES = vtysh_main.c vtysh.c vtysh_user.c vtysh_config.c
 nodist_vtysh_SOURCES = vtysh_cmd.c
+CLEANFILES = vtysh_cmd.c
 noinst_HEADERS = vtysh.h vtysh_user.h
 vtysh_LDADD = ../lib/libzebra.a @LIBCAP@
 
diff --git a/vtysh/extract.pl b/vtysh/extract.pl
deleted file mode 100755 (executable)
index 8488e01..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-#! /usr/bin/perl
-##
-## Virtual terminal interface shell command extractor.
-## Copyright (C) 2000 Kunihiro Ishiguro
-## 
-## This file is part of GNU Zebra.
-## 
-## GNU Zebra is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by the
-## Free Software Foundation; either version 2, or (at your option) any
-## later version.
-## 
-## GNU Zebra is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-## 
-## You should have received a copy of the GNU General Public License
-## along with GNU Zebra; see the file COPYING.  If not, write to the Free
-## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-## 02111-1307, USA.  
-##
-
-print <<EOF;
-#include <zebra.h>
-#include "command.h"
-#include "vtysh.h"
-
-EOF
-
-$ignore{'"interface IFNAME"'} = "ignore";
-$ignore{'"ip vrf NAME"'} = "ignore";
-$ignore{'"router rip"'} = "ignore";
-$ignore{'"router ripng"'} = "ignore";
-$ignore{'"router ospf"'} = "ignore";
-$ignore{'"router ospf <0-65535>"'} = "ignore";
-$ignore{'"router ospf6"'} = "ignore";
-$ignore{'"router bgp <1-65535>"'} = "ignore";
-$ignore{'"router bgp <1-65535> view WORD"'} = "ignore";
-$ignore{'"router isis WORD"'} = "ignore";
-$ignore{'"address-family ipv4"'} = "ignore";
-$ignore{'"address-family ipv4 (unicast|multicast)"'} = "ignore";
-$ignore{'"address-family ipv6"'} = "ignore";
-$ignore{'"address-family ipv6 unicast"'} = "ignore";
-$ignore{'"address-family vpnv4"'} = "ignore";
-$ignore{'"address-family vpnv4 unicast"'} = "ignore";
-$ignore{'"address-family ipv4 vrf NAME"'} = "ignore";
-$ignore{'"exit-address-family"'} = "ignore";
-$ignore{'"key chain WORD"'} = "ignore";
-$ignore{'"key <0-2147483647>"'} = "ignore";
-$ignore{'"route-map WORD (deny|permit) <1-65535>"'} = "ignore";
-$ignore{'"show route-map"'} = "ignore";
-
-foreach (@ARGV) {
-    $file = $_;
-
-    open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I. -I.. -I../lib $file |");
-    local $/; undef $/;
-    $line = <FH>;
-    close (FH);
-
-    @defun = ($line =~ /(?:DEFUN|ALIAS)\s*\((.+?)\);?\s?\s?\n/sg);
-    @install = ($line =~ /install_element \(\s*[0-9A-Z_]+,\s*&[^;]*;\s*\n/sg);
-
-    # DEFUN process
-    foreach (@defun) {
-       my (@defun_array);
-       @defun_array = split (/,/);
-       $defun_array[0] = '';
-
-
-       # Actual input command string.
-       $str = "$defun_array[2]";
-       $str =~ s/^\s+//g;
-       $str =~ s/\s+$//g;
-
-       # Get VTY command structure.  This is needed for searching
-       # install_element() command.
-       $cmd = "$defun_array[1]";
-       $cmd =~ s/^\s+//g;
-       $cmd =~ s/\s+$//g;
-
-        # $protocol is VTYSH_PROTO format for redirection of user input
-       if ($file =~ /lib/) {
-           if ($file =~ /keychain.c/) {
-              $protocol = "VTYSH_RIPD";
-           }
-           if ($file =~ /routemap.c/) {
-              $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD";
-           }
-           if ($file =~ /filter.c/) {
-              if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_ZEBRA|VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD";
-             } else {
-                 $protocol = "VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD";
-              }
-           }
-           if ($file =~ /plist.c/) {
-             if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD";
-              } else {
-                 $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD";
-              }
-           }
-           if ($file =~ /distribute.c/) {
-              if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_RIPNGD";
-              } else {
-                 $protocol = "VTYSH_RIPD";
-              }
-           }
-           if ($file =~ /if_rmap.c/) {
-              if ($defun_array[1] =~ m/ipv6/) {
-                 $protocol = "VTYSH_RIPNGD";
-              } else {
-                 $protocol = "VTYSH_RIPD";
-              }
-           }
-        } else {
-           ($protocol) = ($file =~ /\/([a-z0-9]+)/);
-           $protocol = "VTYSH_" . uc $protocol;
-        }
-
-       # Append _vtysh to structure then build DEFUN again
-       $defun_array[1] = $cmd . "_vtysh";
-       $defun_body = join (", ", @defun_array);
-
-       # $cmd -> $str hash for lookup
-       $cmd2str{$cmd} = $str;
-       $cmd2defun{$cmd} = $defun_body;
-       $cmd2proto{$cmd} = $protocol;
-    }
-
-    # install_element() process
-    foreach (@install) {
-       my (@element_array);
-       @element_array = split (/,/);
-
-       # Install node
-       $enode = $element_array[0];
-       $enode =~ s/^\s+//g;
-       $enode =~ s/\s+$//g;
-       ($enode) = ($enode =~ /([0-9A-Z_]+)$/);
-
-       # VTY command structure.
-       ($ecmd) = ($element_array[1] =~ /&([^\)]+)/);
-       $ecmd =~ s/^\s+//g;
-       $ecmd =~ s/\s+$//g;
-
-       # Register $ecmd
-       if (defined ($cmd2str{$ecmd})
-           && ! defined ($ignore{$cmd2str{$ecmd}})) {
-           my ($key);
-           $key = $enode . "," . $cmd2str{$ecmd};
-           $ocmd{$key} = $ecmd;
-           $odefun{$key} = $cmd2defun{$ecmd};
-           push (@{$oproto{$key}}, $cmd2proto{$ecmd});
-       }
-    }
-}
-
-# Check finaly alive $cmd;
-foreach (keys %odefun) {
-    my ($node, $str) = (split (/,/));
-    my ($cmd) = $ocmd{$_};
-    $live{$cmd} = $_;
-}
-
-# Output DEFSH
-foreach (keys %live) {
-    my ($proto);
-    my ($key);
-    $key = $live{$_};
-    $proto = join ("|", @{$oproto{$key}});
-    printf "DEFSH ($proto$odefun{$key})\n\n";
-}
-
-# Output install_element
-print <<EOF;
-void
-vtysh_init_cmd ()
-{
-EOF
-
-foreach (keys %odefun) {
-    my ($node, $str) = (split (/,/));
-    $cmd = $ocmd{$_};
-    $cmd =~ s/_cmd/_cmd_vtysh/;
-    printf "  install_element ($node, &$cmd);\n";
-}
-
-print <<EOF
-}
-EOF
diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
new file mode 100755 (executable)
index 0000000..6882b10
--- /dev/null
@@ -0,0 +1,194 @@
+#! @PERL@
+##
+## Virtual terminal interface shell command extractor.
+## Copyright (C) 2000 Kunihiro Ishiguro
+## 
+## This file is part of GNU Zebra.
+## 
+## GNU Zebra is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+## 
+## GNU Zebra is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with GNU Zebra; see the file COPYING.  If not, write to the Free
+## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.  
+##
+
+print <<EOF;
+#include <zebra.h>
+#include "command.h"
+#include "vtysh.h"
+
+EOF
+
+$ignore{'"interface IFNAME"'} = "ignore";
+$ignore{'"ip vrf NAME"'} = "ignore";
+$ignore{'"router rip"'} = "ignore";
+$ignore{'"router ripng"'} = "ignore";
+$ignore{'"router ospf"'} = "ignore";
+$ignore{'"router ospf <0-65535>"'} = "ignore";
+$ignore{'"router ospf6"'} = "ignore";
+$ignore{'"router bgp <1-65535>"'} = "ignore";
+$ignore{'"router bgp <1-65535> view WORD"'} = "ignore";
+$ignore{'"router isis WORD"'} = "ignore";
+$ignore{'"address-family ipv4"'} = "ignore";
+$ignore{'"address-family ipv4 (unicast|multicast)"'} = "ignore";
+$ignore{'"address-family ipv6"'} = "ignore";
+$ignore{'"address-family ipv6 unicast"'} = "ignore";
+$ignore{'"address-family vpnv4"'} = "ignore";
+$ignore{'"address-family vpnv4 unicast"'} = "ignore";
+$ignore{'"address-family ipv4 vrf NAME"'} = "ignore";
+$ignore{'"exit-address-family"'} = "ignore";
+$ignore{'"key chain WORD"'} = "ignore";
+$ignore{'"key <0-2147483647>"'} = "ignore";
+$ignore{'"route-map WORD (deny|permit) <1-65535>"'} = "ignore";
+$ignore{'"show route-map"'} = "ignore";
+
+foreach (@ARGV) {
+    $file = $_;
+
+    open (FH, "cpp -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I. -I.. -I../lib $file |");
+    local $/; undef $/;
+    $line = <FH>;
+    close (FH);
+
+    @defun = ($line =~ /(?:DEFUN|ALIAS)\s*\((.+?)\);?\s?\s?\n/sg);
+    @install = ($line =~ /install_element \(\s*[0-9A-Z_]+,\s*&[^;]*;\s*\n/sg);
+
+    # DEFUN process
+    foreach (@defun) {
+       my (@defun_array);
+       @defun_array = split (/,/);
+       $defun_array[0] = '';
+
+
+       # Actual input command string.
+       $str = "$defun_array[2]";
+       $str =~ s/^\s+//g;
+       $str =~ s/\s+$//g;
+
+       # Get VTY command structure.  This is needed for searching
+       # install_element() command.
+       $cmd = "$defun_array[1]";
+       $cmd =~ s/^\s+//g;
+       $cmd =~ s/\s+$//g;
+
+        # $protocol is VTYSH_PROTO format for redirection of user input
+       if ($file =~ /lib/) {
+           if ($file =~ /keychain.c/) {
+              $protocol = "VTYSH_RIPD";
+           }
+           if ($file =~ /routemap.c/) {
+              $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD";
+           }
+           if ($file =~ /filter.c/) {
+              if ($defun_array[1] =~ m/ipv6/) {
+                 $protocol = "VTYSH_ZEBRA|VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD";
+             } else {
+                 $protocol = "VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD";
+              }
+           }
+           if ($file =~ /plist.c/) {
+             if ($defun_array[1] =~ m/ipv6/) {
+                 $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD";
+              } else {
+                 $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD";
+              }
+           }
+           if ($file =~ /distribute.c/) {
+              if ($defun_array[1] =~ m/ipv6/) {
+                 $protocol = "VTYSH_RIPNGD";
+              } else {
+                 $protocol = "VTYSH_RIPD";
+              }
+           }
+           if ($file =~ /if_rmap.c/) {
+              if ($defun_array[1] =~ m/ipv6/) {
+                 $protocol = "VTYSH_RIPNGD";
+              } else {
+                 $protocol = "VTYSH_RIPD";
+              }
+           }
+        } else {
+           ($protocol) = ($file =~ /\/([a-z0-9]+)/);
+           $protocol = "VTYSH_" . uc $protocol;
+        }
+
+       # Append _vtysh to structure then build DEFUN again
+       $defun_array[1] = $cmd . "_vtysh";
+       $defun_body = join (", ", @defun_array);
+
+       # $cmd -> $str hash for lookup
+       $cmd2str{$cmd} = $str;
+       $cmd2defun{$cmd} = $defun_body;
+       $cmd2proto{$cmd} = $protocol;
+    }
+
+    # install_element() process
+    foreach (@install) {
+       my (@element_array);
+       @element_array = split (/,/);
+
+       # Install node
+       $enode = $element_array[0];
+       $enode =~ s/^\s+//g;
+       $enode =~ s/\s+$//g;
+       ($enode) = ($enode =~ /([0-9A-Z_]+)$/);
+
+       # VTY command structure.
+       ($ecmd) = ($element_array[1] =~ /&([^\)]+)/);
+       $ecmd =~ s/^\s+//g;
+       $ecmd =~ s/\s+$//g;
+
+       # Register $ecmd
+       if (defined ($cmd2str{$ecmd})
+           && ! defined ($ignore{$cmd2str{$ecmd}})) {
+           my ($key);
+           $key = $enode . "," . $cmd2str{$ecmd};
+           $ocmd{$key} = $ecmd;
+           $odefun{$key} = $cmd2defun{$ecmd};
+           push (@{$oproto{$key}}, $cmd2proto{$ecmd});
+       }
+    }
+}
+
+# Check finaly alive $cmd;
+foreach (keys %odefun) {
+    my ($node, $str) = (split (/,/));
+    my ($cmd) = $ocmd{$_};
+    $live{$cmd} = $_;
+}
+
+# Output DEFSH
+foreach (keys %live) {
+    my ($proto);
+    my ($key);
+    $key = $live{$_};
+    $proto = join ("|", @{$oproto{$key}});
+    printf "DEFSH ($proto$odefun{$key})\n\n";
+}
+
+# Output install_element
+print <<EOF;
+void
+vtysh_init_cmd ()
+{
+EOF
+
+foreach (keys %odefun) {
+    my ($node, $str) = (split (/,/));
+    $cmd = $ocmd{$_};
+    $cmd =~ s/_cmd/_cmd_vtysh/;
+    printf "  install_element ($node, &$cmd);\n";
+}
+
+print <<EOF
+}
+EOF