aboutsummaryrefslogtreecommitdiff
path: root/contrib/gnunet.m4
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gnunet.m4')
-rw-r--r--contrib/gnunet.m472
1 files changed, 72 insertions, 0 deletions
diff --git a/contrib/gnunet.m4 b/contrib/gnunet.m4
new file mode 100644
index 000000000..6d9332db3
--- /dev/null
+++ b/contrib/gnunet.m4
@@ -0,0 +1,72 @@
1# Autoconf macro for working with GNUnet
2# This file is in the public domain.
3#
4# AM_PATH_GNUNET([MINIMUM-VERSION = 0.15.3, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
5# Find the GNUnet installation, either automatically or through the
6# --with-gnunet-prefix flag
7#
8# This macro runs the pkg-config and, if needed, the gnunet-config tool
9# provided by GNUnet itself.
10#
11# The gnunet-config tool can be overridden by setting the GNUNET_CONFIG
12# variable before executing the configure script.
13#
14# The variables GNUNET_CFLAGS and GNUNET_LIBS will be set to appropriate
15# values and are made available to Automake.
16AC_DEFUN([AM_PATH_GNUNET],
17[AC_ARG_WITH([gnunet-prefix],
18 [AS_HELP_STRING([--with-gnunet-prefix=PATH],
19 [PATH to the GNUnet installation])],
20 [gnunet_prefix="$withval"],
21 [gnunet_prefix=""])
22 AC_ARG_ENABLE([debug-log],
23 [AS_HELP_STRING([--disable-debug-log],
24 [Disable all DEBUG-level logging])],
25 [],
26 [enable_debug_log=yes])
27 AC_ARG_VAR([GNUNET_CONFIG],[The gnunet-config tool])
28 min_gnunet_version=m4_if([$1], ,0.15.3,$1)
29 # Make sure the specified version is at least the version with
30 # the features required to use this macro
31 AS_VERSION_COMPARE([$min_gnunet_version],[0.15.3],
32 [AC_MSG_WARN([The specified GNUnet version $min_gnunet_version is too old.])
33 AC_MSG_WARN([The minimum version has been set to 0.15.3])
34 min_gnunet_version="0.15.3"])
35 AS_IF([test "x${GNUNET_CONFIG+set}" != "xset"],
36 [PKG_CHECK_MODULES([GNUNET],[gnunetutil >= $min_gnunet_version],
37 [gnunet_pkgconfig=yes],[gnunet_pkgconfig=no])
38 AS_IF([test "x$gnunet_pkgconfig" = "xno" && test "x$gnunet_prefix" != "x"],
39 [gnunet_PATH="$PATH"
40 AS_IF([test "x$prefix" != "xNONE"],
41 [gnunet_PATH="$prefix/bin${PATH_SEPARATOR}$prefix/usr/bin"])
42 AC_PATH_PROG([GNUNET_CONFIG],[gnunet-config],[no],[$gnunet_PATH])
43 AS_UNSET([gnunet_PATH])],
44 [GNUNET_CONFIG="pkg-config gnunetutil"])])
45 AC_MSG_CHECKING([if GNUnet version is >= $min_gnunet_version])
46 gnunet_result=no
47 AS_IF([test "x$GNUNET_CONFIG" != "xno" && test -n "$GNUNET_CONFIG"],
48 [gnunet_version=`$GNUNET_CONFIG --version | tr ' ' '\n' | sed -n '2p'`
49 AS_VERSION_COMPARE([$gnunet_version],[$min_gnunet_version],
50 [gnunet_result=no],
51 [gnunet_result=yes],
52 [gnunet_result=yes])
53 AS_UNSET([gnunet_version])])
54 AS_IF([test "x$gnunet_result" != "xyes"],
55 [AC_MSG_RESULT([no])
56 m4_if([$3], ,:,[$3])],
57 [AC_MSG_RESULT([yes])
58 m4_if([$2], ,:,[$2])
59 AC_CHECK_HEADERS([sys/socket.h netinet/in.h byteswap.h])
60 AS_IF([test "x${GNUNET_CFLAGS+set}" != "xset"],
61 [GNUNET_CFLAGS=`$GNUNET_CONFIG --cflags`
62 AC_SUBST([GNUNET_CFLAGS])])
63 AS_IF([test "x${GNUNET_LIBS+set}" != "xset"],
64 [GNUNET_LIBS=`$GNUNET_CONFIG --libs`
65 AC_SUBST([GNUNET_LIBS])])
66 AS_IF([test "x$enable_debug_log" = "xno"],
67 [AC_DEFINE([GNUNET_EXTRA_LOGGING],
68 [0],
69 [0 if debug messages should be culled])])])
70 AS_UNSET([gnunet_result])
71 AS_UNSET([min_gnunet_version])
72])