Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0-or-later
0003 #
0004 # Copyright (C) 2017 Imagination Technologies
0005 # Author: Paul Burton <paul.burton@mips.com>
0006 #
0007 # This script merges configuration fragments for boards supported by the
0008 # generic MIPS kernel. It checks each for requirements specified using
0009 # formatted comments, and then calls merge_config.sh to merge those
0010 # fragments which have no unmet requirements.
0011 #
0012 # An example of requirements in your board config fragment might be:
0013 #
0014 # # require CONFIG_CPU_MIPS32_R2=y
0015 # # require CONFIG_CPU_LITTLE_ENDIAN=y
0016 #
0017 # This would mean that your board is only included in kernels which are
0018 # configured for little endian MIPS32r2 CPUs, and not for example in kernels
0019 # configured for 64 bit or big endian systems.
0020 #
0021 
0022 srctree="$1"
0023 objtree="$2"
0024 ref_cfg="$3"
0025 cfg="$4"
0026 boards_origin="$5"
0027 shift 5
0028 
0029 # Only print Skipping... lines if the user explicitly specified BOARDS=. In the
0030 # general case it only serves to obscure the useful output about what actually
0031 # was included.
0032 case ${boards_origin} in
0033 "command line")
0034         print_skipped=1
0035         ;;
0036 environment*)
0037         print_skipped=1
0038         ;;
0039 *)
0040         print_skipped=0
0041         ;;
0042 esac
0043 
0044 for board in $@; do
0045         board_cfg="${srctree}/arch/mips/configs/generic/board-${board}.config"
0046         if [ ! -f "${board_cfg}" ]; then
0047                 echo "WARNING: Board config '${board_cfg}' not found"
0048                 continue
0049         fi
0050 
0051         # For each line beginning with # require, cut out the field following
0052         # it & search for that in the reference config file. If the requirement
0053         # is not found then the subshell will exit with code 1, and we'll
0054         # continue on to the next board.
0055         grep -E '^# require ' "${board_cfg}" | \
0056             cut -d' ' -f 3- | \
0057             while read req; do
0058                 case ${req} in
0059                 *=y)
0060                         # If we require something =y then we check that a line
0061                         # containing it is present in the reference config.
0062                         grep -Eq "^${req}\$" "${ref_cfg}" && continue
0063                         ;;
0064                 *=n)
0065                         # If we require something =n then we just invert that
0066                         # check, considering the requirement met if there isn't
0067                         # a line containing the value =y in the reference
0068                         # config.
0069                         grep -Eq "^${req/%=n/=y}\$" "${ref_cfg}" || continue
0070                         ;;
0071                 *)
0072                         echo "WARNING: Unhandled requirement '${req}'"
0073                         ;;
0074                 esac
0075 
0076                 [ ${print_skipped} -eq 1 ] && echo "Skipping ${board_cfg}"
0077                 exit 1
0078         done || continue
0079 
0080         # Merge this board config fragment into our final config file
0081         ${srctree}/scripts/kconfig/merge_config.sh \
0082                 -m -O ${objtree} ${cfg} ${board_cfg} \
0083                 | grep -Ev '^(#|Using)'
0084 done