minstall.in revision e0a2b6df
1#!/bin/sh
2# $XTermId: minstall.in,v 1.21 2014/02/27 23:43:50 tom Exp $
3# -----------------------------------------------------------------------------
4# this file is part of xterm
5#
6# Copyright 2001-2013,2014 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
118# "X" is usually in the miscellaneous section, along with "undocumented".
119# Use that to guess an appropriate section.  This relies on having the manpage
120# installed.
121X_MANPAGE=X
122X_MANSECT=`man $X_MANPAGE 2>&1 | grep $X_MANPAGE'([^)]*)' | head -n 1 | tr '\012' '\040' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
123test -z "$X_MANSECT" && X_MANSECT=$suffix
124
125VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,version.h,'`
126PATCH_NUM=`fgrep XTERM_PATCH $VERSION_H|sed -e 's/[^0-9]*//g'`
127PATCH_YMD=`fgrep XTERM_DATE  $VERSION_H|sed -e 's,[^0-9/.-]*,,g'`
128
129# Make capitalization variants
130APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'`
131APP_chr1=`echo "$APP_name" | sed -e 's/^.//'`
132APP_Name=${APP_chr0}${APP_chr1}
133APP_NAME=`echo "$APP_name" | tr '[a-z]' '[A-Z]'`
134
135# Provide for renaming in test-builds:
136USE_chr0=`echo "$USE_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'`
137USE_chr1=`echo "$USE_name" | sed -e 's/^.//'`
138USE_Name=${USE_chr0}${USE_chr1}
139USE_NAME=`echo "$USE_name" | tr '[a-z]' '[A-Z]'`
140
141sed	-e 's%__vendorversion__%"X Window System"%' \
142	-e 's%__app_version__%Patch\ \#'$PATCH_NUM% \
143	-e 's%__app_date__%'$PATCH_YMD% \
144	-e "s%^\.TH [^ ][^ ]*%.TH $USE_NAME%" \
145	-e "s%^\.ds N $APP_Name%.ds N $USE_Name%" \
146	-e "s%^\.ds n $APP_name%.ds n $USE_name%" \
147	-e 's%^'"$APP_name"' \\- %'"$USE_name"' \- %' \
148	-e s%__default_termname__%@default_TERM@% \
149	-e s%__default_termid__%@default_termid@% \
150	-e s%__alt_sends_esc__%@alt_sends_esc@% \
151	-e s%__meta_sends_esc__%@meta_sends_esc@% \
152	-e s%__backarrow_is_bs__%@backarrow_is_bs@% \
153	-e s%__backarrow_is_erase__%@backarrow_is_erase@% \
154	-e s%__delete_is_del__%@delete_is_del@% \
155	-e s%__default_class__%$APP_TYPE% \
156	-e s%__apploaddir__%$APPS_DIR% \
157	-e s%__mansuffix__%$MY_MANSECT%g \
158	-e s%__miscmansuffix__%$X_MANSECT%g \
159	-e s%__pixmapsdir__%$XPMS_DIR% \
160	-e s%fIutmp'\\%fI'$UTMP_NAME'\\%g' \
161	-e s%/etc/utmp%$UTMP_PATH%g \
162	-e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
163	-e s%/etc/wtmp%$WTMP_PATH%g \
164	$OLD_FILE >$NEW_FILE
165# diff -u $OLD_FILE $NEW_FILE
166
167echo "$MINSTALL $OLD_FILE $END_FILE"
168eval "$MINSTALL $NEW_FILE $END_FILE"
169
170rm -f $NEW_FILE
171