diff options
author | Phil Sutter <phil@nwl.cc> | 2010-04-11 02:14:56 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2010-06-12 14:02:48 +0200 |
commit | a0f533460bcb41a04d592345303348575f2e23e2 (patch) | |
tree | 04a410486da0a160094c86a69db123b21cf58c93 /package/pkgmaker | |
parent | 27ad978f93dcf77403f80f2c651359267d7602bb (diff) |
auto-generate package/Config.in
The algorithm in package/pkgmaker works as follows:
1) for all package/*/Makefile
a) parse PKG_NAME and PKG_SECTION
b) skip if PKG_SECTION is 'kernel' (special ones)
c) check if Config.in{,.lib,.manual} contain something
d) fetch the first word of the first prompt from any result from c)
e) fetch the verbose section name from package/SECTIONS.list based on
PKG_SECTION, or just 'libs' if it's about Config.in.lib
f) write results to package/package_section_list, in the form:
'<Config.in prompt> <path to Config.in file> <verbose section name>'
2) sort package/package_section_list first by <verbose section name>,
next by <Config.in prompt>
3) create package/Config.in.auto using the result from 2)
Diffstat (limited to 'package/pkgmaker')
-rw-r--r-- | package/pkgmaker | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/package/pkgmaker b/package/pkgmaker index ea89424e7..bb91dbe37 100644 --- a/package/pkgmaker +++ b/package/pkgmaker @@ -71,7 +71,7 @@ for dn in */Makefile; do typeset -u dnu=${dn//-/_} dnu=${dnu//+/X} - ( # fd 4 = Config.in; fd 5 = Config.in.lib + ( # fd 4 = Config.in; fd 5 = Config.in.lib; fd 6 = Config.in.kmod g5=0 # Handle master package (directory) @@ -264,3 +264,79 @@ EOF ) 4>Config.in 5>Config.in.lib 6>Config.in.kmod cd .. done + +# return good if given file exists and is non-empty +function non_empty_file() { + [[ -f "$1" ]] || return 1 + [[ -n "$(cat "$1")" ]] || return 1 + return 0 +} + +# print the verbose section name for a given section tag +function lookup_section_string() { + str="$(grep ^$1\ SECTIONS.list | cut -d ' ' -f '2-')" + [[ -n $str ]] && { echo $str; return; } + echo $1 +} + +# print the first prompt's first word's value in a given Config.in file +function get_first_prompt() { + prompt="$(grep -m 1 "prompt " $1 | sed -n 's/.*"\([^ \.]*\)[ \.].*"/\1/p')" + [[ -n $prompt ]] && echo $prompt +} + +# collect packages along with their section and +# create a list of '<name> <path to config.in> <section string>' for later sorting +rm -f package_section_list +for dn in */Makefile; do + dn=${dn%/*} + pbar="Pass 3: $dn ..." + print -nu2 "$pbar\r" + + cd $dn + eval $($GMAKE dump="PKG_NAME PKG_SECTION") + cd .. + + # ignore section kernel, these are included inside target/config + [[ $PKG_SECTION = kernel ]] && continue + + PKG_SECTION=${PKG_SECTION:-none} + + has_config_in=false + if non_empty_file $dn/Config.in; then + prompt="$(get_first_prompt $dn/Config.in)" + prompt="${prompt:-$PKG_NAME}" + echo "$prompt $dn/Config.in $(lookup_section_string $PKG_SECTION)" + has_config_in=true + fi + if non_empty_file $dn/Config.in.lib; then + prompt="$(get_first_prompt $dn/Config.in.lib)" + prompt="${prompt:-$PKG_NAME}" + echo "$prompt $dn/Config.in.lib $(lookup_section_string libs)" + has_config_in=true + fi + if non_empty_file $dn/Config.in.manual; then + prompt="$(get_first_prompt $dn/Config.in.manual)" + prompt="${prompt:-$PKG_NAME}" + echo "$prompt $dn/Config.in.manual $(lookup_section_string $PKG_SECTION)" + has_config_in=true + fi + $has_config_in || print -u2 "$dn: No Config.in file found?!" +done >package_section_list + +# create the Config.in.auto from the sorted list from above +cursec="" +sort -k 3 -k 1 -f package_section_list | while read name file section; do + pbar="Pass 4: $name ..." + print -nu2 "$pbar\r" + + if [[ $cursec != $section ]]; then + [[ -n $cursec ]] && print "endmenu\n" + + print "menu \"$section\"" + cursec="$section" + fi + print "source \"package/$file\"" +done >Config.in.auto +print "endmenu\n" >>Config.in.auto +rm -f package_section_list |