Створюю невеличку програму, що використовує libnet.Що треба занести в configure.in, аби була можливість використовувати результатиlibnet-config --cflagslibnet-config --definesпід час генерації Makefile за допомогою configure ?
dnl ##################################################dnl Checks for libnet (shamelessly horked from dsniff)dnl ##################################################AC_MSG_CHECKING(for libnet)AC_ARG_WITH(libnet,[ --with-libnet=DIR use libnet in DIR],[ case "$withval" in yes|no) AC_MSG_RESULT(no) ;; *) AC_MSG_RESULT($withval) if test -f $withval/include/libnet.h -a -f $withval/lib/libnet.a; then owd=`pwd` if cd $withval; then withval=`pwd` cd $owd fi LNETINC="-I$withval/include" LNETINCDIR="$withval/include" LNETLIB="-L$withval/lib -lnet" else AC_ERROR(libnet.h or libnet.a not found in $withval) fi ;; esac ],[ if test -f ${prefix}/include/libnet.h; then LNETINC="-I${prefix}/include" LNETINCDIR="$prefix/include" LNETLIB="-L${prefix}/lib -lnet" elif test -f /usr/include/libnet.h; then LNETINCDIR="/usr/include" LNETLIB="-lnet" else AC_MSG_RESULT(no) AC_ERROR(libnet not found) fi AC_MSG_RESULT(yes) ])AC_SUBST(LNETINC)AC_SUBST(LNETLIB)OLDLIBS="$LIBS"LIBS="$LNETLIB"dnl Check to see what version of libnetdnl this code has been reduced a lot, but probably still could bednl reduced quite a bit more if we chose tooAC_MSG_CHECKING(for libnet version)AC_TRY_RUN([#include <string.h>#define LIBNET_LIL_ENDIAN 1#include "$LNETINCDIR/libnet.h"#define LIB_TEST "1.0"/* * simple proggy to test the version of libnet * returns zero if it's 1.0.x * or one otherwise */intmain (int argc, char *argv[]){ if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0) exit(0); exit(1);}], libnet_ver_10=yes AC_MSG_RESULT(1.0.x), libnet_ver_10=no, libnet_ver_10=no )AC_TRY_RUN([#include <string.h>#include "$LNETINCDIR/libnet.h"#define LIB_TEST "1.1"/* * simple proggy to test the version of libnet * returns zero if it's 1.0.x * or one otherwise */intmain (int argc, char *argv[]){ if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0) exit(0); exit(1);}], libnet_ver_11=yes AC_MSG_RESULT(1.1.x), libnet_ver_11=no, libnet_ver_11=no )if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then AC_MSG_RESULT(unknown) AC_MSG_ERROR(Unable to determine version of libnet)fiif test $libnet_ver_10 = yes ; then AC_MSG_ERROR(Libnet version 1.0.x is no longer supported. Please upgrade to 1.1.0 or better)fidnl restore LIBSLIBS="$OLDLIBS"
INCS = ... @LNETINC@LIBS = ... @LNETLIB@