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