======================================== Do not apply this patch to the main line ========================================
What is this tool? ------------------ This tool converts boards.cfg to defconfig and Kconfig files. It automatically generates - arch/${ARCH}/Kconfig - board/Kconfig - board/${VENDOR}/${BOARD}/Kconfig - board/${BOARD}/Kconfig - configs/*_defconfig How to use? ----------- Open tools/print_allconfigs with an editor. Adjust cross compilers part for your environment. # Specify your favoriate cross tools CROSS_COMPILE_ARC=arc-linux- CROSS_COMPILE_AARCH64=aarch64-linux-gnu- CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi- [snip] CROSS_COMPILE_X86=i386-linux- And then, run "tools/genkconfig". Why is this patch here? ----------------------- The file boards.cfg is touched very frequently. All the time, new/old boards are being added/removed. The next commit was generated based on the u-boot/master at the time I posted it. It will become out-dated soon. You can update it with this tool. Signed-off-by: Masahiro Yamada <yamad...@jp.panasonic.com> --- tools/genkconfig | 253 +++++++++++++++++++++++++++++++++++++++++++++++++ tools/print_allconfigs | 77 +++++++++++++++ 2 files changed, 330 insertions(+) create mode 100755 tools/genkconfig create mode 100755 tools/print_allconfigs diff --git a/tools/genkconfig b/tools/genkconfig new file mode 100755 index 0000000..5f84f72 --- /dev/null +++ b/tools/genkconfig @@ -0,0 +1,253 @@ +#!/bin/bash + +set -e + +rm -rf configs +mkdir -p configs/spl configs/tpl +find board -name Kconfig | xargs rm -f + +get_arch() +{ + case "$arch" in + powerpc) echo PPC;; + *) echo ${1^^};; + esac +} + +arch_list="arc arm avr32 blackfin m68k microblaze mips nds32 nios2 openrisc powerpc sandbox sh sparc x86" + +for arch in $arch_list +do + ARCH=$(get_arch $arch) + + case "$arch" in + blackfin) menu="Blackfin";; + m68k) menu="M68000";; + microblaze) menu="MicroBlaze";; + nios2) menu="Nios II";; + openrisc) menu="OpenRISC";; + powerpc) menu="PowerPC";; + sandbox) menu="Sandbox";; + sh) menu="SuperH";; + x86) menu="x86";; + *) menu=${arch^^};; + esac + +cat <<EOF > arch/$arch/Kconfig +menu "$menu architecture" + depends on $ARCH + +config SYS_ARCH + string + default "$arch" + +choice + prompt "Target select" + +EOF + +done + +write_defconfig () +{ + echo >> $defconfig "CONFIG_$ARCH=y" + echo >> $defconfig "CONFIG_$TARGET=y" +} + +write_main_defconfig () +{ + if [ "$spl_enable" = "y" ]; then + echo >> $defconfig "CONFIG_SPL=y" + fi + + if [ "$tpl_enable" = "y" ]; then + echo >> $defconfig "CONFIG_TPL=y" + fi + + write_defconfig +} + +write_kconfig () +{ + echo >> $kconfig + echo >> $kconfig "if $TARGET" + echo >> $kconfig + + echo >> $kconfig "config SYS_CPU" + echo >> $kconfig " string" + if [ "$spl_cpu" != "$cpu" ]; then + echo >> $kconfig " default \"$spl_cpu\" if SPL_BUILD" + echo >> $kconfig " default \"$cpu\" if !SPL_BUILD" + else + echo >> $kconfig " default \"$cpu\"" + fi + echo >> $kconfig + + echo >> $kconfig "config SYS_BOARD" + echo >> $kconfig " string" + echo >> $kconfig " default \"$board\"" + echo >> $kconfig + + if [ "$vendor" != "-" ]; then + echo >> $kconfig "config SYS_VENDOR" + echo >> $kconfig " string" + echo >> $kconfig " default \"$vendor\"" + echo >> $kconfig + fi + + if [ "$soc" != "-" ]; then + echo >> $kconfig "config SYS_SOC" + echo >> $kconfig " string" + echo >> $kconfig " default \"$soc\"" + echo >> $kconfig + fi + + echo >> $kconfig "config SYS_CONFIG_NAME" + echo >> $kconfig " string" + echo >> $kconfig " default \"$config_name\"" + echo >> $kconfig + + if [ "$extra_options" ]; then + # O2MNT_O2M110, O2MNT_O2M112, O2MNT_O2M113 boards include + # double-quotations in the extra option field. + # We must escape them. + echo >> $kconfig "config SYS_EXTRA_OPTIONS" + echo >> $kconfig " string" + echo >> $kconfig " default \"$(echo "$extra_options" | sed -e 's/"/\\"/g')\"" + echo >> $kconfig + fi + + # Andrea "llandre" Marson <andrea.mar...@dave-tech.it> + # includes double-quotations in his name. + # We must escape them. + echo >> $kconfig "config BOARD_MAINTAINER" + echo >> $kconfig " string" + echo >> $kconfig " default \"$(echo "$maintainers" | sed -e 's/"/\\"/g')\"" + echo >> $kconfig + + echo >> $kconfig "config BOARD_STATUS" + echo >> $kconfig " string" + echo >> $kconfig " default \"$status\"" + echo >> $kconfig + + echo >> $kconfig "endif" +} + +while read -r status arch cpu soc vendor board target options maintainers +do + case $status in + Active) + status="Active +4" ;; + Orphan) + status="Orphan (since $orphan_date)";; + *) + orphan_date=$maintainers + case $orphan_date in + "September, 2013") orphan_date=2013.09;; + "March, 2014") orphan_date=2014.03;; + "April, 2014") orphan_date=2014.04;; + *) ;; + esac + + continue + ;; + esac + + echo "processing $target" + + if [ "$arch" = "aarch64" ]; then + arch=arm + fi + + # Tegra SoCs have different "cpu" and "spl_cpu" + spl_cpu=${cpu#*:} + cpu=${cpu%:*} + + if [ "$board" = "-" ]; then + board=$target + fi + + if [ "$board" = "<none>" ]; then + board= + fi + + config_name=$target + extra_options= + + [ "$options" != "-" ] && { + tmp="${options%:*}" + if [ "$tmp" ] ; then + config_name="$tmp" + fi + + if [ "${tmp}" != "$options" ] ; then + extra_options=${options#*:} + fi + } + + all_configs=$(tools/print_allconfigs $target) + + if echo $all_configs | grep -q "CONFIG_SPL=y"; then + spl_enable=y + else + spl_enable= + fi + + if echo $all_configs | grep -q "CONFIG_TPL=y"; then + tpl_enable=y + else + tpl_enable= + fi + + TARGET=$(echo TARGET_${target^^} | sed -e 's/-/_/g') + ARCH=$(get_arch $arch) + + defconfig=configs/${target}_defconfig + write_main_defconfig + + if [ "$spl_enable" = "y" ]; then + defconfig=configs/spl/${target}_defconfig + write_defconfig + fi + + if [ "$tpl_enable" = "y" ]; then + defconfig=configs/tpl/${target}_defconfig + write_defconfig + fi + + if [ -z "$board" ]; then + kconfig=board/$vendor/Kconfig + elif [ "$vendor" != "-" ]; then + kconfig=board/$vendor/$board/Kconfig + else + kconfig=board/$board/Kconfig + fi + + write_kconfig + + echo "source \"$kconfig\"" >> board/Kconfig + + echo >> arch/$arch/Kconfig "config $TARGET" + echo >> arch/$arch/Kconfig " bool \"Support $target\"" + echo >> arch/$arch/Kconfig + +done < boards.cfg + +sort board/Kconfig | uniq > board/Kconfig.tmp +mv board/Kconfig.tmp board/Kconfig + +for arch in $arch_list +do +cat<<EOF >> arch/$arch/Kconfig +endchoice + +endmenu +EOF +done + +for i in $(find board -path "board/*/Kconfig") +do + # dropping the empty line at the beginning + sed -e "1d" $i > $i.tmp + mv $i.tmp $i +done diff --git a/tools/print_allconfigs b/tools/print_allconfigs new file mode 100755 index 0000000..e00c333 --- /dev/null +++ b/tools/print_allconfigs @@ -0,0 +1,77 @@ +#!/bin/sh +# Print all config macros for specified board +# +# Usage: tools/getconfigs <board> + +# Specify your favoriate cross tools +CROSS_COMPILE_ARC=arc-linux- +CROSS_COMPILE_AARCH64=aarch64-linux-gnu- +CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi- +CROSS_COMPILE_AVR32=avr32-linux- +CROSS_COMPILE_BLACKFIN=bfin-elf- +CROSS_COMPILE_M68K=m68k-linux- +CROSS_COMPILE_MICROBLAZE=microblaze-linux- +CROSS_COMPILE_MIPS=mips-linux- +CROSS_COMPILE_NDS32=nds32le-linux- +CROSS_COMPILE_NIOS2=nios2-linux- +CROSS_COMPILE_OPENRISC=or32-linux- +CROSS_COMPILE_POWERPC=powerpc-linux- +CROSS_COMPILE_SH=sh4-gentoo-linux-gnu- +CROSS_COMPILE_SPARC=sparc-elf- +CROSS_COMPILE_X86=i386-linux- + +if [ ! -r boards.cfg ]; then + echo >&2 "boards.cfg: not found" + echo >&2 "Run \"tools/print_allconfigs <target_board>\" at the top directory" + echo >&2 "Exit." + exit 1 +fi + +if [ $# != 1 ]; then + echo >&2 "Usage: tools/print_allconfigs <target_board>" + echo >&2 "Exit." + exit 2 +fi + +target=$1 + + +get_arch() { + local target=$1 + + awk '$7 == "'$target'" { print $2 }' boards.cfg +} + +arch=$(get_arch $target) + +if [ -z "$arch" ]; then + echo >&2 "$target: target board not found in boards.cfg" + echo >&2 "Exit." + exit 3 +fi + +ARCH=$(echo $arch | tr '[:lower:]' '[:upper:]') + +eval CROSS_COMPILE=\$CROSS_COMPILE_$ARCH + +export CROSS_COMPILE + +rm -f include/autoconf.mk + +make ${target}_config include/autoconf.mk >/dev/null || { \ + echo >&2 "make failed." + echo >&2 "Please check if CROSS_COMPILE_<ARCH> is correctly set." + echo >&2 "Exit." + exit 4 +} + +if [ ! -f include/autoconf.mk ]; then + echo >&2 "include/autoconf.mk: not found." + echo >&2 "Internal error." + echo >&2 "Exit." + exit 5 +fi + +cat include/autoconf.mk + +exit 0 -- 1.8.3.2 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot