Solaris 8 patches

David Scott Page page at cs.utexas.edu
Wed Apr 10 16:44:31 EDT 2002


Hi,

Enclosed is a patch to get the CVS version of about 0800 on 20020410
to compile on Solaris 8 SPARC. There is also some minor cleanup that
applies in general.  Please let me know if this is suitable, or what
would make it so, as I would like to start expanding the Solaris
support (userlevel) available in the click distribution.

The resulting click installation successfully executes test-align and
click on the test.click sample (although a core dump at
userlevel/click.cc=>delete lexer was introduced between click-1.2.3
and current).

--
Scott Page

Patch description:
================== acclick.m4 ==============================

Endianess: Need to test for $cross-compiling=no when $endian_hdr=no. 
Add whitespace to clarify macro boundaries.

Test that a user specified PCAP_LIB can be linked.
Whitespace addition to clarify macro boundaries.

================== configure.in ============================

Test for libraries defining gethostbyname and connect (if not in
libc). Per the Solaris manpage, gethostbyname is supposed to be
dynamically linked, and the Sun supplied libpcap is dynamically linked
to libnsl and libsocket.

================== kerneltap.cc ============================= 

Allow #if !(defined(__linux__) || defined(__FreeBSD__) ||
defined(__OpenBSD__)) hosts to compile.

================== Procedure ================================

0. test -f Makefile && make distclean
1. Patch configure.in, acclick.m4, kerneltap.cc with supplied patch.
2. cp -p acclick.m4 aclocal.m4
3. autoconf
4. cd to build directory and configure per INSTALL. E.g.  a
configuration for Solaris using the Sun supplied gcc and PCAP library
installed in /opt/sfw:

PATH=/opt/local/bin:/opt/sfw/bin:$PATH CPPFLAGS='-DBSD_COMP' LDFLAGS='-R/opt/sfw/lib' PCAP_INCLUDES='-I/opt/sfw/include' PCAP_LIBS='-L/opt/sfw/lib' LIBS='-lsocket -lnsl' ../click/configure --enable-tools=host --disable-linuxmodule --prefix /var/local/click

================================ Patch ========================================
diff -Naur click-cvs20020409/acclick.m4 click/acclick.m4
--- click-cvs20020409/acclick.m4	Wed Mar 27 01:50:40 2002
+++ click/acclick.m4	Wed Apr 10 17:05:19 2002
@@ -227,23 +227,40 @@
     test "$HAVE_PCAP" != yes && PCAP_INCLUDES=
     AC_SUBST(PCAP_INCLUDES)
 
-
     dnl libraries
-    
-    if test "$HAVE_PCAP" = yes -a ${PCAP_LIBS-NO} = NO; then
-	AC_CACHE_CHECK(for -lpcap, ac_cv_pcap_library_path,
-	    saveflags="$LDFLAGS"
-	    savelibs="$LIBS"
-	    LIBS="$savelibs -lpcap"
-	    AC_LANG_C
-	    AC_TRY_LINK_FUNC(pcap_open_live, ac_cv_pcap_library_path="found",
-		LDFLAGS="$saveflags -L/usr/local/lib"
-		AC_TRY_LINK_FUNC(pcap_open_live, ac_cv_pcap_library_path="-L/usr/local/lib",
-		    ac_cv_pcap_library_path="not found"))
-	    LDFLAGS="$saveflags"
-	    LIBS="$savelibs")
 
-	if test "$ac_cv_pcap_library_path" = "found"; then
+    if test "$HAVE_PCAP" = yes ; then
+	if test ${PCAP_LIBS-NO} = NO; then
+	    AC_CACHE_CHECK(for -lpcap, 
+                ac_cv_pcap_library_path,
+		saveflags="$LDFLAGS"
+		savelibs="$LIBS"
+		LIBS="$savelibs -lpcap $SOCKET_LIBS"
+		AC_LANG_C
+		AC_TRY_LINK_FUNC(pcap_open_live, 
+                                ac_cv_pcap_library_path="found",
+				LDFLAGS="$saveflags -L/usr/local/lib"
+		                AC_TRY_LINK_FUNC(pcap_open_live, 
+				    ac_cv_pcap_library_path="-L/usr/local/lib",
+				    ac_cv_pcap_library_path="not found"))
+		LDFLAGS="$saveflags"
+		LIBS="$savelibs")
+	else
+	    AC_CACHE_CHECK(for -lpcap in "$PCAP_LIBS", 
+                ac_cv_pcap_library_path,
+		saveflags="$LDFLAGS"
+		LDFLAGS="$saveflags $PCAP_LIBS"
+		savelibs="$LIBS"
+		LIBS="$savelibs -lpcap $SOCKET_LIBS"
+		AC_LANG_C
+		AC_TRY_LINK_FUNC(pcap_open_live, 
+				ac_cv_pcap_library_path="$PCAP_LIBS",
+			        ac_cv_pcap_library_path="not found")
+		LDFLAGS="$saveflags"
+		LIBS="$savelibs")
+
+	fi
+        if test "$ac_cv_pcap_library_path" = "found"; then
 	    PCAP_LIBS='-lpcap'
 	elif test "$ac_cv_pcap_library_path" != "not found"; then
 	    PCAP_LIBS="$ac_cv_pcap_library_path -lpcap"
