#!/bin/bash set -e # Source the directory paths DIR="${BASH_SOURCE%/*}" if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi . "$DIR/project_structure" export PATH=$PATH:$TOOLCHAIN CLEAN_ALL=no CLEAN_TARGET=no CLEAN_DIST=no CLEAN_CONFIG=no usage() { echo -e "\nUsage: ./clean_buildroot.sh [option]" echo -e "\tChoose one of the following options." echo -e "\t-a|--all Clean all the built objects" echo -e "\t-d|--dist Clean all the built objects and all disributives" echo -e "\t-c|--config Clean current config" echo -e "\t-t|--target Clean the target rootfs" echo -e "\t-h|--help Print this help message and exit" } if [[ $# -gt 0 ]]; then key="$1" case $key in -a|--all) CLEAN_ALL=yes shift ;; -d|--dist) CLEAN_ALL=yes CLEAN_DIST=yes shift ;; -c|--config) CLEAN_CONFIG=yes shift ;; -t|--target) CLEAN_TARGET=yes shift ;; -h|--help) usage exit 0 ;; *) echo "Unknown option!" usage exit 0 ;; esac else usage exit 0 fi # Check for spaces in the path case "${BUILDROOT_ROOT}" in *\ * ) echo -e "\n\nBuildroot does not support having spaces in its path!\n" echo -e "${BUILDROOT_ROOT}\n" exit 0 ;; esac cd "${BUILDROOT_ROOT}" || echo -e "\nCould not change to ${BUILDROOT_ROOT}!" if [[ "${CLEAN_CONFIG}" = yes ]]; then #Clean the current config if [[ -f "${TOOLS_BUILD}/.config" ]]; then (set -x; rm "${TOOLS_BUILD}/.config") fi fi if [[ "${CLEAN_TARGET}" = "yes" ]]; then # Clean the rootfs rm -rf "$TOOLS_BUILD/target" rm -rf "$MCLINUX_PATH/linux/target" fi if [[ -z `echo $MCLINUX_ROOT` ]]; then export MCLINUX_ROOT="$MCLINUX_PATH"; fi if [[ "${CLEAN_ALL}" = "yes" ]]; then make clean -C $BUILDROOT_ROOT O=$TOOLS_BUILD fi if [[ "${CLEAN_DIST}" = "yes" ]]; then make distclean -C $BUILDROOT_ROOT O=$TOOLS_BUILD fi