Ethereal-dev: Re: [Ethereal-dev] autoconf patches to 0.8.16

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date: Thu, 8 Mar 2001 00:47:42 -0600
On Wed, Mar 07, 2001 at 11:20:52PM -0600, ethereal-dev@xxxxxxxxxxxxxxxxxx wrote:
> Build patches:
>   1. Added --with-libpcap-include=DIR and --with-libpcap-lib=DIR
>      to specify path to libpcap library.
>   2. Added --with-zlib=DIR to specify the path to zlib
>   3. Remove hard-coding /usr/local/include and /usr/local/lib. This
>      is gross.

Ok, let's try again. New patch attached with Guy's suggestions
applied.

-- 
albert chin (china@xxxxxxxxxxxxxxxxxx)

-- snip snip
--- acinclude.m4.orig	Wed Mar  7 20:20:40 2001
+++ acinclude.m4	Thu Mar  8 00:37:09 2001
@@ -242,39 +242,65 @@
 #
 AC_DEFUN(AC_ETHEREAL_PCAP_CHECK,
 [
-	# Evidently, some systems have pcap.h, etc. in */include/pcap
-	AC_MSG_CHECKING(for extraneous pcap header directories)
-	found_pcap_dir=""
-	for pcap_dir in /usr/include/pcap /usr/local/include/pcap $prefix/include
-	do
-	  if test -d $pcap_dir ; then
-	    CFLAGS="$CFLAGS -I$pcap_dir"
-	    CPPFLAGS="$CPPFLAGS -I$pcap_dir"
-	    found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
-	  fi
-	done
-
-	if test "$found_pcap_dir" != "" ; then
-	  AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
-	else
-	  AC_MSG_RESULT(not found)
+	AC_ARG_WITH(pcap,
+	[  --with-pcap[=DIR]       use libpcap for packet capturing (and
+                          search DIR for includes/libraries) [default=yes]],[
+		case "${with_pcap}" in
+		no)
+			use_pcap=no
+			;;
+		yes)
+			use_pcap=yes
+			;;
+		*)
+			use_pcap=yes
+			if test -d "${with_pcap}"; then
+				CPPFLAGS="${CPPFLAGS} -I${with_pcap}/include"
+				LDFLAGS="${LDFLAGS} -L${with_pcap}/lib"
+			fi
+			;;
+		esac
+	])
+
+	# if --with-pcap not set to a path, search in pre-defined locations
+	if test "${with_pcap}" = "yes"; then
+		# Evidently, some systems have pcap.h, etc. in */include/pcap
+		AC_MSG_CHECKING(for extraneous pcap header directories)
+		found_pcap_dir=""
+
+		for pcap_dir in /usr/include/pcap /usr/local/include/pcap \
+		$prefix/include; do
+			if test -d $pcap_dir ; then
+				CPPFLAGS="$CPPFLAGS -I$pcap_dir"
+				found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
+				break
+			fi
+		done
+
+		if test "$found_pcap_dir" != "" ; then
+			AC_MSG_RESULT([$found_pcap_dir added to CPPFLAGS])
+		else
+			AC_MSG_RESULT([not found])
+		fi
 	fi
 
