make.sh 1.89 KB
#!/bin/sh

DIR_NAME=$(basename $(realpath .))

build_path="../output-${DIR_NAME}"
module_install="../out"
firmware_install="../out"

if [ -z "${CP_DIR}" ]
then
    CP_DIR="../../release /tftpboot/${FA_PRODUCT} /nfs/${FA_PRODUCT}"
fi

image_filename="arch/arm/boot/uImage"
dtb_filename="arch/arm/boot/dts/imx6s-prime-oven.dtb"

image_target_filename="uImage"
dtb_target_filename="imx6s-prime-oven.dtb"

if [ -f .config ]; then
	echo ".....mrproper"
	make mrproper
fi

if [ ! -d $build_path ]; then
	mkdir $build_path
	#chmod 777 $build_path
fi


if [ ! -f $build_path/.config ]; then
	echo ".....imx6s prime oven defconfig"
	ARCH=arm make arm=ARM O=$build_path distclean 
	ARCH=arm make arm=ARM O=$build_path imx6s_prime_oven_defconfig
fi


if [ "$1" = "" ]; then
	ARCH=arm make arm=ARM O=$build_path uImage LOADADDR=0x10008000
	ARCH=arm make arm=ARM O=$build_path dtbs
else
	ARCH=arm make arm=ARM O=$build_path $1 $2 $3
	ARCH=arm make arm=ARM O=$build_path dtbs
fi

if [ "$1" = "dtb" ]; then
	ARCH=arm make arm=ARM O=$build_path dtbs
fi


# build kernel modules
if [ "$1" = "modules" ] ; then
	ARCH=arm INSTALL_MOD_PATH=$module_install   make arm=ARM O=$build_path modules
	ARCH=arm INSTALL_MOD_PATH=$module_install   make arm=ARM O=$build_path modules_install
	ARCH=arm INSTALL_MOD_PATH=$firmware_install make arm=ARM O=$build_path firmware_install
fi

if [ -f $build_path/$image_filename ]; then
    for DEST_DIR in ${CP_DIR}
    do
        mkdir -p ${DEST_DIR}

        echo "copy from image $build_path/$image_filename to ${DEST_DIR}/$image_target_filename"
        cp  $build_path/$image_filename ${DEST_DIR}/$image_target_filename
    done
fi

if [ -f $build_path/$dtb_filename ]; then
    for DEST_DIR in ${CP_DIR}
    do
        mkdir -p ${DEST_DIR}

        echo "copy from dtb $build_path/$dtb_filename to ${DEST_DIR}/$dtb_target_filename"
        cp  $build_path/$dtb_filename ${DEST_DIR}/$dtb_target_filename
    done
fi