/[groff]/groff/contrib/pdfmark/pdfroff.sh
ViewVC logotype

Diff of /groff/contrib/pdfmark/pdfroff.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by wl, Mon May 2 10:31:10 2005 UTC revision 1.4 by wl, Wed May 18 07:03:07 2005 UTC
# Line 1  Line 1 
1  #!/bin/sh  #! /bin/sh
2  # ------------------------------------------------------------------------------  # ------------------------------------------------------------------------------
3  #  #
4  # Function: Format PDF Output from groff Markup  # Function: Format PDF Output from groff Markup
# Line 37  Line 37 
37  #  #
38    CMD=`exec 2>$NULLDEV; basename $0` || CMD=$0    CMD=`exec 2>$NULLDEV; basename $0` || CMD=$0
39  #  #
40    # To ensure that prerequisite helper programs are available, and are
41    # executable, a [fairly] portable method of detecting such programs is
42    # provided by function `searchpath'.
43    #
44      searchpath(){
45      #
46      # Usage:  searchpath progname path
47      #
48        IFS="${PATH_SEPARATOR-":"}" prog=':'
49        for dir in $2
50        do
51          for ext in '' '.exe'
52          #
53          # try `progname' with all well known extensions
54          # (e.g. Win32 may require `progname.exe')
55          #
56          do
57            try="$dir/$1$ext"
58            test -f "$try" && test -x "$try" && prog="$try" && break
59          done
60          test "$prog" = ":" || break
61        done
62        echo "$prog"
63      }
64    # @PATH_SEARCH_SETUP@
65    #
66  # We need both 'grep' and 'sed' programs, to parse script options,  # We need both 'grep' and 'sed' programs, to parse script options,
67  # and we also need 'cat', to display help and some error messages,  # and we also need 'cat', to display help and some error messages,
68  # so ensure they are all installed, before we continue.  # so ensure they are all installed, before we continue.
69  # (Again, note that we first check the status from 'type', BEFORE  #
70  #  we attempt to use the result, because Cygwin's 'ash' uses 'stdout'    CAT=`searchpath cat "$PATH"`
71  #  instead of 'stderr', to display its 'not found' message).    GREP=`searchpath grep "$PATH"`
72  #    SED=`searchpath sed "$PATH"`
   CAT=':' GREP=':' SED=':'  
   type cat >$NULLDEV 2>&1 && CAT=`set :\`type cat\` ; eval echo '$'$#`  
   type grep >$NULLDEV 2>&1 && GREP=`set :\`type grep\` ; eval echo '$'$#`  
   type sed >$NULLDEV 2>&1 && SED=`set :\`type sed\` ; eval echo '$'$#`  
73  #  #
74  # Another fundamental requirement is the 'groff' program itself;  # Another fundamental requirement is the 'groff' program itself;
75  # we will first perform a PATH search to locate this;  however,  # we MUST use a 'groff' program located in 'GROFF_BIN_DIR', if this
76  # we will prefer any version existing in a specified GROFF_BIN_DIR,  # is specified; if not, we will search 'GROFF_BIN_PATH', only falling
77  # or, if unspecified, the installed location of 'groff' programs;  # back to a 'PATH' search, if neither of these is specified.
78  # (this will override the result of the initial PATH search).  #
79  #    if test -n "$GROFF_BIN_DIR"
80    GROFF=':'    then
81    type groff >$NULLDEV 2>&1 && GROFF=`set :\`type groff\` ; eval echo '$'$#`      GPATH=GROFF_BIN_DIR
82    type ${GROFF_BIN_DIR="@GROFF_BIN_DIR@"}/groff >$NULLDEV 2>&1 \      GROFF=`searchpath groff "$GROFF_BIN_DIR"`
83      && GROFF=`set :\`type $GROFF_BIN_DIR/groff\` ; eval echo '$'$#`  #
84      elif test -n "$GROFF_BIN_PATH"
85      then
86        GPATH=GROFF_BIN_PATH
87        GROFF=`searchpath groff "$GROFF_BIN_PATH"`
88    #
89      else
90        GPATH=PATH
91        GROFF=`searchpath groff "$PATH"`
92      fi
93  #  #
94  # If one or more of these is missing, diagnose and bail out.  # If one or more of these is missing, diagnose and bail out.
95  #  #
96    NO=''    NO='' NOPROG="$CMD: installation problem: cannot find program"
   NOPROG="$CMD: installation problem: cannot find program"  
