1100936Snectar#!/bin/sh
2100936Snectar
3142425Snectar# This script is used by test/Makefile to check whether a sane 'pod2man'
4100936Snectar# is installed.
5100936Snectar# ('make install' should not try to run 'pod2man' if it does not exist or if
6100936Snectar# it is a broken 'pod2man' version that is known to cause trouble. if we find
7100936Snectar# the system 'pod2man' to be broken, we use our own copy instead)
8100936Snectar#
9100936Snectar# In any case, output an appropriate command line for running (or not
10100936Snectar# running) pod2man.
11100936Snectar
12100936Snectar
13100936SnectarIFS=:
14109998Smarkmif test "$OSTYPE" = "msdosdjgpp"; then IFS=";"; fi
15109998Smarkm
16109998Smarkmtry_without_dir=true
17100936Snectar# First we try "pod2man", then "$dir/pod2man" for each item in $PATH.
18109998Smarkmfor dir in dummy${IFS}$PATH; do
19100936Snectar    if [ "$try_without_dir" = true ]; then
20100936Snectar      # first iteration
21100936Snectar      pod2man=pod2man
22100936Snectar      try_without_dir=false
23100936Snectar    else
24100936Snectar      # second and later iterations
25100936Snectar      pod2man="$dir/pod2man"
26100936Snectar      if [ ! -f "$pod2man" ]; then  # '-x' is not available on Ultrix
27100936Snectar        pod2man=''
28100936Snectar      fi
29100936Snectar    fi
30100936Snectar
31100936Snectar    if [ ! "$pod2man" = '' ]; then
32100936Snectar        failure=none
33100936Snectar
34109998Smarkm	if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | fgrep OpenSSL >/dev/null; then
35109998Smarkm	    :
36109998Smarkm	else
37109998Smarkm	    failure=BasicTest
38109998Smarkm	fi
39100936Snectar
40109998Smarkm	if [ "$failure" = none ]; then
41109998Smarkm	    if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | grep '^MARKER - ' >/dev/null; then
42109998Smarkm	        failure=MultilineTest
43109998Smarkm	    fi
44100936Snectar	fi
45100936Snectar
46100936Snectar
47100936Snectar        if [ "$failure" = none ]; then
48100936Snectar            echo "$pod2man"
49100936Snectar            exit 0
50100936Snectar        fi
51100936Snectar
52100936Snectar        echo "$pod2man does not work properly ('$failure' failed).  Looking for another pod2man ..." >&2
53100936Snectar    fi
54100936Snectardone
55100936Snectar
56100936Snectarecho "No working pod2man found.  Consider installing a new version." >&2
57109998Smarkmecho "As a workaround, we'll use a bundled old copy of pod2man.pl." >&2
58109998Smarkmecho "$1 ../../util/pod2man.pl"
59