pwd=$(pwd)
# just for debugging 1 ln:
#echo $pwd ; read NOP
# You can do:
# export BUILD_DIR="where-you-should-be-to-run-this"
# before running this script
if [ ! -n "$BUILD_DIR" ]; then
    if [ -n "$1" ]; then
        # Or you can set it with the 1st arg:
        BUILD_DIR="$1"
    else
        echo "we need a \$BUILD_DIR defined, read the script pls."
        sleep 3
        exit 0
    fi
else
    echo \$BUILD_DIR: $BUILD_DIR; read NOP
fi
# You also need the \$LOGS_DIR set (or replace those instances with a path you
# to your liking)
# So you can do:
# export LOGS_DIR="where-the-logs-should-go"
if [ ! -n "$LOGS_DIR" ]; then
    if [ -n "$2" ]; then
        # Or you can set it with the 2nd arg:
        LOGS_DIR="$2"
    else
        echo "we need a \$LOGS_DIR defined, read the script pls."
        sleep 3
        exit 0
    fi
else
    echo \$LOGS_DIR: $LOGS_DIR; read NOP
fi
# This implies that after unsuccessful tries, you simple rm/mv the cinelerra
# dir, so to make a new attempt anew:
if [ "$pwd" == "$BUILD_DIR" ] && [ ! -d "cinelerra" ]; then
    cp -ia cinelerra.bak cinelerra
else
    if [ "$pwd" == "$BUILD_DIR" ]; then
        echo "Not cp'ing, exists:"
        ls -ld cinelerra
        du -s --block-size=M cinelerra
    else
        echo "Not in the $BUILD_DIR, read the script pls."
        sleep 3
        exit 0
    fi
fi ; read NOP
cd cinelerra/ ; pwd ; read NOP
are_you_done="n"
while [ "$are_you_done" == "n" ]; do
    git status |& tee $LOGS_DIR/cinelerra_git_status_$(date +%y%m%d_%H%M)
    # You can reply "n" and, say, checkout some other tag in git in another
    # terminal:
    echo "Compile with this tag/version? If not done with git type \"n\"."
    echo "Anything else moves on out of this loop."
    read are_you_done
done
cd cinelerra-5.1/ && pwd ; read NOP
# as per the CinelerraGG_Manual/single_user_build.html
sudo -s blds/bld_prepare.sh debian-testing |& \
    tee $LOGS_DIR/cinelerra_bld_prepare.sh_debian-testing_$(date +%y%m%d_%H%M) ; read NOP
./autogen.sh |& tee $LOGS_DIR/cinelerra_autogen.sh_$(date +%y%m%d_%H%M) ; read NOP
echo "Next: ./configure --with-single-user" ; read NOP &&
./configure --with-single-user |& \
    tee $LOGS_DIR/cinelerra_configure--with-single-user_$(date +%y%m%d_%H%M) ; read NOP
make |& tee $LOGS_DIR/cinelerra_make_$(date +%y%m%d_%H%M) ; echo "END of script ${0##*/}"
