Miscellaneous script portability enhancements.
[s-roff.git] / arch / misc / shdeps.sh
blob133aea5eacb0eca7f13a314f1582f8393b3fe24b
1 #! /bin/sh
2 # shdeps.sh: Generate OS dependency fixups, for `groff' shell scripts
4 # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 # Written by Keith Marshall (keith.d.marshall@ntlworld.com)
7 # Invoked only by `make', as:
8 # $(SHELL) shdeps.sh "$(RT_SEP)" "$(SH_SEP)" "$(bindir)" > shdeps.sed
9 #
10 # This file is part of groff.
12 # groff is free software; you can redistribute it and/or modify it under
13 # the terms of the GNU General Public License as published by the Free
14 # Software Foundation; either version 2, or (at your option) any later
15 # version.
17 # groff is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License along
23 # with groff; see the file COPYING. If not, write to the Free Software
24 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 cat << ETX
27 # shdeps.sed: Script generated automatically by \`make' -- do not modify!
29 /^$/N
30 /@GROFF_BIN_PATH_SETUP@/c\\
31 ETX
33 if [ "$1$2" = "::" ]
34 then
35 # `PATH_SEPARATOR' is `:' both at `groff' run time, and in `make',
36 # implying an implementation which is completely POSIX compliant.
37 # Simply apply the `GROFF_BIN_PATH' and `PATH_SEPARATOR' values
38 # determined by `configure', in all cases.
40 cat << ETX
42 GROFF_RUNTIME="\${GROFF_BIN_PATH=$3}:"
43 /@PATH_SEARCH_SETUP@/d
44 ETX
46 else
47 # `PATH_SEPARATOR' is NOT always `:',
48 # which suggests an implementation for a Microsoft platform.
49 # We need to choose the `GROFF_BIN_PATH' format and `PATH_SEPARATOR'
50 # which will suit the user's choice of shell.
52 # Note that some Windows users may specify the `--prefix' path
53 # using backslash characters, instead of `/', preferred by POSIX,
54 # so we will also fix that up.
56 POSIX_BINDIR=`echo $3 | tr '\\\\' /`
57 cat << ETX
58 # (The value required is dependent on the user's choice of shell,\\
59 # and its associated POSIX emulation capabilities.)\\
61 case "\$OSTYPE" in\\
62 msys)\\
63 GROFF_RUNTIME=\${GROFF_BIN_PATH="`
64 case "$POSIX_BINDIR" in
65 [a-zA-Z]:*)
66 IFS=':'
67 set -- $POSIX_BINDIR
68 case "$2" in
69 /*) POSIX_BINDIR="/$1$2" ;;
70 *) POSIX_BINDIR="/$1/$2" ;;
71 esac
72 shift 2
73 for dir
75 POSIX_BINDIR="$POSIX_BINDIR:$dir"
76 done
78 esac
79 echo "$POSIX_BINDIR"`"}":" ;;\\
80 cygwin)\\
81 : \${GROFF_BIN_PATH="\`cygpath -w '$POSIX_BINDIR'\`"}\\
82 GROFF_RUNTIME=\`cygpath "\$GROFF_BIN_PATH"\`":" ;;\\
83 *)\\
84 GROFF_RUNTIME=\${GROFF_BIN_PATH="$POSIX_BINDIR"}";" ;;\\
85 esac
86 ETX
87 # On Microsoft platforms, we may also need to configure
88 # the PATH search function, used in the `pdfroff' script,
89 # to use ';', instead of ':', as the PATH_SEPARATOR.
91 cat << ETX
92 /@PATH_SEARCH_SETUP@/c\\
93 #\\
94 # This implementation is configured for a Microsoft platform.\\
95 # Thus, the default PATH_SEPARATOR is ';', although some shells may\\
96 # use the POSIX standard ':' instead. Therefore, we need to examine\\
97 # the OSTYPE environment variable, to identify which is appropriate\\
98 # to make PATH searches work correctly.\\
99 #\\
100 case "\$OSTYPE" in\\
102 msys | cygwin)\\
104 # These emulate POSIX, and use ':'\\
106 PATH_SEPARATOR=\${PATH_SEPARATOR-':'} ;;\\
108 *)\\
110 # For anything else, default to ';'\\
112 PATH_SEPARATOR=\${PATH_SEPARATOR-';'} ;;\\
113 esac
118 # eof