generic-board-config.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. #
  4. # Copyright (C) 2017 Imagination Technologies
  5. # Author: Paul Burton <[email protected]>
  6. #
  7. # This script merges configuration fragments for boards supported by the
  8. # generic MIPS kernel. It checks each for requirements specified using
  9. # formatted comments, and then calls merge_config.sh to merge those
  10. # fragments which have no unmet requirements.
  11. #
  12. # An example of requirements in your board config fragment might be:
  13. #
  14. # # require CONFIG_CPU_MIPS32_R2=y
  15. # # require CONFIG_CPU_LITTLE_ENDIAN=y
  16. #
  17. # This would mean that your board is only included in kernels which are
  18. # configured for little endian MIPS32r2 CPUs, and not for example in kernels
  19. # configured for 64 bit or big endian systems.
  20. #
  21. srctree="$1"
  22. objtree="$2"
  23. ref_cfg="$3"
  24. cfg="$4"
  25. boards_origin="$5"
  26. shift 5
  27. # Only print Skipping... lines if the user explicitly specified BOARDS=. In the
  28. # general case it only serves to obscure the useful output about what actually
  29. # was included.
  30. case ${boards_origin} in
  31. "command line")
  32. print_skipped=1
  33. ;;
  34. environment*)
  35. print_skipped=1
  36. ;;
  37. *)
  38. print_skipped=0
  39. ;;
  40. esac
  41. for board in $@; do
  42. board_cfg="${srctree}/arch/mips/configs/generic/board-${board}.config"
  43. if [ ! -f "${board_cfg}" ]; then
  44. echo "WARNING: Board config '${board_cfg}' not found"
  45. continue
  46. fi
  47. # For each line beginning with # require, cut out the field following
  48. # it & search for that in the reference config file. If the requirement
  49. # is not found then the subshell will exit with code 1, and we'll
  50. # continue on to the next board.
  51. grep -E '^# require ' "${board_cfg}" | \
  52. cut -d' ' -f 3- | \
  53. while read req; do
  54. case ${req} in
  55. *=y)
  56. # If we require something =y then we check that a line
  57. # containing it is present in the reference config.
  58. grep -Eq "^${req}\$" "${ref_cfg}" && continue
  59. ;;
  60. *=n)
  61. # If we require something =n then we just invert that
  62. # check, considering the requirement met if there isn't
  63. # a line containing the value =y in the reference
  64. # config.
  65. grep -Eq "^${req/%=n/=y}\$" "${ref_cfg}" || continue
  66. ;;
  67. *)
  68. echo "WARNING: Unhandled requirement '${req}'"
  69. ;;
  70. esac
  71. [ ${print_skipped} -eq 1 ] && echo "Skipping ${board_cfg}"
  72. exit 1
  73. done || continue
  74. # Merge this board config fragment into our final config file
  75. ${srctree}/scripts/kconfig/merge_config.sh \
  76. -m -O ${objtree} ${cfg} ${board_cfg} \
  77. | grep -Ev '^(#|Using)'
  78. done