1 # Usage: 2 # DC_ASK_OPTLIB(library, function, header, description, packagename, libdefine, headerdefine) 3 # Only the last argument is optional, because they will only be defined if both the lib 4 # and header are found 5 # Example: 6 # DC_ASK_OPTLIB(z, compress2, zlib.h, [ Support zlib], zlib, HAVE_LIBZ, HAVE_ZLIB_H) 7 AC_DEFUN(DC_ASK_OPTLIB, [ 8 AC_ARG_WITH($5, [ --with-$5 $4], [ 9 # Specified 10 LIBSPEC=$withval 11 ], [ 12 # Not specified 13 LIBSPECFLAGS=`pkg-config --libs $5 2>/dev/null` 14 LIBSPECCFLAGS=`pkg-config --cflags $5 2>/dev/null` 15 AC_CHECK_LIB($1, $2, [ 16 OLDCPPFLAGS="$CPPFLAGS" 17 OLDCFLAGS="$CFLAGS" 18 CPPFLAGS="$CPPFLAGS $LIBSPECCFLAGS" 19 CFLAGS="$CFLAGS $LIBSPECCFLAGS" 20 AC_CHECK_HEADER($3, [ 21 LIBSPEC=yes 22 ], [ 23 LIBSPEC=no 24 ]) 25 CPPFLAGS="$OLDCPPFLAGS" 26 CFLAGS="$OLDCFLAGS" 27 ], [ 28 LIBSPEC=no 29 AC_MSG_WARN(Didn't find $5) 30 ], $LIBSPECFLAGS) 31 ]) 32 case $LIBSPEC in 33 no) 34 AC_MSG_WARN(Support for $5 disabled) 35 ;; 36 *) 37 if test "${LIBSPEC}" = "yes"; then 38 true 39 else 40 LIBSPECFLAGS="-L${LIBSPEC}/lib ${LIBSPECFLAGS}" 41 LIBSPECCFLAGS="-I${LIBSPEC}/include ${LIBSPECCFLAGS}" 42 fi 43 AC_CHECK_LIB($1, $2, [ 44 OLDCFLAGS="$CFLAGS" 45 OLDCPPFLAGS="$CPPFLAGS" 46 CPPFLAGS="$CPPFLAGS ${LIBSPECCFLAGS}" 47 CFLAGS="$CFLAGS ${LIBSPECCFLAGS}" 48 AC_CHECK_HEADER($3, [ 49 if test -n "$7"; then 50 AC_DEFINE($7, [1], [Define to 1 if you have the <$3> header file.]) 51 fi 52 if test -n "$6"; then 53 AC_DEFINE($6, [1], [Define to 1 if you have $2 from $5]) 54 fi 55 LDFLAGS="$LDFLAGS $LIBSPECFLAGS" 56 LIBS="$LIBS -l$1" 57 ], [ 58 CFLAGS="$OLDCFLAGS" 59 CPPFLAGS="$OLDCPPFLAGS" 60 AC_MSG_ERROR(Could not find $3) 61 ]) 62 ], [ 63 AC_MSG_ERROR(Could not find $5) 64 ], $LIBSPECFLAGS) 65 ;; 66 esac 67 ]) |