#!/bin/bash set -e KERNEL_MENUCONFIG=no KERNEL_KEEPCONFIG=no KERNEL_DEFCONFIG=no KERNEL_SAVEDEFCONFIG=no BOARD_DEF=no TARGET_BUILD=no BRD="NVCOM02TEM" # default board type usage() { echo -e "\nUsage: ./build_lin3.18.sh [option] [--nvcom02-tem|--mc24r2-em|--mct04em|--mc30sf6em|--mct06em|--mct03pem|--mc0428em-pci]\n" echo -e "Choose one of the following options." echo -e "\t-m|--menuconfig\t\tCall kernel menuconfig end exit" echo -e "\t-d|--defconfig\t\tBuild kernel with defconfig for defined board" echo -e "\t-k|--keepconfig\t\tBuild kernel with current .config" echo -e "\t-s|--savedefconfig\tCall kernel savedefconfig and exit" echo -e "\t-t|--target\t\tCreate target only" 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=$PATH:$TOOLCHAIN if [[ $# > 1 ]] ; then BOARD_DEF=yes . "$DIR/target_brd.sh" "$2" BRD=${TARGET_BOARD} else if [[ ${TARGET_BOARD} ]]; then BRD=${TARGET_BOARD}; fi fi if [[ $# > 0 ]]; then key="$1" case $key in -m|--menuconfig) KERNEL_MENUCONFIG=yes shift # past argument ;; -d|--defconfig) KERNEL_DEFCONFIG=yes shift # past argument ;; -k|--keepconfig) KERNEL_KEEPCONFIG=yes shift # past argument ;; -s|--savedefconfig) KERNEL_SAVEDEFCONFIG=yes shift # past argument ;; -t|--target) TARGET_BUILD=yes shift # past argument ;; -h|--help) usage exit 0 ;; *) echo "Unknown option!" usage exit 0 ;; esac if [[ ${KERNEL_MENUCONFIG} = "yes" ]]; then # Run the linux menuconfig tool cd "${KERNEL_ROOT}" ARCH=mips make menuconfig echo -e "\nThe changes will be saved to .config. In order to build with these changes call " echo -e "'build_kernel.sh -k'. In order to save the changes in a defconfig file call " echo -e "'build_lin3.18.sh -s'.\n" usage exit 0 fi if [[ ${KERNEL_SAVEDEFCONFIG} = "yes" ]]; then cd ${KERNEL_ROOT} ARCH=mips make savedefconfig #echo ${BRD} case ${BRD} in MC0428EM-PCI) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc0428em-pci/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc0428em-pci/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc0428em-pci/ ;; MC24R2EM) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc24r2-em/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc24r2-em/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc24r2-em/ ;; MCT04EM) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct04em/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct04em/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct04em/ ;; MC30SF6EM) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/30sf6em/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/30sf6em/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/30sf6em/ ;; MCT06EM) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct06em/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct06em/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct06em/ ;; MCT03PEM) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct03pem/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct03pem/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct03pem/ ;; NVCOM02TEM | *) ## move generated defconfig to board configs directory if [[ -f $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/nvcom02-tem/linux_defconfig ]] ; then rm $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/nvcom02-tem/linux_defconfig fi cd $KERNEL_ROOT mv defconfig linux_defconfig mv linux_defconfig $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/nvcom02-tem/ ;; esac echo -e "\nSaved defconfig\n" usage exit 0 fi if [[ ${KERNEL_KEEPCONFIG} = "yes" ]] ; then cd "${KERNEL_ROOT}" ARCH=mips make $KERNEL_PARALLEL_COMPIL #mipsel-buildroot-linux-uclibc-objdump -D vmlinux >vmlinux.dis exit 0 fi if [[ ${KERNEL_DEFCONFIG} = "yes" ]] ; then cd "${KERNEL_ROOT}" case ${BRD} in MC0428EMPCI) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc0428em-pci/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; MC24R2EM) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mc24r2-em/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; MCT04EM) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct04em/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; MC30SF6EM) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/30sf6em/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; MCT06EM) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct06em/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; MCT03PEM) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/mct03pem/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; NVCOM02TEM | *) ## copy board defconfig to linux configs directory cp $PROJECT_OVERLAY_ROOT/buildroot/board/elvees_multicore/nvcom02-tem/$KERNEL_DEFCONFIG_FILE arch/mips/configs ;; esac ARCH=mips make defconfig KBUILD_DEFCONFIG=$KERNEL_DEFCONFIG_FILE rm arch/mips/configs/$KERNEL_DEFCONFIG_FILE #if [[ ${BOARD_DEF} != "yes" ]] ; then ARCH=mips make menuconfig #fi ARCH=mips make $KERNEL_PARALLEL_COMPIL #mipsel-buildroot-linux-uclibc-objdump -D vmlinux >vmlinux.dis exit 0 fi if [[ ${TARGET_BUILD} = "yes" ]] ; then cd "${KERNEL_ROOT}" ARCH=mips make V=2 $KERNEL_PARALLEL_COMPIL exit 0 fi fi usage exit 0