#!/bin/bash set -e BUILDROOT_MENUCONFIG=no BUILDROOT_TOOLCHAIN=no BUILDROOT_KEEPCONFIG=no UCLIBC_MENUCONFIG=no BUSYBOX_MENUCONFIG=no BUILDROOT_DEFCONFIG=no usage() { echo -e "\nUsage: ./build_buildroot.sh [option]" echo -e "\tChoose one of the following options." # echo -e "\t-d|--defconfig\t\tMake with defconfig" echo -e "\t-m|--menuconfig\t\tCall buildroot menuconfig and exit" echo -e "\t-s|--savedefconfig\t\tSave defconfig based on current .config" echo -e "\t-t|--toolchain\t\tBuild just the toolchain and exit" echo -e "\t-k|--keepconfig\t\tBuild buildroot with current .config" echo -e "\t-b|--busiboxconfig\tBusybox menuconfig" echo -e "\t-u|--uclibcconfig\tUclibc menuconfig" echo -e "\t-h|--help\t\tPrint this help message and exit" } mk_defconfig() { cp -v "${BUILDROOT_DEFCONFIG_PATH}"/"${BUILDROOT_DEFCONFIG_FILE}" "${BUILDROOT_ROOT}"/configs/ make "${BUILDROOT_DEFCONFIG_FILE}" -C $BUILDROOT_ROOT O=$TOOLS_BUILD } # Source the directory paths DIR="${BASH_SOURCE%/*}" if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi . "$DIR/project_structure" export BASE_DIR if [[ $# -gt 0 ]]; then key="$1" case $key in -m|--menuconfig) BUILDROOT_MENUCONFIG=yes shift # past argument ;; -s|--savedefconfig) BUILDROOT_DEFCONFIG=yes shift # past argument ;; -t|--toolchain) BUILDROOT_TOOLCHAIN=yes shift # past argument ;; -k|--keepconfig) BUILDROOT_KEEPCONFIG=yes shift # past argument ;; -b|--busyboxconfig) BUSYBOX_MENUCONFIG=yes shift # past argument ;; -u|--uclibcconfig) UCLIBC_MENUCONFIG=yes shift # past argument ;; -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}" if [[ -z `echo $MCLINUX_ROOT` ]]; then export MCLINUX_ROOT="$MCLINUX_PATH"; fi if [[ "${BUILDROOT_MENUCONFIG}" = "yes" ]]; then mk_defconfig make menuconfig -C $BUILDROOT_ROOT O=$TOOLS_BUILD echo -e "\nThe changes will be saved to .config. In order to build with these changes call " echo -e "'build_buildroot.sh -k'.\n" usage exit 0 fi if [[ "${BUILDROOT_DEFCONFIG}" = "yes" ]]; then make savedefconfig -C $BUILDROOT_ROOT O=$TOOLS_BUILD cp -v "${BUILDROOT_ROOT}/configs/${BUILDROOT_DEFCONFIG_FILE}" "${BUILDROOT_DEFCONFIG_PATH}" usage exit 0 fi if [[ "${BUILDROOT_TOOLCHAIN}" = "yes" ]]; then echo -e "\nBuilding only the toolchain" make toolchain -C $BUILDROOT_ROOT O=$TOOLS_BUILD $BUILDROOT_PARALLEL_COMPIL exit 0 fi if [[ "${BUSYBOX_MENUCONFIG}" = "yes" ]]; then export CONFIGS_DIR=$MCLINUX_ROOT/project-overlay/buildroot/board/elvees_multicore/common make busybox-menuconfig -C $BUILDROOT_ROOT O=$TOOLS_BUILD BUSYBOX_CONFIG_FILE=$CONFIGS_DIR/busybox.config echo -e "\nThe changes will be saved to /project-overlay/buildroot/board/elvees_multicore/common/busybox.config.\n" usage exit 0 fi if [[ "${UCLIBC_MENUCONFIG}" = "yes" ]]; then export CONFIGS_DIR=$MCLINUX_ROOT/project-overlay/buildroot/board/elvees_multicore/common make uclibc-menuconfig -C $BUILDROOT_ROOT O=$TOOLS_BUILD UCLIBC_CONFIG_FILE=$CONFIGS_DIR/uclibc.config echo -e "\nThe changes will be saved to /project-overlay/buildroot/board/elvees_multicore/common/uclibc.config.\n" usage exit 0 fi if [[ "${BUILDROOT_KEEPCONFIG}" = "yes" ]]; then export CONFIGS_DIR=$MCLINUX_ROOT/project-overlay/buildroot/board/elvees_multicore/common make -C $BUILDROOT_ROOT O=$BUILD_DIR UCLIBC_CONFIG_FILE=$CONFIGS_DIR/uclibc.config BUSYBOX_CONFIG_FILE=$CONFIGS_DIR/busybox.config $BUILDROOT_PARALLEL_COMPIL # copy target to the linux target directory target_dir="$MCLINUX_ROOT/linux" if [[ -d $target_dir ]] then rm -rf "$target_dir/target" else mkdir "$target_dir" fi sudo mv ${BASE_DIR}/target "$target_dir" fi exit 0