diff -urN linux.org/Documentation/autoconf.txt linux-2.6.13/Documentation/autoconf.txt --- linux.org/Documentation/autoconf.txt 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.13/Documentation/autoconf.txt 2005-09-15 15:36:35.000000000 +0200 @@ -0,0 +1,161 @@ + +Constist: +******** + +The Linux Auto-Config consist of Files, auto_conf.c, an upgraded conf.c and Makefile, a directory +(rules) which contains a rules_list and the scripts, and a xmlparser written by Tim Hockin. + + + + +How does it work: +***************** + +The trick of all is a framworking program, that means adding binaries or scripts without +touching the real program. The program starts like if you are starting a make config, but at that point +where it wants an input from you, the function auto_conf gets called with that option-question +as a parameter. We are comparing this option with in a list manual-written +Kconfig option. Each of those options in the list has its own script which will be +executed in parallel by accordance. For putting an option in the rules_list you need +the Option and a script that does the work for the option and then gives a value +to the stout. This value will be redirected through a pipe to our main program which will +write the config-name for the option into the .config file. + + + + +How to add a rule: +******************* + + +The basic of the script is that it must give an answer to stdout. +Since the rules_list is written in xml there are some conditions for adding rules. +To add a rule (for the specified option), you have to know first the option name +and the name of the menu that contains it. +The easiest way, to do this, is to run make menuconfig, and see in which menu or submenu your option belongs to. +Each of those has its own XML-Tag: + + +: beginnging of the list. + +: + Has the attribute "name" and "must_have". In attribute "name" the name of the menu should be written. + Attribute "must_have" shows the min. number of option, that in a menu should be choosen for a proper Kernel. + can contains options or submenus(the same as ). + + + In the attribut name the option name should be written. And the contain of the Option Tag + is the name of rule that belongs to that option. + +example: + + + + + + + + + + + + +How to make a rule +******************* + +A rule can be either a script or binary or... The main job is to +give out an answer to stout for the actually option-question, it doesn't matter +how. + +We have three types of answer: + +sym-answers: either y, n, m or \n. + +string-answer: can be maximal 128 characters + +option-answer: By the manual configuration normally you have to type an number + but a rule for an option should give out an y, if it want to be choosen. + + + + + +For example: the option is "Networking Support" + the program looks in the our list (which is called rules_list) + to find the "Networking Support" and if this option is in there, + a certain script (which we call it a rule) will be executed. + In this example the script name is hw_grep1.pm which + reads a given Parameter and searches for this Parameter, + lspci and dmesg with the help of grep. In this Case the Parameter + will be "Ethernet|Network". + + hw_grep1.pm: + + $found=''; + $found=`lspci | grep "@ARGV"`; + if($found ne '') { + print("y\n"); + } + else { + $found=`grep -E "@ARGV" /var/log/dmesg `; + if($found ne ''){ + print("y\n"); + } + else { + print("n\n"); + } + } + 1; + + + + + + This script checks if there is an Ethernet or + a Network card on the target System. + If it is true, it gives in this case a 'y' to stdout. + And for some options there can't be any script-rules, for instance software such as FTP or TCPIP etc..., + those question either get answered as 'build in' or as 'module'. + !! the answers must always have a '\n' at the end + +The rule-binary should be copied in the directory /scripts/kconfig/rules/ + + + +Messages: +******************* + +When the amount of needed Options in some menus are not choosen, +messages will be given out in the stdout, at the end of the configuration. +Containig Name of the menus. + +This can be happen: + +1. if for some options they rules are not applied. The reason for that is for some Hardware Option there is no rule. + +2. if your System doesn't support the Hardware i.e. you don't have an ethernet Card. + +In this case either your upgrade the autoconfig with rules or your contact me. + +If you are getting messages please include the following information: + +1. a copy of your lspci, /proc/cpuinfo and /var/log/dmesg + +2. a copy of your messages + + + +TO DO: +******************* + +1. The Framework has to be extend for the Systems that aren't supported. + +2 .A way to ask for the Hardware-Devices directly from the I/O. + + +Contact: +******************* + +Suggestion and comments are welcome. + +Email: Ahmad Reza Cheraghi diff -urN linux.org/scripts/kconfig/auto_conf.c linux-2.6.13/scripts/kconfig/auto_conf.c --- linux.org/scripts/kconfig/auto_conf.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.13/scripts/kconfig/auto_conf.c 2005-09-15 15:39:40.000000000 +0200 @@ -0,0 +1,302 @@ +/************************************************************************************** +* * +* auto_conf.c: Framework for autogeneration a Kernel Configuration * +* * +* This project was done in the Niederrhein University of Applied Sciences * +* * +* Copyright (C) 2005 Ahmad Reza Cheraghi * +* This is free software, see GNU General Public License 2 for details. * +* * +* * +* This Framework autogenerate a Configuration based on the given rules * +* It does not guaranty that a Kernel can work after this generation since * +* it is in his test-stage. * +* * +* * +* Report errors, bugs, additions, wishes and comments to me: * +* * +* * +* For futher information please refer to the README.txt * +* * +* * +**************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmlparser.h" + +static struct xml_element *ret; +signed char answerbuf[128]; +int error_flag = 0; + +static int reading_xml_tree(struct xml_element* element, const char * option); + +enum { + read_tree, + check_tree +} tree_mode = read_tree; + + + +/************************************************************************ + * exec_rule() * + * * + * calls a child process, that redirect stout to the pipe * + * and execute the rule-script throught the Unix Process * + * system(). * + * The parent reads from the pipe, and copied in the variable * + * answer. * + ***********************************************************************/ + +static int exec_rule(const char* rule) +{ + int pd[2]; + pid_t childpid; + char directory[128]; + + /* + * reading the dirctory where the rules are + */ + strncpy(directory,"scripts/kconfig/rules/", 128); + + strcat(directory, rule); + + pipe(pd); + + if (( childpid = fork() ) == 0) { + dup2(pd[1], STDOUT_FILENO); + + close(pd[0]); + close(pd[1]); + /* + * calling the rule + */ + system(directory); + exit(0); + } + close(pd[1]); + /* + * waiting for the child process to complete + */ + while ( wait ((int *) 0) != childpid) + continue; + /* + * reading from the pipe, that is the answer from the rule + */ + read( pd[0], answerbuf, 128 ); + close(pd[0]); + return 0; +} + + +/************************************************************************ +* get_rule() * +* * +* compares the option from the rules_list with the actual * +* option, if they are the same, the rule that is containing * +* int the list will be read and give to the function exec_rule * +* * +* After that, it will be checked if the answer is positive and it * +* so and if the menu has a priority for arising the must_have * +* counter. * +* * +***********************************************************************/ + +static int get_rule (struct xml_element* child, const char * option) +{ + struct xml_prop *attribute; + char content[128]; + attribute = NULL; + + attribute = get_next_attribute(child, attribute); + + if (attribute==NULL) { + return 0; + } + + if (strcmp(get_attribute_name(attribute),"name") != 0) { + printf("error in rules_list by Tag