Imported Upstream version 1.23.0
[platform/upstream/groff.git] / arch / misc / shdeps.sh
1 #! /bin/sh
2 # shdeps.sh: Generate OS dependency fixups, for 'groff' shell scripts
3 #
4 # Copyright (C) 2004-2020 Free Software Foundation, Inc.
5 #      Written by Keith Marshall (keith.d.marshall@ntlworld.com)
6 #
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.
11 #
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 3 of the License, or
15 # (at your option) any later version.
16 #
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.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
25 cat << ETX
26 # shdeps.sed: Script generated automatically by 'make' -- do not modify!
27
28 /^$/N
29 /@GROFF_BIN_PATH_SETUP@/c\\
30 ETX
31
32 if [ "$1$2" = "::" ]
33 then
34   # 'PATH_SEPARATOR' is ':' both at 'groff' run time, and in 'make',
35   # implying an implementation which is completely POSIX compliant.
36   # Simply apply the 'GROFF_BIN_PATH' and 'PATH_SEPARATOR' values
37   # determined by 'configure', in all cases.
38
39   cat << ETX
40 \\
41 GROFF_RUNTIME="\${GROFF_BIN_PATH=$3}:"
42 /@PATH_SEARCH_SETUP@/d
43 ETX
44
45 else
46   # 'PATH_SEPARATOR' is NOT always ':',
47   # which suggests an implementation for a Microsoft platform.
48   # We need to choose the 'GROFF_BIN_PATH' format and 'PATH_SEPARATOR'
49   # which will suit the user's choice of shell.
50   #
51   # Note that some Windows users may specify the '--prefix' path
52   # using backslash characters, instead of '/', preferred by POSIX,
53   # so we will also fix that up.
54
55   POSIX_BINDIR=`echo $3 | tr '\\\\' /`
56   cat << ETX
57 # (The value required is dependent on the user's choice of shell,\\
58 #  and its associated POSIX emulation capabilities.)\\
59 \\
60 case "\$OSTYPE" in\\
61   msys)\\
62     GROFF_RUNTIME=\${GROFF_BIN_PATH="`
63       case "$POSIX_BINDIR" in
64         [a-zA-Z]:*)
65           IFS=':'
66           set -- $POSIX_BINDIR
67           case "$2" in
68             /*) POSIX_BINDIR="/$1$2"  ;;
69              *) POSIX_BINDIR="/$1/$2" ;;
70           esac
71           shift 2
72           for dir
73             do
74               POSIX_BINDIR="$POSIX_BINDIR:$dir"
75             done
76           ;;
77       esac
78       echo "$POSIX_BINDIR"`"}":" ;;\\
79   cygwin)\\
80     : \${GROFF_BIN_PATH="\`cygpath -w '$POSIX_BINDIR'\`"}\\
81     GROFF_RUNTIME=\`cygpath "\$GROFF_BIN_PATH"\`":" ;;\\
82   *)\\
83     GROFF_RUNTIME=\${GROFF_BIN_PATH="$POSIX_BINDIR"}";" ;;\\
84 esac
85 ETX
86   # On Microsoft platforms, we may also need to configure
87   # the PATH search function, used in the `pdfroff' script,
88   # to use ';', instead of ':', as the PATH_SEPARATOR.
89
90   cat << ETX
91 /@PATH_SEARCH_SETUP@/c\\
92 #\\
93 # This implementation is configured for a Microsoft platform.\\
94 # Thus, the default PATH_SEPARATOR is ';', although some shells may\\
95 # use the POSIX standard ':' instead.  Therefore, we need to examine\\
96 # the OSTYPE environment variable, to identify which is appropriate\\
97 # to make PATH searches work correctly.\\
98 #\\
99   case "\$OSTYPE" in\\
100 #\\
101     msys | cygwin)\\
102     #\\
103     # These emulate POSIX, and use ':'\\
104     #\\
105       PATH_SEPARATOR=\${PATH_SEPARATOR-':'} ;;\\
106 #\\
107     *)\\
108     #\\
109     # For anything else, default to ';'\\
110     #\\
111       PATH_SEPARATOR=\${PATH_SEPARATOR-';'} ;;\\
112   esac
113 ETX
114
115 fi
116
117 # eof