gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 01/09: 5708: allow gnunet-config to output build config informa


From: gnunet
Subject: [gnunet] 01/09: 5708: allow gnunet-config to output build config informations
Date: Fri, 17 Sep 2021 19:03:17 +0200

This is an automated email from the git hooks/post-receive script.

alessio-vanni pushed a commit to branch master
in repository gnunet.

commit fd1bcccb9b6063d0501c81323eef81c0dd7a6340
Author: Alessio Vanni <vannilla@firemail.cc>
AuthorDate: Fri Jul 23 18:20:33 2021 +0200

    5708: allow gnunet-config to output build config informations
    
    With this commit, `gnunet-config' is now able to print some informations 
about
    how GNUnet was built through some additional flags (here `--cflags', 
`--libs'
    and `--prefix'.)
    
    These flags allow `gnunet-config' to behave like other `*-config' tools
    provided by other applications/libraries, which are used by third-party
    applications, especially when the tool is provided by a library, to properly
    compile using the flags recommended by the library/application.
    
    In terms of GNUnet, any client or service connecting to any GNUnet service 
can
    now be built using some variation of the following:
    
    cc $(gnunet-config --cflags) -o my-client client.c $(gnunet-config --libs)
---
 src/util/Makefile.am     |  5 +++++
 src/util/gnunet-config.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index e720112be..ab66756b4 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -227,6 +227,11 @@ gnunet_config_SOURCES = \
 gnunet_config_LDADD = \
   libgnunetutil.la \
   $(GN_LIBINTL)
+gnunet_config_CPPFLAGS = \
+ -DINCLUDEDIR=\"$(includedir)\" \
+ -DLIBDIR=\"$(libdir)\" \
+ -DPREFIX=\"$(prefix)\" \
+ $(AM_CPPFLAGS)
 
 gnunet_uri_SOURCES = \
  gnunet-uri.c
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c
index 3932ff1bf..0a5c0712b 100644
--- a/src/util/gnunet-config.c
+++ b/src/util/gnunet-config.c
@@ -74,6 +74,21 @@ static int rewrite;
  */
 static int full;
 
+/**
+ * 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.
@@ -150,6 +165,23 @@ run (void *cls,
 
   (void) cls;
   (void) args;
+  if (1 == cflags || 1 == libs || 1 == prefix)
+  {
+    /* These values are defined in the makefile */
+    if (1 == cflags)
+    {
+      fprintf (stdout, "%s\n", "-I"INCLUDEDIR);
+    }
+    if (1 == libs)
+    {
+      fprintf (stdout, "%s\n", "-L"LIBDIR" -lgnunetutil");
+    }
+    if (1 == prefix)
+    {
+      fprintf (stdout, "%s\n", PREFIX);
+    }
+    return;
+  }
   if (NULL != backend_check)
   {
     char *name;
@@ -364,6 +396,21 @@ main (int argc, char *const *argv)
                                  "VALUE",
                                  gettext_noop ("value to set"),
                                  &value),
+    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_GETOPT_OPTION_END
   };
   int ret;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]