@@ -255,7 +272,6 @@
     test "$HAVE_PCAP" != yes && PCAP_LIBS=
     AC_SUBST(PCAP_LIBS)
 
-
     if test "$HAVE_PCAP" = yes; then
 	AC_DEFINE(HAVE_PCAP)
     fi
@@ -467,9 +483,9 @@
     AC_CHECK_HEADERS(endian.h machine/endian.h, endian_hdr=$ac_hdr; break, endian_hdr=no)
     if test "x$endian_hdr" != xno; then
 	AC_CACHE_CHECK(endianness, ac_cv_endian,
-	dnl can't use AC_TRY_CPP because it throws out the results
-	ac_cv_endian=0
-	[cat > conftest.$ac_ext <<EOF
+	    dnl can't use AC_TRY_CPP because it throws out the results
+	    ac_cv_endian=0
+	    [cat > conftest.$ac_ext <<EOF
 [#]line __oline__ "configure"
 #include "confdefs.h"
 #include <$endian_hdr>
@@ -481,19 +497,20 @@
 0
 #endif
 EOF
-	ac_try="$ac_cpp conftest.$ac_ext >conftest.result 2>conftest.out"
-	AC_TRY_EVAL(ac_try)
-	ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-	if test -z "$ac_err"; then
-	    ac_cv_endian=`grep '^[1234]' conftest.result`
-	    test -z "$ac_cv_endian" && ac_cv_endian=0
-	else
-	    echo "$ac_err" >&5
-	    echo "configure: failed program was:" >&5
-	    cat conftest.$ac_ext >&5
-	fi
-	rm -f conftest*])
-    else
+	    ac_try="$ac_cpp conftest.$ac_ext >conftest.result 2>conftest.out"
+	    AC_TRY_EVAL(ac_try)
+	    ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+	    if test -z "$ac_err"; then
+		ac_cv_endian=`grep '^[1234]' conftest.result`
+		test -z "$ac_cv_endian" && ac_cv_endian=0
+	    else
+		echo "$ac_err" >&5
+		echo "configure: failed program was:" >&5
+		cat conftest.$ac_ext >&5
+	    fi
+	    rm -f conftest*]
+	)
+    elif test "x$cross_compiling" != xyes ; then
 	AC_CACHE_CHECK(endianness, ac_cv_endian,
 	    [AC_TRY_RUN([#ifdef __cplusplus
 extern "C" void exit(int);
@@ -509,8 +526,11 @@
     u.i = ('1') | ('2' << 8) | ('3' << 16) | ('4' << 24);
     fprintf(f, "%4.4s\n", u.c);
     exit(0);
-}], ac_cv_endian=`cat conftestdata`, ac_cv_endian=0, ac_cv_endian=0)])
+}	    ], ac_cv_endian=`cat conftestdata`, ac_cv_endian=0, ac_cv_endian=0)]
+	)
+    else
+	ac_cv_endian=0
     fi
     AC_DEFINE_UNQUOTED(CLICK_BYTE_ORDER, $ac_cv_endian)
     AC_CHECK_HEADERS(byteswap.h)
-    ])
+])
diff -Naur click-cvs20020409/configure.in click/configure.in
--- click-cvs20020409/configure.in	Thu Mar 28 04:04:55 2002
+++ click/configure.in	Wed Apr 10 16:56:12 2002
@@ -227,13 +227,21 @@
 
 
 dnl
-dnl sockets
+dnl sockets. gethostbyname is used by, at least, libpcap.
 dnl
 
+dnl need autoconf-2.52 AC_LANG_PUSH(C)
+AC_LANG_C
+savelibs="$LIBS"
+LIBS=
 SOCKET_LIBS=
-dnl AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="-lnsl $SOCKET_LIBS")
-AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket $SOCKET_LIBS")
+AC_SEARCH_LIBS(connect, socket, SOCKET_LIBS="$LIBS", , $savelibs)
+LIBS=
+AC_SEARCH_LIBS(gethostbyname, nsl, SOCKET_LIBS="$SOCKET_LIBS $LIBS", , $SOCKET_LIBS $savelibs)
+LIBS="$savelibs"
 AC_SUBST(SOCKET_LIBS)
+dnl need autoconf-2.52 AC_LANG_POP(C)
+AC_LANG_CPLUSPLUS
 
 
 dnl
diff -Naur click-cvs20020409/elements/userlevel/kerneltap.cc click/elements/userlevel/kerneltap.cc
--- click-cvs20020409/elements/userlevel/kerneltap.cc	Fri Apr  5 21:01:15 2002
+++ click/elements/userlevel/kerneltap.cc	Wed Apr 10 17:50:08 2002
@@ -244,6 +244,11 @@
     Packet *p = Packet::make(_headroom, b, cc, 0);
     p->pull(2);
 #endif
+#else
+    Packet *p = Packet::make(_headroom, b, cc, 0); // dummy
+    click_chatter("KernelTap: OS not supported.") ;
+    p->kill() ;
+    return ;
 #endif
 
   struct timeval tv;



More information about the click mailing list