#!/usr/bin/env bash

if [ -e ${BASE_DIR}/prtsoft_dir.sh ]
then
    source ${BASE_DIR}/prtsoft_dir.sh
    echo "Prtsoft Dir: ${PRTSOFT_DIR}"
    echo "Out_Name Dir: ${OUT_NAME}"
	cd ${PRTSOFT_DIR}
	if [ -n "$OUT_NAME" ]
	then
		echo "cp ${PRTSOFT_DIR}/O/stripped/${OUT_NAME}.elf ${BASE_DIR}/target/opt/prtsoft.elf"
		cp ${PRTSOFT_DIR}/O/stripped/${OUT_NAME}.elf ${BASE_DIR}/target/opt/prtsoft.elf
		echo "cp -r ${PRTSOFT_DIR}/O/${OUT_NAME}_nll/* ${BASE_DIR}/target/"
		cp -r ${PRTSOFT_DIR}/O/${OUT_NAME}_nll/* ${BASE_DIR}/target/
	else
		VPJMAKE=$(gawk -F"[<>]" '/<pjpath>/{printf($3);}' .pjmkinfo)
    	gawk -f $VPJMAKE/nll_copy.awk ${BASE_DIR}/target .nllinfo
	fi
fi

# echo "POST-BUILD-SH"
# echo $BINARIES_DIR

if [ -e "$BINARIES_DIR/uImage.CV5_34_39_500B" ]
then
	mv "$BINARIES_DIR/uImage.CV5_34_39_500B" "$BINARIES_DIR/uImage.CV_34_39_500B"
fi

if [ -e "$BINARIES_DIR/uImage.CV5_34_39_500B_KiTi" ]
then
	mv "$BINARIES_DIR/uImage.CV5_34_39_500B_KiTi" "$BINARIES_DIR/uImage.CV_34_39_500B_KiTi"
fi
