#!/bin/sh
set -e

if [[ -z $1 ]]
then
  echo "usage: \"$0\" <output directory>"
  exit 1
fi

self_="$(readlink -f "$0")"
cd -- "${self_%/*/*}"
gen_docs_="${self_%/*}/cmake_gen_html.sh"
clean_="${self_%/*}/clean.sh"
parent_dir_="${self_%/*/*}"
output_dir_="$1"

cd -- "$parent_dir_"
"$clean_"
mkdir -p build/doc/html
"$gen_docs_" >/dev/null
mkdir -p "$output_dir_"
rsync -trL --delete build/doc/html/ "$output_dir_"
