xref: /freebsd/contrib/ncurses/misc/run_tic.in (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
118259542SPeter Wemm#!@SHELL@
2*21817992SBaptiste Daroussin# $Id: run_tic.in,v 1.40 2022/07/16 19:37:03 tom Exp $
318259542SPeter Wemm##############################################################################
4*21817992SBaptiste Daroussin# Copyright 2019-2020,2022 Thomas E. Dickey                                  #
5e1865124SBaptiste Daroussin# Copyright 2000-2012,2017 Free Software Foundation, Inc.                    #
618259542SPeter Wemm#                                                                            #
718259542SPeter Wemm# Permission is hereby granted, free of charge, to any person obtaining a    #
818259542SPeter Wemm# copy of this software and associated documentation files (the "Software"), #
918259542SPeter Wemm# to deal in the Software without restriction, including without limitation  #
1018259542SPeter Wemm# the rights to use, copy, modify, merge, publish, distribute, distribute    #
1118259542SPeter Wemm# with modifications, sublicense, and/or sell copies of the Software, and to #
1218259542SPeter Wemm# permit persons to whom the Software is furnished to do so, subject to the  #
1318259542SPeter Wemm# following conditions:                                                      #
1418259542SPeter Wemm#                                                                            #
1518259542SPeter Wemm# The above copyright notice and this permission notice shall be included in #
1618259542SPeter Wemm# all copies or substantial portions of the Software.                        #
1718259542SPeter Wemm#                                                                            #
1818259542SPeter Wemm# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
1918259542SPeter Wemm# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
2018259542SPeter Wemm# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
2118259542SPeter Wemm# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
2218259542SPeter Wemm# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
2318259542SPeter Wemm# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
2418259542SPeter Wemm# DEALINGS IN THE SOFTWARE.                                                  #
2518259542SPeter Wemm#                                                                            #
2618259542SPeter Wemm# Except as contained in this notice, the name(s) of the above copyright     #
2718259542SPeter Wemm# holders shall not be used in advertising or otherwise to promote the sale, #
2818259542SPeter Wemm# use or other dealings in this Software without prior written               #
2918259542SPeter Wemm# authorization.                                                             #
3018259542SPeter Wemm##############################################################################
3118259542SPeter Wemm#
3206bfebdeSXin LI# Author: Thomas E. Dickey 1996-on
3318259542SPeter Wemm#
3418259542SPeter Wemm# This script is used to install terminfo.src using tic.  We use a script
3518259542SPeter Wemm# because the path checking is too awkward to do in a makefile.
3618259542SPeter Wemm#
3718259542SPeter Wemm# Assumes:
3818259542SPeter Wemm#	The leaf directory names (lib, tabset, terminfo)
3918259542SPeter Wemm#
40aae38d10SBaptiste Daroussinecho "** Building terminfo database, please wait..."
4118259542SPeter Wemm#
4218259542SPeter Wemm# The script is designed to be run from the misc/Makefile as
4318259542SPeter Wemm#	make install.data
4418259542SPeter Wemm
45*21817992SBaptiste Daroussin: "${suffix:=@EXEEXT@}"
46*21817992SBaptiste Daroussin: "${DESTDIR:=@DESTDIR@}"
47*21817992SBaptiste Daroussin: "${prefix:=@prefix@}"
48*21817992SBaptiste Daroussin: "${exec_prefix:=@exec_prefix@}"
49*21817992SBaptiste Daroussin: "${bindir:=@bindir@}"
50*21817992SBaptiste Daroussin: "${top_srcdir:=@top_srcdir@}"
51*21817992SBaptiste Daroussin: "${srcdir:=@srcdir@}"
52*21817992SBaptiste Daroussin: "${datarootdir:=@datarootdir@}"
53*21817992SBaptiste Daroussin: "${datadir:=@datadir@}"
54*21817992SBaptiste Daroussin: "${TIC_PATH:=@TIC@}"
55*21817992SBaptiste Daroussin: "${ticdir:=@TERMINFO@}"
56*21817992SBaptiste Daroussin: "${source:=@TERMINFO_SRC@}"
57*21817992SBaptiste Daroussin: "${cross_compiling:=no}"
58*21817992SBaptiste Daroussin: "${ext_funcs:=@NCURSES_EXT_FUNCS@}"
5918259542SPeter Wemm
6018259542SPeter Wemmtest -z "${DESTDIR}" && DESTDIR=
6118259542SPeter Wemm
6239f2269fSPeter Wemm# Allow tic to run either from the install-path, or from the build-directory.
6339f2269fSPeter Wemm# Do not do this if we appear to be cross-compiling.  In that case, we rely
6439f2269fSPeter Wemm# on the host's copy of tic to compile the terminfo database.
6506bfebdeSXin LIif test "x$cross_compiling" = "xno"
6606bfebdeSXin LIthen
6706bfebdeSXin LI	if test -f ../progs/tic$suffix
6806bfebdeSXin LI	then
6918259542SPeter Wemm		case "$PATH" in
7006bfebdeSXin LI		\@PATH_SEPARATOR@*)
7106bfebdeSXin LI			PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir$PATH"
7206bfebdeSXin LI			;;
7306bfebdeSXin LI		*)
7406bfebdeSXin LI			PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir@PATH_SEPARATOR@$PATH"
7506bfebdeSXin LI			;;
7618259542SPeter Wemm		esac
7718259542SPeter Wemm		export PATH
7806bfebdeSXin LI		if test @DFT_LWR_MODEL@ = shared
7906bfebdeSXin LI		then
804a1a9510SRong-En Fan			SHLIB="sh $srcdir/shlib"
8106bfebdeSXin LI			TIC_PATH="$SHLIB tic"
8206bfebdeSXin LI		else
8306bfebdeSXin LI			TIC_PATH="tic"
8406bfebdeSXin LI		fi
8506bfebdeSXin LI	elif test "$TIC_PATH" = unknown
8606bfebdeSXin LI	then
87aae38d10SBaptiste Daroussin		echo "? no tic program found"
8806bfebdeSXin LI		exit 1
8906bfebdeSXin LI	fi
904a1a9510SRong-En Fanelse
914a1a9510SRong-En Fan	# Cross-compiling, so don't set PATH or run shlib.
924a1a9510SRong-En Fan	SHLIB=
934a1a9510SRong-En Fan	# reset $suffix, since it applies to the target, not the build platform.
944a1a9510SRong-En Fan	suffix=
9539f2269fSPeter Wemmfi
9618259542SPeter Wemm
974a1a9510SRong-En Fan
9818259542SPeter Wemm# set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
9918259542SPeter Wemm# the PATH we just set.
1004a1a9510SRong-En FanSHLIB_PATH=$PATH
1014a1a9510SRong-En Fanexport SHLIB_PATH
10218259542SPeter Wemm
1034a1a9510SRong-En Fan# set a variable to simplify environment update in shlib
1044a1a9510SRong-En FanSHLIB_HOST=@host_os@
1054a1a9510SRong-En Fanexport SHLIB_HOST
1064a1a9510SRong-En Fan
1074a1a9510SRong-En Fan# don't use user's TERMINFO variable
108aae38d10SBaptiste Daroussinunset TERMINFO_DIRS
109aae38d10SBaptiste DaroussinTERMINFO="${DESTDIR}$ticdir" ; export TERMINFO
11018259542SPeter Wemmumask 022
11118259542SPeter Wemm
11218259542SPeter Wemm# Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
113aae38d10SBaptiste DaroussinTICDIR=`echo "$TERMINFO" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
11418259542SPeter Wemm
11506bfebdeSXin LI# Parent directory may not exist, which would confuse the install for hashed
11606bfebdeSXin LI# database.  Fix.
11706bfebdeSXin LIPARENT=`echo "$TERMINFO" | sed -e 's%/[^/]*$%%'`
11806bfebdeSXin LIif test -n "$PARENT"
11906bfebdeSXin LIthen
120*21817992SBaptiste Daroussin	mkdir -p "$PARENT"
12106bfebdeSXin LIfi
12206bfebdeSXin LI
12318259542SPeter Wemm# Remove the old terminfo stuff; we don't care if it existed before, and it
12418259542SPeter Wemm# would generate a lot of confusing error messages if we tried to overwrite it.
12518259542SPeter Wemm# We explicitly remove its contents rather than the directory itself, in case
12618259542SPeter Wemm# the directory is actually a symbolic link.
127aae38d10SBaptiste Daroussinif test -d "$TERMINFO"
128aae38d10SBaptiste Daroussinthen
129*21817992SBaptiste Daroussin	( cd "$TERMINFO" && rm -fr ./? 2>/dev/null )
130aae38d10SBaptiste Daroussinelif test -f "$TERMINFO.db"
131aae38d10SBaptiste Daroussinthen
132aae38d10SBaptiste Daroussin	( rm -f "$TERMINFO.db" 2>/dev/null )
133aae38d10SBaptiste Daroussinfi
13418259542SPeter Wemm
1354a1a9510SRong-En Fanif test "$ext_funcs" = 1 ; then
13618259542SPeter Wemmcat <<EOF
13706bfebdeSXin LIRunning $TIC_PATH to install $TERMINFO ...
13818259542SPeter Wemm
1394a1a9510SRong-En Fan	You may see messages regarding extended capabilities, e.g., AX.
1404a1a9510SRong-En Fan	These are extended terminal capabilities which are compiled
14118259542SPeter Wemm	using
14218259542SPeter Wemm		tic -x
1434a1a9510SRong-En Fan	If you have ncurses 4.2 applications, you should read the INSTALL
1444a1a9510SRong-En Fan	document, and install the terminfo without the -x option.
14518259542SPeter Wemm
14618259542SPeter WemmEOF
147e1865124SBaptiste Daroussin$TIC_PATH -V
148aae38d10SBaptiste Daroussinif ( $TIC_PATH -x -s -o "$TERMINFO" $source )
14918259542SPeter Wemmthen
150aae38d10SBaptiste Daroussin	echo "** built new $TERMINFO"
15118259542SPeter Wemmelse
152aae38d10SBaptiste Daroussin	echo "? tic could not build $TERMINFO"
15318259542SPeter Wemm	exit 1
15418259542SPeter Wemmfi
1554a1a9510SRong-En Fanelse
1564a1a9510SRong-En Fancat <<EOF
15706bfebdeSXin LIRunning $TIC_PATH to install $TERMINFO ...
1584a1a9510SRong-En Fan
1594a1a9510SRong-En Fan	You may see messages regarding unknown capabilities, e.g., AX.
1604a1a9510SRong-En Fan	These are extended terminal capabilities which may be compiled
1614a1a9510SRong-En Fan	using
1624a1a9510SRong-En Fan		tic -x
1634a1a9510SRong-En Fan	If you have ncurses 4.2 applications, you should read the INSTALL
1644a1a9510SRong-En Fan	document, and install the terminfo without the -x option.
1654a1a9510SRong-En Fan
1664a1a9510SRong-En FanEOF
167e1865124SBaptiste Daroussin$TIC_PATH -V
168aae38d10SBaptiste Daroussinif ( $TIC_PATH -s -o "$TERMINFO" $source )
1694a1a9510SRong-En Fanthen
170aae38d10SBaptiste Daroussin	echo "** built new $TERMINFO"
1714a1a9510SRong-En Fanelse
172aae38d10SBaptiste Daroussin	echo "? tic could not build $TERMINFO"
1734a1a9510SRong-En Fan	exit 1
1744a1a9510SRong-En Fanfi
1754a1a9510SRong-En Fanfi
17618259542SPeter Wemm
17718259542SPeter Wemm# Make a symbolic link to provide compatibility with applications that expect
17818259542SPeter Wemm# to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
17918259542SPeter Wemm# all systems support symbolic links, and those that do provide a variety
18018259542SPeter Wemm# of options for 'test'.
18118259542SPeter Wemmif test "$TICDIR" != "$TERMINFO" ; then
182aae38d10SBaptiste Daroussin	( rm -f "$TICDIR" 2>/dev/null )
183aae38d10SBaptiste Daroussin	if ( cd "$TICDIR" 2>/dev/null )
18418259542SPeter Wemm	then
185*21817992SBaptiste Daroussin		cd "$TICDIR" || exit
18618259542SPeter Wemm		TICDIR=`pwd`
187aae38d10SBaptiste Daroussin		if test "$TICDIR " != "$TERMINFO "; then
18818259542SPeter Wemm			# Well, we tried.  Some systems lie to us, so the
18918259542SPeter Wemm			# installer will have to double-check.
19018259542SPeter Wemm			echo "Verify if $TICDIR and $TERMINFO are the same."
19118259542SPeter Wemm			echo "The new terminfo is in $TERMINFO; the other should be a link to it."
19218259542SPeter Wemm			echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
19318259542SPeter Wemm		fi
19418259542SPeter Wemm	else
195*21817992SBaptiste Daroussin		cd ${DESTDIR}$prefix || exit
19618259542SPeter Wemm		# Construct a symbolic link that only assumes $ticdir has the
19718259542SPeter Wemm		# same $prefix as the other installed directories.
1984a1a9510SRong-En Fan		RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'`
19918259542SPeter Wemm		if test "$RELATIVE" != "$ticdir" ; then
2004a1a9510SRong-En Fan			RELATIVE=../`echo $ticdir|sed -e 's%^'$prefix'/%%' -e 's%^/%%'`
20118259542SPeter Wemm		fi
202aae38d10SBaptiste Daroussin		if ( @LN_S@ "$RELATIVE" "$TICDIR" )
20318259542SPeter Wemm		then
204aae38d10SBaptiste Daroussin			echo "** sym-linked $TICDIR for compatibility"
2054a1a9510SRong-En Fan		else
206aae38d10SBaptiste Daroussin			echo "** could not sym-link $TICDIR for compatibility"
20718259542SPeter Wemm		fi
20818259542SPeter Wemm	fi
20918259542SPeter Wemmfi
2104a1a9510SRong-En Fan# vile:shmode
211