Skip to content

Instantly share code, notes, and snippets.

@burmecia
Created May 20, 2016 03:52
Show Gist options
  • Save burmecia/97b1478a5b1d603ebadb2e73804233ef to your computer and use it in GitHub Desktop.
Save burmecia/97b1478a5b1d603ebadb2e73804233ef to your computer and use it in GitHub Desktop.
sample m4 macro to check library
# libsnappy_tests.m4
# gl_LIBSNAPPY_TESTS()
# -------------------
# Check if libsnappy is available.
AC_DEFUN([gl_LIBSNAPPY_TESTS],
[
LIBSNAPPY_LIBS=
LIBSNAPPY_LDFLAGS=
LDFLAGS_SAVE="$LDFLAGS"
if test -n "$LIBSNAPPY_SEARCH_LIBS"; then
LDFLAGS="-L$LIBSNAPPY_SEARCH_LIBS $LDFLAGS"
AC_CHECK_LIB(snappy, snappy_compress,
[
LIBSNAPPY_LDFLAGS="-L$LIBSNAPPY_SEARCH_LIBS"
LIBSNAPPY_LIBS="-lsnappy"
],
[
AC_MSG_ERROR([required library libsnappy was not found in requested location $LIBSNAPPY_SEARCH_LIBS])
]
)
else
AC_CHECK_LIB(snappy, snappy_compress,
[],
[
AC_MSG_ERROR([required library libsnappy was not found on your system, please check https://code.google.com/p/snappy/])
]
)
fi
LDFLAGS="$LDFLAGS_SAVE"
AC_SUBST(LIBSNAPPY_LIBS)
AC_SUBST(LIBSNAPPY_LDFLAGS)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment