#! /usr/bin/bash

# On Fedora 30 and Centos 8 we need rst2man but on earlier versions we need rst2man-3
CONV=rst2man
source /etc/os-release
if [[ $ID == fedora ]] && (( $VERSION_ID < 30 )); then
    CONV=rst2man-3
fi
if [[ $ID == centos ]] && (( $VERSION_ID < 8 )); then
    CONV=rst2man-3
fi

mkdir -p man1
rm -f man1/*.1
$CONV README.ct-cache.rst man1/ct-cache.1
$CONV README.ct-cache-clean.rst man1/ct-cache-clean.1
$CONV README.ct-cake.rst man1/ct-cake.1
$CONV README.rst man1/compiletools.1
$CONV README.ct-commandline.rst man1/ct-commandline.1
$CONV README.ct-config.rst man1/ct-config.1
$CONV README.ct-findtargets.rst man1/ct-findtargets.1
$CONV README.ct-filelist.rst man1/ct-filelist.1
$CONV README.ct-gitroot.rst man1/ct-gitroot.1
$CONV README.ct-headertree.rst man1/ct-headertree.1
$CONV README.ct-jobs.rst man1/ct-jobs.1
$CONV README.ct-list-variants.rst man1/ct-list-variants.1
$CONV README.ct-magicflags.rst man1/ct-magicflags.1
