#!/bin/sh

mkdir -p doc/man

pandoc --standalone --to man --metadata title=djbsort --metadata section=3 < doc/api.md | sed 's/^    //' > doc/man/djbsort.3
pandoc --standalone --to man --metadata title=djbsort-test --metadata section=1 < doc/djbsort-test.md | sed 's/^    //' > doc/man/djbsort-test.1
pandoc --standalone --to man --metadata title=djbsort-fulltest --metadata section=1 < doc/djbsort-fulltest.md | sed 's/^    //' > doc/man/djbsort-fulltest.1
pandoc --standalone --to man --metadata title=djbsort-speed --metadata section=1 < doc/djbsort-speed.md | sed 's/^    //' > doc/man/djbsort-speed.1

for bits in 32 64
do
  for what in int uint float
  do
    for sort in djbsort_${what}${bits} djbsort_${what}${bits}down
    do
      rm -f doc/man/"$sort".3
      ln -s djbsort.3 doc/man/"$sort".3
    done
  done
done
