#!/bin/bash set -e UBOOT_MENUCONFIG=no UBOOT_KEEPCONFIG=no UBOOT_SAVECONFIG=no UBOOT_MPROP=no UBOOT_CLEAN=no usage() { echo -e "\nUsage: ./build_uboot.sh [option] \n" echo -e "Available options are:" echo -e "\t-m|--menuconfig\t\tCall u-boot menuconfig end exit" echo -e "\t-k|--keepconfig\t\tBuild u-boot with current .config" echo -e "\t-s|--savedefconfig\tCall u-boot savedefconfig and exit" echo -e "\t-p|--prop\t\tCall u-boot make mproper and exit" echo -e "\t-c|--clean\t\tCall u-boot make clean and exit" echo -e "\t-h|--help\t\tPrint this help message and exit" } # Source the directory paths DIR="${BASH_SOURCE%/*}" if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi . "$DIR/project_structure" export PATH=$TOOLCHAIN:$PATH export CROSS_COMPILE=mipsel-buildroot-linux-uclibc- #echo "PATH = " $PATH #echo "CROSS_COMPILE = " $CROSS_COMPILE cwd=$pwd if [[ $# > 0 ]]; then key="$1" case $key in -m|--menuconfig) UBOOT_MENUCONFIG=yes shift # past argument ;; -k|--keepconfig) UBOOT_KEEPCONFIG=yes shift # past argument ;; -s|--savedefconfig) UBOOT_SAVEDEFCONFIG=yes shift # past argument ;; -p|--prop) UBOOT_MPROP=yes shift ;; -c|--clean) UBOOT_CLEAN=yes shift ;; -h|--help) usage exit 0 ;; *) echo "Unknown option!" usage exit 0 ;; esac if [[ ${UBOOT_MENUCONFIG} = "yes" ]]; then # Run menuconfig tool cd "${UBOOT_PATH}" #make mrproper O=${UBOOT_PATH}/tmp #make menuconfig O=${UBOOT_PATH}/tmp make menuconfig O=${UBOOT_PATH}/tmp echo -e "\nThe changes will be saved to .config." echo -e "In order to build with these changes call 'build_uboot.sh -k'." echo -e "In order to save the changes in a defconfig file call 'build_uboot.sh -s'.\n" usage cd $cwd exit 0 fi if [[ ${UBOOT_SAVEDEFCONFIG} = "yes" ]]; then cd ${UBOOT_PATH} make savedefconfig O=${UBOOT_PATH}/tmp echo -e "\nSaved defconfig\n" usage cd $cwd exit 0 fi if [[ ${UBOOT_KEEPCONFIG} = "yes" ]] ; then cd "${UBOOT_PATH}" make O=${UBOOT_PATH}/tmp cd $cwd exit 0 fi if [[ ${UBOOT_MPROP} = "yes" ]] ; then cd "${UBOOT_PATH}" make mrproper make mrproper O=${UBOOT_PATH}/tmp usage cd $cwd exit 0 fi if [[ ${UBOOT_CLEAN} = "yes" ]] ; then cd "${UBOOT_PATH}" make clean O=${UBOOT_PATH}/tmp usage cd $cwd exit 0 fi fi usage exit 0