summaryrefslogtreecommitdiffstats
path: root/arch/misc/shdeps.sh
blob: 844b3682a7d5060ca5e71bff4d991d0aa28a91a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /bin/sh
# shdeps.sh: Generate OS dependency fixups, for 'groff' shell scripts
#
# Copyright (C) 2004-2020 Free Software Foundation, Inc.
#      Written by Keith Marshall (keith.d.marshall@ntlworld.com)
#
# Invoked only by 'make', as:
#    $(SHELL) shdeps.sh "$(RT_SEP)" "$(SH_SEP)" "$(bindir)" > shdeps.sed
#
# This file is part of groff.
#
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# groff is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

cat << ETX
# shdeps.sed: Script generated automatically by 'make' -- do not modify!

/^$/N
/@GROFF_BIN_PATH_SETUP@/c\\
ETX

if [ "$1$2" = "::" ]
then
  # 'PATH_SEPARATOR' is ':' both at 'groff' run time, and in 'make',
  # implying an implementation which is completely POSIX compliant.
  # Simply apply the 'GROFF_BIN_PATH' and 'PATH_SEPARATOR' values
  # determined by 'configure', in all cases.

  cat << ETX
\\
GROFF_RUNTIME="\${GROFF_BIN_PATH=$3}:"
/@PATH_SEARCH_SETUP@/d
ETX

else
  # 'PATH_SEPARATOR' is NOT always ':',
  # which suggests an implementation for a Microsoft platform.
  # We need to choose the 'GROFF_BIN_PATH' format and 'PATH_SEPARATOR'
  # which will suit the user's choice of shell.
  #
  # Note that some Windows users may specify the '--prefix' path
  # using backslash characters, instead of '/', preferred by POSIX,
  # so we will also fix that up.

  POSIX_BINDIR=`echo $3 | tr '\\\\' /`
  cat << ETX
# (The value required is dependent on the user's choice of shell,\\
#  and its associated POSIX emulation capabilities.)\\
\\
case "\$OSTYPE" in\\
  msys)\\
    GROFF_RUNTIME=\${GROFF_BIN_PATH="`
      case "$POSIX_BINDIR" in
	[a-zA-Z]:*)
	  IFS=':'
	  set -- $POSIX_BINDIR
	  case "$2" in
	    /*) POSIX_BINDIR="/$1$2"  ;;
	     *) POSIX_BINDIR="/$1/$2" ;;
	  esac
	  shift 2
	  for dir
	    do
	      POSIX_BINDIR="$POSIX_BINDIR:$dir"
	    done
	  ;;
      esac
      echo "$POSIX_BINDIR"`"}":" ;;\\
  cygwin)\\
    : \${GROFF_BIN_PATH="\`cygpath -w '$POSIX_BINDIR'\`"}\\
    GROFF_RUNTIME=\`cygpath "\$GROFF_BIN_PATH"\`":" ;;\\
  *)\\
    GROFF_RUNTIME=\${GROFF_BIN_PATH="$POSIX_BINDIR"}";" ;;\\
esac
ETX
  # On Microsoft platforms, we may also need to configure
  # the PATH search function, used in the `pdfroff' script,
  # to use ';', instead of ':', as the PATH_SEPARATOR.

  cat << ETX
/@PATH_SEARCH_SETUP@/c\\
#\\
# This implementation is configured for a Microsoft platform.\\
# Thus, the default PATH_SEPARATOR is ';', although some shells may\\
# use the POSIX standard ':' instead.  Therefore, we need to examine\\
# the OSTYPE environment variable, to identify which is appropriate\\
# to make PATH searches work correctly.\\
#\\
  case "\$OSTYPE" in\\
#\\
    msys | cygwin)\\
    #\\
    # These emulate POSIX, and use ':'\\
    #\\
      PATH_SEPARATOR=\${PATH_SEPARATOR-':'} ;;\\
#\\
    *)\\
    #\\
    # For anything else, default to ';'\\
    #\\
      PATH_SEPARATOR=\${PATH_SEPARATOR-';'} ;;\\
  esac
ETX

fi

# eof