pod2mantest revision 256281
125184Sjkh#!/bin/sh
225184Sjkh
342270Sjkh# This script is used by test/Makefile to check whether a sane 'pod2man'
425184Sjkh# is installed.
525184Sjkh# ('make install' should not try to run 'pod2man' if it does not exist or if
625184Sjkh# it is a broken 'pod2man' version that is known to cause trouble. if we find
725184Sjkh# the system 'pod2man' to be broken, we use our own copy instead)
825184Sjkh#
925184Sjkh# In any case, output an appropriate command line for running (or not
1025184Sjkh# running) pod2man.
1125184Sjkh
1225184Sjkh
1325184SjkhIFS=:
1425184Sjkhif test "$OSTYPE" = "msdosdjgpp"; then IFS=";"; fi
1525184Sjkh
1625184Sjkhtry_without_dir=true
1725184Sjkh# First we try "pod2man", then "$dir/pod2man" for each item in $PATH.
1825184Sjkhfor dir in dummy${IFS}$PATH; do
1925184Sjkh    if [ "$try_without_dir" = true ]; then
2025184Sjkh      # first iteration
2125184Sjkh      pod2man=pod2man
2225184Sjkh      try_without_dir=false
2325184Sjkh    else
2425184Sjkh      # second and later iterations
2525184Sjkh      pod2man="$dir/pod2man"
2625184Sjkh      if [ ! -f "$pod2man" ]; then  # '-x' is not available on Ultrix
2725184Sjkh        pod2man=''
2840006Sphk      fi
2940006Sphk    fi
3040006Sphk
3140006Sphk    if [ ! "$pod2man" = '' ]; then
3240006Sphk        failure=none
3340006Sphk
3425184Sjkh	if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | fgrep OpenSSL >/dev/null; then
3525184Sjkh	    :
3625184Sjkh	else
3733682Sbrian	    failure=BasicTest
3825184Sjkh	fi
3925184Sjkh
4025184Sjkh	if [ "$failure" = none ]; then
4125184Sjkh	    if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | grep '^MARKER - ' >/dev/null; then
4225184Sjkh	        failure=MultilineTest
4325184Sjkh	    fi
4425184Sjkh	fi
4525184Sjkh
4625184Sjkh
4725184Sjkh        if [ "$failure" = none ]; then
4825184Sjkh            echo "$pod2man"
4925184Sjkh            exit 0
5025184Sjkh        fi
5125184Sjkh
5225184Sjkh        echo "$pod2man does not work properly ('$failure' failed).  Looking for another pod2man ..." >&2
5325184Sjkh    fi
5425184Sjkhdone
5525184Sjkh
5625184Sjkhecho "No working pod2man found.  Consider installing a new version." >&2
5725184Sjkhecho "As a workaround, we'll use a bundled old copy of pod2man.pl." >&2
5825184Sjkhecho "$1 ../../util/pod2man.pl"
5925184Sjkh