#!/usr/bin/env bash # # # Bash script for creating videos of the animation examples. # The videos will optionally be included in the RST gallery. test -z "$1" && exit 1 # Where the current script resides (need absolute path) script_name="$1" script_dir=$(dirname "${script_name}") script="@GMT_SOURCE_DIR@/doc/examples/${script_name}" if ! [ -x "${script}" ]; then echo "error: cannot execute script ${script}." >&2 exit 1 fi # choose awk if command -v gawk >/dev/null 2>&1 ; then export AWK=gawk elif command -v nawk >/dev/null 2>&1 ; then export AWK=nawk else export AWK=awk fi # Temporary change LANG to C LANG=C # Use executables from GMT_BINARY_DIR, fallback to CMAKE_INSTALL_PREFIX/GMT_BINDIR export PATH="@GMT_BINARY_DIR@/src:$PATH" # for gmt_shell_functions.sh export GMT_SHAREDIR="@GMT_SOURCE_DIR@/share" # Create a temporary directory exec_dir in the build dir # Then copy all of its contents (except files excluded by GLOBIGNORE) # Run remainder of this GMT script there exec_dir="@CMAKE_CURRENT_BINARY_DIR@/${script_dir}" rm -rf "$exec_dir" mkdir -p "$exec_dir" cd "$exec_dir" shopt -s extglob GLOBIGNORE="!(*.bat|*.sh)" for file in "$src"/* ; do test -f "$file" && ln -s "$file" . done unset GLOBIGNORE # Start with proper GMT defaults gmt set -Du FORMAT_TIME_STAMP "Version 6" # Now run the original script . "${script}" animate