xref: /freebsd/contrib/ncurses/misc/run_tic.in (revision 580744621f33383027108364dcadad718df46ffe)
1#!@SHELL@
2# $Id: run_tic.in,v 1.38 2020/02/15 15:30:53 tom Exp $
3##############################################################################
4# Copyright 2019,2020 Thomas E. Dickey                                       #
5# Copyright 2000-2012,2017 Free Software Foundation, Inc.                    #
6#                                                                            #
7# Permission is hereby granted, free of charge, to any person obtaining a    #
8# copy of this software and associated documentation files (the "Software"), #
9# to deal in the Software without restriction, including without limitation  #
10# the rights to use, copy, modify, merge, publish, distribute, distribute    #
11# with modifications, sublicense, and/or sell copies of the Software, and to #
12# permit persons to whom the Software is furnished to do so, subject to the  #
13# following conditions:                                                      #
14#                                                                            #
15# The above copyright notice and this permission notice shall be included in #
16# all copies or substantial portions of the Software.                        #
17#                                                                            #
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
21# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
24# DEALINGS IN THE SOFTWARE.                                                  #
25#                                                                            #
26# Except as contained in this notice, the name(s) of the above copyright     #
27# holders shall not be used in advertising or otherwise to promote the sale, #
28# use or other dealings in this Software without prior written               #
29# authorization.                                                             #
30##############################################################################
31#
32# Author: Thomas E. Dickey 1996-on
33#
34# This script is used to install terminfo.src using tic.  We use a script
35# because the path checking is too awkward to do in a makefile.
36#
37# Assumes:
38#	The leaf directory names (lib, tabset, terminfo)
39#
40echo "** Building terminfo database, please wait..."
41#
42# The script is designed to be run from the misc/Makefile as
43#	make install.data
44
45: ${suffix:=@EXEEXT@}
46: ${DESTDIR:=@DESTDIR@}
47: ${prefix:=@prefix@}
48: ${exec_prefix:=@exec_prefix@}
49: ${bindir:=@bindir@}
50: ${top_srcdir:=@top_srcdir@}
51: ${srcdir:=@srcdir@}
52: ${datarootdir:=@datarootdir@}
53: ${datadir:=@datadir@}
54: ${TIC_PATH:=@TIC@}
55: ${ticdir:=@TERMINFO@}
56: ${source:=@TERMINFO_SRC@}
57: ${LN_S:="@LN_S@"}
58: ${cross_compiling:=no}
59: ${ext_funcs:=@NCURSES_EXT_FUNCS@}
60
61test -z "${DESTDIR}" && DESTDIR=
62
63# Allow tic to run either from the install-path, or from the build-directory.
64# Do not do this if we appear to be cross-compiling.  In that case, we rely
65# on the host's copy of tic to compile the terminfo database.
66if test "x$cross_compiling" = "xno"
67then
68	if test -f ../progs/tic$suffix
69	then
70		case "$PATH" in
71		\@PATH_SEPARATOR@*)
72			PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir$PATH"
73			;;
74		*)
75			PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir@PATH_SEPARATOR@$PATH"
76			;;
77		esac
78		export PATH
79		if test @DFT_LWR_MODEL@ = shared
80		then
81			SHLIB="sh $srcdir/shlib"
82			TIC_PATH="$SHLIB tic"
83		else
84			TIC_PATH="tic"
85		fi
86	elif test "$TIC_PATH" = unknown
87	then
88		echo "? no tic program found"
89		exit 1
90	fi
91else
92	# Cross-compiling, so don't set PATH or run shlib.
93	SHLIB=
94	# reset $suffix, since it applies to the target, not the build platform.
95	suffix=
96fi
97
98
99# set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
100# the PATH we just set.
101SHLIB_PATH=$PATH
102export SHLIB_PATH
103
104# set a variable to simplify environment update in shlib
105SHLIB_HOST=@host_os@
106export SHLIB_HOST
107
108# don't use user's TERMINFO variable
109unset TERMINFO_DIRS
110TERMINFO="${DESTDIR}$ticdir" ; export TERMINFO
111umask 022
112
113# Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
114TICDIR=`echo "$TERMINFO" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
115
116# Parent directory may not exist, which would confuse the install for hashed
117# database.  Fix.
118PARENT=`echo "$TERMINFO" | sed -e 's%/[^/]*$%%'`
119if test -n "$PARENT"
120then
121	test -d $PARENT || mkdir -p $PARENT
122fi
123
124# Remove the old terminfo stuff; we don't care if it existed before, and it
125# would generate a lot of confusing error messages if we tried to overwrite it.
126# We explicitly remove its contents rather than the directory itself, in case
127# the directory is actually a symbolic link.
128if test -d "$TERMINFO"
129then
130	( cd "$TERMINFO" && rm -fr ? 2>/dev/null )
131elif test -f "$TERMINFO.db"
132then
133	( rm -f "$TERMINFO.db" 2>/dev/null )
134fi
135
136if test "$ext_funcs" = 1 ; then
137cat <<EOF
138Running $TIC_PATH to install $TERMINFO ...
139
140	You may see messages regarding extended capabilities, e.g., AX.
141	These are extended terminal capabilities which are compiled
142	using
143		tic -x
144	If you have ncurses 4.2 applications, you should read the INSTALL
145	document, and install the terminfo without the -x option.
146
147EOF
148$TIC_PATH -V
149if ( $TIC_PATH -x -s -o "$TERMINFO" $source )
150then
151	echo "** built new $TERMINFO"
152else
153	echo "? tic could not build $TERMINFO"
154	exit 1
155fi
156else
157cat <<EOF
158Running $TIC_PATH to install $TERMINFO ...
159
160	You may see messages regarding unknown capabilities, e.g., AX.
161	These are extended terminal capabilities which may be compiled
162	using
163		tic -x
164	If you have ncurses 4.2 applications, you should read the INSTALL
165	document, and install the terminfo without the -x option.
166
167EOF
168$TIC_PATH -V
169if ( $TIC_PATH -s -o "$TERMINFO" $source )
170then
171	echo "** built new $TERMINFO"
172else
173	echo "? tic could not build $TERMINFO"
174	exit 1
175fi
176fi
177
178# Make a symbolic link to provide compatibility with applications that expect
179# to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
180# all systems support symbolic links, and those that do provide a variety
181# of options for 'test'.
182if test "$TICDIR" != "$TERMINFO" ; then
183	( rm -f "$TICDIR" 2>/dev/null )
184	if ( cd "$TICDIR" 2>/dev/null )
185	then
186		cd "$TICDIR"
187		TICDIR=`pwd`
188		if test "$TICDIR "!= "$TERMINFO "; then
189			# Well, we tried.  Some systems lie to us, so the
190			# installer will have to double-check.
191			echo "Verify if $TICDIR and $TERMINFO are the same."
192			echo "The new terminfo is in $TERMINFO; the other should be a link to it."
193			echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
194		fi
195	else
196		cd ${DESTDIR}$prefix
197		# Construct a symbolic link that only assumes $ticdir has the
198		# same $prefix as the other installed directories.
199		RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'`
200		if test "$RELATIVE" != "$ticdir" ; then
201			RELATIVE=../`echo $ticdir|sed -e 's%^'$prefix'/%%' -e 's%^/%%'`
202		fi
203		if ( @LN_S@ "$RELATIVE" "$TICDIR" )
204		then
205			echo "** sym-linked $TICDIR for compatibility"
206		else
207			echo "** could not sym-link $TICDIR for compatibility"
208		fi
209	fi
210fi
211# vile:shmode
212