#!/bin/sh

# Get the architecture from the environment variable
ARCH=${ARCH}

if [ -n "$ARCH" ]; then
  # Loop through each file in the configs directory
  for defconfig in "arch/$ARCH/configs/"*"_defconfig"; do
    if [ "$defconfig" != "arch/$ARCH/configs/generic_defconfig" ]; then
      # Make the given configuration
      make $(basename "$defconfig")

      # Save the configuration to a defconfig file
      make savedefconfig

      # Move the defconfig file to the configs directory
      mv defconfig "$defconfig"
    fi
  done
else
  echo "Error: ARCH environment variable is not set."
  exit 1
fi