97    test "$CAT" = ":" && echo >&2 "$NOPROG 'cat' in PATH" && NO="$NO 'cat'"    test "$CAT" = ":" && echo >&2 "$NOPROG 'cat' in PATH" && NO="$NO 'cat'"
98    test "$GREP" = ":" && echo >&2 "$NOPROG 'grep' in PATH" && NO="$NO 'grep'"    test "$GREP" = ":" && echo >&2 "$NOPROG 'grep' in PATH" && NO="$NO 'grep'"
99    test "$GROFF" = ":" && echo >&2 "$NOPROG 'groff' in $GBIN" && NO="$NO 'groff'"    test "$GROFF" = ":" && echo >&2 "$NOPROG 'groff' in $GPATH" && NO="$NO 'groff'"
100    test "$SED" = ":" && echo >&2 "$NOPROG 'sed' in PATH" && NO="$NO 'sed'"    test "$SED" = ":" && echo >&2 "$NOPROG 'sed' in PATH" && NO="$NO 'sed'"
101    if test -n "$NO"    if test -n "$NO"
102    then    then
# Line 349  Line 379 
379  #   In order to correctly resolve 'pdfmark' references,  #   In order to correctly resolve 'pdfmark' references,
380  #   we need to have both the 'awk' and 'diff' programs available.  #   we need to have both the 'awk' and 'diff' programs available.
381  #  #
382      NO='' AWK=':'      NO=''
383      eval set ${GROFF_AWK_INTERPRETER-"@GROFF_AWK_INTERPRETERS@"}      if test -n "$GROFF_AWK_INTERPRETER"
384      while test $# -gt 0      then
385      do        AWK="$GROFF_AWK_INTERPRETER"
386        type $1 >$NULLDEV 2>&1 && AWK=`set :\`type $1\` ; eval echo '$'$#`        test -f "$AWK" && test -x "$AWK" || AWK=":"
387        test "$AWK" = ":" || set "$AWK"      else
388        shift        for prog in @GROFF_AWK_INTERPRETERS@
389      done        do
390      type diff >$NULLDEV 2>&1 && DIFF=`set :\`type diff\` ; eval echo '$'$#`          AWK=`searchpath $prog "$PATH"`
391            test "$AWK" = ":" || break
392          done
393        fi
394        DIFF=`searchpath diff "$PATH"`
395      test "$AWK" = ":" && echo >&2 "$NOPROG 'awk' in PATH" && NO="$NO 'awk'"      test "$AWK" = ":" && echo >&2 "$NOPROG 'awk' in PATH" && NO="$NO 'awk'"
396      test "$DIFF" = ":" && echo >&2 "$NOPROG 'diff' in PATH" && NO="$NO 'diff'"      test "$DIFF" = ":" && echo >&2 "$NOPROG 'diff' in PATH" && NO="$NO 'diff'"
397      if test -n "$NO"      if test -n "$NO"
# Line 443  Line 477 
477  # from which the PDF output will be compiled -- but before proceding further ...  # from which the PDF output will be compiled -- but before proceding further ...
478  # let's make sure we have a GhostScript interpreter to convert them!  # let's make sure we have a GhostScript interpreter to convert them!
479  #  #
480    GS=':'    if test -n "$GROFF_GHOSTSCRIPT_INTERPRETER"
481    eval set ${GROFF_GHOSTSCRIPT_INTERPRETER-"@GROFF_GHOSTSCRIPT_INTERPRETERS@"}    then
482    while test $# -gt 0      GS="$GROFF_GHOSTSCRIPT_INTERPRETER"
483    do      test -f "$GS" && test -x "$GS" || GS=":"
484      type $1 >$NULLDEV 2>&1 && GS=`set :\`type $1\` ; eval echo '$'$#`    else
485      test "$GS" = ":" || set "$GS"      for prog in @GROFF_GHOSTSCRIPT_INTERPRETERS@
486      shift      do
487    done        GS=`searchpath $prog "$PATH"`
488          test "$GS" = ":" || break
489        done
490      fi
491  #  #
492  # If we could not find a GhostScript interpreter, then we can do no more.  # If we could not find a GhostScript interpreter, then we can do no more.
493  #  #

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26