summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2021-09-17 18:59:13 +0200
committerAlessio Vanni <vannilla@firemail.cc>2021-09-17 18:59:13 +0200
commitad9c10e6e660c45c8da630a7ea0f8c013a6661e2 (patch)
tree454a5c1f86bffe60308bcf8ceb309a8388fc50b1
parent5df20a349cabc2ebd3747292be97239fdf837386 (diff)
parentc7ed99ce83e15bab7fc7240a77da703d98a06edd (diff)
Merge branch 'dev/vanni/build-info' into 'master'
-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.c59
4 files changed, 153 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 = \
conf/gnunet/gnunet-user.conf \
conf/nss/nssswitch.conf \
conf/wireshark/wireshark.lua \
+ gnunet.m4 \
$(PACKAGES_FILES) \
$(INITD_FILES) \
Makefile.inc \
@@ -77,3 +78,6 @@ test_gnunet_prefix_LDADD = \
$(LTLIBICONV) \
$(GN_LIBINTL) \
$(LIBLTDL) -lunistring $(XLIB)
+
+aclocaldir = $(datadir)/aclocal
+aclocal_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 @@
+# Autoconf macro for working with GNUnet
+# This file is in the public domain.
+#
+# AM_PATH_GNUNET([MINIMUM-VERSION = 0.15.3, [ACTION-IF-FOUND, [ACTION-IF-NOT-FOUND]]])
+# Find the GNUnet installation, either automatically or through the
+# --with-gnunet-prefix flag
+#
+# This macro runs the pkg-config and, if needed, the gnunet-config tool
+# provided by GNUnet itself.
+#
+# The gnunet-config tool can be overridden by setting the GNUNET_CONFIG
+# variable before executing the configure script.
+#
+# The variables GNUNET_CFLAGS and GNUNET_LIBS will be set to appropriate
+# values and are made available to Automake.
+AC_DEFUN([AM_PATH_GNUNET],
+[AC_ARG_WITH([gnunet-prefix],
+ [AS_HELP_STRING([--with-gnunet-prefix=PATH],
+ [PATH to the GNUnet installation])],
+ [gnunet_prefix="$withval"],
+ [gnunet_prefix=""])
+ AC_ARG_ENABLE([debug-log],
+ [AS_HELP_STRING([--disable-debug-log],
+ [Disable all DEBUG-level logging])],
+ [],
+ [enable_debug_log=yes])
+ AC_ARG_VAR([GNUNET_CONFIG],[The gnunet-config tool])
+ min_gnunet_version=m4_if([$1], ,0.15.3,$1)
+ # Make sure the specified version is at least the version with
+ # the features required to use this macro
+ AS_VERSION_COMPARE([$min_gnunet_version],[0.15.3],
+ [AC_MSG_WARN([The specified GNUnet version $min_gnunet_version is too old.])
+ AC_MSG_WARN([The minimum version has been set to 0.15.3])
+ min_gnunet_version="0.15.3"])
+ AS_IF([test "x${GNUNET_CONFIG+set}" != "xset"],
+ [PKG_CHECK_MODULES([GNUNET],[gnunetutil >= $min_gnunet_version],
+ [gnunet_pkgconfig=yes],[gnunet_pkgconfig=no])
+ AS_IF([test "x$gnunet_pkgconfig" = "xno" && test "x$gnunet_prefix" != "x"],
+ [gnunet_PATH="$PATH"
+ AS_IF([test "x$prefix" != "xNONE"],
+ [gnunet_PATH="$prefix/bin${PATH_SEPARATOR}$prefix/usr/bin"])
+ AC_PATH_PROG([GNUNET_CONFIG],[gnunet-config],[no],[$gnunet_PATH])
+ AS_UNSET([gnunet_PATH])],
+ [GNUNET_CONFIG="pkg-config gnunetutil"])])
+ AC_MSG_CHECKING([if GNUnet version is >= $min_gnunet_version])
+ gnunet_result=no
+ AS_IF([test "x$GNUNET_CONFIG" != "xno" && test -n "$GNUNET_CONFIG"],
+ [gnunet_version=`$GNUNET_CONFIG --version | tr ' ' '\n' | sed -n '2p'`
+ AS_VERSION_COMPARE([$gnunet_version],[$min_gnunet_version],
+ [gnunet_result=no],
+ [gnunet_result=yes],
+ [gnunet_result=yes])
+ AS_UNSET([gnunet_version])])
+ AS_IF([test "x$gnunet_result" != "xyes"],
+ [AC_MSG_RESULT([no])
+ m4_if([$3], ,:,[$3])],
+ [AC_MSG_RESULT([yes])
+ m4_if([$2], ,:,[$2])
+ AC_CHECK_HEADERS([sys/socket.h netinet/in.h byteswap.h])
+ AS_IF([test "x${GNUNET_CFLAGS+set}" != "xset"],
+ [GNUNET_CFLAGS=`$GNUNET_CONFIG --cflags`
+ AC_SUBST([GNUNET_CFLAGS])])
+ AS_IF([test "x${GNUNET_LIBS+set}" != "xset"],
+ [GNUNET_LIBS=`$GNUNET_CONFIG --libs`
+ AC_SUBST([GNUNET_LIBS])])
+ AS_IF([test "x$enable_debug_log" = "xno"],
+ [AC_DEFINE([GNUNET_EXTRA_LOGGING],
+ [0],
+ [0 if debug messages should be culled])])])
+ AS_UNSET([gnunet_result])
+ AS_UNSET([min_gnunet_version])
+])
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 @@
.Os
.Sh NAME
.Nm gnunet-config
-.Nd manipulate GNUnet configuration files
+.Nd manipulate GNUnet configuration files and provide informations on how GNUnet was built
.Sh SYNOPSIS
.Nm
.Op Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND
+.Op Fl C | -cflags
.Op Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
+.Op Fl F | -full
.Op Fl f | -filename
.Op Fl h | -help
+.Op Fl j | -libs
.Op Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
.Op Fl o Ar OPTION | Fl -option= Ns Ar OPTION
+.Op Fl p | -prefix
+.Op Fl r | -rewrite
.Op Fl S |-list-sections
.Op Fl s Ar SECTION | Fl -section= Ns Ar SECTION
.Op Fl V Ar VALUE | Fl -value Ar VALUE
.Op Fl v | -version
-.Op Fl r | -rewrite
-.Op Fl F | -full
.Sh DESCRIPTION
.Nm
can be used to read or modify GNUnet configuration files.
+It can also provide informations to properly build applications on top of
+GNUnet, like appropriate values for CFLAGS or the installation prefix.
.Bl -tag -width indent
.It Fl b Ar BACKEND | Fl -supported-backend= Ns Ar BACKEND
Tests 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).
+.It Fl C | -cflags
+Print an appropriate value for CFLAGS to compile applications on top of GNUnet.
.It Fl c Ar FILENAME | Fl -config= Ns Ar FILENAME
Use the configuration file FILENAME.
+.It Fl F | -full
+Write the full configuration, not just the deltas to the defaults.
.It Fl f | -filename
Try to perform expansions as if the option values represent filenames (will also be applied even if the option is not really a filename).
.It Fl h | -help
Print short help on options.
+.It Fl j | -libs
+Print an appropriate value for LIBS to compile applications on top of GNUnet.
.It Fl L Ar LOGLEVEL | Fl -loglevel= Ns Ar LOGLEVEL
Use LOGLEVEL for logging.
Valid values are DEBUG, INFO, WARNING and ERROR.
@@ -60,6 +71,10 @@ Valid values are DEBUG, INFO, WARNING and ERROR.
Which configuration option should be accessed or edited.
Required to set a value.
If not given, all values of a given section will be printed in the format "OPTION = VALUE".
+.It Fl p | -prefix
+Print GNUnet's installation prefix (for example /usr/local.)
+.It Fl r | -rewrite
+Write the configuration to file, even if it did not change.
.It Fl S |-list-sections
List available configuration sections for use with --section.
.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.
Must only be given together with -s and -o options.
.It Fl v | -version
Print GNUnet version number.
-.It Fl r | -rewrite
-Write the configuration to file, even if it did not change.
-.It Fl F | -full
-Write the full configuration, not just the deltas to the defaults.
.El
.Sh SEE ALSO
The 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..2ca78577e 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -36,6 +36,25 @@ static char *backend_check;
/**
+ * If printing the value of CFLAGS has been requested.
+ */
+static int cflags;
+
+
+/**
+ * If printing the value of LIBS has been requested.
+ */
+static int libs;
+
+
+/**
+ * If printing the value of PREFIX has been requested.
+ */
+static int prefix;
+
+
+/**
+ * Print each option in a given section.
* Main task to run to perform operations typical for
* gnunet-config as per the configuration settings
* given in @a cls.
@@ -54,6 +73,28 @@ run (void *cls,
{
struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls;
+ if (1 == cflags || 1 == libs || 1 == prefix)
+ {
+ char *prefixdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX);
+ char *libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR);
+
+ if (1 == cflags)
+ {
+ fprintf (stdout, "-I%sinclude\n", prefixdir);
+ }
+ if (1 == libs)
+ {
+ fprintf (stdout, "-L%s -lgnunetutil\n", libdir);
+ }
+ if (1 == prefix)
+ {
+ fprintf (stdout, "%s\n", prefixdir);
+ }
+ cs->global_ret = 0;
+ GNUNET_free (prefixdir);
+ GNUNET_free (libdir);
+ return;
+ }
if (NULL != backend_check)
{
char *name;
@@ -97,6 +138,24 @@ main (int argc,
gettext_noop (
"test if the current installation supports the specified BACKEND"),
&backend_check)),
+ GNUNET_GETOPT_option_flag (
+ 'C',
+ "cflags",
+ gettext_noop (
+ "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"),
+ &cflags),
+ GNUNET_GETOPT_option_flag (
+ 'j',
+ "libs",
+ gettext_noop (
+ "Provide an appropriate value for LIBS to applications building on top of GNUnet"),
+ &libs),
+ GNUNET_GETOPT_option_flag (
+ 'p',
+ "prefix",
+ gettext_noop (
+ "Provide the path under which GNUnet was installed"),
+ &prefix),
GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
GNUNET_GETOPT_OPTION_END
};