-	# Pcap header checks
-	AC_CHECK_HEADER(net/bpf.h,,
-	    AC_MSG_ERROR([[Header file net/bpf.h not found; if you installed libpcap from source, did you also do \"make install-incl\"?]]))
-	AC_CHECK_HEADER(pcap.h,, AC_MSG_ERROR(Header file pcap.h not found.))
-
-	#
-	# Check to see if we find "pcap_open_live" in "-lpcap".
-	#
-	AC_CHECK_LIB(pcap, pcap_open_live,
-	  [
-	    PCAP_LIBS=-lpcap
-	    AC_DEFINE(HAVE_LIBPCAP)
-	  ], AC_MSG_ERROR(Library libpcap not found.),
-	  $SOCKET_LIBS $NSL_LIBS)
-	AC_SUBST(PCAP_LIBS)
+	if test "${use_pcap}" = "yes"; then
+		# Pcap header checks
+		AC_CHECK_HEADER(net/bpf.h, ,
+			AC_MSG_ERROR([[Header file net/bpf.h not found; if you installed libpcap from source, did you also do \"make install-incl\"?]]))
+		AC_CHECK_HEADER(pcap.h, ,
+			AC_MSG_ERROR([Header file pcap.h not found]))
+
+		#
+		# Check to see if we find "pcap_open_live" in "-lpcap".
+		#
+		AC_CHECK_LIB(pcap, pcap_open_live,[
+			PCAP_LIBS=-lpcap
+			AC_DEFINE(HAVE_LIBPCAP)],
+			AC_MSG_ERROR([Library libpcap not found]),
+			$SOCKET_LIBS $NSL_LIBS)
+		AC_SUBST(PCAP_LIBS)
+	fi
 ])
 
 #
@@ -282,16 +308,40 @@
 #
 AC_DEFUN(AC_ETHEREAL_ZLIB_CHECK,
 [
-        AC_CHECK_HEADER(zlib.h,,enable_zlib=no)
+	_cppflags=${CPPFLAGS}
+	_ldflags=${LDFLAGS}
+
+	AC_ARG_WITH(zlib,
+	[  --with-zlib[=DIR]       use zlib to read compressed data (and
+                          search in DIR for includes/libraries) [default=yes]],[
+		case "${with_zlib}" in
+		no)
+			use_zlib=no
+			;;
+		yes)
+			use_zlib=yes
+			;;
+		*)
+			use_zlib=yes
+			if test -d "$with_zlib"; then
+				CPPFLAGS="${CPPFLAGS} -I$withval/include"
+				LDFLAGS="${LDFLAGS} -L$withval/lib"
+			fi
+			;;
+		esac
+	])
 
-        dnl
-        dnl Check for "gzgets()" in zlib, because we need it, but
-        dnl some older versions of zlib don't have it.  It appears
-        dnl from the ChangeLog that any released version of zlib
-        dnl with "gzgets()" should have the other routines we
-        dnl depend on, such as "gzseek()", "gztell()", and "zError()".
-        dnl
-        AC_CHECK_LIB(z, gzgets,,enable_zlib=no)
+	if test "${use_zlib}" = "yes"; then
+		AC_CHECK_HEADER(zlib.h,
+    			AC_CHECK_LIB(z, gzread, , use_zlib=no),
+			use_zlib=no)
+
+		if test "${use_zlib}" = "no"; then
+			CPPFLAGS=${_cppflags}
+			LDFLAGS=${_ldflags}
+			AC_MSG_WARN([zlib not found -- disabling compressed capture file support])
+		fi
+	fi
 ])
 
 #
--- configure.in.orig	Wed Mar  7 20:20:32 2001
+++ configure.in	Thu Mar  8 00:12:58 2001
@@ -126,13 +126,8 @@
 # as various packages we use ("libpcap", "zlib", an SNMP library)
 # may have been installed under "/usr/local/include".
 #
-CFLAGS="$CFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I\$(top_srcdir)/epan -I/usr/local/include"
-CPPFLAGS="$CPPFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I\$(top_srcdir)/epan -I/usr/local/include"
-
-#
-# Arrange that we search for libraries in "/usr/local/lib".
-#
-AC_ETHEREAL_ADD_DASH_L(LDFLAGS, /usr/local/lib)
+CFLAGS="$CFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I\$(top_srcdir)/epan"
+CPPFLAGS="$CPPFLAGS -I\$(top_srcdir) -I\$(top_srcdir)/wiretap -I\$(top_srcdir)/epan"
 
 # Create DATAFILE_DIR #define for config.h
 DATAFILE_DIR=$sysconfdir
@@ -253,7 +248,7 @@
 # Enable/disable randpkt
 
 AC_ARG_ENABLE(randpkt,
-[  --enable-randpkt         build randpkt.  [default=no]],,enable_randpkt=no)
+[  --enable-randpkt        build randpkt.  [default=no]],,enable_randpkt=no)
 
 if test "x$enable_randpkt" = "xyes" ; then
 	randpkt_bin="randpkt"
@@ -272,32 +267,10 @@
 AC_ETHEREAL_SOCKET_LIB_CHECK
 
 dnl pcap check
-AC_ARG_ENABLE(pcap,
-[  --enable-pcap           use libpcap for packet capturing.  [default=yes]],,enable_pcap=yes)
-
-AC_MSG_CHECKING(whether to use libpcap for packet capture)
-if test "x$enable_pcap" = "xno" ; then
-	AC_MSG_RESULT(no)
-else
-	AC_MSG_RESULT(yes)
-	AC_ETHEREAL_PCAP_CHECK
-fi
+AC_ETHEREAL_PCAP_CHECK
 
 dnl zlib check
-AC_ARG_ENABLE(zlib,
-[  --enable-zlib           use zlib to read compressed data.  [default=yes]],,enable_zlib=yes)
-
-AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
-if test "x$enable_zlib" = "xno" ; then
-        AC_MSG_RESULT(no)
-else
-        AC_MSG_RESULT(yes)
-        AC_ETHEREAL_ZLIB_CHECK
-	if test "x$enable_zlib" = "xno" ; then
-		AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
-	fi
-fi
-
+AC_ETHEREAL_ZLIB_CHECK
 
 dnl ipv6 check
 AC_ARG_ENABLE(ipv6,
@@ -350,7 +323,6 @@
 else
 	AC_MSG_RESULT(yes)
 	AC_ETHEREAL_SSL_CHECK
-	AC_MSG_CHECKING(SSL_LIBS=$SSL_LIBS)
 fi
 AC_SUBST(SSL_LIBS)
 
@@ -473,7 +445,7 @@
 
 dnl check for plugins directory - stolen from Amanda's configure.in
 AC_ARG_WITH(plugindir,
-  [  --with-plugindir=DIR   install plugins in DIR],
+  [  --with-plugindir=DIR    install plugins in DIR],
   [
   case "$withval" in
   "" | y | ye | yes | n | no)
@@ -543,8 +515,8 @@
 echo "                      Build dftest : $enable_dftest"
 echo ""
 echo "                    Install setuid : $setuid_message"
-echo "                  Use pcap library : $enable_pcap"
-echo "                  Use zlib library : $enable_zlib"
+echo "                  Use pcap library : $use_pcap"
+echo "                  Use zlib library : $use_zlib"
 echo "          Use IPv6 name resolution : $enable_ipv6"
 echo "                  Use SNMP library : $snmp_libs_message"
 
--- wiretap/acinclude.m4.orig	Wed Mar  7 20:44:55 2001
+++ wiretap/acinclude.m4	Thu Mar  8 00:37:15 2001
@@ -207,26 +207,54 @@
 #
 AC_DEFUN(AC_WIRETAP_PCAP_CHECK,
 [
-	# Evidently, some systems have pcap.h, etc. in */include/pcap
-	AC_MSG_CHECKING(for extraneous pcap header directories)
-	found_pcap_dir=""
-	for pcap_dir in /usr/include/pcap /usr/local/include/pcap $prefix/include
-	do
-	  if test -d $pcap_dir ; then
-	    CFLAGS="$CFLAGS -I$pcap_dir"
-	    CPPFLAGS="$CPPFLAGS -I$pcap_dir"
-	    found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
-	  fi
-	done
-
-	if test "$found_pcap_dir" != "" ; then
-	  AC_MSG_RESULT(found --$found_pcap_dir added to CFLAGS)
-	else
-	  AC_MSG_RESULT(not found)
+	_cppflags=${CPPFLAGS}
+
+	AC_ARG_WITH(pcap,
+	[  --with-pcap[=DIR]       use libpcap for packet capturing (and
+                          search DIR for includes)],[
+		case "${with_pcap}" in
+		no)
+			use_pcap=no
+			;;
+		yes)
+			use_pcap=yes
+			;;
+		*)
+			use_pcap=yes
+			if test -d "$withval"; then
+				CPPFLAGS="${CPPFLAGS} -I$withval/include"
+			fi
+			;;
+		esac
+	])
+
+	# if --with-pcap not set to a path, search in pre-defined locations
+	if test "${with_pcap}" = "yes"; then
+		# Evidently, some systems have pcap.h, etc. in */include/pcap
+		AC_MSG_CHECKING(for extraneous pcap header directories)
+		found_pcap_dir=""
+
+		for pcap_dir in /usr/include/pcap /usr/local/include/pcap \
+		$prefix/include; do
+			if test -d $pcap_dir ; then
+				CPPFLAGS="$CPPFLAGS -I$pcap_dir"
+				found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
+				break
+			fi
+		done
+
+		if test "$found_pcap_dir" != "" ; then
+			AC_MSG_RESULT([$found_pcap_dir added to CPPFLAGS])
+		else
+			AC_MSG_RESULT([not found])
+		fi
 	fi
 
-	# Pcap header check
-	AC_CHECK_HEADERS(pcap.h)
+	if test "${use_pcap}" = "yes"; then
+		# Pcap header checks
+		AC_CHECK_HEADERS(pcap.h, ,
+			test -n "${_cppflags}" && CPPFLAGS=${_cppflags})
+	fi
 ])
 
 #
@@ -234,14 +262,38 @@
 #
 AC_DEFUN(AC_WIRETAP_ZLIB_CHECK,
 [
-        AC_CHECK_HEADER(zlib.h,,enable_zlib=no)
+	_cppflags=${CPPFLAGS}
+	_ldflags=${LDFLAGS}
+
+	AC_ARG_WITH(zlib,
+	[  --with-zlib[=DIR]       use zlib to read compressed data (and
+                          search in DIR for includes/libraries)],[
+		case "${with_zlib}" in
+		no)
+			use_zlib=no
+			;;
+		yes)
+			use_zlib=yes
+			;;
+		*)
+			use_zlib=yes
+			if test -d "$with_zlib"; then
+				CPPFLAGS="${CPPFLAGS} -I$withval/include"
+				LDFLAGS="${LDFLAGS} -L$withval/lib"
+			fi
+			;;
+		esac
+	])
 
