Skip to content

Instantly share code, notes, and snippets.

@ahf
Created February 9, 2018 18:42
Show Gist options
  • Save ahf/1212c08af8570d46dd073bd854a656c2 to your computer and use it in GitHub Desktop.
Save ahf/1212c08af8570d46dd073bd854a656c2 to your computer and use it in GitHub Desktop.
diff --git a/configure.ac b/configure.ac
index 3cb187b..a567b6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -952,6 +952,35 @@ if test "x$have_zstd" = "xyes"; then
AC_DEFINE(HAVE_ZSTD,1,[Have Zstd])
TOR_ZSTD_CFLAGS="${ZSTD_CFLAGS}"
TOR_ZSTD_LIBS="${ZSTD_LIBS}"
+
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
+ LIBS="$TOR_ZSTD_LIBS $LIBS"
+ LDFLAGS="$TOR_ZSTD_LIBS $LDFLAGS"
+
+ AC_MSG_CHECKING([whether we can link against libzstd])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <stdio.h>
+ #include <zstd.h>
+ int main(int argc, char **argv)
+ {
+ size_t v = ZSTD_versionNumber();
+ printf("%d.%d.%d", (int)v / 10000 % 100,
+ (int)v / 100 % 100,
+ (int)v % 100);
+ return 0;
+ }
+ ]], [$TOR_ZSTD_CFLAGS $TOR_ZSTD_LIBS])],
+ [zstd_linkable=yes; AC_MSG_RESULT([yes])],
+ [zstd_linkable=no; AC_MSG_RESULT([no])])
+
+ if test "x$zstd_linkable" = "xno" ; then
+ AC_MSG_ERROR([Unable to link against libzstd.])
+ fi
+
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
fi
AC_SUBST(TOR_ZSTD_CFLAGS)
AC_SUBST(TOR_ZSTD_LIBS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment