X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=m4%2Fax_check_atm.m4;fp=m4%2Fax_check_atm.m4;h=004fe9f351a046ff92f6b864ff74005aa27c530c;hb=2883dd07101bf851e2ea368f0c04c91aea85cff2;hp=0000000000000000000000000000000000000000;hpb=9c7ba0d42dee5e3f84ecb6e4fcdbefc6c1cd965c;p=ppp.git diff --git a/m4/ax_check_atm.m4 b/m4/ax_check_atm.m4 new file mode 100644 index 0000000..004fe9f --- /dev/null +++ b/m4/ax_check_atm.m4 @@ -0,0 +1,93 @@ +# SYNOPSIS +# +# AX_CHECK_ATM([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for libatm in a number of default locations, or in a provided location +# (via --with-atm=). Sets +# ATM_CFLAGS +# ATM_LDFLAGS +# ATM_LIBS +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# LICENSE +# +# Copyright (c) 2021 Eivind Naess +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_CHECK_ATM], [ + AC_ARG_WITH([atm], + [AS_HELP_STRING([--with-atm=DIR], + [With libatm support, see http://linux-atm.sourceforge.net])], + [ + case "$withval" in + "" | y | ye | yes) + atmdirs="/usr/local /usr/lib /usr" + ;; + n | no) + with_atm="no" + ;; + *) + atmdirs="$withval" + ;; + esac + ]) + + if [ test "x${with_atm}" != "xno" ] ; then + ATM_LIBS="-latm" + for atmdir in $atmdirs; do + AC_MSG_CHECKING([for atm.h in $atmdir]) + if test -f "$atmdir/include/atm.h"; then + ATM_CFLAGS="-I$atmdir/include" + ATM_LDFLAGS="-L$atmdir/lib" + AC_MSG_RESULT([yes]) + break + else + AC_MSG_RESULT([no]) + fi + done + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + AC_MSG_CHECKING([if compiling and linking against libatm works]) + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $ATM_LDFLAGS" + LIBS="$ATM_LIBS $LIBS" + CPPFLAGS="$ATM_CFLAGS $CPPFLAGS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + #include ], + [text2atm(NULL,NULL,0,0);])], + [ + AC_MSG_RESULT([yes]) + with_atm=yes + $1 + ], [ + AC_MSG_RESULT([no]) + with_atm="" + $2 + ]) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + + AC_SUBST([ATM_CFLAGS]) + AC_SUBST([ATM_LIBS]) + AC_SUBST([ATM_LDFLAGS]) + fi + AM_CONDITIONAL(WITH_LIBATM, test -n "${with_atm}") +]) +