From d85ab01c951792e2aeed4496e9d355f23ef3f5cd Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN" Date: Wed, 3 Aug 2016 22:11:42 +0200 Subject: [PATCH] frontends: add the meta-frontend kconfig Install 'kconfig', the meta-frontend that can be used to as a frontend to all kconfig tools. Signed-off-by: "Yann E. MORIN" --- .gitignore | 1 + configure.ac | 15 ++++++++++++++ frontends/Makefile.am | 12 +++++++++++ frontends/kconfig.in | 48 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 frontends/kconfig.in diff --git a/.gitignore b/.gitignore index da028f8..95fc7fc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .libs/ +/frontends/kconfig /frontends/conf/kconfig-conf /frontends/gconf/kconfig-gconf /frontends/mconf/kconfig-mconf diff --git a/configure.ac b/configure.ac index e44b442..31eef71 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,13 @@ AC_SUBST([enable_L10n], [${enable_L10n:-yes}]) #---------------------------------------- # Options to selectively enable/disable frontends # All are selected by default +AC_ARG_ENABLE( + [kconfig], + [AS_HELP_STRING( + [--disable-kconfig], + [kconfig, the meta-frontend to all kconfig tools (default=yes)])]) +AC_SUBST([enable_kconfig], [${enable_kconfig:-yes}]) + AC_ARG_ENABLE( [conf], [AS_HELP_STRING( @@ -426,6 +433,9 @@ AS_IF( #---------------------------------------- # Setup automake conditional build +AM_CONDITIONAL( + [COND_kconfig], + [test "$enable_kconfig" = "yes"]) AM_CONDITIONAL( [COND_conf], [test "$enable_conf" = "yes"]) @@ -469,6 +479,11 @@ AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"]) AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"]) AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"]) +[kcfg_list="$fe_list"] +AS_IF([test "$enable_utils" = "yes"], [kcfg_list="$kcfg_list diff merge tweak"]) +AS_IF([test "$has_gettext" = "yes"], [kcfg_list="$kcfg_list gettext"]) +AC_SUBST([kcfg_list], [${kcfg_list}]) + [lib_list=] AS_IF( [test "$enable_shared" = "yes"], diff --git a/frontends/Makefile.am b/frontends/Makefile.am index 0badbc8..6e77564 100644 --- a/frontends/Makefile.am +++ b/frontends/Makefile.am @@ -1,3 +1,6 @@ +if COND_kconfig + MAYBE_kconfig = kconfig +endif if COND_conf MAYBE_conf = conf endif @@ -14,3 +17,12 @@ if COND_qconf MAYBE_qconf = qconf endif SUBDIRS = $(MAYBE_conf) $(MAYBE_mconf) $(MAYBE_nconf) $(MAYBE_gconf) $(MAYBE_qconf) + +EXTRA_DIST = kconfig.in + +bin_SCRIPTS = $(MAYBE_kconfig) + +kconfig: kconfig.in + $(AM_V_GEN)$(SED) -e 's/@KCFG_LIST@/$(kcfg_list)/g' \ + $< >$@ + @chmod +x $@ diff --git a/frontends/kconfig.in b/frontends/kconfig.in new file mode 100644 index 0000000..110204c --- /dev/null +++ b/frontends/kconfig.in @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +LIST="@KCFG_LIST@" + +main() { + local kcfg="${1}"; shift + local k + + case "${kcfg}" in + "") error "what should I do (see -h)?\n";; + -h|--help) help; exit 0;; + -*) error "no such option '%s'\n" "${kcfg}";; + esac + + for k in ${LIST}; do + if [ "${kcfg}" = "${k}" ]; then + exec kconfig-${kcfg} "${@}" + error "cannot execute tool '%s'\n" "${kcfg}" + fi + done + error "no such tool '%s'\n" "${kcfg}" +} + +help() { + cat <<-_EOF_ +NAME + kconfig - meta-frontend to kconfig tools + +SYNOPSIS + kconfig -h|--help + kconfig [option ...] + +DESCRIPTION + kconfig is the meta-frontend to all other kconfig tools: + ${LIST} + + The acceptable options depend on what tool is being called. +_EOF_ +} + +error() { + local fmt="${1}"; shift + + printf "kconfig: ${fmt}" "${@}" >&2 + exit 1 +} + +main "${@}" -- 2.39.2