diff options
author | Alessio Vanni <vannilla@firemail.cc> | 2021-09-17 18:59:13 +0200 |
---|---|---|
committer | Alessio Vanni <vannilla@firemail.cc> | 2021-09-17 18:59:13 +0200 |
commit | ad9c10e6e660c45c8da630a7ea0f8c013a6661e2 (patch) | |
tree | 454a5c1f86bffe60308bcf8ceb309a8388fc50b1 | |
parent | 5df20a349cabc2ebd3747292be97239fdf837386 (diff) | |
parent | c7ed99ce83e15bab7fc7240a77da703d98a06edd (diff) | |
download | gnunet-ad9c10e6e660c45c8da630a7ea0f8c013a6661e2.tar.gz gnunet-ad9c10e6e660c45c8da630a7ea0f8c013a6661e2.zip |
Merge branch 'dev/vanni/build-info' into 'master'
-rw-r--r-- | contrib/Makefile.am | 4 | ||||
-rw-r--r-- | contrib/gnunet.m4 | 72 | ||||
-rw-r--r-- | doc/man/gnunet-config.1 | 25 | ||||
-rw-r--r-- | src/util/gnunet-config.c | 59 |
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 = \ | |||
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 | |||
82 | aclocaldir = $(datadir)/aclocal | ||
83 | 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 @@ | |||
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. | ||
16 | AC_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 |
46 | can be used to read or modify GNUnet configuration files. | 49 | can be used to read or modify GNUnet configuration files. |
50 | It can also provide informations to properly build applications on top of | ||
51 | GNUnet, 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 |
49 | 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). | 54 | 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). |
55 | .It Fl C | -cflags | ||
56 | Print 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 |
51 | Use the configuration file FILENAME. | 58 | Use the configuration file FILENAME. |
59 | .It Fl F | -full | ||
60 | Write the full configuration, not just the deltas to the defaults. | ||
52 | .It Fl f | -filename | 61 | .It Fl f | -filename |
53 | Try to perform expansions as if the option values represent filenames (will also be applied even if the option is not really a filename). | 62 | Try 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 |
55 | Print short help on options. | 64 | Print short help on options. |
65 | .It Fl j | -libs | ||
66 | Print 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 |
57 | Use LOGLEVEL for logging. | 68 | Use LOGLEVEL for logging. |
58 | Valid values are DEBUG, INFO, WARNING and ERROR. | 69 | Valid values are DEBUG, INFO, WARNING and ERROR. |
@@ -60,6 +71,10 @@ Valid values are DEBUG, INFO, WARNING and ERROR. | |||
60 | Which configuration option should be accessed or edited. | 71 | Which configuration option should be accessed or edited. |
61 | Required to set a value. | 72 | Required to set a value. |
62 | If not given, all values of a given section will be printed in the format "OPTION = VALUE". | 73 | If not given, all values of a given section will be printed in the format "OPTION = VALUE". |
74 | .It Fl p | -prefix | ||
75 | Print GNUnet's installation prefix (for example /usr/local.) | ||
76 | .It Fl r | -rewrite | ||
77 | Write the configuration to file, even if it did not change. | ||
63 | .It Fl S |-list-sections | 78 | .It Fl S |-list-sections |
64 | List available configuration sections for use with --section. | 79 | List 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. | |||
70 | Must only be given together with -s and -o options. | 85 | Must only be given together with -s and -o options. |
71 | .It Fl v | -version | 86 | .It Fl v | -version |
72 | Print GNUnet version number. | 87 | Print GNUnet version number. |
73 | .It Fl r | -rewrite | ||
74 | Write the configuration to file, even if it did not change. | ||
75 | .It Fl F | -full | ||
76 | Write the full configuration, not just the deltas to the defaults. | ||
77 | .El | 88 | .El |
78 | .Sh SEE ALSO | 89 | .Sh SEE ALSO |
79 | The full documentation for gnunet is maintained as a Texinfo manual. | 90 | 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; | |||
36 | 36 | ||
37 | 37 | ||
38 | /** | 38 | /** |
39 | * If printing the value of CFLAGS has been requested. | ||
40 | */ | ||
41 | static int cflags; | ||
42 | |||
43 | |||
44 | /** | ||
45 | * If printing the value of LIBS has been requested. | ||
46 | */ | ||
47 | static int libs; | ||
48 | |||
49 | |||
50 | /** | ||
51 | * If printing the value of PREFIX has been requested. | ||
52 | */ | ||
53 | static int prefix; | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Print each option in a given section. | ||
39 | * Main task to run to perform operations typical for | 58 | * Main task to run to perform operations typical for |
40 | * gnunet-config as per the configuration settings | 59 | * gnunet-config as per the configuration settings |
41 | * given in @a cls. | 60 | * given in @a cls. |
@@ -54,6 +73,28 @@ run (void *cls, | |||
54 | { | 73 | { |
55 | struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls; | 74 | struct GNUNET_CONFIGURATION_ConfigSettings *cs = cls; |
56 | 75 | ||
76 | if (1 == cflags || 1 == libs || 1 == prefix) | ||
77 | { | ||
78 | char *prefixdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_PREFIX); | ||
79 | char *libdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); | ||
80 | |||
81 | if (1 == cflags) | ||
82 | { | ||
83 | fprintf (stdout, "-I%sinclude\n", prefixdir); | ||
84 | } | ||
85 | if (1 == libs) | ||
86 | { | ||
87 | fprintf (stdout, "-L%s -lgnunetutil\n", libdir); | ||
88 | } | ||
89 | if (1 == prefix) | ||
90 | { | ||
91 | fprintf (stdout, "%s\n", prefixdir); | ||
92 | } | ||
93 | cs->global_ret = 0; | ||
94 | GNUNET_free (prefixdir); | ||
95 | GNUNET_free (libdir); | ||
96 | return; | ||
97 | } | ||
57 | if (NULL != backend_check) | 98 | if (NULL != backend_check) |
58 | { | 99 | { |
59 | char *name; | 100 | char *name; |
@@ -97,6 +138,24 @@ main (int argc, | |||
97 | gettext_noop ( | 138 | gettext_noop ( |
98 | "test if the current installation supports the specified BACKEND"), | 139 | "test if the current installation supports the specified BACKEND"), |
99 | &backend_check)), | 140 | &backend_check)), |
141 | GNUNET_GETOPT_option_flag ( | ||
142 | 'C', | ||
143 | "cflags", | ||
144 | gettext_noop ( | ||
145 | "Provide an appropriate value for CFLAGS to applications building on top of GNUnet"), | ||
146 | &cflags), | ||
147 | GNUNET_GETOPT_option_flag ( | ||
148 | 'j', | ||
149 | "libs", | ||
150 | gettext_noop ( | ||
151 | "Provide an appropriate value for LIBS to applications building on top of GNUnet"), | ||
152 | &libs), | ||
153 | GNUNET_GETOPT_option_flag ( | ||
154 | 'p', | ||
155 | "prefix", | ||
156 | gettext_noop ( | ||
157 | "Provide the path under which GNUnet was installed"), | ||
158 | &prefix), | ||
100 | GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs), | 159 | GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs), |
101 | GNUNET_GETOPT_OPTION_END | 160 | GNUNET_GETOPT_OPTION_END |
102 | }; | 161 | }; |