diff options
author | Kalev Lember <klember@redhat.com> | 2017-01-30 13:20:11 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-01-30 12:38:14 +0000 |
commit | b02e3be83eeb8f3a9c70c597d1bedb595b81a79c (patch) | |
tree | 79437df40f234d37b12d77b092353c8ac69ddaeb | |
parent | 081ced436e3a984d2e4a33c935448b345aec2f95 (diff) | |
download | appstream-glib-b02e3be83eeb8f3a9c70c597d1bedb595b81a79c.tar.gz |
Fix the build with gperf 3.1
gperf 3.1 generates lookup functions that take a size_t length
parameter instead of unsigned int. Test for this at configure time.
Fixes: https://github.com/hughsie/appstream-glib/issues/148
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | libappstream-glib/as-tag.c | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index 9055273..7f7b8da 100644 --- a/configure.ac +++ b/configure.ac @@ -159,6 +159,26 @@ if test x$GPERF = xno ; then AC_MSG_ERROR([gperf not found]) fi +GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)" +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include <string.h> + const char * in_word_set(const char *, size_t); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=size_t], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + #include <string.h> + const char * in_word_set(const char *, unsigned); + $GPERF_TEST] + )], + [GPERF_LEN_TYPE=unsigned], + [AC_MSG_ERROR([unable to determine gperf len type])] + )] +) +AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type]) + PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.45.8 gio-2.0 gobject-2.0 gthread-2.0 gio-unix-2.0 gmodule-2.0) PKG_CHECK_MODULES(UUID, uuid) PKG_CHECK_MODULES(LIBARCHIVE, libarchive) diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c index 8bb9519..faf7eb0 100644 --- a/libappstream-glib/as-tag.c +++ b/libappstream-glib/as-tag.c @@ -35,8 +35,7 @@ #include "as-tag.h" -/* we need to define this now as gperf just writes a big header file */ -const struct tag_data *_as_tag_from_gperf (const char *tag, guint etag); +const struct tag_data *_as_tag_from_gperf (const char *tag, GPERF_LEN_TYPE etag); #include "as-tag-private.h" /** @@ -78,7 +77,7 @@ as_tag_from_string_full (const gchar *tag, AsTagFlags flags) return AS_TAG_UNKNOWN; /* use a perfect hash */ - ky = _as_tag_from_gperf (tag, (guint) strlen (tag)); + ky = _as_tag_from_gperf (tag, (GPERF_LEN_TYPE) strlen (tag)); if (ky != NULL) etag = ky->etag; |