#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-2.0-or-later
#
# DESCR: Check that every vendor and board has a Kconfig.name

LC_ALL=C export LC_ALL
FAIL=0

for i in src/mainboard/*/; do
  if [ -r $i/Kconfig ]; then
    if [ ! -r $i/Kconfig.name ]; then
      VENDOR="$(grep -A2 MAINBOARD_VENDOR $i/Kconfig | tail -1 | cut -f2 -d\")"
      echo "Vendor $VENDOR missing $i/Kconfig.name."
      FAIL=1
    fi
  fi
done

for i in src/mainboard/*/*/; do
  if [ -r $i/Kconfig ]; then
    if [ ! -r $i/Kconfig.name ]; then
      BOARD="$(grep -A2 MAINBOARD_PART_NUMBER $i/Kconfig | tail -1 | cut -f2 -d\")"
      echo "Mainboard $BOARD missing $i/Kconfig.name"
      FAIL=1
    fi
  fi
done

exit $FAIL