From 60d9468f45778f3c07e801d71652ed54785f5ed8 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 9 Nov 2004 18:32:22 +0000 Subject: [PATCH] From Koryn Grant: correctly detect and configure libpcap for both 2.4.x-series and and 2.5.x-series DAG software releases. --- configure.in | 202 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 163 insertions(+), 39 deletions(-) diff --git a/configure.in b/configure.in index 0aae744..999eb0e 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.107 2004-03-28 20:31:07 fenner Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.108 2004-11-09 18:32:22 guy Exp $ (LBL) dnl dnl Copyright (c) 1994, 1995, 1996, 1997 dnl The Regents of the University of California. All rights reserved. @@ -6,7 +6,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl -AC_REVISION($Revision: 1.107 $) +AC_REVISION($Revision: 1.108 $) AC_PREREQ(2.50) AC_INIT(pcap.c) @@ -249,16 +249,19 @@ if test $ac_cv_lbl_proc_net_dev = yes; then fi AC_MSG_RESULT($ac_cv_lbl_proc_net_dev) -AC_ARG_WITH(dag, [ --with-dag[=DIR] include DAG support (located in directory DIR, if supplied). [default=yes, on BSD and Linux, if present]], +# Check for Endace DAG card support. +AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)], [ if test "$withval" = no then + # User doesn't want DAG support. want_dag=no elif test "$withval" = yes then + # User wants DAG support but hasn't specified a directory. want_dag=yes - dag_root= else + # User wants DAG support and has specified a directory, so use the provided value. want_dag=yes dag_root=$withval fi @@ -267,9 +270,22 @@ AC_ARG_WITH(dag, [ --with-dag[=DIR] include DAG support (located in dire # Use DAG API if present, otherwise don't # want_dag=ifpresent - dag_root=/root/dag ]) -ac_cv_lbl_dag_api=no + +AC_ARG_WITH([dag-includes], [ --with-dag-includes=DIR Endace DAG include directory], +[ + # User wants DAG support and has specified a header directory, so use the provided value. + want_dag=yes + dag_include_dir=$withval +],[]) + +AC_ARG_WITH([dag-libraries], [ --with-dag-libraries=DIR Endace DAG library directory], +[ + # User wants DAG support and has specified a library directory, so use the provided value. + want_dag=yes + dag_lib_dir=$withval +],[]) + case "$V_PCAP" in linux|bpf|dag) # @@ -285,60 +301,167 @@ linux|bpf|dag) # If they expressed no preference, don't include it. # if test $want_dag = yes; then - AC_MSG_ERROR(DAG support only available with 'linux' 'bpf' and 'dag' packet capture types) + AC_MSG_ERROR([DAG support is only available with 'linux' 'bpf' and 'dag' packet capture types]) elif test $want_dag = yes; then want_dag=no fi ;; esac -if test "$with_dag" != no; then - AC_MSG_CHECKING(whether we have DAG API) +ac_cv_lbl_dag_api=no +if test "$want_dag" != no; then + AC_MSG_CHECKING([whether we have DAG API headers]) + + # If necessary, set default paths for DAG API headers and libraries. if test -z "$dag_root"; then - dag_root=$srcdir/../dag + dag_root=/usr/local fi - if test -r "$dag_root/tools" -a -r "$dag_root/include"; then - dag_tools_dir="$dag_root/tools" + if test -z "$dag_include_dir"; then dag_include_dir="$dag_root/include" - else - dag_tools_dir="$dag_root" - dag_include_dir="$dag_root" fi - ac_cv_lbl_dag_api=no - if test -r "$dag_include_dir/dagapi.h" -a -r "$dag_tools_dir/dagapi.o" -a -r "$dag_tools_dir/dagopts.o"; then - V_INCLS="$V_INCLS -I $dag_include_dir" - V_LIBS="$V_LIBS $dag_tools_dir/dagapi.o $dag_tools_dir/dagopts.o" - if test "$V_PCAP" != dag ; then - SSRC="pcap-dag.c" + if test -z "$dag_lib_dir"; then + dag_lib_dir="$dag_root/lib" + fi + + if test -z "$dag_tools_dir"; then + dag_tools_dir="$dag_root/tools" fi + + if test -r $dag_include_dir/dagapi.h; then ac_cv_lbl_dag_api=yes fi - if test -r "$dag_root/lib/dagreg.c"; then # DAG 2.5.x - if test -r "$dag_tools_dir/dagreg.o"; then - V_LIBS="$V_LIBS $dag_tools_dir/dagreg.o" - else + AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)]) +fi + +if test $ac_cv_lbl_dag_api = yes; then + + AC_MSG_CHECKING([dagapi.o]) + dagapi_obj=no + if test -r $dag_tools_dir/dagapi.o; then + + # 2.4.x. + dagapi_obj=$dag_tools_dir/dagapi.o + + elif test -r $dag_lib_dir/dagapi.o; then + + # 2.5.x. + dagapi_obj=$dag_lib_dir/dagapi.o + + elif test -r $dag_lib_dir/libdag.a; then + + # 2.5.x. + ar x $dag_lib_dir/libdag.a dagapi.o + if test -r ./dagapi.o; then + dagapi_obj=./dagapi.o + fi + fi + + if test $dagapi_obj = no; then + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) ac_cv_lbl_dag_api=no - fi - fi - dag_version= - if test $ac_cv_lbl_dag_api = yes -a -r "$dag_root/VERSION"; then - dag_version=" (`cat $dag_root/VERSION`)" - fi - AC_MSG_RESULT($ac_cv_lbl_dag_api$dag_version) - if test $ac_cv_lbl_dag_api = no; then - if test "$want_dag" = yes; then - AC_MSG_ERROR(DAG API not found under directory $dag_root; use --without-dag) - fi else - AC_DEFINE(HAVE_DAG_API, 1, [define if you have a DAG API]) + AC_MSG_RESULT([yes ($dagapi_obj)]) + fi +fi + +if test $ac_cv_lbl_dag_api = yes; then + + AC_MSG_CHECKING([dagopts.o]) + dagopts_obj=no + if test -r $dag_tools_dir/dagopts.o; then + + # 2.4.x. + dagopts_obj=$dag_tools_dir/dagopts.o + + elif test -r $dag_lib_dir/dagopts.o; then + + # 2.5.x. + dagopts_obj=$dag_lib_dir/dagopts.o + + elif test -r $dag_lib_dir/libdag.a; then + + # 2.5.x. + ar x $dag_lib_dir/libdag.a dagopts.o + if test -r ./dagopts.o; then + dagopts_obj=./dagopts.o + fi + fi + + if test $dagopts_obj = no; then + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) + ac_cv_lbl_dag_api=no + else + AC_MSG_RESULT([yes ($dagopts_obj)]) fi fi -if test "$V_PCAP" = dag -a "$ac_cv_lbl_dag_api" = no; then - AC_MSG_ERROR(Specifying the capture type as 'dag' requires the DAG API to be present; use --with-dag=DIR) +if test $ac_cv_lbl_dag_api = yes; then + + # Under 2.5.x only we need to add dagreg.o. + if test -r $dag_include_dir/dagreg.h; then + + AC_MSG_CHECKING([dagreg.o]) + dagreg_obj=no + if test -r $dag_lib_dir/dagreg.o; then + + # Object file is ready and waiting. + dagreg_obj=$dag_lib_dir/dagreg.o + + elif test -r $dag_lib_dir/libdag.a; then + + # Extract from libdag.a. + ar x $dag_lib_dir/libdag.a dagreg.o + if test -r ./dagreg.o; then + dagreg_obj=./dagreg.o + fi + fi + + if test $dagreg_obj = no; then + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)]) + ac_cv_lbl_dag_api=no + else + AC_MSG_RESULT([yes ($dagreg_obj)]) + fi + fi +fi + +if test $ac_cv_lbl_dag_api = yes; then + + V_INCLS="$V_INCLS -I$dag_include_dir" + V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj" + if test $V_PCAP != dag ; then + SSRC="pcap-dag.c" + fi + + # See if we can find a general version string. + # Don't need to save and restore LIBS to prevent -ldag being included if there's a found-action (arg 3). + saved_ldflags=$LDFLAGS + LDFLAGS="-L$dag_lib_dir" + AC_CHECK_LIB([dag], [dag_attach_stream], [dag_version="2.5.x"], [dag_version="2.4.x"]) + LDFLAGS=$saved_ldflags + + # See if we can find a specific version string. + AC_MSG_CHECKING([the DAG API version]) + if test -r "$dag_root/VERSION"; then + dag_version="`cat $dag_root/VERSION`" + fi + AC_MSG_RESULT([$dag_version]) + AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) +fi + +if test $ac_cv_lbl_dag_api = no; then + if test "$want_dag" = yes; then + # User wanted DAG support but we couldn't find it. + AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag]) + fi + + if test "$V_PCAP" = dag; then + # User requested "dag" capture type but the DAG API wasn't found. + AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)]) + fi fi @@ -405,6 +528,7 @@ sinix*) solaris*) AC_DEFINE(HAVE_SOLARIS,1,[On solaris]) ;; + darwin*) DYEXT="dylib" V_CCOPT="$V_CCOPT -fno-common"