Skip to content

Instantly share code, notes, and snippets.

@FreddieChopin
Created April 6, 2017 06:13
Show Gist options
  • Save FreddieChopin/b2ec415ee4eacbd4b92499bbf4e934be to your computer and use it in GitHub Desktop.
Save FreddieChopin/b2ec415ee4eacbd4b92499bbf4e934be to your computer and use it in GitHub Desktop.
Patch for kconfig-frontends (HEAD of git repository) that fixes build failure with gperf 3.1
diff --git a/Makefile.am b/Makefile.am
index 926bf11..65126c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,7 @@ dist_EXTRA_libs_parser_libkconfig_parser_la_SOURCES = \
libs_parser_libkconfig_parser_la_CPPFLAGS = \
-DROOTMENU="\"$(root_menu)\"" \
-DCONFIG_=\"$(config_prefix)\" \
+ -DGPERF_LEN_TYPE="$(GPERF_LEN_TYPE)" \
$(intl_CPPFLAGS) \
-I$(top_srcdir)/libs/parser
libs_parser_libkconfig_parser_la_CFLAGS = \
diff --git a/configure.ac b/configure.ac
index bfaf058..fe574d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -231,6 +231,22 @@ AS_IF(
AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
#----------------------------------------
+# gperf 3.1 generates functions with 'size_t' instead of 'unsigned int'
+AC_MSG_CHECKING([for the type used in gperf declarations])
+echo "#include <string.h>" > conftest.gperf.c
+echo "const char * in_word_set(const char *, GPERF_LEN_TYPE);" >> conftest.gperf.c
+echo foo,bar | ${GPERF} -L ANSI-C >> conftest.gperf.c
+AS_IF(
+ [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='size_t' >/dev/null 2>&1],
+ [AC_MSG_RESULT([size_t])
+ GPERF_LEN_TYPE='size_t'],
+ [${CC} -c -o /dev/null conftest.gperf.c -DGPERF_LEN_TYPE='unsigned int' >/dev/null 2>&1],
+ [AC_MSG_RESULT([unsigned int])
+ GPERF_LEN_TYPE='unsigned int'],
+ [AC_MSG_ERROR([unable to determine gperf len type])])
+rm -f conftest.gperf.c
+AC_SUBST([GPERF_LEN_TYPE])
+#----------------------------------------
# Check for gettext, for the kconfig frontends
[has_gettext="$enable_L10n"]
AS_IF(
diff --git a/libs/parser/hconf.gperf b/libs/parser/hconf.gperf
index ac498f0..434483b 100644
--- a/libs/parser/hconf.gperf
+++ b/libs/parser/hconf.gperf
@@ -9,7 +9,7 @@
struct kconf_id;
-static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+static const struct kconf_id *kconf_id_lookup(register const char *str, register GPERF_LEN_TYPE len);
%%
mainmenu, T_MAINMENU, TF_COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment