From: Yann E. MORIN Date: Wed, 3 Aug 2016 19:15:53 +0000 (+0200) Subject: buildsystem: do not use program-prefix to set the kconfig- prefix X-Git-Tag: v4.7.0.0~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f6cc4445afb527655a0dbb551252547e55f8b3ef;p=kconfig-frontends buildsystem: do not use program-prefix to set the kconfig- prefix Currently, we use automake's --program-prefix to set the prefix of the kconfig executables to 'kconfig-'. However, this is neither very nice nor very reliable. In some cases, the standard practice distributions use is to force the prefix to be empty, in which case this would create clashes with other tools (esp. diff and merge). Furthermore, we use a dirty trick to achieve this, by initialising program-prefix before initialising automake. There is no guarantee this will continue to work with future automake versions. Stop using this trick, and directly include the 'kconfig-' prefix for all programs (binaries and scripts alike) that we may generate and install. Signed-off-by: "Yann E. MORIN" --- diff --git a/.gitignore b/.gitignore index 58139e6..da028f8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,16 +8,11 @@ .libs/ -/frontends/conf/conf -/frontends/conf/*-conf -/frontends/gconf/gconf -/frontends/gconf/*-gconf -/frontends/mconf/mconf -/frontends/mconf/*-mconf -/frontends/nconf/nconf -/frontends/nconf/*-nconf -/frontends/qconf/qconf -/frontends/qconf/*-qconf +/frontends/conf/kconfig-conf +/frontends/gconf/kconfig-gconf +/frontends/mconf/kconfig-mconf +/frontends/nconf/kconfig-nconf +/frontends/qconf/kconfig-qconf /frontends/qconf/qconf.moc /libs/images/images.c @@ -26,9 +21,8 @@ /libs/parser/lconf.c /libs/parser/yconf.c -/utils/tweak -/utils/gettext -/utils/*-gettext +/utils/kconfig-tweak +/utils/kconfig-gettext aclocal.m4 configure diff --git a/configure.ac b/configure.ac index c404185..ad923e9 100644 --- a/configure.ac +++ b/configure.ac @@ -20,14 +20,6 @@ AC_CONFIG_MACRO_DIR([scripts/.autostuff/m4]) #---------------------------------------- # Prepare automake -# We want to allow the user to override our default program-prefix, -# so we must set-it now, before automake has a chance to interpret -# it, but after the options are parsed, so as not to overwrite the -# value (if any) set by the user -AS_IF( - [test "$program_prefix" = NONE], - [program_prefix=kconfig-]) - AM_INIT_AUTOMAKE([foreign]) # For releases, enable silent rules, unless the user explicitly @@ -511,7 +503,6 @@ AC_MSG_NOTICE([- parser library :$lib_list]) AC_MSG_NOTICE([ - root-menu prompt : $root_menu]) AC_MSG_NOTICE([ - config prefix : $config_prefix]) AC_MSG_NOTICE([- frontends :$fe_list]) -AC_MSG_NOTICE([ - transform name : $program_transform_name]) AC_MSG_NOTICE([ - localised : $has_gettext]) AC_MSG_NOTICE([- install utilities : $enable_utils]) AC_MSG_NOTICE([- CFLAGS CXXFLAGS : $wall_CFLAGS $werror_CFLAGS]) diff --git a/frontends/conf/Makefile.am b/frontends/conf/Makefile.am index 10566cc..38db98f 100644 --- a/frontends/conf/Makefile.am +++ b/frontends/conf/Makefile.am @@ -1,10 +1,10 @@ -bin_PROGRAMS = conf +bin_PROGRAMS = kconfig-conf -conf_SOURCES = conf.c -conf_CPPFLAGS = $(AM_CPPFLAGS) \ - $(intl_CPPFLAGS) \ - -I$(top_srcdir)/libs/parser -conf_CFLAGS = $(AM_CFLAGS) $(kf_CFLAGS) -conf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(intl_LIBS) \ - $(conf_EXTRA_LIBS) +kconfig_conf_SOURCES = conf.c +kconfig_conf_CPPFLAGS = $(AM_CPPFLAGS) \ + $(intl_CPPFLAGS) \ + -I$(top_srcdir)/libs/parser +kconfig_conf_CFLAGS = $(AM_CFLAGS) $(kf_CFLAGS) +kconfig_conf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(intl_LIBS) \ + $(conf_EXTRA_LIBS) diff --git a/frontends/gconf/Makefile.am b/frontends/gconf/Makefile.am index 93ad7d4..abdb193 100644 --- a/frontends/gconf/Makefile.am +++ b/frontends/gconf/Makefile.am @@ -1,17 +1,17 @@ -bin_PROGRAMS = gconf +bin_PROGRAMS = kconfig-gconf -gconf_SOURCES = gconf.c gconf.glade -gconf_CPPFLAGS = $(AM_CPPFLAGS) \ - $(intl_CPPFLAGS) \ - -I$(top_srcdir)/libs/parser \ - -I$(top_builddir)/libs/images \ - -DGUI_PATH='"$(pkgdatadir)/gconf.glade"' -gconf_CFLAGS = $(AM_CFLAGS) \ - $(kf_CFLAGS) \ - $(gtk_CFLAGS) -gconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(top_builddir)/libs/images/libkconfig-images.a \ - $(intl_LIBS) $(gtk_LIBS) $(gconf_EXTRA_LIBS) -gconfdir = $(pkgdatadir) -gconf_DATA = gconf.glade +kconfig_gconf_SOURCES = gconf.c gconf.glade +kconfig_gconf_CPPFLAGS = $(AM_CPPFLAGS) \ + $(intl_CPPFLAGS) \ + -I$(top_srcdir)/libs/parser \ + -I$(top_builddir)/libs/images \ + -DGUI_PATH='"$(pkgdatadir)/gconf.glade"' +kconfig_gconf_CFLAGS = $(AM_CFLAGS) \ + $(kf_CFLAGS) \ + $(gtk_CFLAGS) +kconfig_gconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(top_builddir)/libs/images/libkconfig-images.a \ + $(intl_LIBS) $(gtk_LIBS) $(gconf_EXTRA_LIBS) +kconfig_gconfdir = $(pkgdatadir) +kconfig_gconf_DATA = gconf.glade EXTRA_DIST = gconf.c.patch diff --git a/frontends/mconf/Makefile.am b/frontends/mconf/Makefile.am index 47240f2..175a712 100644 --- a/frontends/mconf/Makefile.am +++ b/frontends/mconf/Makefile.am @@ -1,13 +1,13 @@ -bin_PROGRAMS = mconf +bin_PROGRAMS = kconfig-mconf -mconf_SOURCES = mconf.c -mconf_CPPFLAGS = $(AM_CPPFLAGS) \ - $(ncurses_mconf_CPPFLAGS) \ - $(intl_CPPFLAGS) \ - -I$(top_srcdir)/libs \ - -I$(top_srcdir)/libs/parser -mconf_CFLAGS = $(AM_CFLAGS) \ - $(kf_CFLAGS) -mconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(top_builddir)/libs/lxdialog/libkconfig-lxdialog.a \ - $(intl_LIBS) $(ncurses_LIBS) $(mconf_EXTRA_LIBS) +kconfig_mconf_SOURCES = mconf.c +kconfig_mconf_CPPFLAGS = $(AM_CPPFLAGS) \ + $(ncurses_mconf_CPPFLAGS) \ + $(intl_CPPFLAGS) \ + -I$(top_srcdir)/libs \ + -I$(top_srcdir)/libs/parser +kconfig_mconf_CFLAGS = $(AM_CFLAGS) \ + $(kf_CFLAGS) +kconfig_mconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(top_builddir)/libs/lxdialog/libkconfig-lxdialog.a \ + $(intl_LIBS) $(ncurses_LIBS) $(mconf_EXTRA_LIBS) diff --git a/frontends/nconf/Makefile.am b/frontends/nconf/Makefile.am index 90a6154..de0664b 100644 --- a/frontends/nconf/Makefile.am +++ b/frontends/nconf/Makefile.am @@ -1,12 +1,12 @@ -bin_PROGRAMS = nconf +bin_PROGRAMS = kconfig-nconf -nconf_SOURCES = nconf.c nconf.gui.c nconf.h -nconf_CPPFLAGS = $(AM_CPPFLAGS) \ - $(intl_CPPFLAGS) \ - $(ncurses_nconf_CPPFLAGS) \ - -I$(top_srcdir)/libs/parser -nconf_CFLAGS = $(AM_CFLAGS) \ - $(kf_CFLAGS) -nconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(intl_LIBS) $(ncurses_panel_menu_LIBS) $(ncurses_LIBS) \ - $(nconf_EXTRA_LIBS) +kconfig_nconf_SOURCES = nconf.c nconf.gui.c nconf.h +kconfig_nconf_CPPFLAGS = $(AM_CPPFLAGS) \ + $(intl_CPPFLAGS) \ + $(ncurses_nconf_CPPFLAGS) \ + -I$(top_srcdir)/libs/parser +kconfig_nconf_CFLAGS = $(AM_CFLAGS) \ + $(kf_CFLAGS) +kconfig_nconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(intl_LIBS) $(ncurses_panel_menu_LIBS) $(ncurses_LIBS) \ + $(nconf_EXTRA_LIBS) diff --git a/frontends/qconf/Makefile.am b/frontends/qconf/Makefile.am index 3feabd3..bc49498 100644 --- a/frontends/qconf/Makefile.am +++ b/frontends/qconf/Makefile.am @@ -1,18 +1,18 @@ -bin_PROGRAMS = qconf +bin_PROGRAMS = kconfig-qconf -qconf_SOURCES = qconf.cc qconf.h +kconfig_qconf_SOURCES = qconf.cc qconf.h BUILT_SOURCES = qconf.moc -qconf_CPPFLAGS = $(AM_CPPFLAGS) \ - $(intl_CPPFLAGS) \ - -I$(top_srcdir)/libs/parser \ - -I$(top_builddir)/libs/images -qconf_CXXFLAGS = $(AM_CXXFLAGS) \ - $(kf_CFLAGS) \ - $(Qt5_CFLAGS) \ - -fPIC -qconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(top_builddir)/libs/images/libkconfig-images.a \ - $(intl_LIBS) $(Qt5_LIBS) $(qconf_EXTRA_LIBS) +kconfig_qconf_CPPFLAGS = $(AM_CPPFLAGS) \ + $(intl_CPPFLAGS) \ + -I$(top_srcdir)/libs/parser \ + -I$(top_builddir)/libs/images +kconfig_qconf_CXXFLAGS = $(AM_CXXFLAGS) \ + $(kf_CFLAGS) \ + $(Qt5_CFLAGS) \ + -fPIC +kconfig_qconf_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(top_builddir)/libs/images/libkconfig-images.a \ + $(intl_LIBS) $(Qt5_LIBS) $(qconf_EXTRA_LIBS) CLEANFILES = qconf.moc EXTRA_DIST = qconf.cc.patch diff --git a/scripts/ksync.list b/scripts/ksync.list index aa8b9b6..c2d66fa 100644 --- a/scripts/ksync.list +++ b/scripts/ksync.list @@ -28,9 +28,9 @@ scripts/kconfig/menu.c --> libs/parser/menu.c scripts/kconfig/symbol.c --> libs/parser/symbol.c scripts/kconfig/util.c --> libs/parser/util.c scripts/kconfig/zconf.y --> libs/parser/yconf.y -scripts/config --> utils/tweak.in -scripts/diffconfig --> utils/diff -scripts/kconfig/merge_config.sh --> utils/merge +scripts/config --> utils/kconfig-tweak.in +scripts/diffconfig --> utils/kconfig-diff +scripts/kconfig/merge_config.sh --> utils/kconfig-merge scripts/kconfig/kxgettext.c --> utils/gettext.c Documentation/kbuild/kconfig-language.txt --> docs/kconfig-language.txt Documentation/kbuild/kconfig.txt --> docs/kconfig.txt diff --git a/utils/Makefile.am b/utils/Makefile.am index b3f55df..6438110 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1,21 +1,21 @@ -bin_SCRIPTS = tweak -dist_bin_SCRIPTS = diff merge +bin_SCRIPTS = kconfig-tweak +dist_bin_SCRIPTS = kconfig-diff kconfig-merge if COND_utils_gettext - MAYBE_utils_gettext = gettext + MAYBE_utils_gettext = kconfig-gettext endif bin_PROGRAMS = $(MAYBE_utils_gettext) -gettext_SOURCES = gettext.c -gettext_CPPFLAGS = $(AM_CPPFLAGS) \ - -I$(top_srcdir)/libs/parser -gettext_CFLAGS = $(AM_CFLAGS) $(kf_CFLAGS) -gettext_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ - $(intl_LIBS) -CLEANFILES = tweak -EXTRA_DIST = tweak.in tweak.in.patch +kconfig_gettext_SOURCES = gettext.c +kconfig_gettext_CPPFLAGS = $(AM_CPPFLAGS) \ + -I$(top_srcdir)/libs/parser +kconfig_gettext_CFLAGS = $(AM_CFLAGS) $(kf_CFLAGS) +kconfig_gettext_LDADD = $(top_builddir)/libs/parser/libkconfig-parser.la \ + $(intl_LIBS) +CLEANFILES = kconfig-tweak +EXTRA_DIST = kconfig-tweak.in kconfig-tweak.in.patch -tweak: tweak.in +kconfig-tweak: kconfig-tweak.in $(AM_V_GEN)$(SED) -e "s/@CONFIG_@/$(config_prefix)/g" \ $< >$@ @chmod +x $@ diff --git a/utils/diff b/utils/diff deleted file mode 100755 index 0db267d..0000000 --- a/utils/diff +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/python -# -# diffconfig - a tool to compare .config files. -# -# originally written in 2006 by Matt Mackall -# (at least, this was in his bloatwatch source code) -# last worked on 2008 by Tim Bird -# - -import sys, os - -def usage(): - print("""Usage: diffconfig [-h] [-m] [ ] - -Diffconfig is a simple utility for comparing two .config files. -Using standard diff to compare .config files often includes extraneous and -distracting information. This utility produces sorted output with only the -changes in configuration values between the two files. - -Added and removed items are shown with a leading plus or minus, respectively. -Changed items show the old and new values on a single line. - -If -m is specified, then output will be in "merge" style, which has the -changed and new values in kernel config option format. - -If no config files are specified, .config and .config.old are used. - -Example usage: - $ diffconfig .config config-with-some-changes --EXT2_FS_XATTR n - CRAMFS n -> y - EXT2_FS y -> n - LOG_BUF_SHIFT 14 -> 16 - PRINTK_TIME n -> y -""") - sys.exit(0) - -# returns a dictionary of name/value pairs for config items in the file -def readconfig(config_file): - d = {} - for line in config_file: - line = line[:-1] - if line[:7] == "CONFIG_": - name, val = line[7:].split("=", 1) - d[name] = val - if line[-11:] == " is not set": - d[line[9:-11]] = "n" - return d - -def print_config(op, config, value, new_value): - global merge_style - - if merge_style: - if new_value: - if new_value=="n": - print("# CONFIG_%s is not set" % config) - else: - print("CONFIG_%s=%s" % (config, new_value)) - else: - if op=="-": - print("-%s %s" % (config, value)) - elif op=="+": - print("+%s %s" % (config, new_value)) - else: - print(" %s %s -> %s" % (config, value, new_value)) - -def main(): - global merge_style - - # parse command line args - if ("-h" in sys.argv or "--help" in sys.argv): - usage() - - merge_style = 0 - if "-m" in sys.argv: - merge_style = 1 - sys.argv.remove("-m") - - argc = len(sys.argv) - if not (argc==1 or argc == 3): - print("Error: incorrect number of arguments or unrecognized option") - usage() - - if argc == 1: - # if no filenames given, assume .config and .config.old - build_dir="" - if "KBUILD_OUTPUT" in os.environ: - build_dir = os.environ["KBUILD_OUTPUT"]+"/" - configa_filename = build_dir + ".config.old" - configb_filename = build_dir + ".config" - else: - configa_filename = sys.argv[1] - configb_filename = sys.argv[2] - - try: - a = readconfig(open(configa_filename)) - b = readconfig(open(configb_filename)) - except (IOError): - e = sys.exc_info()[1] - print("I/O error[%s]: %s\n" % (e.args[0],e.args[1])) - usage() - - # print items in a but not b (accumulate, sort and print) - old = [] - for config in a: - if config not in b: - old.append(config) - old.sort() - for config in old: - print_config("-", config, a[config], None) - del a[config] - - # print items that changed (accumulate, sort, and print) - changed = [] - for config in a: - if a[config] != b[config]: - changed.append(config) - else: - del b[config] - changed.sort() - for config in changed: - print_config("->", config, a[config], b[config]) - del b[config] - - # now print items in b but not in a - # (items from b that were in a were removed above) - new = sorted(b.keys()) - for config in new: - print_config("+", config, None, b[config]) - -main() diff --git a/utils/kconfig-diff b/utils/kconfig-diff new file mode 100755 index 0000000..0db267d --- /dev/null +++ b/utils/kconfig-diff @@ -0,0 +1,131 @@ +#!/usr/bin/python +# +# diffconfig - a tool to compare .config files. +# +# originally written in 2006 by Matt Mackall +# (at least, this was in his bloatwatch source code) +# last worked on 2008 by Tim Bird +# + +import sys, os + +def usage(): + print("""Usage: diffconfig [-h] [-m] [ ] + +Diffconfig is a simple utility for comparing two .config files. +Using standard diff to compare .config files often includes extraneous and +distracting information. This utility produces sorted output with only the +changes in configuration values between the two files. + +Added and removed items are shown with a leading plus or minus, respectively. +Changed items show the old and new values on a single line. + +If -m is specified, then output will be in "merge" style, which has the +changed and new values in kernel config option format. + +If no config files are specified, .config and .config.old are used. + +Example usage: + $ diffconfig .config config-with-some-changes +-EXT2_FS_XATTR n + CRAMFS n -> y + EXT2_FS y -> n + LOG_BUF_SHIFT 14 -> 16 + PRINTK_TIME n -> y +""") + sys.exit(0) + +# returns a dictionary of name/value pairs for config items in the file +def readconfig(config_file): + d = {} + for line in config_file: + line = line[:-1] + if line[:7] == "CONFIG_": + name, val = line[7:].split("=", 1) + d[name] = val + if line[-11:] == " is not set": + d[line[9:-11]] = "n" + return d + +def print_config(op, config, value, new_value): + global merge_style + + if merge_style: + if new_value: + if new_value=="n": + print("# CONFIG_%s is not set" % config) + else: + print("CONFIG_%s=%s" % (config, new_value)) + else: + if op=="-": + print("-%s %s" % (config, value)) + elif op=="+": + print("+%s %s" % (config, new_value)) + else: + print(" %s %s -> %s" % (config, value, new_value)) + +def main(): + global merge_style + + # parse command line args + if ("-h" in sys.argv or "--help" in sys.argv): + usage() + + merge_style = 0 + if "-m" in sys.argv: + merge_style = 1 + sys.argv.remove("-m") + + argc = len(sys.argv) + if not (argc==1 or argc == 3): + print("Error: incorrect number of arguments or unrecognized option") + usage() + + if argc == 1: + # if no filenames given, assume .config and .config.old + build_dir="" + if "KBUILD_OUTPUT" in os.environ: + build_dir = os.environ["KBUILD_OUTPUT"]+"/" + configa_filename = build_dir + ".config.old" + configb_filename = build_dir + ".config" + else: + configa_filename = sys.argv[1] + configb_filename = sys.argv[2] + + try: + a = readconfig(open(configa_filename)) + b = readconfig(open(configb_filename)) + except (IOError): + e = sys.exc_info()[1] + print("I/O error[%s]: %s\n" % (e.args[0],e.args[1])) + usage() + + # print items in a but not b (accumulate, sort and print) + old = [] + for config in a: + if config not in b: + old.append(config) + old.sort() + for config in old: + print_config("-", config, a[config], None) + del a[config] + + # print items that changed (accumulate, sort, and print) + changed = [] + for config in a: + if a[config] != b[config]: + changed.append(config) + else: + del b[config] + changed.sort() + for config in changed: + print_config("->", config, a[config], b[config]) + del b[config] + + # now print items in b but not in a + # (items from b that were in a were removed above) + new = sorted(b.keys()) + for config in new: + print_config("+", config, None, b[config]) + +main() diff --git a/utils/kconfig-merge b/utils/kconfig-merge new file mode 100755 index 0000000..67d1314 --- /dev/null +++ b/utils/kconfig-merge @@ -0,0 +1,170 @@ +#!/bin/sh +# merge_config.sh - Takes a list of config fragment values, and merges +# them one by one. Provides warnings on overridden values, and specified +# values that did not make it to the resulting .config file (due to missed +# dependencies or config symbol removal). +# +# Portions reused from kconf_check and generate_cfg: +# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check +# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg +# +# Copyright (c) 2009-2010 Wind River Systems, Inc. +# Copyright 2011 Linaro +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. + +clean_up() { + rm -f $TMP_FILE + exit +} +trap clean_up HUP INT TERM + +usage() { + echo "Usage: $0 [OPTIONS] [CONFIG [...]]" + echo " -h display this help text" + echo " -m only merge the fragments, do not execute the make command" + echo " -n use allnoconfig instead of alldefconfig" + echo " -r list redundant entries when merging fragments" + echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." +} + +RUNMAKE=true +ALLTARGET=alldefconfig +WARNREDUN=false +OUTPUT=. + +while true; do + case $1 in + "-n") + ALLTARGET=allnoconfig + shift + continue + ;; + "-m") + RUNMAKE=false + shift + continue + ;; + "-h") + usage + exit + ;; + "-r") + WARNREDUN=true + shift + continue + ;; + "-O") + if [ -d $2 ];then + OUTPUT=$(echo $2 | sed 's/\/*$//') + else + echo "output directory $2 does not exist" 1>&2 + exit 1 + fi + shift 2 + continue + ;; + *) + break + ;; + esac +done + +if [ "$#" -lt 1 ] ; then + usage + exit +fi + +if [ -z "$KCONFIG_CONFIG" ]; then + if [ "$OUTPUT" != . ]; then + KCONFIG_CONFIG=$(readlink -m -- "$OUTPUT/.config") + else + KCONFIG_CONFIG=.config + fi +fi + +INITFILE=$1 +shift; + +if [ ! -r "$INITFILE" ]; then + echo "The base file '$INITFILE' does not exist. Exit." >&2 + exit 1 +fi + +MERGE_LIST=$* +SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) + +echo "Using $INITFILE as base" +cat $INITFILE > $TMP_FILE + +# Merge files, printing warnings on overridden values +for MERGE_FILE in $MERGE_LIST ; do + echo "Merging $MERGE_FILE" + if [ ! -r "$MERGE_FILE" ]; then + echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 + exit 1 + fi + CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) + + for CFG in $CFG_LIST ; do + grep -q -w $CFG $TMP_FILE || continue + PREV_VAL=$(grep -w $CFG $TMP_FILE) + NEW_VAL=$(grep -w $CFG $MERGE_FILE) + if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then + echo Value of $CFG is redefined by fragment $MERGE_FILE: + echo Previous value: $PREV_VAL + echo New value: $NEW_VAL + echo + elif [ "$WARNREDUN" = "true" ]; then + echo Value of $CFG is redundant by fragment $MERGE_FILE: + fi + sed -i "/$CFG[ =]/d" $TMP_FILE + done + cat $MERGE_FILE >> $TMP_FILE +done + +if [ "$RUNMAKE" = "false" ]; then + cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG" + echo "#" + echo "# merged configuration written to $KCONFIG_CONFIG (needs make)" + echo "#" + clean_up + exit +fi + +# If we have an output dir, setup the O= argument, otherwise leave +# it blank, since O=. will create an unnecessary ./source softlink +OUTPUT_ARG="" +if [ "$OUTPUT" != "." ] ; then + OUTPUT_ARG="O=$OUTPUT" +fi + + +# Use the merged file as the starting point for: +# alldefconfig: Fills in any missing symbols with Kconfig default +# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set +make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET + + +# Check all specified config values took (might have missed-dependency issues) +for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do + + REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) + ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG") + if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then + echo "Value requested for $CFG not in final .config" + echo "Requested value: $REQUESTED_VAL" + echo "Actual value: $ACTUAL_VAL" + echo "" + fi +done + +clean_up diff --git a/utils/kconfig-tweak.in b/utils/kconfig-tweak.in new file mode 100644 index 0000000..9c2fdae --- /dev/null +++ b/utils/kconfig-tweak.in @@ -0,0 +1,225 @@ +#!/bin/bash +# Manipulate options in a .config file from the command line + +myname=${0##*/} + +# If no prefix forced, use the default @CONFIG_@ +CONFIG_="${CONFIG_-@CONFIG_@}" + +usage() { + cat >&2 <"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + +txt_subst() { + local before="$1" + local after="$2" + local infile="$3" + local tmpfile="$infile.swp" + + sed -e "s:$before:$after:" "$infile" >"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + +txt_delete() { + local text="$1" + local infile="$2" + local tmpfile="$infile.swp" + + sed -e "/$text/d" "$infile" >"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + +set_var() { + local name=$1 new=$2 before=$3 + + name_re="^($name=|# $name is not set)" + before_re="^($before=|# $before is not set)" + if test -n "$before" && grep -Eq "$before_re" "$FN"; then + txt_append "^$before=" "$new" "$FN" + txt_append "^# $before is not set" "$new" "$FN" + elif grep -Eq "$name_re" "$FN"; then + txt_subst "^$name=.*" "$new" "$FN" + txt_subst "^# $name is not set" "$new" "$FN" + else + echo "$new" >>"$FN" + fi +} + +undef_var() { + local name=$1 + + txt_delete "^$name=" "$FN" + txt_delete "^# $name is not set" "$FN" +} + +if [ "$1" = "--file" ]; then + FN="$2" + if [ "$FN" = "" ] ; then + usage + fi + shift 2 +else + FN=.config +fi + +if [ "$1" = "" ] ; then + usage +fi + +MUNGE_CASE=yes +while [ "$1" != "" ] ; do + CMD="$1" + shift + case "$CMD" in + --keep-case|-k) + MUNGE_CASE=no + continue + ;; + --refresh) + ;; + --*-after|-E|-D|-M) + checkarg "$1" + A=$ARG + checkarg "$2" + B=$ARG + shift 2 + ;; + -*) + checkarg "$1" + shift + ;; + esac + case "$CMD" in + --enable|-e) + set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y" + ;; + + --disable|-d) + set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set" + ;; + + --module|-m) + set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m" + ;; + + --set-str) + # sed swallows one level of escaping, so we need double-escaping + set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\"" + shift + ;; + + --set-val) + set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" + shift + ;; + --undefine|-u) + undef_var "${CONFIG_}$ARG" + ;; + + --state|-s) + if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then + echo n + else + V="$(grep "^${CONFIG_}$ARG=" $FN)" + if [ $? != 0 ] ; then + echo undef + else + V="${V/#${CONFIG_}$ARG=/}" + V="${V/#\"/}" + V="${V/%\"/}" + V="${V//\\\"/\"}" + echo "${V}" + fi + fi + ;; + + --enable-after|-E) + set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A" + ;; + + --disable-after|-D) + set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A" + ;; + + --module-after|-M) + set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" + ;; + + # undocumented because it ignores --file (fixme) + --refresh) + yes "" | make oldconfig + ;; + + *) + usage + ;; + esac +done diff --git a/utils/kconfig-tweak.in.patch b/utils/kconfig-tweak.in.patch new file mode 100644 index 0000000..5a85fe7 --- /dev/null +++ b/utils/kconfig-tweak.in.patch @@ -0,0 +1,23 @@ +diff --git a/utils/kconfig-tweak.in b/utils/kconfig-tweak.in +--- a/utils/kconfig-tweak.in ++++ b/utils/kconfig-tweak.in +@@ -3,8 +3,8 @@ + + myname=${0##*/} + +-# If no prefix forced, use the default CONFIG_ +-CONFIG_="${CONFIG_-CONFIG_}" ++# If no prefix forced, use the default @CONFIG_@ ++CONFIG_="${CONFIG_-@CONFIG_@}" + + usage() { + cat >&2 <&2 - exit 1 - fi - shift 2 - continue - ;; - *) - break - ;; - esac -done - -if [ "$#" -lt 1 ] ; then - usage - exit -fi - -if [ -z "$KCONFIG_CONFIG" ]; then - if [ "$OUTPUT" != . ]; then - KCONFIG_CONFIG=$(readlink -m -- "$OUTPUT/.config") - else - KCONFIG_CONFIG=.config - fi -fi - -INITFILE=$1 -shift; - -if [ ! -r "$INITFILE" ]; then - echo "The base file '$INITFILE' does not exist. Exit." >&2 - exit 1 -fi - -MERGE_LIST=$* -SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" -TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) - -echo "Using $INITFILE as base" -cat $INITFILE > $TMP_FILE - -# Merge files, printing warnings on overridden values -for MERGE_FILE in $MERGE_LIST ; do - echo "Merging $MERGE_FILE" - if [ ! -r "$MERGE_FILE" ]; then - echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 - exit 1 - fi - CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) - - for CFG in $CFG_LIST ; do - grep -q -w $CFG $TMP_FILE || continue - PREV_VAL=$(grep -w $CFG $TMP_FILE) - NEW_VAL=$(grep -w $CFG $MERGE_FILE) - if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then - echo Value of $CFG is redefined by fragment $MERGE_FILE: - echo Previous value: $PREV_VAL - echo New value: $NEW_VAL - echo - elif [ "$WARNREDUN" = "true" ]; then - echo Value of $CFG is redundant by fragment $MERGE_FILE: - fi - sed -i "/$CFG[ =]/d" $TMP_FILE - done - cat $MERGE_FILE >> $TMP_FILE -done - -if [ "$RUNMAKE" = "false" ]; then - cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG" - echo "#" - echo "# merged configuration written to $KCONFIG_CONFIG (needs make)" - echo "#" - clean_up - exit -fi - -# If we have an output dir, setup the O= argument, otherwise leave -# it blank, since O=. will create an unnecessary ./source softlink -OUTPUT_ARG="" -if [ "$OUTPUT" != "." ] ; then - OUTPUT_ARG="O=$OUTPUT" -fi - - -# Use the merged file as the starting point for: -# alldefconfig: Fills in any missing symbols with Kconfig default -# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set -make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET - - -# Check all specified config values took (might have missed-dependency issues) -for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do - - REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) - ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG") - if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then - echo "Value requested for $CFG not in final .config" - echo "Requested value: $REQUESTED_VAL" - echo "Actual value: $ACTUAL_VAL" - echo "" - fi -done - -clean_up diff --git a/utils/tweak.in b/utils/tweak.in deleted file mode 100644 index 9c2fdae..0000000 --- a/utils/tweak.in +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/bash -# Manipulate options in a .config file from the command line - -myname=${0##*/} - -# If no prefix forced, use the default @CONFIG_@ -CONFIG_="${CONFIG_-@CONFIG_@}" - -usage() { - cat >&2 <"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" -} - -txt_subst() { - local before="$1" - local after="$2" - local infile="$3" - local tmpfile="$infile.swp" - - sed -e "s:$before:$after:" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" -} - -txt_delete() { - local text="$1" - local infile="$2" - local tmpfile="$infile.swp" - - sed -e "/$text/d" "$infile" >"$tmpfile" - # replace original file with the edited one - mv "$tmpfile" "$infile" -} - -set_var() { - local name=$1 new=$2 before=$3 - - name_re="^($name=|# $name is not set)" - before_re="^($before=|# $before is not set)" - if test -n "$before" && grep -Eq "$before_re" "$FN"; then - txt_append "^$before=" "$new" "$FN" - txt_append "^# $before is not set" "$new" "$FN" - elif grep -Eq "$name_re" "$FN"; then - txt_subst "^$name=.*" "$new" "$FN" - txt_subst "^# $name is not set" "$new" "$FN" - else - echo "$new" >>"$FN" - fi -} - -undef_var() { - local name=$1 - - txt_delete "^$name=" "$FN" - txt_delete "^# $name is not set" "$FN" -} - -if [ "$1" = "--file" ]; then - FN="$2" - if [ "$FN" = "" ] ; then - usage - fi - shift 2 -else - FN=.config -fi - -if [ "$1" = "" ] ; then - usage -fi - -MUNGE_CASE=yes -while [ "$1" != "" ] ; do - CMD="$1" - shift - case "$CMD" in - --keep-case|-k) - MUNGE_CASE=no - continue - ;; - --refresh) - ;; - --*-after|-E|-D|-M) - checkarg "$1" - A=$ARG - checkarg "$2" - B=$ARG - shift 2 - ;; - -*) - checkarg "$1" - shift - ;; - esac - case "$CMD" in - --enable|-e) - set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y" - ;; - - --disable|-d) - set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set" - ;; - - --module|-m) - set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m" - ;; - - --set-str) - # sed swallows one level of escaping, so we need double-escaping - set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\"" - shift - ;; - - --set-val) - set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1" - shift - ;; - --undefine|-u) - undef_var "${CONFIG_}$ARG" - ;; - - --state|-s) - if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then - echo n - else - V="$(grep "^${CONFIG_}$ARG=" $FN)" - if [ $? != 0 ] ; then - echo undef - else - V="${V/#${CONFIG_}$ARG=/}" - V="${V/#\"/}" - V="${V/%\"/}" - V="${V//\\\"/\"}" - echo "${V}" - fi - fi - ;; - - --enable-after|-E) - set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A" - ;; - - --disable-after|-D) - set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A" - ;; - - --module-after|-M) - set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" - ;; - - # undocumented because it ignores --file (fixme) - --refresh) - yes "" | make oldconfig - ;; - - *) - usage - ;; - esac -done diff --git a/utils/tweak.in.patch b/utils/tweak.in.patch deleted file mode 100644 index c4b8557..0000000 --- a/utils/tweak.in.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/utils/tweak.in b/utils/tweak.in ---- a/utils/tweak.in -+++ b/utils/tweak.in -@@ -3,8 +3,8 @@ - - myname=${0##*/} - --# If no prefix forced, use the default CONFIG_ --CONFIG_="${CONFIG_-CONFIG_}" -+# If no prefix forced, use the default @CONFIG_@ -+CONFIG_="${CONFIG_-@CONFIG_@}" - - usage() { - cat >&2 <