rrsync improvements
[rsync.git] / maybe-make-man
1 #!/bin/sh
2
3 if [ x"$2" = x ]; then
4     echo "Usage: $0 SRC_DIR NAME.NUM.md" 1>&2
5     exit 1
6 fi
7
8 srcdir="$1"
9 inname="$2"
10 flagfile="$srcdir/.md2man-works"
11
12 if [ ! -d "$srcdir" ]; then
13     echo "The specified SRC_DIR is not a directory: $srcdir" 1>&2
14     exit 1
15 fi
16
17 if [ ! -f "$flagfile" ]; then
18     # We test our smallest manpage just to see if the python setup works.
19     if "$srcdir/md2man" --test "$srcdir/rsync-ssl.1.md" >/dev/null 2>&1; then
20         touch $flagfile
21     else
22         outname=`echo "$inname" | sed 's/\.md$//'`
23         if [ -f "$outname" ]; then
24             exit 0
25         elif [ -f "$srcdir/$outname" ]; then
26             echo "Copying $srcdir/$outname"
27             cp -p "$srcdir/$outname" .
28             exit 0
29         else
30             echo "ERROR: $outname cannot be created."
31             if [ -f "$HOME/build_farm/build_test.fns" ]; then
32                 exit 0 # No exit errorno to avoid a build failure in the samba build farm
33             else
34                 exit 1
35             fi
36         fi
37     fi
38 fi
39
40 "$srcdir/md2man" -s "$srcdir" "$srcdir/$inname"