aboutsummaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index cb33dc36c..43280597a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -42,6 +42,48 @@ AC_DEFUN([TOR_DEFINE_CODEPATH],
AC_SUBST(TOR_LDFLAGS_$2)
])
+dnl 1:flags
+AC_DEFUN([TOR_CHECK_CFLAGS], [
+ AS_VAR_PUSHDEF([VAR],[tor_cv_cflags_$1])
+ AC_CACHE_CHECK([whether the compiler accepts $1], VAR, [
+ tor_saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -pedantic -Werror $1"
+ AC_TRY_COMPILE([], [return 0;],
+ [AS_VAR_SET(VAR,yes)],
+ [AS_VAR_SET(VAR,no)])
+ CFLAGS="$tor_saved_CFLAGS"
+ ])
+ if test x$VAR = xyes; then
+ CFLAGS="$CFLAGS $1"
+ fi
+ AS_VAR_POPDEF([VAR])
+])
+
+dnl 1:flags
+dnl 2:extra ldflags
+dnl 3:extra libraries
+AC_DEFUN([TOR_CHECK_LDFLAGS], [
+ AS_VAR_PUSHDEF([VAR],[tor_cv_ldflags_$1])
+ AC_CACHE_CHECK([whether the linker accepts $1], VAR, [
+ tor_saved_CFLAGS="$CFLAGS"
+ tor_saved_LDFLAGS="$LDFLAGS"
+ tor_saved_LIBS="$LIBS"
+ CFLAGS="$CFLAGS -pedantic -Werror"
+ LDFLAGS="$LDFLAGS $2 $1"
+ LIBS="$LIBS $3"
+ AC_TRY_LINK([], [return 0;],
+ [AS_VAR_SET(VAR,yes)],
+ [AS_VAR_SET(VAR,no)])
+ CFLAGS="$tor_saved_CFLAGS"
+ LDFLAGS="$tor_saved_LDFLAGS"
+ LIBS="$tor_saved_LIBS"
+ ])
+ if test x$VAR = xyes; then
+ LDFLAGS="$LDFLAGS $1"
+ fi
+ AS_VAR_POPDEF([VAR])
+])
+
dnl 1:libname
AC_DEFUN([TOR_WARN_MISSING_LIB], [
h=""