minstall.in revision f2e35a3a
1#!/bin/sh
2# $XTermId: minstall.in,v 1.26 2021/01/27 01:36:06 tom Exp $
3# -----------------------------------------------------------------------------
4# this file is part of xterm
5#
6# Copyright 2001-2019,2021 by Thomas E. Dickey
7#
8#                         All Rights Reserved
9#
10# Permission is hereby granted, free of charge, to any person obtaining a
11# copy of this software and associated documentation files (the
12# "Software"), to deal in the Software without restriction, including
13# without limitation the rights to use, copy, modify, merge, publish,
14# distribute, sublicense, and/or sell copies of the Software, and to
15# permit persons to whom the Software is furnished to do so, subject to
16# the following conditions:
17#
18# The above copyright notice and this permission notice shall be included
19# in all copies or substantial portions of the Software.
20#
21# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
25# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28#
29# Except as contained in this notice, the name(s) of the above copyright
30# holders shall not be used in advertising or otherwise to promote the
31# sale, use or other dealings in this Software without prior written
32# authorization.
33# -----------------------------------------------------------------------------
34#
35# Install manpages, substituting a reasonable section value since XFree86 4.x
36# and derived imakes do not use constants...
37#
38# Parameters:
39#	$1 = program to invoke as "install"
40#	$2 = manpage to install
41#	$3 = final installed-path
42#	$4 = app-defaults directory
43#	$5 = app-defaults class
44#	$6 = application name, normally "xterm"
45#	$7 = application name transformed
46#	$8 = pixmap directory
47#
48# Other values correspond to definitions in xtermcfg.h, and cannot be directly
49# modified using "make".  They are substituted directly into this script.
50#
51
52# override locale...
53LANG=C;		export LANG
54LANGUAGE=C;	export LANGUAGE
55LC_ALL=C;	export LC_ALL
56LC_CTYPE=C;	export LC_CTYPE
57XTERM_LOCALE=C	export XTERM_LOCALE
58
59# avoid interference by the "man" command.
60for p in /bin /usr/bin
61do
62if test -f $p/cat ; then
63MANPAGER="cat";   export MANPAGER
64PAGER="cat";      export PAGER
65break
66fi
67done
68
69# get parameters
70MINSTALL="$1"
71OLD_FILE="$2"
72END_FILE="$3"
73APPS_DIR="$4"
74APP_TYPE="$5"
75APP_name="$6"
76USE_name="$7"
77XPMS_DIR="$8"
78
79suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
80NEW_FILE=temp$$
81
82MY_MANSECT=$suffix
83
84# utmp and wtmp have different pathnames on different systems, but there
85# are only a few common choices.  Note that they may not necessarily appear
86# in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
87# the way the configure script is designed.
88UTMP_NAME=utmp
89UTMP_PATH=/etc
90for name in /etc /var/adm /var/run /var/log
91do
92	if test -f $name/utmpx ; then
93		UTMP_NAME=utmpx
94		UTMP_PATH=$name
95		break
96	elif test -f $name/utmp ; then
97		UTMP_PATH=$name
98		break
99	fi
100done
101UTMP_PATH=$UTMP_PATH/$UTMP_NAME
102
103WTMP_NAME=wtmp
104WTMP_PATH=/etc
105for name in /etc /var/adm /var/run /var/log
106do
107	if test -f $name/wtmpx ; then
108		WTMP_NAME=wtmpx
109		WTMP_PATH=$name
110		break
111	elif test -f $name/wtmp ; then
112		WTMP_PATH=$name
113		break
114	fi
115done
116WTMP_PATH=$WTMP_PATH/$WTMP_NAME
117
118lower=abcdefghijklmnopqrstuvwxyz
119upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
120
121# "X" is usually in the miscellaneous section, along with "undocumented".
122# Use that to guess an appropriate section.  This relies on having the manpage
123# installed.
124X_MANPAGE=X
125X_MANSECT=`man $X_MANPAGE 2>&1 | grep $X_MANPAGE'([^)]*)' | head -n 1 | tr '\012' '\040' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
126test -z "$X_MANSECT" && X_MANSECT=$suffix
127
128VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,version.h,'`
129PATCH_NUM=`${FGREP-fgrep} XTERM_PATCH "$VERSION_H" | sed -e 's/[^0-9]*//g'`
130PATCH_YMD=`${FGREP-fgrep} XTERM_DATE  "$VERSION_H" | sed -e 's,[^0-9/.-]*,,g'`
131
132# Make capitalization variants
133APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr "$lower" "$upper"`
134APP_chr1=`echo "$APP_name" | sed -e 's/^.//'`
135APP_Name=${APP_chr0}${APP_chr1}
136# APP_NAME=`echo "$APP_name" | tr "$lower" "$upper"`
137
138# Provide for renaming in test-builds:
139USE_chr0=`echo "$USE_name" | sed -e 's/^\(.\).*/\1/' | tr "$lower" "$upper"`
140USE_chr1=`echo "$USE_name" | sed -e 's/^.//'`
141USE_Name=${USE_chr0}${USE_chr1}
142USE_NAME=`echo "$USE_name" | tr "$lower" "$upper"`
143
144sed	-e 's%__vendorversion__%"X Window System"%' \
145	-e 's%__app_version__%Patch\ \#'"$PATCH_NUM"% \
146	-e 's%__app_date__%'"$PATCH_YMD"% \
147	-e 's%^\.TH [^ ][^ ]*%.TH '"$USE_NAME"% \
148	-e 's%^\.ds N '"$APP_Name"'%.ds N '"$USE_Name"% \
149	-e 's%^\.ds n '"$APP_name"'%.ds n '"$USE_name"% \
150	-e 's%^'"$APP_name"' \\- %'"$USE_name"' \- %' \
151	-e "s%__default_termname__%@default_TERM@%" \
152	-e "s%__default_termid__%@default_termid@%" \
153	-e "s%__alt_sends_esc__%@alt_sends_esc@%" \
154	-e "s%__meta_sends_esc__%@meta_sends_esc@%" \
155	-e "s%__backarrow_is_bs__%@backarrow_is_bs@%" \
156	-e "s%__backarrow_is_erase__%@backarrow_is_erase@%" \
157	-e "s%__delete_is_del__%@delete_is_del@%" \
158	-e "s%__double_buffer__%@double_buffer@%" \
159	-e "s%__initial_erase__%@initial_erase@%" \
160	-e "s%__default_class__%$APP_TYPE%" \
161	-e "s%__apploaddir__%$APPS_DIR%" \
162	-e "s%__mansuffix__%$MY_MANSECT%g" \
163	-e "s%__miscmansuffix__%$X_MANSECT%g" \
164	-e "s%__pixmapsdir__%$XPMS_DIR%" \
165	-e 's%fIutmp\\%fI'$UTMP_NAME'\\%g' \
166	-e "s%/etc/utmp%$UTMP_PATH%g" \
167	-e 's%fIwtmp\\%fI'$WTMP_NAME'\\%g' \
168	-e "s%/etc/wtmp%$WTMP_PATH%g" \
169	-e 's%/\\(\*\*%/*%g' \
170	"$OLD_FILE" >$NEW_FILE
171# diff -u $OLD_FILE $NEW_FILE
172
173echo "$MINSTALL $OLD_FILE $END_FILE"
174eval "$MINSTALL $NEW_FILE $END_FILE"
175
176rm -f $NEW_FILE
177