andrewm@58: #!/bin/bash andrewm@58: # giuliomoro@377: # This script copies the core Bela files to the BeagleBone Black andrewm@58: # in preparation for building projects. It will remove any existing giuliomoro@377: # Bela directory before copying the files over andrewm@58: giuliomoro@367: [ -z "$BBB_ADDRESS" ] && BBB_ADDRESS="root@192.168.7.2" giuliomoro@377: [ -z "$BBB_BELA_HOME" ] && BBB_BELA_HOME="~/Bela/" andrewm@58: andrewm@58: function usage andrewm@58: { andrewm@58: THIS_SCRIPT=`basename "$0"` andrewm@58: echo "Usage: $THIS_SCRIPT [-b path-on-beaglebone]" andrewm@58: andrewm@58: echo " giuliomoro@377: This script copies the core Bela files to the BeagleBone, REMOVING andrewm@58: any previous files found at that location. This should be done before andrewm@58: running any of the other build scripts in this directory. The -b option giuliomoro@367: changes the default path, which is otherwise $BBB_BELA_HOME." andrewm@58: } andrewm@58: andrewm@58: OPTIND=1 andrewm@58: andrewm@58: while getopts "b:h" opt; do andrewm@58: case $opt in giuliomoro@367: b) BBB_BELA_HOME=$OPTARG andrewm@58: ;; andrewm@58: h|\?) usage andrewm@58: exit 1 andrewm@58: esac andrewm@58: done andrewm@58: giuliomoro@377: echo "Copying Bela core files to $BBB_BELA_HOME" andrewm@58: andrewm@58: shift $((OPTIND-1)) andrewm@58: andrewm@58: # Find location of this script so we can locate the rest of the files giuliomoro@300: SCRIPTPATH=$(readlink "$0") andrewm@58: SCRIPTDIR=$(dirname "$SCRIPTPATH") andrewm@58: giuliomoro@377: read -p "Warning: this script will DELETE any existing Bela files from your BeagleBone! Continue? (y/N) " -r andrewm@58: echo giuliomoro@243: if [[ $REPLY = [yY] ]] andrewm@58: then giuliomoro@377: # Stop Bela if running and remove all files giuliomoro@377: echo "Stopping Bela and removing old files." giuliomoro@377: ssh $BBB_ADDRESS "screen -X -S Bela quit &>/dev/null; pkill Bela; sleep 0.5 ; rm -rf $BBB_BELA_HOME ; mkdir $BBB_BELA_HOME" andrewm@58: andrewm@58: # Copy relevant files to BeagleBone Black andrewm@58: echo "Copying new files to BeagleBone..." giuliomoro@367: scp -r $SCRIPTDIR/../core $SCRIPTDIR/../include $SCRIPTDIR/../Makefile $SCRIPTDIR/../libNE10.a $SCRIPTDIR/../libprussdrv.a $SCRIPTDIR/../examples $BBB_ADDRESS:$BBB_BELA_HOME &&\ giuliomoro@243: scp $SCRIPTDIR/../libpd.so $BBB_ADDRESS:/usr/lib giuliomoro@64: if [ $? -ne 0 ] giuliomoro@64: then giuliomoro@64: echo "Error while copying files" giuliomoro@64: exit giuliomoro@64: fi andrewm@58: # Make remaining directories needed for building andrewm@58: echo "Creating directory structure on BeagleBone..." giuliomoro@367: ssh $BBB_ADDRESS "mkdir -p $BBB_BELA_HOME/build ; mkdir -p $BBB_BELA_HOME/build/core ; mkdir -p $BBB_BELA_HOME/build/projects; mkdir -p $BBB_BELA_HOME/projects" &&\ andrewm@58: echo "Done." giuliomoro@83: else giuliomoro@83: echo "Aborting..." andrewm@58: fi andrewm@58: