1
0
Fork 0

kconfig: use long options in conf

The list of options supported by conf is growing
and their abbreviation did not resemble anything usefull.

So drop the single letter options in favour of long options.

The long options are named equal to what we know from
the make target.
The internal implmentation was changed to match this,
resulting in much more readable code.

Support for short options is dropped - no one is supposed
to call this program direct anyway.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
wifi-calibration
Sam Ravnborg 2010-07-31 23:35:26 +02:00 committed by Michal Marek
parent ac1ffde1ba
commit 4062f1a4c0
2 changed files with 105 additions and 126 deletions

View File

@ -21,53 +21,47 @@ menuconfig: $(obj)/mconf
$< $(Kconfig) $< $(Kconfig)
config: $(obj)/conf config: $(obj)/conf
$< $(Kconfig) $< --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf nconfig: $(obj)/nconf
$< $(Kconfig) $< $(Kconfig)
oldconfig: $(obj)/conf oldconfig: $(obj)/conf
$< -o $(Kconfig) $< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/generated $(Q)mkdir -p include/generated
$< -s $(Kconfig) $< --$@ $(Kconfig)
localmodconfig: $(obj)/streamline_config.pl $(obj)/conf localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)perl $< $(srctree) $(Kconfig) > .tmp.config $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
$(Q)if [ -f .config ]; then \ $(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \ cmp -s .tmp.config .config || \
(mv -f .config .config.old.1; \ (mv -f .config .config.old.1; \
mv -f .tmp.config .config; \ mv -f .tmp.config .config; \
$(obj)/conf -s $(Kconfig); \ $(obj)/conf --silentoldconfig $(Kconfig); \
mv -f .config.old.1 .config.old) \ mv -f .config.old.1 .config.old) \
else \ else \
mv -f .tmp.config .config; \ mv -f .tmp.config .config; \
$(obj)/conf -s $(Kconfig); \ $(obj)/conf --silentoldconfig $(Kconfig); \
fi fi
$(Q)rm -f .tmp.config $(Q)rm -f .tmp.config
localyesconfig: $(obj)/streamline_config.pl $(obj)/conf localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
$(Q)perl $< $(srctree) $(Kconfig) > .tmp.config $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
$(Q)sed -i s/=m/=y/ .tmp.config $(Q)sed -i s/=m/=y/ .tmp.config
$(Q)if [ -f .config ]; then \ $(Q)if [ -f .config ]; then \
cmp -s .tmp.config .config || \ cmp -s .tmp.config .config || \
(mv -f .config .config.old.1; \ (mv -f .config .config.old.1; \
mv -f .tmp.config .config; \ mv -f .tmp.config .config; \
$(obj)/conf -s $(Kconfig); \ $(obj)/conf --silentoldconfig $(Kconfig); \
mv -f .config.old.1 .config.old) \ mv -f .config.old.1 .config.old) \
else \ else \
mv -f .tmp.config .config; \ mv -f .tmp.config .config; \
$(obj)/conf -s $(Kconfig); \ $(obj)/conf --silentoldconfig $(Kconfig); \
fi fi
$(Q)rm -f .tmp.config $(Q)rm -f .tmp.config
nonint_oldconfig: $(obj)/conf
$< -b $(Kconfig)
loose_nonint_oldconfig: $(obj)/conf
$< -B $(Kconfig)
# Create new linux.pot file # Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
# The symlink is used to repair a deficiency in arch/um # The symlink is used to repair a deficiency in arch/um
@ -91,30 +85,26 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
$(Q)rm -f arch/um/Kconfig.arch $(Q)rm -f arch/um/Kconfig.arch
$(Q)rm -f $(obj)/config.pot $(Q)rm -f $(obj)/config.pot
PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig PHONY += allnoconfig allyesconfig allmodconfig randconfig
randconfig: $(obj)/conf allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf
$< -r $(Kconfig) $< --$@ $(Kconfig)
allyesconfig: $(obj)/conf PHONY += nonint_oldconfig loose_nonint_oldconfig defconfig
$< -y $(Kconfig)
allnoconfig: $(obj)/conf nonint_oldconfig loose_nonint_oldconfig: $(obj)/conf
$< -n $(Kconfig) $< --$@ $(Kconfig)
allmodconfig: $(obj)/conf
$< -m $(Kconfig)
defconfig: $(obj)/conf defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),) ifeq ($(KBUILD_DEFCONFIG),)
$< -d $(Kconfig) $< --defconfig $(Kconfig)
else else
@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
$(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif endif
%_defconfig: $(obj)/conf %_defconfig: $(obj)/conf
$(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
# Help text used by make help # Help text used by make help
help: help:

View File

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
@ -23,18 +24,19 @@
static void conf(struct menu *menu); static void conf(struct menu *menu);
static void check_conf(struct menu *menu); static void check_conf(struct menu *menu);
enum { enum input_mode {
ask_all, oldaskconfig,
ask_new, silentoldconfig,
ask_silent, oldconfig,
dont_ask, allnoconfig,
dont_ask_dont_tell, allyesconfig,
set_default, allmodconfig,
set_yes, randconfig,
set_mod, defconfig,
set_no, nonint_oldconfig,
set_random loose_nonint_oldconfig,
} input_mode = ask_all; } input_mode = oldaskconfig;
char *defconfig_file; char *defconfig_file;
static int indent = 1; static int indent = 1;
@ -100,14 +102,14 @@ static int conf_askvalue(struct symbol *sym, const char *def)
} }
switch (input_mode) { switch (input_mode) {
case ask_new: case oldconfig:
case ask_silent: case silentoldconfig:
if (sym_has_value(sym)) { if (sym_has_value(sym)) {
printf("%s\n", def); printf("%s\n", def);
return 0; return 0;
} }
check_stdin(); check_stdin();
case ask_all: case oldaskconfig:
fflush(stdout); fflush(stdout);
fgets(line, 128, stdin); fgets(line, 128, stdin);
return 1; return 1;
@ -297,15 +299,15 @@ static int conf_choice(struct menu *menu)
printf("?"); printf("?");
printf("]: "); printf("]: ");
switch (input_mode) { switch (input_mode) {
case ask_new: case oldconfig:
case ask_silent: case silentoldconfig:
if (!is_new) { if (!is_new) {
cnt = def; cnt = def;
printf("%d\n", cnt); printf("%d\n", cnt);
break; break;
} }
check_stdin(); check_stdin();
case ask_all: case oldaskconfig:
fflush(stdout); fflush(stdout);
fgets(line, 128, stdin); fgets(line, 128, stdin);
strip(line); strip(line);
@ -363,9 +365,9 @@ static void conf(struct menu *menu)
switch (prop->type) { switch (prop->type) {
case P_MENU: case P_MENU:
if ((input_mode == ask_silent || if ((input_mode == silentoldconfig ||
input_mode == dont_ask || input_mode == nonint_oldconfig ||
input_mode == dont_ask_dont_tell) && input_mode == loose_nonint_oldconfig) &&
rootEntry != menu) { rootEntry != menu) {
check_conf(menu); check_conf(menu);
return; return;
@ -424,9 +426,9 @@ static void check_conf(struct menu *menu)
if (sym && !sym_has_value(sym)) { if (sym && !sym_has_value(sym)) {
if (sym_is_changable(sym) || if (sym_is_changable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
if (input_mode == dont_ask || if (input_mode == nonint_oldconfig ||
input_mode == dont_ask_dont_tell) { input_mode == loose_nonint_oldconfig) {
if (input_mode == dont_ask && if (input_mode == nonint_oldconfig &&
sym->name && !sym_is_choice_value(sym)) { sym->name && !sym_is_choice_value(sym)) {
if (!unset_variables) if (!unset_variables)
fprintf(stderr, "The following" fprintf(stderr, "The following"
@ -448,6 +450,20 @@ static void check_conf(struct menu *menu)
check_conf(child); check_conf(child);
} }
static struct option long_opts[] = {
{"oldaskconfig", no_argument, NULL, oldaskconfig},
{"oldconfig", no_argument, NULL, oldconfig},
{"silentoldconfig", no_argument, NULL, silentoldconfig},
{"defconfig", optional_argument, NULL, defconfig},
{"allnoconfig", no_argument, NULL, allnoconfig},
{"allyesconfig", no_argument, NULL, allyesconfig},
{"allmodconfig", no_argument, NULL, allmodconfig},
{"randconfig", no_argument, NULL, randconfig},
{"nonint_oldconfig", no_argument, NULL, nonint_oldconfig},
{"loose_nonint_oldconfig", no_argument, NULL, loose_nonint_oldconfig},
{NULL, 0, NULL, 0}
};
int main(int ac, char **av) int main(int ac, char **av)
{ {
int opt; int opt;
@ -458,38 +474,16 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR); bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); textdomain(PACKAGE);
while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) { while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) {
input_mode = (enum input_mode)opt;
switch (opt) { switch (opt) {
case 'o': case silentoldconfig:
input_mode = ask_silent;
break;
case 's':
input_mode = ask_silent;
sync_kconfig = 1; sync_kconfig = 1;
break; break;
case 'b': case defconfig:
input_mode = dont_ask;
break;
case 'B':
input_mode = dont_ask_dont_tell;
break;
case 'd':
input_mode = set_default;
break;
case 'D':
input_mode = set_default;
defconfig_file = optarg; defconfig_file = optarg;
break; break;
case 'n': case randconfig:
input_mode = set_no;
break;
case 'm':
input_mode = set_mod;
break;
case 'y':
input_mode = set_yes;
break;
case 'r':
{ {
struct timeval now; struct timeval now;
unsigned int seed; unsigned int seed;
@ -502,17 +496,12 @@ int main(int ac, char **av)
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
srand(seed); srand(seed);
input_mode = set_random;
break; break;
} }
case 'h': case '?':
printf(_("See README for usage info\n"));
exit(0);
break;
default:
fprintf(stderr, _("See README for usage info\n")); fprintf(stderr, _("See README for usage info\n"));
exit(1); exit(1);
break;
} }
} }
if (ac == optind) { if (ac == optind) {
@ -537,7 +526,7 @@ int main(int ac, char **av)
} }
switch (input_mode) { switch (input_mode) {
case set_default: case defconfig:
if (!defconfig_file) if (!defconfig_file)
defconfig_file = conf_get_default_confname(); defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) { if (conf_read(defconfig_file)) {
@ -547,27 +536,27 @@ int main(int ac, char **av)
exit(1); exit(1);
} }
break; break;
case ask_silent: case silentoldconfig:
case ask_all: case oldaskconfig:
case ask_new: case oldconfig:
case dont_ask: case nonint_oldconfig:
case dont_ask_dont_tell: case loose_nonint_oldconfig:
conf_read(NULL); conf_read(NULL);
break; break;
case set_no: case allnoconfig:
case set_mod: case allyesconfig:
case set_yes: case allmodconfig:
case set_random: case randconfig:
name = getenv("KCONFIG_ALLCONFIG"); name = getenv("KCONFIG_ALLCONFIG");
if (name && !stat(name, &tmpstat)) { if (name && !stat(name, &tmpstat)) {
conf_read_simple(name, S_DEF_USER); conf_read_simple(name, S_DEF_USER);
break; break;
} }
switch (input_mode) { switch (input_mode) {
case set_no: name = "allno.config"; break; case allnoconfig: name = "allno.config"; break;
case set_mod: name = "allmod.config"; break; case allyesconfig: name = "allyes.config"; break;
case set_yes: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break;
case set_random: name = "allrandom.config"; break; case randconfig: name = "allrandom.config"; break;
default: break; default: break;
} }
if (!stat(name, &tmpstat)) if (!stat(name, &tmpstat))
@ -592,37 +581,37 @@ int main(int ac, char **av)
} }
switch (input_mode) { switch (input_mode) {
case set_no: case allnoconfig:
conf_set_all_new_symbols(def_no); conf_set_all_new_symbols(def_no);
break; break;
case set_yes: case allyesconfig:
conf_set_all_new_symbols(def_yes); conf_set_all_new_symbols(def_yes);
break; break;
case set_mod: case allmodconfig:
conf_set_all_new_symbols(def_mod); conf_set_all_new_symbols(def_mod);
break; break;
case set_random: case randconfig:
conf_set_all_new_symbols(def_random); conf_set_all_new_symbols(def_random);
break; break;
case set_default: case defconfig:
conf_set_all_new_symbols(def_default); conf_set_all_new_symbols(def_default);
break; break;
case ask_new: case oldconfig:
case ask_all: case oldaskconfig:
rootEntry = &rootmenu; rootEntry = &rootmenu;
conf(&rootmenu); conf(&rootmenu);
input_mode = ask_silent; input_mode = silentoldconfig;
/* fall through */ /* fall through */
case dont_ask: case nonint_oldconfig:
case dont_ask_dont_tell: case loose_nonint_oldconfig:
case ask_silent: case silentoldconfig:
/* Update until a loop caused no more changes */ /* Update until a loop caused no more changes */
do { do {
conf_cnt = 0; conf_cnt = 0;
check_conf(&rootmenu); check_conf(&rootmenu);
} while (conf_cnt && } while (conf_cnt &&
(input_mode != dont_ask && (input_mode != nonint_oldconfig &&
input_mode != dont_ask_dont_tell)); input_mode != loose_nonint_oldconfig));
break; break;
} }
@ -638,7 +627,7 @@ int main(int ac, char **av)
fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
return 1; return 1;
} }
} else if (!unset_variables || input_mode != dont_ask) { } else if (!unset_variables || input_mode != nonint_oldconfig) {
if (conf_write(NULL)) { if (conf_write(NULL)) {
fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
exit(1); exit(1);