multiconfig.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. #
  3. # A wrapper script to adjust Kconfig for U-Boot
  4. #
  5. # This file will be removed after cleaning up defconfig files
  6. #
  7. # Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
  8. #
  9. # SPDX-License-Identifier: GPL-2.0+
  10. #
  11. set -e
  12. # Make a configuration target
  13. # Usage:
  14. # run_make_config <target> <objdir>
  15. # <target>: Make target such as "config", "menuconfig", "defconfig", etc.
  16. run_make_config () {
  17. # Linux expects defconfig files in arch/$(SRCARCH)/configs/ directory,
  18. # but U-Boot has them in configs/ directory.
  19. # Give SRCARCH=.. to fake scripts/kconfig/Makefile.
  20. $MAKE -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. $1
  21. }
  22. do_silentoldconfig () {
  23. run_make_config silentoldconfig
  24. # If the following part fails, include/config/auto.conf should be
  25. # deleted so "make silentoldconfig" will be re-run on the next build.
  26. $MAKE -f $srctree/scripts/Makefile.autoconf || {
  27. rm -f include/config/auto.conf
  28. exit 1
  29. }
  30. # include/config.h has been updated after "make silentoldconfig".
  31. # We need to touch include/config/auto.conf so it gets newer
  32. # than include/config.h.
  33. # Otherwise, 'make silentoldconfig' would be invoked twice.
  34. touch include/config/auto.conf
  35. }
  36. cleanup_after_defconfig () {
  37. rm -f configs/.tmp_defconfig
  38. # ignore 'Directory not empty' error
  39. # without using non-POSIX option '--ignore-fail-on-non-empty'
  40. rmdir arch configs 2>/dev/null || true
  41. }
  42. # Usage:
  43. # do_board_defconfig <board>_defconfig
  44. do_board_defconfig () {
  45. defconfig_path=$srctree/configs/$1
  46. if [ ! -r $defconfig_path ]; then
  47. echo >&2 "***"
  48. echo >&2 "*** Can't find default configuration \"configs/$1\"!"
  49. echo >&2 "***"
  50. exit 1
  51. fi
  52. mkdir -p arch configs
  53. # prefix "*:" is deprecated. Drop it simply.
  54. sed -e 's/^[+A-Z]*://' $defconfig_path > configs/.tmp_defconfig
  55. run_make_config .tmp_defconfig || {
  56. cleanup_after_defconfig
  57. exit 1
  58. }
  59. cleanup_after_defconfig
  60. }
  61. do_board_felconfig () {
  62. do_board_defconfig ${1%%_felconfig}_defconfig
  63. if ! grep -q CONFIG_ARCH_SUNXI=y .config || ! grep -q CONFIG_SPL=y .config ; then
  64. echo "$progname: Cannot felconfig a non-sunxi or non-SPL platform" >&2
  65. exit 1
  66. fi
  67. sed -i -e 's/\# CONFIG_SPL_FEL is not set/CONFIG_SPL_FEL=y\nCONFIG_UART0_PORT_F=n/g' \
  68. .config
  69. }
  70. do_others () {
  71. run_make_config $1
  72. }
  73. progname=$(basename $0)
  74. target=$1
  75. case $target in
  76. *_defconfig)
  77. do_board_defconfig $target;;
  78. *_felconfig)
  79. do_board_felconfig $target;;
  80. *_config)
  81. # backward compatibility
  82. do_board_defconfig ${target%_config}_defconfig;;
  83. silentoldconfig)
  84. do_silentoldconfig;;
  85. *)
  86. do_others $target;;
  87. esac