-        dnl
-        dnl Check for "gzgets()" in zlib, because we need it, but
-        dnl some older versions of zlib don't have it.  It appears
-        dnl from the ChangeLog that any released version of zlib
-        dnl with "gzgets()" should have the other routines we
-        dnl depend on, such as "gzseek()", "gztell()", and "zError()".
-        dnl
-        AC_CHECK_LIB(z, gzgets,,enable_zlib=no)
+	if test "${use_zlib}" = "yes"; then
+		AC_CHECK_HEADER(zlib.h,
+    			AC_CHECK_LIB(z, gzread, , use_zlib=no),
+			use_zlib=no)
+
+		if test "${use_zlib}" = "no"; then
+			CPPFLAGS=${_cppflags}
+			LDFLAGS=${_ldflags}
+			AC_MSG_WARN([zlib not found -- disabling compressed capture file support])
+		fi
+	fi
 ])
--- wiretap/configure.in.orig	Thu Mar  8 00:45:00 2001
+++ wiretap/configure.in	Thu Mar  8 00:01:53 2001
@@ -81,18 +81,6 @@
 AC_WIRETAP_PCAP_CHECK
 
 dnl zlib check
-AC_ARG_ENABLE(zlib,
-[  --enable-zlib           use zlib to read compressed data.  [default=yes]],,enable_zlib=yes)
-
-AC_MSG_CHECKING(whether to use zlib for reading compressed capture files)
-if test "x$enable_zlib" = "xno" ; then
-        AC_MSG_RESULT(no)
-else
-        AC_MSG_RESULT(yes)
-	AC_WIRETAP_ZLIB_CHECK
-	if test "x$enable_zlib" = "xno" ; then
-		AC_MSG_RESULT(zlib not found - disabling compressed capture file support)
-	fi
-fi
+AC_WIRETAP_ZLIB_CHECK
 
 AC_OUTPUT(Makefile)