#!/bin/sh

package=ntruprime
namespace=sntrup

mkdir -p doc/man

pandoc --standalone --to man --metadata title=$namespace --metadata section=3 < doc/api.md | sed 's/^    //' > doc/man/$namespace.3
for param in 653 761 857 953 1013 1277
do
  for manpage in "$param" "$param"_keypair "$param"_enc "$param"_dec
  do
    rm -f doc/man/$namespace"$manpage".3
    ln -s $namespace.3 doc/man/$namespace"$manpage".3
  done
done

pandoc --standalone --to man --metadata title=$namespace --metadata section=1 < doc/cli.md | sed 's/^    //' > doc/man/$namespace.1
for param in 653 761 857 953 1013 1277
do
  for manpage in "$param" "$param"-keypair "$param"-enc "$param"-dec
  do
    rm -f doc/man/$namespace"$manpage".1
    ln -s $namespace.1 doc/man/$namespace"$manpage".1
  done
done

pandoc --standalone --to man --metadata title=${package}-fulltest --metadata section=1 < doc/${package}-fulltest.md | sed 's/^    //' > doc/man/${package}-fulltest.1
pandoc --standalone --to man --metadata title=${package}-test --metadata section=1 < doc/${package}-test.md | sed 's/^    //' > doc/man/${package}-test.1
pandoc --standalone --to man --metadata title=${package}-speed --metadata section=1 < doc/${package}-speed.md | sed 's/^    //' > doc/man/${package}-speed.1
