minstall.in revision 04b94745
1#!/bin/sh
2# $XTermId: minstall.in,v 1.32 2023/10/08 21:11:07 tom Exp $
3# -----------------------------------------------------------------------------
4# this file is part of xterm
5#
6# Copyright 2001-2022,2023 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
69prefix=@prefix@
70exec_prefix=@exec_prefix@
71datarootdir=@datarootdir@
72datadir=@datadir@
73
74# get parameters
75MINSTALL="$1"
76OLD_FILE="$2"
77END_FILE="$3"
78APP_name="$4"
79USE_name="$5"
80
81suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
82NEW_FILE=temp$$
83
84MY_MANSECT=$suffix
85
86lower=abcdefghijklmnopqrstuvwxyz
87upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
88
89# "X" is usually in the miscellaneous section, along with "undocumented".
90# Use that to guess an appropriate section.  This relies on having the manpage
91# installed.
92X_MANPAGE=X
93X_MANSECT=`man $X_MANPAGE 2>&1 | grep $X_MANPAGE'([^)]*)' | head -n 1 | tr '\012' '\040' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
94test -z "$X_MANSECT" && X_MANSECT=$suffix
95
96VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,version.h,'`
97PATCH_NUM=`@FGREP@ XTERM_PATCH "$VERSION_H" | sed -e 's/[^0-9]*//g'`
98PATCH_YMD=`@FGREP@ XTERM_DATE  "$VERSION_H" | sed -e 's,[^0-9/.-]*,,g'`
99
100# Make capitalization variants
101APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr "$lower" "$upper"`
102APP_chr1=`echo "$APP_name" | sed -e 's/^.//'`
103APP_Name=${APP_chr0}${APP_chr1}
104# APP_NAME=`echo "$APP_name" | tr "$lower" "$upper"`
105
106# Provide for renaming in test-builds:
107USE_chr0=`echo "$USE_name" | sed -e 's/^\(.\).*/\1/' | tr "$lower" "$upper"`
108USE_chr1=`echo "$USE_name" | sed -e 's/^.//'`
109USE_Name=${USE_chr0}${USE_chr1}
110USE_NAME=`echo "$USE_name" | tr "$lower" "$upper"`
111
112sed	-e 's%__vendorversion__%"X Window System"%' \
113	-e 's%__app_version__%Patch\ \#'"$PATCH_NUM"% \
114	-e 's%__app_date__%'"$PATCH_YMD"% \
115	-e 's%^\.TH [^ ][^ ]*%.TH '"$USE_NAME"% \
116	-e 's%^\.ds N '"$APP_Name"'%.ds N '"$USE_Name"% \
117	-e 's%^\.ds n '"$APP_name"'%.ds n '"$USE_name"% \
118	-e 's%^'"$APP_name"' \\- %'"$USE_name"' \- %' \
119	-e "s%__default_termname__%@default_TERM@%" \
120	-e "s%__default_termid__%@default_termid@%" \
121	-e "s%__alt_sends_esc__%@alt_sends_esc@%" \
122	-e "s%__meta_sends_esc__%@meta_sends_esc@%" \
123	-e "s%__backarrow_is_bs__%@backarrow_is_bs@%" \
124	-e "s%__backarrow_is_erase__%@backarrow_is_erase@%" \
125	-e "s%__delete_is_del__%@delete_is_del@%" \
126	-e "s%__double_buffer__%@double_buffer@%" \
127	-e "s%__initial_erase__%@initial_erase@%" \
128	-e "s%__default_class__%@APP_CLASS@%" \
129	-e "s%__apploaddir__%@APPSDIR@%" \
130	-e "s%__mansuffix__%$MY_MANSECT%g" \
131	-e "s%__miscmansuffix__%$X_MANSECT%g" \
132	-e "s%__pixmapsdir__%@PIXMAPDIR@%" \
133	-e "s%__strings_max__%@STRINGS_MAX@%" \
134	-e "s%__utmp_name__%@UTMP_NAME@%g" \
135	-e "s%__utmp_path__%@UTMP_PATH@%g" \
136	-e "s%__wtmp_name__%@WTMP_NAME@%g" \
137	-e "s%__wtmp_path__%@WTMP_PATH@%g" \
138	-e 's%/\\(\*\*%/*%g' \
139	"$OLD_FILE" >$NEW_FILE
140# diff -u $OLD_FILE $NEW_FILE
141
142echo "$MINSTALL $OLD_FILE $END_FILE"
143eval "$MINSTALL $NEW_FILE $END_FILE"
144
145rm -f $NEW_FILE
146