aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/Makefile.am4
-rw-r--r--contrib/gnunet.m472
-rw-r--r--doc/man/gnunet-config.125
-rw-r--r--src/util/gnunet-config.c52
4 files changed, 146 insertions, 7 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index f42fb684d..150e47ff0 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -53,6 +53,7 @@ EXTRA_DIST = \
53 conf/gnunet/gnunet-user.conf \ 53 conf/gnunet/gnunet-user.conf \
54 conf/nss/nssswitch.conf \ 54 conf/nss/nssswitch.conf \
55 conf/wireshark/wireshark.lua \ 55 conf/wireshark/wireshark.lua \
56 gnunet.m4 \
56 $(PACKAGES_FILES) \ 57 $(PACKAGES_FILES) \
57 $(INITD_FILES) \ 58 $(INITD_FILES) \
58 Makefile.inc \ 59 Makefile.inc \
@@ -77,3 +78,6 @@ test_gnunet_prefix_LDADD = \
77 $(LTLIBICONV) \ 78 $(LTLIBICONV) \
78 $(GN_LIBINTL) \ 79 $(GN_LIBINTL) \
79 $(LIBLTDL) -lunistring $(XLIB) 80 $(LIBLTDL) -lunistring $(XLIB)
81
82aclocaldir = $(datadir)/aclocal
83aclocal_DATA = gnunet.m4
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])
diff --git a/doc/man/gnunet-config.1 b/doc/man/gnunet-config.1
index 03f180c29..c749c03b5 100644
--- a/doc/man/gnunet-config.1
+++ b/doc/man/gnunet-config.1
@@ -26,33 +26,44 @@
26.Os 26.Os
27.Sh NAME 27.Sh NAME
28.Nm gnunet-config 28.Nm gnunet-config
29.Nd manipulate GNUnet configuration files 29.Nd manipulate GNUnet configuration files and provide informations on how GNUnet was built
30.Sh SYNOPSIS 30.Sh SYNOPSIS
31.Nm 31.Nm
32.Op Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND 32.Op Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND
33.Op Fl C | -cflags
33.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME 34.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
35.Op Fl F | -full
34.Op Fl f | -filename 36.Op Fl f | -filename
35.Op Fl h | -help 37.Op Fl h | -help
38.Op Fl j | -libs
36.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL 39.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
37.Op Fl o Ar OPTION | Fl -option= Ns Ar OPTION 40.Op Fl o Ar OPTION | Fl -option= Ns Ar OPTION
41.Op Fl p | -prefix
42.Op Fl r | -rewrite
38.Op Fl S |-list-sections 43.Op Fl S |-list-sections
39.Op Fl s Ar SECTION | Fl -section= Ns Ar SECTION 44.Op Fl s Ar SECTION | Fl -section= Ns Ar SECTION
40.Op Fl V Ar VALUE | Fl -value Ar VALUE 45.Op Fl V Ar VALUE | Fl -value Ar VALUE
41.Op Fl v | -version 46.Op Fl v | -version
42.Op Fl r | -rewrite
43.Op Fl F | -full
44.Sh DESCRIPTION 47.Sh DESCRIPTION
45.Nm 48.Nm
46can be used to read or modify GNUnet configuration files. 49can be used to read or modify GNUnet configuration files.
50It can also provide informations to properly build applications on top of
51GNUnet, like appropriate values for CFLAGS or the installation prefix.
47.Bl -tag -width indent 52.Bl -tag -width indent
48.It Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND 53.It Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND
49Tests whether the specified BACKEND is supported by the current installation. The backend must match the name of a plugin, e.g. "namestore_postgres" for the Postgres database backend of the "NAMESTORE" service. If the BACKEND is supported, gnunet-config will return a status code of 0 (success), otherwise 77 (unsupported). When this option is specified, no other options may be specified. Specifying this option together with other options will cause gnunet-config to return a status code of 1 (error). 54Tests whether the specified BACKEND is supported by the current installation. The backend must match the name of a plugin, e.g. "namestore_postgres" for the Postgres database backend of the "NAMESTORE" service. If the BACKEND is supported, gnunet-config will return a status code of 0 (success), otherwise 77 (unsupported). When this option is specified, no other options may be specified. Specifying this option together with other options will cause gnunet-config to return a status code of 1 (error).
55.It Fl C | -cflags
56Print an appropriate value for CFLAGS to compile applications on top of GNUnet.
50.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME 57.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
51Use the configuration file FILENAME. 58Use the configuration file FILENAME.
59.It Fl F | -full
60Write the full configuration, not just the deltas to the defaults.
52.It Fl f | -filename 61.It Fl f | -filename
53Try to perform expansions as if the option values represent filenames (will also be applied even if the option is not really a filename). 62Try to perform expansions as if the option values represent filenames (will also be applied even if the option is not really a filename).
54.It Fl h | -help 63.It Fl h | -help
55Print short help on options. 64Print short help on options.
65.It Fl j | -libs
66Print an appropriate value for LIBS to compile applications on top of GNUnet.
56.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL 67.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
57Use LOGLEVEL for logging. 68Use LOGLEVEL for logging.
58Valid values are DEBUG, INFO, WARNING and ERROR. 69Valid values are DEBUG, INFO, WARNING and ERROR.
@@ -60,6 +71,10 @@ Valid values are DEBUG, INFO, WARNING and ERROR.
60Which configuration option should be accessed or edited. 71Which configuration option should be accessed or edited.
61Required to set a value. 72Required to set a value.
62If not given, all values of a given section will be printed in the format "OPTION = VALUE". 73If not given, all values of a given section will be printed in the format "OPTION = VALUE".
74.It Fl p | -prefix
75Print GNUnet's installation prefix (for example /usr/local.)
76.It Fl r | -rewrite
77Write the configuration to file, even if it did not change.
63.It Fl S |-list-sections 78.It Fl S |-list-sections
64List available configuration sections for use with --section. 79List available configuration sections for use with --section.
65.It Fl s Ar SECTION | Fl -section= Ns Ar SECTION 80.It Fl s Ar SECTION | Fl -section= Ns Ar SECTION
@@ -70,10 +85,6 @@ Configuration value to store in the given section under the given option.
70Must only be given together with -s and -o options. 85Must only be given together with -s and -o options.
71.It Fl v | -version 86.It Fl v | -version
72Print GNUnet version number. 87Print GNUnet version number.
73.It Fl r | -rewrite
74Write the configuration to file, even if it did not change.
75.It Fl F | -full
76Write the full configuration, not just the deltas to the defaults.
77.El 88.El
78.Sh SEE ALSO 89.Sh SEE ALSO
79The full documentation for gnunet is maintained as a Texinfo manual. 90The full documentation for gnunet is maintained as a Texinfo manual.
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 797de0b0d..a195d6014 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -36,6 +36,23 @@ static char *backend_check;
36 36
37 37
38/** 38/**
39 * If printing the value of CFLAGS has been requested.
40 */
41static int cflags;
42
43/**
44 * If printing the value of LIBS has been requested.
45 */
46static int libs;
47
48/**
49 * If printing the value of PREFIX has been requested.
50 */
51static int prefix;
52
53
54/**
55 * Print each option in a given section.
39 * Main task to run to perform operations typical for 56 * Main task to run to perform operations typical for
40 * gnunet-config as per the configuration settings 57 * gnunet-config as per the configuration settings
41 * given in @a cls. 58 * given in @a cls.
@@ -54,6 +71,26 @@ run (void *cls,
54{ 71{
55 struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls; 72 struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
56 73
74 if (1 == cflags || 1 == libs || 1 == prefix)
75 {
76 char *prefixdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
77 char *libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR);
78 if (1 == cflags)
79 {
80 fprintf (stdout, "-I%sinclude\n", prefixdir);
81 }
82 if (1 == libs)
83 {
84 fprintf (stdout, "-L%s -lgnunetutil\n", libdir);
85 }
86 if (1 == prefix)
87 {
88 fprintf (stdout, "%s\n", prefixdir);
89 }
90 GNUNET_free (prefixdir);
91 GNUNET_free (libdir);
92 return;
93 }
57 if (NULL != backend_check) 94 if (NULL != backend_check)
58 { 95 {
59 char *name; 96 char *name;
@@ -97,6 +134,21 @@ main (int argc,
97 gettext_noop ( 134 gettext_noop (
98 "test if the current installation supports the specified BACKEND"), 135 "test if the current installation supports the specified BACKEND"),
99 &backend_check)), 136 &backend_check)),
137 GNUNET_GETOPT_option_flag ('C',
138 "cflags",
139 gettext_noop (
140 "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"),
141 &cflags),
142 GNUNET_GETOPT_option_flag ('j',
143 "libs",
144 gettext_noop (
145 "Provide an appropriate value for LIBS to applications building on top of GNUnet"),
146 &libs),
147 GNUNET_GETOPT_option_flag ('p',
148 "prefix",
149 gettext_noop (
150 "Provide the path under which GNUnet was installed"),
151 &prefix),
100 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs), 152 GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
101 GNUNET_GETOPT_OPTION_END 153 GNUNET_GETOPT_OPTION_END
102 }; 154 };