[libnma/ac/release: 5/9] build: move GCR API checking to a macro




commit 1437de1448276c29fcf2bd3cf980eb4ed3c253db
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Mar 8 20:09:33 2022 +0100

    build: move GCR API checking to a macro
    
    This way it can be reused between Gtk3-based gcr and gcr-gtk4.

 configure.ac | 120 ++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 61 insertions(+), 59 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index caa575c8..70293402 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,64 @@ AM_CONDITIONAL(WITH_LIBNMA_GTK4, test "$with_libnma_gtk4" != "no")
 AC_DEFINE(WITH_GCR_GTK4, 0, [Define if GTK4 Gcr is available])
 AM_CONDITIONAL(WITH_GCR_GTK4, false)
 
+dnl GCR API is declared subject to change, do an extensive check of the prototypes
+AC_DEFUN([CHECK_GCR_API], [
+        CFLAGS_SAVED="$CFLAGS"
+        CFLAGS="$CFLAGS $2"
+        AC_MSG_CHECKING([for $1 usefulness])
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+                          #include <gcr/gcr.h>
+                          #include <gck/gck.h>
+
+                          const GckAttribute *gck_attributes_find (GckAttributes *attrs, gulong attr_type);
+                          gboolean gck_attributes_find_string (GckAttributes *attrs, gulong attr_type, gchar 
**value);
+                          gboolean gck_attributes_find_ulong (GckAttributes *attrs, gulong attr_type, gulong 
*value);
+                          GckAttributes *gck_attributes_new_empty (gulong first_type, ...);
+                          void gck_attributes_unref (gpointer attrs);
+                          void gck_builder_add_all (GckBuilder *builder, GckAttributes *attrs);
+                          void gck_builder_add_only (GckBuilder *builder, GckAttributes *attrs, gulong 
only_type, ...);
+                          GckAttributes *gck_builder_end (GckBuilder *builder);
+                          GckBuilder *gck_builder_new (GckBuilderFlags flags);
+                          void gck_enumerator_next_async (GckEnumerator *self, gint max_objects, 
GCancellable *cancellable,
+                                                          GAsyncReadyCallback callback, gpointer user_data);
+                          GList *gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult *result, 
GError **error);
+                          void gck_list_unref_free (GList *reflist);
+                          GList *gck_modules_get_slots (GList *modules, gboolean token_present);
+                          void gck_modules_initialize_registered_async (GCancellable *cancellable, 
GAsyncReadyCallback callback,
+                                                                        gpointer user_data);
+                          GList *gck_modules_initialize_registered_finish (GAsyncResult *result, GError 
**error);
+                          void gck_object_get_async (GckObject *self, const gulong *attr_types, guint 
n_attr_types,
+                                                     GCancellable *cancellable, GAsyncReadyCallback 
callback, gpointer user_data);
+                          GckAttributes *gck_object_get_finish (GckObject *self, GAsyncResult *result, 
GError **error);
+                          void gck_session_login_async (GckSession *self, gulong user_type, const guchar 
*pin,
+                                                        gsize n_pin, GCancellable *cancellable,
+                                                        GAsyncReadyCallback callback, gpointer user_data);
+                          gboolean gck_session_login_finish (GckSession *self, GAsyncResult *result, GError 
**error);
+                          GckSlotInfo *gck_slot_get_info (GckSlot *self);
+                          GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
+                          #if GCR_CHECK_VERSION(3,90,0)
+                          void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, 
GTlsInteraction *interaction,
+                                                            GCancellable *cancellable, GAsyncReadyCallback 
callback,
+                                                            gpointer user_data);
+                          gchar *gck_uri_data_build (GckUriData *uri_data, GckUriFlags flags);
+                          GckUriData *gck_uri_data_parse (const gchar *string, GckUriFlags flags, GError 
**error);
+                          #else
+                          void gck_slot_open_session_async (GckSlot *self, GckSessionOptions options, 
GCancellable *cancellable,
+                                                            GAsyncReadyCallback callback, gpointer 
user_data);
+                          gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
+                          GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, GError **error);
+                          #endif
+                          GckSession *gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, 
GError **error);
+                          void gck_token_info_free (GckTokenInfo *token_info);
+                          void gck_uri_data_free (GckUriData *uri_data);
+                          gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
+                          gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
+                          GcrCertificate *gcr_simple_certificate_new (const guchar *data, gsize n_data);
+                          ])], [$3], [$4])
+        AC_MSG_RESULT(${have_gcr})
+        CFLAGS="$CFLAGS_SAVED"
+])
+
 dnl GCR for PKCS#11 enabled certificate chooser
 AC_ARG_WITH(gcr, AS_HELP_STRING([--with-gcr], [Enable advanced certificate chooser (default: auto)]))
 if (test "${with_gcr}" == "no"); then
