summaryrefslogtreecommitdiff
path: root/maintainer
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2017-07-05 02:19:42 (GMT)
committerAlexey Neyman <stilor@att.net>2017-07-08 17:57:56 (GMT)
commitff0a1a3da605ca157e3f3d0ed2d8b9acb30c2f69 (patch)
tree3866631ee0fa3fc650fd71de948f9a8b32bfc359 /maintainer
parent50a387afa7abd24255ef865dada5d324265e1250 (diff)
Switch gen-kconfig to new framework
Also: - Move companion_* to comp_* to match the kconfig symbols - Replace bootstrap with former gen-versions.sh - Fold *.in.2 into their respective first parts; this moves common options to the end - if it is undesirable, inclusion of *.in can be moved where *.in.2 used to be (but that will also move version selection after common options). - Retire addToolVersion.sh (may later replace with a more comprehensive script that tries to download the added tarballs, copy the patches and try to apply them, and create a version.desc). Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'maintainer')
-rwxr-xr-xmaintainer/addToolVersion.sh238
-rwxr-xr-xmaintainer/gen-kconfig.sh160
-rwxr-xr-xmaintainer/gen-versions.sh560
-rw-r--r--maintainer/kconfig-choice.template32
-rw-r--r--maintainer/kconfig-menu.template20
5 files changed, 52 insertions, 958 deletions
diff --git a/maintainer/addToolVersion.sh b/maintainer/addToolVersion.sh
deleted file mode 100755
index 38c2e55..0000000
--- a/maintainer/addToolVersion.sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#!/bin/sh
-set -e
-
-# Adds a new version to one of the toolchain component
-myname="$0"
-
-# Parse the tools' paths configuration
-# It is expected that this script is only to be run from the
-# source directory of crosstool-NG, so it is trivial to find
-# paths.sh (we can't use ". paths.sh", as POSIX states that
-# $PATH should be searched for, and $PATH most probably doe
-# not include "."), hence the "./".
-. "./paths.sh"
-
-doHelp() {
- cat <<-EOF
- Usage: ${myname} <--tool> <[options] version [...]> ...
- 'tool' in one of:
- gcc, binutils, glibc, uClibc, uClibc-ng, newlib, linux, gdb,
- duma, strace, ltrace, libelf, gmp, mpfr, isl, cloog, mpc,
- mingw-w64, expat, ncurses, musl, gettext, zlib, libiconv
-
- Valid options for all tools:
- --stable, -s, +x (default)
- mark the version as being stable (as opposed to experimental, below)
-
- --experimental, -x, +s
- mark the version as being experimental (as opposed to stable, above)
-
- --current, -c, +o (default)
- mark the version as being cuurent (as opposed to obsolete, below)
-
- --obsolete, -o, +c
- mark the version as being obsolete (as opposed to current, above)
-
- Note: setting a new tool resets to the defaults: 'stable' and 'current'.
-
- 'version' is a valid version for the specified tool.
-
- Examples:
- add stable current version 2.6.19.2 to linux kernel:
- ${myname} --linux 2.6.19.2
-
- add experimental obsolete version 2.3.5 and stable current versions 2.6.1
- and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc:
- ${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3
-EOF
-}
-
-# Extract field $3 from version $1 with separator $2
-getVersionField() {
- local version="$1"
- local sep="$2"
- local field="$3"
-
- echo "${version}${sep}${sep}${sep}${sep}" |cut -d ${sep} -f ${field}
-}
-
-# Effectively add a version to the specified tool
-# $cat : tool category
-# $tool : tool name
-# $tool_prefix : tool directory prefix
-# $EXP : set to non empty if experimental, to empty otherwise
-# OBS : set to non empty if obsolete, to empty otherwise
-# $1 : version string to add
-addToolVersion() {
- local version="$1"
- local file="$2"
- local config_ver_option
- local exp_obs_prompt
- local deps v ver_M ver_m ver_p
- local SedExpr1 SedExpr2
-
- [ -f "${file}" ] || return 0
-
- v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;')
-
- config_ver_option="${cat}_V_${v}"
-
- # Check for existing version: it can be legitimitate for an end-user
- # to try adding a new version if the one he/she wants is not listed.
- # But it can be the case where the version is hidden behind either one
- # of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed.
- if ${grep} -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1; then
- echo "'${tool}': version '${version}' already present:"
- ${grep} -A1 -B0 -n \
- -E "^(config ${config_ver_option}| {4}prompt \"${version}\")$" \
- "${file}" /dev/null
- return 0
- fi
-
- SedExpr1="${SedExpr1}config ${config_ver_option}\n"
- SedExpr1="${SedExpr1} bool\n"
- SedExpr1="${SedExpr1} prompt \"${version}"
- case "${EXP},${OBS}" in
- ,) ;;
- ,*) exp_obs_prompt=" (OBSOLETE)"
- deps=" depends on OBSOLETE"
- ;;
- *,) exp_obs_prompt=" (EXPERIMENTAL)"
- deps=" depends on EXPERIMENTAL"
- ;;
- *) exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)"
- deps=" depends on EXPERIMENTAL \\&\\& OBSOLETE"
- ;;
- esac
- [ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}"
- SedExpr1="${SedExpr1}\""
- [ -n "${deps}" ] && SedExpr1="${SedExpr1}\n${deps}"
- case "${tool}" in
- gcc)
- # Extract 'M'ajor and 'm'inor from version string
- ver_M=$(getVersionField "${version}" . 1)
- ver_m=$(getVersionField "${version}" . 2)
- if [ ${ver_M} -ge 4 ] && [ ${ver_m} -ge 2 ]; then
- SedExpr1="${SedExpr1}\n select CC_GCC_${ver_M}_${ver_m}"
- fi
- ;;
- binutils)
- # Extract 'M'ajor, 'm'inor, sometimes 'p'atch from version string
- # TODO: Rework this
- ver_M=$(getVersionField "${version}" . 1)
- ver_m=$(getVersionField "${version}" . 2)
- ver_p=$(getVersionField "${version}" . 3)
- if [ ${ver_M} -eq 2 -a ${ver_m} -eq 27 ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_27_or_later"
- elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 26 ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_26_or_later"
- elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 25 -a ${ver_p} -eq 1 ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_25_1_or_later"
- elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 25 -a -z ${ver_p} ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_25_or_later"
- elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 24 ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_24_or_later"
- elif [ ${ver_M} -eq 2 -a ${ver_m} -eq 23 -a ${ver_p} -eq 2 ]; then
- SedExpr1="${SedExpr1}\n select BINUTILS_2_23_2_or_later"
- fi
- ;;
- uClibc)
- # uClibc-0.9.33.2 needs some love
- ver_M=$(getVersionField "${version}" . 1)
- ver_m=$(getVersionField "${version}" . 2)
- ver_p=$(getVersionField "${version}" . 3)
- if [ ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 33 ]; then
- SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_0_9_33_2_or_later"
- fi
- ;;
- uClibc-ng)
- # uClibc-ng-1.0.15 changed threading configuration, no longer compatible
- # with the rest of uClibc gang.
- ver_M=$(getVersionField "${version}" . 1)
- ver_m=$(getVersionField "${version}" . 2)
- ver_p=$(getVersionField "${version}" . 3)
- if [ ${ver_M} -eq 1 -a ${ver_m} -eq 0 -a ${ver_p} -eq 15 ]; then
- SedExpr1="${SedExpr1}\n select LIBC_UCLIBC_NG_1_0_15_or_later"
- fi
- ;;
- gdb)
- # gdb-7.0 and above have special handling
- ver_M=$(getVersionField "${version}" . 1)
- ver_m=$(getVersionField "${version}" . 2)
- if [ ${ver_M} -ge 7 ]; then
- if [ ${ver_m} -ge 2 ]; then
- SedExpr1="${SedExpr1}\n select GDB_7_2_or_later"
- else
- SedExpr1="${SedExpr1}\n select GDB_7_0_or_later"
- fi
- fi
- ;;
- esac
- SedExpr2=" default \"${version}\" if ${config_ver_option}"
- "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_BELOW)$/\1\n\n'"${SedExpr1}"'/;' "${file}"
- "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_STRING_BELOW)$/\1\n'"${SedExpr2}"'/;' "${file}"
-}
-
-cat=
-tool=
-tool_prefix=
-VERSION=
-EXP=
-OBS=
-
-if [ $# -eq 0 ]; then
- doHelp
- exit 1
-fi
-
-while [ $# -gt 0 ]; do
- case "$1" in
- # Tools:
- --gcc) EXP=; OBS=; cat=CC_GCC; tool=gcc; tool_prefix=cc; dot2suffix=;;
- --binutils) EXP=; OBS=; cat=BINUTILS; tool=binutils; tool_prefix=binutils; dot2suffix=;;
- --glibc) EXP=; OBS=; cat=LIBC_GLIBC; tool=glibc; tool_prefix=libc; dot2suffix=;;
- --uClibc) EXP=; OBS=; cat=LIBC_UCLIBC; tool=uClibc; tool_prefix=libc; dot2suffix=;;
- --uClibc-ng)EXP=; OBS=; cat=LIBC_UCLIBC_NG; tool=uClibc; tool_prefix=libc; dot2suffix=;;
- --newlib) EXP=; OBS=; cat=LIBC_NEWLIB; tool=newlib; tool_prefix=libc; dot2suffix=;;
- --mingw-w64)EXP=; OBS=; cat=WINAPI; tool=mingw; tool_prefix=libc; dot2suffix=;;
- --musl) EXP=; OBS=; cat=LIBC_MUSL; tool=musl; tool_prefix=libc; dot2suffix=;;
- --linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel; dot2suffix=;;
- --gdb) EXP=; OBS=; cat=GDB; tool=gdb; tool_prefix=debug; dot2suffix=;;
- --duma) EXP=; OBS=; cat=DUMA; tool=duma; tool_prefix=debug; dot2suffix=;;
- --strace) EXP=; OBS=; cat=STRACE; tool=strace; tool_prefix=debug; dot2suffix=;;
- --ltrace) EXP=; OBS=; cat=LTRACE; tool=ltrace; tool_prefix=debug; dot2suffix=;;
- --gmp) EXP=; OBS=; cat=GMP; tool=gmp; tool_prefix=companion_libs; dot2suffix=;;
- --mpfr) EXP=; OBS=; cat=MPFR; tool=mpfr; tool_prefix=companion_libs; dot2suffix=;;
- --isl) EXP=; OBS=; cat=ISL; tool=isl; tool_prefix=companion_libs; dot2suffix=;;
- --cloog) EXP=; OBS=; cat=CLOOG; tool=cloog; tool_prefix=companion_libs; dot2suffix=;;
- --mpc) EXP=; OBS=; cat=MPC; tool=mpc; tool_prefix=companion_libs; dot2suffix=;;
- --libelf) EXP=; OBS=; cat=LIBELF; tool=libelf; tool_prefix=companion_libs; dot2suffix=;;
- --expat) EXP=; OBS=; cat=EXPAT; tool=expat; tool_prefix=companion_libs; dot2suffix=;;
- --ncurses) EXP=; OBS=; cat=NCURSES; tool=ncurses; tool_prefix=companion_libs; dot2suffix=;;
- --gettext) EXP=; OBS=; cat=GETTEXT; tool=gettext; tool_prefix=companion_libs; dot2suffix=;;
- --libiconv) EXP=; OBS=; cat=LIBICONV; tool=libiconv; tool_prefix=companion_libs; dot2suffix=;;
- --zlib) EXP=; OBS=; cat=ZLIB; tool=zlib; tool_prefix=companion_tools; dot2suffix=;;
- --make) EXP=; OBS=; cat=MAKE; tool=make; tool_prefix=companion_tools; dot2suffix=;;
- --m4) EXP=; OBS=; cat=M4; tool=m4; tool_prefix=companion_tools; dot2suffix=;;
- --autoconf) EXP=; OBS=; cat=AUTOCONF; tool=autoconf; tool_prefix=companion_tools; dot2suffix=;;
- --automake) EXP=; OBS=; cat=AUTOMAKE; tool=automake; tool_prefix=companion_tools; dot2suffix=;;
- --libtool) EXP=; OBS=; cat=LIBTOOL; tool=libtool; tool_prefix=companion_tools; dot2suffix=;;
-
- # Tools options:
- -x|--experimental|+s) EXP=1;;
- -s|--stable|+x) EXP=;;
- -o|--obsolete|+c) OBS=1;;
- -c|--current|+o) OBS=;;
-
- # Misc:
- -h|--help) doHelp; exit 0;;
- -*) echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;;
-
- # Version string:
- *) [ -n "${tool}" ] || { doHelp; exit 1; }
- file_base="config/${tool_prefix}/${tool}.in"
- addToolVersion "$1" "${file_base}${dot2suffix}"
- ;;
- esac
- shift
-done
diff --git a/maintainer/gen-kconfig.sh b/maintainer/gen-kconfig.sh
deleted file mode 100755
index 096599c..0000000
--- a/maintainer/gen-kconfig.sh
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/bin/bash
-
-set -e
-
-# Accept overrides from command line if needed
-sed=${SED:-sed}
-grep=${GREP:-grep}
-
-# Generate either a choice or a menuconfig with the specified entries.
-#
-# Usage:
-# generate a choice:
-# gen_choice <out-file> <label> <config-prefix> <base-dir>
-#
-# generate a menuconfig:
-# gen_menu <out-file> <label> <config-prefix> <base-dir>
-#
-# where:
-# out-file
-# put the generated choice/menuconfig into that file
-# for choices, it acts as the base bname of the file, the secondary
-# parts (the .in.2) are put in out-file.2
-#
-# label
-# name for the entries family
-# eg. Architecture, Kernel...
-#
-# config-prefix
-# prefix for the choice entries
-# eg. ARCH, KERNEL...
-#
-# base-dir
-# base directory containing config files
-# eg. config/arch, config/kernel...
-#
-
-# Helper: find the base names of all *.in files in a given directory
-get_components() {
- local dir="${1}"
- local f b
-
- for f in ${dir}/*.in; do
- b=${f#${dir}/}
- echo ${b%.in}
- done
-}
-
-# Generate a choice
-# See above for usage
-gen_choice() {
- local out_file="${1}"
- local label="${2}"
- local cfg_prefix="${3}"
- local base_dir="${4}"
- local file entry _entry
-
- # Generate the part-1
- exec >"${out_file}"
- printf '# %s menu\n' "${label}"
- printf '# Generated file, do not edit!!!\n'
- printf '\n'
- printf 'choice GEN_CHOICE_%s\n' "${cfg_prefix}"
- printf ' bool\n'
- printf ' prompt "%s"\n' "${label}"
- printf '\n'
- for entry in `get_components ${base_dir}`; do
- file="${base_dir}/${entry}.in"
- _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
- printf 'config %s_%s\n' "${cfg_prefix}" "${_entry}"
- printf ' bool\n'
- printf ' prompt "%s"\n' "${entry}"
- "${sed}" -r -e '/^## depends on /!d; s/^## / /;' ${file} 2>/dev/null
- "${sed}" -r -e '/^## select /!d; s/^## / /;' ${file} 2>/dev/null
- if "${grep}" -E '^## help' ${file} >/dev/null 2>&1; then
- printf ' help\n'
- "${sed}" -r -e '/^## help ?/!d; s/^## help ?/ /;' ${file} 2>/dev/null
- fi
- printf '\n'
- done
- printf 'endchoice\n'
-
- printf '\n'
- printf 'config %s\n' "${cfg_prefix}"
- printf ' string\n'
- for entry in `get_components ${base_dir}`; do
- file="${base_dir}/${entry}.in"
- _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
- printf ' default "%s" if %s_%s\n' "${entry}" "${cfg_prefix}" "${_entry}"
- done
-
- printf '\n'
- for entry in `get_components ${base_dir}`; do
- file="${base_dir}/${entry}.in"
- _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
- printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}"
- printf 'source "%s"\n' "${file}"
- printf 'endif\n'
- done
-
- # Generate the part-2
- exec >"${out_file}.2"
- printf '# %s second part options\n' "${label}"
- printf '# Generated file, do not edit!!!\n'
- for entry in `get_components ${base_dir}`; do
- file="${base_dir}/${entry}.in"
- _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
- if [ -f "${file}.2" ]; then
- printf '\n'
- printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}"
- printf 'source "%s.2"\n' "${file}"
- printf 'endif\n'
- fi
- done
-}
-
-# Generate a menuconfig
-# See above for usage
-gen_menu() {
- local out_file="${1}"
- local label="${2}"
- local cfg_prefix="${3}"
- local base_dir="${4}"
- local file entry _entry
-
- # Generate the menuconfig
- exec >"${out_file}"
- printf '# %s menu\n' "${label}"
- printf '# Generated file, do not edit!!!\n'
- printf '\n'
- for entry in `get_components ${base_dir}`; do
- file="${base_dir}/${entry}.in"
- _entry=$(printf '%s\n' "${entry}" |"${sed}" -r -s -e 's/[-.+]/_/g;')
- printf 'menuconfig %s_%s\n' "${cfg_prefix}" "${_entry}"
- printf ' bool\n'
- if "${grep}" -E '^## default' ${file} >/dev/null 2>&1; then
- "${sed}" -r -e '/^## default ?/!d; s/^## default ?/ default /;' ${file} 2>/dev/null
- fi
- printf ' prompt "%s"\n' "${entry}"
- "${sed}" -r -e '/^## depends on /!d; s/^## / /;' ${file} 2>/dev/null
- "${sed}" -r -e '/^## select /!d; s/^## / /;' ${file} 2>/dev/null
- if "${grep}" -E '^## help' ${file} >/dev/null 2>&1; then
- printf ' help\n'
- "${sed}" -r -e '/^## help ?/!d; s/^## help ?/ /;' ${file} 2>/dev/null
- fi
- printf '\n'
- printf 'if %s_%s\n' "${cfg_prefix}" "${_entry}"
- printf 'source "%s"\n' "${file}"
- printf 'endif\n'
- printf '\n'
- done
-}
-
-mkdir -p config/gen
-gen_choice config/gen/arch.in "Target Architecture" "ARCH" "config/arch"
-gen_choice config/gen/kernel.in "Target OS" "KERNEL" "config/kernel"
-gen_choice config/gen/cc.in "Compiler" "CC" "config/cc"
-gen_choice config/gen/binutils.in "Binutils" "BINUTILS" "config/binutils"
-gen_choice config/gen/libc.in "C library" "LIBC" "config/libc"
-gen_menu config/gen/debug.in "Debug facilities" "DEBUG" "config/debug"
-gen_menu config/gen/companion_tools.in "Companion tools" "COMP_TOOLS" "config/companion_tools"
diff --git a/maintainer/gen-versions.sh b/maintainer/gen-versions.sh
deleted file mode 100755
index 09ebc0b..0000000
--- a/maintainer/gen-versions.sh
+++ /dev/null
@@ -1,560 +0,0 @@
-#!/bin/bash
-
-########################################
-# Common meta-language implementation. Syntax:
-#
-# The template file is processed line by line, with @@VAR@@ placeholders
-# being replaced with a value of the VAR variable.
-# Special lines start with '#!' and a keyword:
-#
-# #!//
-# Comment, the rest of the line is ignored
-# #!if COND
-# Conditional: the lines until the matching #!end-if are processed
-# only if the conditional COND evaluates to true.
-# #!foreach NAME
-# Iterate over NAME entities (the iterator must be set up first
-# using the set_iter function), processing the lines until the matching
-# #!end-foreach line.
-
-declare -A info
-
-debug()
-{
- if [ -n "${DEBUG}" ]; then
- echo "DEBUG :: $@" >&2
- fi
-}
-
-msg()
-{
- if [ -z "${QUIET}" ]; then
- echo "INFO :: $@" >&2
- fi
-}
-
-warn()
-{
- echo "WARN :: $@" >&2
-}
-
-error()
-{
- echo "ERROR :: $@" >&2
- exit 1
-}
-
-find_end()
-{
- local token="${1}"
- local count=1
-
- # Skip first line, we know it has the proper '#!' command on it
- endline=$[l + 1]
- while [ "${endline}" -le "${end}" ]; do
- case "${tlines[${endline}]}" in
- "#!${token} "*)
- count=$[count + 1]
- ;;
- "#!end-${token}")
- count=$[count - 1]
- ;;
- esac
- if [ "${count}" = 0 ]; then
- return
- fi
- endline=$[endline + 1]
- done
- error "line ${l}: '${token}' token is unpaired"
-}
-
-set_iter()
-{
- local name="${1}"
-
- if [ "${info[iter_${name}]+set}" = "set" ]; then
- error "Iterator over '${name}' is already set up"
- fi
- shift
- debug "Setting iterator over '${name}' to '$*'"
- info[iter_${name}]="$*"
-}
-
-run_if()
-{
- local cond="${1}"
- local endline
-
- find_end "if"
- if eval "${cond}"; then
- debug "True conditional '${cond}' at lines ${l}..${endline}"
- run_lines $[l + 1] $[endline - 1]
- else
- debug "False conditional '${cond}' at lines ${l}..${endline}"
- fi
- lnext=$[endline + 1]
- debug "Continue at line ${lnext}"
-}
-
-do_foreach()
-{
- local var="${1}"
- local v saveinfo
-
- shift
- if [ "`type -t enter_${var}`" != "function" ]; then
- error "No parameter setup routine for iterator over '${var}'"
- fi
- for v in ${info[iter_${var}]}; do
- saveinfo=`declare -p info`
- eval "enter_${var} ${v}"
- eval "$@"
- eval "${saveinfo#declare -A }"
- done
-}
-
-run_foreach()
-{
- local var="${1}"
- local endline
-
- if [ "${info[iter_${var}]+set}" != "set" ]; then
- error "line ${l}: iterator over '${var}' is not defined"
- fi
- find_end "foreach"
- debug "Loop over '${var}', lines ${l}..${endline}"
- do_foreach ${var} run_lines $[l + 1] $[endline - 1]
- lnext=$[endline + 1]
- debug "Continue at line ${lnext}"
-}
-
-run_lines()
-{
- local start="${1}"
- local end="${2}"
- local l lnext s s1 v
-
- debug "Running lines ${start}..${end}"
- l=${start}
- while [ "${l}" -le "${end}" ]; do
- lnext=$[l+1]
- s="${tlines[${l}]}"
- # Expand @@foo@@ to ${info[foo]}. First escape variables/backslashes for evals below.
- s="${s//\\/\\\\}"
- s="${s//\$/\\\$}"
- s1=
- while [ -n "${s}" ]; do
- case "${s}" in
- *@@*@@*)
- v="${s#*@@}"
- v="${v%%@@*}"
- if [ "${info[${v}]+set}" != "set" ]; then
- error "line ${l}: reference to undefined variable '${v}'"
- fi
- s1="${s1}${s%%@@*}\${info[${v}]}"
- s="${s#*@@*@@}"
- ;;
- *@@*)
- error "line ${l}: non-paired @@ markers"
- ;;
- *)
- s1="${s1}${s}"
- break
- ;;
- esac
- done
- s=${s1}
-
- debug "Evaluate: ${s}"
- case "${s}" in
- "#!if "*)
- run_if "${s#* }"
- ;;
- "#!foreach "*)
- run_foreach "${s#* }"
- ;;
- "#!//"*)
- # Comment, do nothing
- ;;
- "#!"*)
- error "line ${l}: unrecognized command"
- ;;
- *)
- # Not a special command
- eval "echo \"${s//\"/\\\"}\""
- ;;
- esac
- l=${lnext}
- done
-}
-
-run_template()
-{
- local -a tlines
- local src="${1}"
-
- debug "Running template ${src}"
- mapfile -O 1 -t tlines < "${src}"
- run_lines 1 ${#tlines[@]}
-}
-
-########################################
-
-# Where the version configs are generated
-config_dir=config/versions
-template=maintainer/kconfig-versions.template
-
-declare -A pkg_forks pkg_milestones pkg_nforks
-declare -a pkg_masters pkg_all pkg_preferred
-
-# Convert the argument to a Kconfig-style macro
-kconfigize()
-{
- local v="${1}"
-
- v=${v//[^0-9A-Za-z_]/_}
- echo "${v^^}"
-}
-
-# Helper for cmp_versions: compare an upstream/debian portion of
-# a version. Returns 0 if equal, otherwise echoes "-1" or "1" and
-# returns 1.
-equal_versions()
-{
- local v1="${1}"
- local v2="${2}"
- local p1 p2
-
- # Compare alternating non-numerical/numerical portions, until
- # non-equal portion is found or either string is exhausted.
- while [ -n "${v1}" -a -n "${v2}" ]; do
- # Find non-numerical portions and compare lexicographically
- p1="${v1%%[0-9]*}"
- p2="${v2%%[0-9]*}"
- v1="${v1#${p1}}"
- v2="${v2#${p2}}"
- #debug "lex [${p1}] v [${p2}]"
- if [ "${p1}" \< "${p2}" ]; then
- echo "-1"
- return 1
- elif [ "${p1}" \> "${p2}" ]; then
- echo "1"
- return 1
- fi
- #debug "rem [${v1}] v [${v2}]"
- # Find numerical portions and compare numerically
- p1="${v1%%[^0-9]*}"
- p2="${v2%%[^0-9]*}"
- v1="${v1#${p1}}"
- v2="${v2#${p2}}"
- #debug "num [${p1}] v [${p2}]"
- if [ "${p1:-0}" -lt "${p2:-0}" ]; then
- echo "-1"
- return 1
- elif [ "${p1:-0}" -gt "${p2:-0}" ]; then
- echo "1"
- return 1
- fi
- #debug "rem [${v1}] v [${v2}]"
- done
- if [ -n "${v1}" ]; then
- echo "1"
- return 1
- elif [ -n "${v2}" ]; then
- echo "-1"
- return 1
- fi
- return 0
-}
-
-# Compare two version strings, similar to sort -V. But we don't
-# want to depend on GNU sort availability on the host.
-# See http://www.debian.org/doc/debian-policy/ch-controlfields.html
-# for description of what the version is expected to be.
-# Returns "-1", "0" or "1" if first version is earlier, same or
-# later than the second.
-cmp_versions()
-{
- local v1="${1}"
- local v2="${2}"
- local e1=0 e2=0 u1 u2 d1=0 d2=0
-
- # Case-insensitive comparison
- v1="${v1^^}"
- v2="${v2^^}"
-
- # Find if the versions contain epoch part
- case "${v1}" in
- *:*)
- e1="${v1%%:*}"
- v1="${v1#*:}"
- ;;
- esac
- case "${v2}" in
- *:*)
- e2="${v2%%:*}"
- v2="${v2#*:}"
- ;;
- esac
-
- # Compare epochs numerically
- if [ "${e1}" -lt "${e2}" ]; then
- echo "-1"
- return
- elif [ "${e1}" -gt "${e2}" ]; then
- echo "1"
- return
- fi
-
- # Find if the version contains a "debian" part.
- # v1/v2 will now contain "upstream" part.
- case "${v1}" in
- *-*)
- d1=${v1##*-}
- v1=${v1%-*}
- ;;
- esac
- case "${v2}" in
- *-*)
- d2=${v2##*-}
- v2=${v2%-*}
- ;;
- esac
-
- # Compare upstream
- if equal_versions "${v1}" "${v2}" && equal_versions "${d1}" "${d2}"; then
- echo "0"
- fi
-}
-
-# Sort versions, descending
-sort_versions()
-{
- local sorted
- local remains="$*"
- local next_remains
- local v vx found
-
- while [ -n "${remains}" ]; do
- #debug "Sorting [${remains}]"
- for v in ${remains}; do
- found=yes
- next_remains=
- #debug "Candidate ${v}"
- for vx in ${remains}; do
- #debug "${v} vs ${vx} :: `cmp_versions ${v} ${vx}`"
- case `cmp_versions ${v} ${vx}` in
- 1)
- next_remains+=" ${vx}"
- ;;
- 0)
- ;;
- -1)
- found=no
- #debug "Bad: earlier than ${vx}"
- break
- ;;
- esac
- done
- if [ "${found}" = "yes" ]; then
- # $v is less than all other members in next_remains
- sorted+=" ${v}"
- remains="${next_remains}"
- #debug "Good candidate ${v} sorted [${sorted}] remains [${remains}]"
- break
- fi
- done
- done
- echo "${sorted}"
-}
-
-read_file()
-{
- local l p
-
- while read l; do
- l="${p}${l}"
- p=
- case "${l}" in
- "")
- continue
- ;;
- *\\)
- p="${l%\\}"
- continue
- ;;
- "#"*)
- continue
- ;;
- *=*)
- echo "info[${l%%=*}]=${l#*=}"
- ;;
- *)
- error "syntax error in '${1}': '${l}'"
- ;;
- esac
- done < "${1}"
-}
-
-read_package_desc()
-{
- read_file "packages/${1}/package.desc"
-}
-
-read_version_desc()
-{
- read_file "packages/${1}/${2}/version.desc"
-}
-
-find_forks()
-{
- local -A info
-
- info[preferred]=${1}
- eval `read_package_desc ${1}`
-
- if [ -n "${info[master]}" ]; then
- pkg_nforks[${info[master]}]=$[pkg_nforks[${info[master]}]+1]
- pkg_forks[${info[master]}]+=" ${1} "
- else
- pkg_preferred[${1}]=${info[preferred]}
- pkg_nforks[${1}]=$[pkg_nforks[${1}]+1]
- pkg_forks[${1}]+=" ${1} "
- pkg_milestones[${1}]=`sort_versions ${info[milestones]}`
- pkg_masters+=( "${1}" )
- fi
- # Keep sorting so that preferred fork is first
- if [ -n "${pkg_preferred[${1}]}" ]; then
- pkg_forks[${1}]="${pkg_preferred[${1}]} ${pkg_forks[${1}]##* ${pkg_preferred[${1}]} } ${pkg_forks[${1}]%% ${pkg_preferred[${1}]} *}"
- fi
-}
-
-check_obsolete_experimental()
-{
- [ -z "${info[obsolete]}" ] && only_obsolete=
- [ -z "${info[experimental]}" ] && only_experimental=
-}
-
-enter_fork()
-{
- local fork="${1}"
- local versions
- local only_obsolete only_experimental
-
- # Set defaults
- info[obsolete]=
- info[experimental]=
- info[repository]=
- info[repository_branch]=
- info[repository_cset]=
- info[repository_subdir]=
- info[bootstrap]=
- info[fork]=${fork}
- info[name]=${fork}
- info[mirrors]=
- info[archive_filename]='@{pkg_name}-@{version}'
- info[archive_dirname]='@{pkg_name}-@{version}'
-
- eval `read_package_desc ${fork}`
-
- info[pfx]=`kconfigize ${fork}`
- info[originpfx]=`kconfigize ${info[origin]}`
- if [ -r "packages/${info[origin]}.help" ]; then
- info[originhelp]=`sed 's/^/ /' "packages/${info[origin]}.help"`
- else
- info[originhelp]=" ${info[master]} from ${info[origin]}."
- fi
-
- if [ -n "${info[repository]}" ]; then
- info[vcs]=${info[repository]%% *}
- info[repository_url]=${info[repository]#* }
- fi
- info[versionlocked]=`kconfigize "${info[versionlocked]}"`
-
- versions=`cd packages/${fork} && \
- for f in */version.desc; do [ -r "${f}" ] && echo "${f%/version.desc}"; done`
- versions=`sort_versions ${versions}`
-
- set_iter version ${versions}
- info[all_versions]=${versions}
-
- # If a fork does not define any versions at all ("rolling release"), do not
- # consider it obsolete/experimental unless it is so marked in the fork's
- # description.
- if [ -n "${versions}" ]; then
- only_obsolete=yes
- only_experimental=yes
- do_foreach version check_obsolete_experimental
- info[only_obsolete]=${only_obsolete}
- info[only_experimental]=${only_experimental}
- else
- info[only_obsolete]=${info[obsolete]}
- info[only_experimental]=${info[experimental]}
- fi
-}
-
-enter_version()
-{
- local -A ver_postfix=( \
- [,yes,,]=" (OBSOLETE)" \
- [,,yes,]=" (EXPERIMENTAL)" \
- [,yes,yes,]=" (OBSOLETE,EXPERIMENTAL)" )
- local version="${1}"
-
- eval `read_version_desc ${info[fork]} ${version}`
- info[ver]=${version}
- info[kcfg]=`kconfigize ${version}`
- info[ver_postfix]=${ver_postfix[,${info[obsolete]},${info[experimental]},]}
-}
-
-enter_milestone()
-{
- local ms="${1}"
- local cmp
-
- info[ms]=${ms}
- info[ms_kcfg]=`kconfigize ${ms}`
- if [ -n "${info[ver]}" ]; then
- info[version_cmp_milestone]=`cmp_versions ${info[ver]} ${info[ms]}`
- fi
-}
-
-rm -rf "${config_dir}"
-mkdir -p "${config_dir}"
-
-pkg_all=( `cd packages && \
- ls */package.desc 2>/dev/null | \
- while read f; do [ -r "${f}" ] && echo "${f%/package.desc}"; done | \
- xargs echo` )
-
-msg "Generating package version descriptions"
-debug "Packages: ${pkg_all[@]}"
-
-# We need to group forks of the same package into the same
-# config file. Discover such relationships and only iterate
-# over "master" packages at the top.
-for p in "${pkg_all[@]}"; do
- find_forks "${p}"
-done
-msg "Master packages: ${pkg_masters[@]}"
-
-# Now for each master, create its kconfig file with version
-# definitions.
-for p in "${pkg_masters[@]}"; do
- msg "Generating '${config_dir}/${p}.in'"
- exec >"${config_dir}/${p}.in"
- # Base definitions for the whole config file
- info=( \
- [master]=${p} \
- [masterpfx]=`kconfigize ${p}` \
- [nforks]=${pkg_nforks[${p}]} \
- [all_milestones]=${pkg_milestones[${p}]} \
- )
- set_iter fork ${pkg_forks[${p}]}
- set_iter milestone ${pkg_milestones[${p}]}
-
- # TBD check that origins are set for all forks if there is more than one? or is it automatic because of a missing variable check?
- # TBD get rid of the "origin" completely and use just the fork name?
- run_template "${template}"
-done
-msg "Done!"
diff --git a/maintainer/kconfig-choice.template b/maintainer/kconfig-choice.template
new file mode 100644
index 0000000..cfb5285
--- /dev/null
+++ b/maintainer/kconfig-choice.template
@@ -0,0 +1,32 @@
+#
+# DO NOT EDIT! This file is automatically generated.
+#
+
+choice GEN_CHOICE_@@prefix@@
+ bool "@@label@@"
+
+#!foreach choice
+config @@prefix@@_@@choice@@
+ bool "@@choice@@"
+#!foreach dependency
+ @@depline@@
+#!end-foreach
+ help
+#!foreach help
+ @@helpline@@
+#!end-foreach
+
+#!end-foreach
+endchoice
+
+config @@prefix@@
+ string
+#!foreach choice
+ default "@@choice@@" if @@prefix@@_@@choice@@
+#!end-foreach
+
+#!foreach choice
+if @@prefix@@_@@choice@@
+source "config/@@dir@@/@@choice@@.in"
+endif
+#!end-foreach
diff --git a/maintainer/kconfig-menu.template b/maintainer/kconfig-menu.template
new file mode 100644
index 0000000..e079a6b
--- /dev/null
+++ b/maintainer/kconfig-menu.template
@@ -0,0 +1,20 @@
+#
+# DO NOT EDIT! This file is automatically generated.
+#
+
+#!foreach choice
+menuconfig @@prefix@@_@@choice@@
+ bool "@@choice@@"
+#!foreach dependency
+ @@depline@@
+#!end-foreach
+ help
+#!foreach help
+ @@helpline@@
+#!end-foreach
+
+if @@prefix@@_@@choice@@
+source "config/@@dir@@/@@choice@@.in"
+endif
+
+#!end-foreach