]> git.meshlink.io Git - meshlink/commitdiff
Add a better autoconf check for libevent.
authorGuus Sliepen <guus@sliepen.eu.org>
Wed, 16 Sep 2009 21:43:19 +0000 (23:43 +0200)
committerGuus Sliepen <guus@sliepen.eu.org>
Wed, 16 Sep 2009 21:43:19 +0000 (23:43 +0200)
configure.in
m4/libevent.m4 [new file with mode: 0644]

index 0561af8b8f7e9272ca4bf27e9fa20cd337c92a6f..2dba9bed51cda082c215c61e1f740aaeb0852019 100644 (file)
@@ -95,11 +95,6 @@ if test -d /sw/lib ; then
   LIBS="$LIBS -L/sw/lib"
 fi
 
-dnl Checks for libraries.
-
-AC_CHECK_LIB(event, event_init,
-  [], [AC_MSG_ERROR(libevent is required)])
-
 dnl Checks for header files.
 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
 
@@ -158,6 +153,7 @@ dnl These are defined in files in m4/
 
 AC_ARG_WITH(libgcrypt, AC_HELP_STRING([--with-libgcrypt], [enable use of libgcrypt instead of OpenSSL])], [])
 
+tinc_LIBEVENT
 tinc_ZLIB
 tinc_LZO
 
diff --git a/m4/libevent.m4 b/m4/libevent.m4
new file mode 100644 (file)
index 0000000..9bc9ae1
--- /dev/null
@@ -0,0 +1,33 @@
+dnl Check to find the libevent headers/libraries
+
+AC_DEFUN([tinc_LIBEVENT],
+[
+  AC_ARG_WITH(libevent,
+    AS_HELP_STRING([--with-libevent=DIR], [libevent base directory, or:]),
+    [libevent="$withval"
+     CPPFLAGS="$CPPFLAGS -I$withval/include"
+     LDFLAGS="$LDFLAGS -L$withval/lib"]
+  )
+
+  AC_ARG_WITH(libevent-include,
+    AS_HELP_STRING([--with-libevent-include=DIR], [libevent headers directory]),
+    [libevent_include="$withval"
+     CPPFLAGS="$CPPFLAGS -I$withval"]
+  )
+
+  AC_ARG_WITH(libevent-lib,
+    AS_HELP_STRING([--with-libevent-lib=DIR], [libevent library directory]),
+    [libevent_lib="$withval"
+     LDFLAGS="$LDFLAGS -L$withval"]
+  )
+
+  AC_CHECK_HEADERS(event.h,
+    [],
+    [AC_MSG_ERROR("libevent header files not found."); break]
+  )
+
+  AC_CHECK_LIB(event, event_init,
+    [LIBS="$LIBS -levent"],
+    [AC_MSG_ERROR("libevent libraries not found.")]
+  )
+])