@@ -155,65 +213,9 @@ if (test "${with_gcr}" == "no"); then
 else
     PKG_CHECK_MODULES(GCR,
                       [gcr-3 >= 3.14, gck-1 >= 3.14],
-                      dnl GCR API is declared subject to change, do an extensive check of the prototypes
-                      GCR_CFLAGS="$GCR_CFLAGS -DGCR_API_SUBJECT_TO_CHANGE -DGCK_API_SUBJECT_TO_CHANGE"
-                      CFLAGS_SAVED="$CFLAGS"
-                      CFLAGS="$CFLAGS $GCR_CFLAGS"
-                      AC_MSG_CHECKING([for GCR usefulness])
-                      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-                                        #include <gcr/gcr.h>
-                                        #include <gck/gck.h>
-
-                                        const GckAttribute *gck_attributes_find (GckAttributes *attrs, 
gulong attr_type);
-                                        gboolean gck_attributes_find_string (GckAttributes *attrs, gulong 
attr_type, gchar **value);
-                                        gboolean gck_attributes_find_ulong (GckAttributes *attrs, gulong 
attr_type, gulong *value);
-                                        GckAttributes *gck_attributes_new_empty (gulong first_type, ...);
-                                        void gck_attributes_unref (gpointer attrs);
-                                        void gck_builder_add_all (GckBuilder *builder, GckAttributes *attrs);
-                                        void gck_builder_add_only (GckBuilder *builder, GckAttributes 
*attrs, gulong only_type, ...);
-                                        GckAttributes *gck_builder_end (GckBuilder *builder);
-                                        GckBuilder *gck_builder_new (GckBuilderFlags flags);
-                                        void gck_enumerator_next_async (GckEnumerator *self, gint 
max_objects, GCancellable *cancellable,
-                                                                        GAsyncReadyCallback callback, 
gpointer user_data);
-                                        GList *gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult 
*result, GError **error);
-                                        void gck_list_unref_free (GList *reflist);
-                                        GList *gck_modules_get_slots (GList *modules, gboolean 
token_present);
-                                        void gck_modules_initialize_registered_async (GCancellable 
*cancellable, GAsyncReadyCallback callback,
-                                                                                      gpointer user_data);
-                                        GList *gck_modules_initialize_registered_finish (GAsyncResult 
*result, GError **error);
-                                        void gck_object_get_async (GckObject *self, const gulong 
*attr_types, guint n_attr_types,
-                                                                   GCancellable *cancellable, 
GAsyncReadyCallback callback, gpointer user_data);
-                                        GckAttributes *gck_object_get_finish (GckObject *self, GAsyncResult 
*result, GError **error);
-                                        void gck_session_login_async (GckSession *self, gulong user_type, 
const guchar *pin,
-                                                                      gsize n_pin, GCancellable *cancellable,
-                                                                      GAsyncReadyCallback callback, gpointer 
user_data);
-                                        gboolean gck_session_login_finish (GckSession *self, GAsyncResult 
*result, GError **error);
-                                        GckSlotInfo *gck_slot_get_info (GckSlot *self);
-                                        GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
-                                        #if GCR_CHECK_VERSION(3,90,0)
-                                        void gck_slot_open_session_async (GckSlot *self, GckSessionOptions 
options, GTlsInteraction *interaction,
-                                                                          GCancellable *cancellable, 
GAsyncReadyCallback callback,
-                                                                          gpointer user_data);
-                                        gchar *gck_uri_data_build (GckUriData *uri_data, GckUriFlags flags);
-                                        GckUriData *gck_uri_data_parse (const gchar *string, GckUriFlags 
flags, GError **error);
-                                        #else
-                                        void gck_slot_open_session_async (GckSlot *self, GckSessionOptions 
options, GCancellable *cancellable,
-                                                                          GAsyncReadyCallback callback, 
gpointer user_data);
-                                        gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
-                                        GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, 
GError **error);
-                                        #endif
-                                        GckSession *gck_slot_open_session_finish (GckSlot *self, 
GAsyncResult *result, GError **error);
-                                        void gck_token_info_free (GckTokenInfo *token_info);
-                                        void gck_uri_data_free (GckUriData *uri_data);
-                                        gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
-                                        gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
-                                        GcrCertificate *gcr_simple_certificate_new (const guchar *data, 
gsize n_data);
-                                        ])],
-                                        have_gcr=yes,
-                                        have_gcr=no)
-                      AC_MSG_RESULT(${have_gcr})
-                      CFLAGS="$CFLAGS_SAVED",
-                      have_gcr=no);
+                      [GCR_CFLAGS="$GCR_CFLAGS -DGCR_API_SUBJECT_TO_CHANGE -DGCK_API_SUBJECT_TO_CHANGE"
+                       CHECK_GCR_API(GCR, $GCR_CFLAGS, have_gcr=yes, have_gcr=no)],
+                      [have_gcr=no])
 fi
 
 if (test "${have_gcr}" == "yes"); then


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