118259542SPeter Wemm#!@SHELL@ 2c5a1e08bSBaptiste Daroussin# $Id: run_tic.in,v 1.44 2025/09/13 16:52:46 tom Exp $ 318259542SPeter Wemm############################################################################## 4c5a1e08bSBaptiste Daroussin# Copyright 2019-2024,2025 Thomas E. Dickey # 572c3fc31SBaptiste 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# 32a0044ffcSXin 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# 40f0179cb6SBaptiste 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 45c5a1e08bSBaptiste Daroussin# Symbols which are not overridden by misc/Makefile: 4624fa7a51SBaptiste Daroussin: "${prefix:=@prefix@}" 4724fa7a51SBaptiste Daroussin: "${exec_prefix:=@exec_prefix@}" 4824fa7a51SBaptiste Daroussin: "${top_srcdir:=@top_srcdir@}" 4924fa7a51SBaptiste Daroussin: "${srcdir:=@srcdir@}" 5024fa7a51SBaptiste Daroussin: "${datarootdir:=@datarootdir@}" 5124fa7a51SBaptiste Daroussin: "${datadir:=@datadir@}" 52c5a1e08bSBaptiste Daroussin: "${cross_compiling:=@cross_compiling@}" 53c5a1e08bSBaptiste Daroussin: "${suffix:=@EXEEXT@}" 5418259542SPeter Wemm 55c5a1e08bSBaptiste Daroussin: "${ext_funcs:=@NCURSES_EXT_FUNCS@}" 56c5a1e08bSBaptiste Daroussin: "${tic_path:=@TIC@}" 57c5a1e08bSBaptiste Daroussin: "${ticdir:=@TERMINFO@}" 58c5a1e08bSBaptiste Daroussin: "${tic_source:=@TERMINFO_SRC@}" 59c5a1e08bSBaptiste Daroussin 60c5a1e08bSBaptiste Daroussin# Symbols which $DESTDIR and/or install-prefix may affect: 61c5a1e08bSBaptiste Daroussin: "${INSTALL_PREFIX:=$prefix}" 62c5a1e08bSBaptiste Daroussin: "${BINDIR:=@bindir@}" 63c5a1e08bSBaptiste Daroussin: "${TICDIR:=$ticdir}" 64c5a1e08bSBaptiste Daroussin 65c5a1e08bSBaptiste Daroussinfailed() { 66c5a1e08bSBaptiste Daroussin echo "? $*" >&2 67c5a1e08bSBaptiste Daroussin exit 1 68c5a1e08bSBaptiste Daroussin} 69c5a1e08bSBaptiste Daroussin 70c5a1e08bSBaptiste Daroussinunset CDPATH 7118259542SPeter Wemm 7239f2269fSPeter Wemm# Allow tic to run either from the install-path, or from the build-directory. 7339f2269fSPeter Wemm# Do not do this if we appear to be cross-compiling. In that case, we rely 7439f2269fSPeter Wemm# on the host's copy of tic to compile the terminfo database. 75c5a1e08bSBaptiste Daroussinif test "$cross_compiling" = "no" 76a0044ffcSXin LIthen 77c5a1e08bSBaptiste Daroussin if test -f ../progs/tic"$suffix" 78a0044ffcSXin LI then 7918259542SPeter Wemm case "$PATH" in 80a0044ffcSXin LI \@PATH_SEPARATOR@*) 81c5a1e08bSBaptiste Daroussin PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${BINDIR}$PATH" 82a0044ffcSXin LI ;; 83a0044ffcSXin LI *) 84c5a1e08bSBaptiste Daroussin PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${BINDIR}@PATH_SEPARATOR@$PATH" 85a0044ffcSXin LI ;; 8618259542SPeter Wemm esac 8718259542SPeter Wemm export PATH 88a0044ffcSXin LI if test @DFT_LWR_MODEL@ = shared 89a0044ffcSXin LI then 904a1a9510SRong-En Fan SHLIB="sh $srcdir/shlib" 91c5a1e08bSBaptiste Daroussin tic_path="$SHLIB tic" 92a0044ffcSXin LI else 93c5a1e08bSBaptiste Daroussin tic_path="tic" 94a0044ffcSXin LI fi 95c5a1e08bSBaptiste Daroussin elif test "$tic_path" = unknown 96a0044ffcSXin LI then 97c5a1e08bSBaptiste Daroussin failed "no tic program found" 98a0044ffcSXin LI fi 994a1a9510SRong-En Fanelse 1004a1a9510SRong-En Fan # Cross-compiling, so don't set PATH or run shlib. 1014a1a9510SRong-En Fan SHLIB= 1024a1a9510SRong-En Fan # reset $suffix, since it applies to the target, not the build platform. 1034a1a9510SRong-En Fan suffix= 10439f2269fSPeter Wemmfi 10518259542SPeter Wemm 1064a1a9510SRong-En Fan 107c5a1e08bSBaptiste Daroussin# Set another env var that doesn't get reset when `shlib' runs, so `shlib' uses 10818259542SPeter Wemm# the PATH we just set. 1094a1a9510SRong-En FanSHLIB_PATH=$PATH 1104a1a9510SRong-En Fanexport SHLIB_PATH 11118259542SPeter Wemm 112c5a1e08bSBaptiste Daroussin# Set a variable to simplify environment update in the shlib script. 1134a1a9510SRong-En FanSHLIB_HOST=@host_os@ 1144a1a9510SRong-En Fanexport SHLIB_HOST 1154a1a9510SRong-En Fan 116c5a1e08bSBaptiste Daroussin# Don't use user's TERMINFO or TERMINFO_DIRS variables. The explicit "-o" 117c5a1e08bSBaptiste Daroussin# option makes this moot, but this may reduce confusion. 118f0179cb6SBaptiste Daroussinunset TERMINFO_DIRS 119c5a1e08bSBaptiste Daroussinunset TERMINFO 12018259542SPeter Wemmumask 022 12118259542SPeter Wemm 12218259542SPeter Wemm# Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo. 123c5a1e08bSBaptiste DaroussinOLD_DIR=`echo "$TICDIR" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'` 12418259542SPeter Wemm 125a0044ffcSXin LI# Parent directory may not exist, which would confuse the install for hashed 126a0044ffcSXin LI# database. Fix. 127c5a1e08bSBaptiste DaroussinPARENT=`echo "$TICDIR" | sed -e 's%/[^/]*$%%'` 128a0044ffcSXin LIif test -n "$PARENT" 129a0044ffcSXin LIthen 13024fa7a51SBaptiste Daroussin mkdir -p "$PARENT" 131a0044ffcSXin LIfi 132a0044ffcSXin LI 13318259542SPeter Wemm# Remove the old terminfo stuff; we don't care if it existed before, and it 13418259542SPeter Wemm# would generate a lot of confusing error messages if we tried to overwrite it. 13518259542SPeter Wemm# We explicitly remove its contents rather than the directory itself, in case 13618259542SPeter Wemm# the directory is actually a symbolic link. 137c5a1e08bSBaptiste Daroussinif test -d "$TICDIR" 138f0179cb6SBaptiste Daroussinthen 139c5a1e08bSBaptiste Daroussin test -w "$TICDIR" || failed "existing $TICDIR is not writable" 140c5a1e08bSBaptiste Daroussin ( cd "$TICDIR" && rm -fr ./? 2>/dev/null ) 141c5a1e08bSBaptiste Daroussinelif test -f "$TICDIR.db" 142f0179cb6SBaptiste Daroussinthen 143c5a1e08bSBaptiste Daroussin ( rm -f "$TICDIR.db" 2>/dev/null ) 144c5a1e08bSBaptiste Daroussin test -f "$TICDIR.db" && failed "cannot remove $TICDIR.db" 145f0179cb6SBaptiste Daroussinfi 14618259542SPeter Wemm 1474a1a9510SRong-En Fanif test "$ext_funcs" = 1 ; then 14818259542SPeter Wemmcat <<EOF 149c5a1e08bSBaptiste DaroussinRunning $tic_path to install $TICDIR ... 15018259542SPeter Wemm 1514a1a9510SRong-En Fan You may see messages regarding extended capabilities, e.g., AX. 1524a1a9510SRong-En Fan These are extended terminal capabilities which are compiled 15318259542SPeter Wemm using 154c5a1e08bSBaptiste Daroussin $tic_path -x 1554a1a9510SRong-En Fan If you have ncurses 4.2 applications, you should read the INSTALL 1564a1a9510SRong-En Fan document, and install the terminfo without the -x option. 15718259542SPeter Wemm 15818259542SPeter WemmEOF 159c5a1e08bSBaptiste Daroussin$tic_path -V 160c5a1e08bSBaptiste Daroussinif ( $tic_path -x -s -o "$TICDIR" "$tic_source" ) 16118259542SPeter Wemmthen 162c5a1e08bSBaptiste Daroussin echo "** built new $TICDIR" 16318259542SPeter Wemmelse 164c5a1e08bSBaptiste Daroussin failed "$tic_path could not build $TICDIR" 16518259542SPeter Wemmfi 1664a1a9510SRong-En Fanelse 1674a1a9510SRong-En Fancat <<EOF 168c5a1e08bSBaptiste DaroussinRunning $tic_path to install $TICDIR ... 1694a1a9510SRong-En Fan 1704a1a9510SRong-En Fan You may see messages regarding unknown capabilities, e.g., AX. 1714a1a9510SRong-En Fan These are extended terminal capabilities which may be compiled 1724a1a9510SRong-En Fan using 173c5a1e08bSBaptiste Daroussin $tic_path -x 1744a1a9510SRong-En Fan If you have ncurses 4.2 applications, you should read the INSTALL 1754a1a9510SRong-En Fan document, and install the terminfo without the -x option. 1764a1a9510SRong-En Fan 1774a1a9510SRong-En FanEOF 178c5a1e08bSBaptiste Daroussin$tic_path -V 179c5a1e08bSBaptiste Daroussinif ( $tic_path -s -o "$TICDIR" "$tic_source" ) 1804a1a9510SRong-En Fanthen 181c5a1e08bSBaptiste Daroussin echo "** built new $TICDIR" 1824a1a9510SRong-En Fanelse 183c5a1e08bSBaptiste Daroussin failed "$tic_path could not build $TICDIR" 1844a1a9510SRong-En Fanfi 1854a1a9510SRong-En Fanfi 18618259542SPeter Wemm 187c5a1e08bSBaptiste Daroussin# Check if we are using symbolic links, or just pretending. 188c5a1e08bSBaptiste Daroussincase "@LN_S@" in 189c5a1e08bSBaptiste Daroussincp\ *) 190c5a1e08bSBaptiste Daroussin OLD_DIR="$TICDIR" 191c5a1e08bSBaptiste Daroussin echo "** assuming we cannot make symbolic links to a directory" 192c5a1e08bSBaptiste Daroussin ;; 193c5a1e08bSBaptiste Daroussin*) 194c5a1e08bSBaptiste Daroussin echo "** assuming we can make symbolic links to a directory" 195c5a1e08bSBaptiste Daroussin ;; 196c5a1e08bSBaptiste Daroussinesac 197c5a1e08bSBaptiste Daroussin 198c5a1e08bSBaptiste Daroussin 19918259542SPeter Wemm# Make a symbolic link to provide compatibility with applications that expect 20018259542SPeter Wemm# to find terminfo under /usr/lib. That is, we'll _try_ to do that. Not 20118259542SPeter Wemm# all systems support symbolic links, and those that do provide a variety 20218259542SPeter Wemm# of options for 'test'. 203c5a1e08bSBaptiste Daroussinif test "$OLD_DIR" != "$TICDIR" ; then 204c5a1e08bSBaptiste Daroussin ( rm -f "$OLD_DIR" 2>/dev/null ) 205c5a1e08bSBaptiste Daroussin if ( cd "$OLD_DIR" 2>/dev/null ) 20618259542SPeter Wemm then 207c5a1e08bSBaptiste Daroussin cd "$OLD_DIR" || exit 208c5a1e08bSBaptiste Daroussin OLD_DIR=`pwd` 209c5a1e08bSBaptiste Daroussin if test "$OLD_DIR " != "$TICDIR "; then 21018259542SPeter Wemm # Well, we tried. Some systems lie to us, so the 21118259542SPeter Wemm # installer will have to double-check. 212c5a1e08bSBaptiste Daroussin echo "Verify if $OLD_DIR and $TICDIR are the same." 213c5a1e08bSBaptiste Daroussin echo "The new terminfo is in $TICDIR; the other should be a link to it." 214c5a1e08bSBaptiste Daroussin echo "Otherwise, remove $OLD_DIR and link it to $TICDIR." 21518259542SPeter Wemm fi 21618259542SPeter Wemm else 217c5a1e08bSBaptiste Daroussin cd "${INSTALL_PREFIX}" || exit 21818259542SPeter Wemm # Construct a symbolic link that only assumes $ticdir has the 21918259542SPeter Wemm # same $prefix as the other installed directories. 220c5a1e08bSBaptiste Daroussin SOURCE=`echo "$ticdir"|sed -e 's%^'"$prefix"'/%%'` 221c5a1e08bSBaptiste Daroussin if test "$SOURCE" != "$ticdir" ; then 222c5a1e08bSBaptiste Daroussin SOURCE=../`echo "$ticdir"|sed -e 's%^'"$prefix"'/%%' -e 's%^/%%'` 22318259542SPeter Wemm fi 224c5a1e08bSBaptiste Daroussin test -d lib || mkdir lib 225c5a1e08bSBaptiste Daroussin cd lib || exit 226c5a1e08bSBaptiste Daroussin TARGET=`pwd`/terminfo 227c5a1e08bSBaptiste Daroussin if ( @LN_S@ "$SOURCE" terminfo ) 22818259542SPeter Wemm then 229c5a1e08bSBaptiste Daroussin echo "** sym-linked $TARGET for compatibility" 2304a1a9510SRong-En Fan else 231c5a1e08bSBaptiste Daroussin echo "** could not sym-link $TARGET for compatibility" 23218259542SPeter Wemm fi 23318259542SPeter Wemm fi 23418259542SPeter Wemmfi 235c5a1e08bSBaptiste Daroussin# vile:shmode ts=4 sw=4 236