On Thu, May 01, 2008 at 06:40:29AM +0200, Roman Zippel wrote:Hi Roman. This is work in progress... I have created a new frontend: aconf.c that is a trimmed down version of conf.c. aconf.c are intended to take care of all the automated configurations such as: all*config, randconfig and the automated defconfig In this way we have conf.c for all the interactive targets and aconf for all the automated targets. This is not exactly what you suggest but I thik a step in the right direction. Comments? Sam /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Copyright (C) 2008 Sam Ravnborg <sam@ravnborg.org> * Released under the terms of the GNU GPL v2.0. */ /* * Generate the automated configs */ #include <locale.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include <sys/stat.h> #define LKC_DIRECT_LINK #include "lkc.h" static void check_conf(struct menu *menu); static void conf(struct menu *menu); enum { set_default, set_yes, set_mod, set_no, set_random } input_mode; static char *defconfig_file; static int conf_cnt; static struct menu *rootEntry; /* Set strig value - it this a nop as it looks like? */ static void conf_string(struct menu *menu) { struct symbol *sym = menu->sym; const char *def; if (!sym_is_changable(sym)) return; if (sym_has_value(sym) && (input_mode != set_default)) return; def = sym_get_string_value(sym); if (def) sym_set_string_value(sym, def); } static void conf_sym(struct menu *menu) { struct symbol *sym = menu->sym; int type; tristate val; if (!sym_is_changable(sym)) return; if (sym_has_value(sym) && (input_mode != set_default)) return; type = sym_get_type(sym); switch (input_mode) { case set_yes: if (sym_tristate_within_range(sym, yes)) { sym_set_tristate_value(sym, yes); break; } /* fallthrough */ case set_mod: if (type == S_TRISTATE) { if (sym_tristate_within_range(sym, mod)) { sym_set_tristate_value(sym, mod); break; } } else if (sym_tristate_within_range(sym, yes)) { sym_set_tristate_value(sym, yes); break; } /* fallthrough */ case set_no: if (sym_tristate_within_range(sym, no)) { sym_set_tristate_value(sym, no); break; } /* fallthrough */ case set_random: do { val = (tristate)(rand() % 3); } while (!sym_tristate_within_range(sym, val)); switch (val) { case no: sym_set_tristate_value(sym, no); break; case mod: sym_set_tristate_value(sym, mod); break; case yes: sym_set_tristate_value(sym, yes); break; } break; /* silence gcc warning */ case set_default: sym_set_tristate_value(sym, sym_get_tristate_value(sym)); break; } } static void conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; int type; bool is_new; int cnt, def; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); } if (sym_get_tristate_value(sym) != yes) return; def_sym = sym_get_choice_value(sym); cnt = def = 0; for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; cnt++; if (child->sym == def_sym) def = cnt; } if (cnt == 1) goto conf_childs; switch (input_mode) { case set_random: if (is_new) def = (rand() % cnt) + 1; /* fallthrough */ case set_default: case set_yes: case set_mod: case set_no: cnt = def; break; } conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } sym_set_choice_value(sym, child->sym); for (child = child->list; child; child = child->next) conf(child); } static void conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; //if (sym) // printf("sym:%s\n", sym->name); prop = menu->prompt; if (prop && prop->type == P_MENU) { if (menu != rootEntry) { check_conf(menu); return; } } if (!sym) goto conf_childs; if (sym_is_choice(sym)) { conf_choice(menu); if (sym->curr.tri != mod) return; goto conf_childs; } switch (sym->type) { case S_INT: case S_HEX: case S_STRING: conf_string(menu); break; default: conf_sym(menu); break; } conf_childs: for (child = menu->list; child; child = child->next) conf(child); } static void check_conf(struct menu *menu) { struct symbol *sym; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { conf_cnt++; rootEntry = menu_get_parent_menu(menu); conf(rootEntry); } } for (child = menu->list; child; child = child->next) check_conf(child); } int main(int ac, char **av) { int opt; const char *name; struct stat tmpstat; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); while ((opt = getopt(ac, av, "dD:nmyrh")) != -1) { switch (opt) { case 'd': input_mode = set_default; break; case 'D': input_mode = set_default; defconfig_file = optarg; break; case 'n': input_mode = set_no; break; case 'm': input_mode = set_mod; break; case 'y': input_mode = set_yes; break; case 'r': input_mode = set_random; srand(time(NULL)); break; case 'h': printf(_("See README for usage info\n")); exit(0); break; default: fprintf(stderr, _("See README for usage info\n")); exit(1); } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); switch (input_mode) { case set_default: if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { printf(_("***\n" "*** Can't find default configuration \"%s\"!\n" "***\n"), defconfig_file); exit(1); } break; case set_no: case set_mod: case set_yes: case set_random: name = getenv("KCONFIG_ALLCONFIG"); if (name && !stat(name, &tmpstat)) { conf_read_simple(name, S_DEF_USER); break; } switch (input_mode) { case set_no: name = "allno.config"; break; case set_mod: name = "allmod.config"; break; case set_yes: name = "allyes.config"; break; case set_random: name = "allrandom.config"; break; default: break; } if (!stat(name, &tmpstat)) conf_read_simple(name, S_DEF_USER); else if (!stat("all.config", &tmpstat)) conf_read_simple("all.config", S_DEF_USER); break; default: break; } do { conf_cnt = 0; check_conf(&rootmenu); } while (conf_cnt); if (conf_write(NULL)) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); return 1; } if (conf_write_autoconf()) { fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); return 1; } return 0; } --
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Linus Torvalds | Linux 2.6.27 |
| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
git: | |
| Denis Bueno | Recovering from repository corruption |
| Linus Torvalds | I'm a total push-over.. |
| J. Bruce Fields | "failed to read delta base object at..." |
| Robin Rosenberg | Re: [wishlist] graphical diff |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Richard Stallman | Real men don't attack straw men |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Paolo Supino | order |
| Simon Horman | Possible regression in HTB |
| Corey Hickey | SFQ: backport some features from ESFQ (try 4) |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Ingo Molnar | Re: [crash] kernel BUG at net/core/dev.c:1328! |
| usb mic not detected | 23 minutes ago | Applications and Utilities |
| Problem in Inserting a module | 1 hour ago | Linux kernel |
| Treason Uncloaked | 6 hours ago | Linux kernel |
| Shared swap partition | 17 hours ago | Linux general |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 2 days ago | Applications and Utilities |
| the kernel how to power off the machine | 2 days ago | Linux kernel |
| Easter Eggs in windows XP | 2 days ago | Windows |
| Root password | 2 days ago | Linux general |
| Where/when DNOTIFY is used? | 2 days ago | Linux kernel |
