aboutsummaryrefslogtreecommitdiff
path: root/misc/run_tic.in
diff options
context:
space:
mode:
Diffstat (limited to 'misc/run_tic.in')
-rw-r--r--misc/run_tic.in145
1 files changed, 85 insertions, 60 deletions
diff --git a/misc/run_tic.in b/misc/run_tic.in
index bd11c4c80d4c..60fbdcc7fa52 100644
--- a/misc/run_tic.in
+++ b/misc/run_tic.in
@@ -1,7 +1,7 @@
#!@SHELL@
-# $Id: run_tic.in,v 1.40 2022/07/16 19:37:03 tom Exp $
+# $Id: run_tic.in,v 1.44 2025/09/13 16:52:46 tom Exp $
##############################################################################
-# Copyright 2019-2020,2022 Thomas E. Dickey #
+# Copyright 2019-2024,2025 Thomas E. Dickey #
# Copyright 2000-2012,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -42,50 +42,59 @@ echo "** Building terminfo database, please wait..."
# The script is designed to be run from the misc/Makefile as
# make install.data
-: "${suffix:=@EXEEXT@}"
-: "${DESTDIR:=@DESTDIR@}"
+# Symbols which are not overridden by misc/Makefile:
: "${prefix:=@prefix@}"
: "${exec_prefix:=@exec_prefix@}"
-: "${bindir:=@bindir@}"
: "${top_srcdir:=@top_srcdir@}"
: "${srcdir:=@srcdir@}"
: "${datarootdir:=@datarootdir@}"
: "${datadir:=@datadir@}"
-: "${TIC_PATH:=@TIC@}"
-: "${ticdir:=@TERMINFO@}"
-: "${source:=@TERMINFO_SRC@}"
-: "${cross_compiling:=no}"
+: "${cross_compiling:=@cross_compiling@}"
+: "${suffix:=@EXEEXT@}"
+
: "${ext_funcs:=@NCURSES_EXT_FUNCS@}"
+: "${tic_path:=@TIC@}"
+: "${ticdir:=@TERMINFO@}"
+: "${tic_source:=@TERMINFO_SRC@}"
+
+# Symbols which $DESTDIR and/or install-prefix may affect:
+: "${INSTALL_PREFIX:=$prefix}"
+: "${BINDIR:=@bindir@}"
+: "${TICDIR:=$ticdir}"
-test -z "${DESTDIR}" && DESTDIR=
+failed() {
+ echo "? $*" >&2
+ exit 1
+}
+
+unset CDPATH
# Allow tic to run either from the install-path, or from the build-directory.
# Do not do this if we appear to be cross-compiling. In that case, we rely
# on the host's copy of tic to compile the terminfo database.
-if test "x$cross_compiling" = "xno"
+if test "$cross_compiling" = "no"
then
- if test -f ../progs/tic$suffix
+ if test -f ../progs/tic"$suffix"
then
case "$PATH" in
\@PATH_SEPARATOR@*)
- PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir$PATH"
+ PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${BINDIR}$PATH"
;;
*)
- PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir@PATH_SEPARATOR@$PATH"
+ PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${BINDIR}@PATH_SEPARATOR@$PATH"
;;
esac
export PATH
if test @DFT_LWR_MODEL@ = shared
then
SHLIB="sh $srcdir/shlib"
- TIC_PATH="$SHLIB tic"
+ tic_path="$SHLIB tic"
else
- TIC_PATH="tic"
+ tic_path="tic"
fi
- elif test "$TIC_PATH" = unknown
+ elif test "$tic_path" = unknown
then
- echo "? no tic program found"
- exit 1
+ failed "no tic program found"
fi
else
# Cross-compiling, so don't set PATH or run shlib.
@@ -95,26 +104,27 @@ else
fi
-# set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
+# Set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
# the PATH we just set.
SHLIB_PATH=$PATH
export SHLIB_PATH
-# set a variable to simplify environment update in shlib
+# Set a variable to simplify environment update in the shlib script.
SHLIB_HOST=@host_os@
export SHLIB_HOST
-# don't use user's TERMINFO variable
+# Don't use user's TERMINFO or TERMINFO_DIRS variables. The explicit "-o"
+# option makes this moot, but this may reduce confusion.
unset TERMINFO_DIRS
-TERMINFO="${DESTDIR}$ticdir" ; export TERMINFO
+unset TERMINFO
umask 022
# Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
-TICDIR=`echo "$TERMINFO" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
+OLD_DIR=`echo "$TICDIR" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
# Parent directory may not exist, which would confuse the install for hashed
# database. Fix.
-PARENT=`echo "$TERMINFO" | sed -e 's%/[^/]*$%%'`
+PARENT=`echo "$TICDIR" | sed -e 's%/[^/]*$%%'`
if test -n "$PARENT"
then
mkdir -p "$PARENT"
@@ -124,87 +134,102 @@ fi
# would generate a lot of confusing error messages if we tried to overwrite it.
# We explicitly remove its contents rather than the directory itself, in case
# the directory is actually a symbolic link.
-if test -d "$TERMINFO"
+if test -d "$TICDIR"
then
- ( cd "$TERMINFO" && rm -fr ./? 2>/dev/null )
-elif test -f "$TERMINFO.db"
+ test -w "$TICDIR" || failed "existing $TICDIR is not writable"
+ ( cd "$TICDIR" && rm -fr ./? 2>/dev/null )
+elif test -f "$TICDIR.db"
then
- ( rm -f "$TERMINFO.db" 2>/dev/null )
+ ( rm -f "$TICDIR.db" 2>/dev/null )
+ test -f "$TICDIR.db" && failed "cannot remove $TICDIR.db"
fi
if test "$ext_funcs" = 1 ; then
cat <<EOF
-Running $TIC_PATH to install $TERMINFO ...
+Running $tic_path to install $TICDIR ...
You may see messages regarding extended capabilities, e.g., AX.
These are extended terminal capabilities which are compiled
using
- tic -x
+ $tic_path -x
If you have ncurses 4.2 applications, you should read the INSTALL
document, and install the terminfo without the -x option.
EOF
-$TIC_PATH -V
-if ( $TIC_PATH -x -s -o "$TERMINFO" $source )
+$tic_path -V
+if ( $tic_path -x -s -o "$TICDIR" "$tic_source" )
then
- echo "** built new $TERMINFO"
+ echo "** built new $TICDIR"
else
- echo "? tic could not build $TERMINFO"
- exit 1
+ failed "$tic_path could not build $TICDIR"
fi
else
cat <<EOF
-Running $TIC_PATH to install $TERMINFO ...
+Running $tic_path to install $TICDIR ...
You may see messages regarding unknown capabilities, e.g., AX.
These are extended terminal capabilities which may be compiled
using
- tic -x
+ $tic_path -x
If you have ncurses 4.2 applications, you should read the INSTALL
document, and install the terminfo without the -x option.
EOF
-$TIC_PATH -V
-if ( $TIC_PATH -s -o "$TERMINFO" $source )
+$tic_path -V
+if ( $tic_path -s -o "$TICDIR" "$tic_source" )
then
- echo "** built new $TERMINFO"
+ echo "** built new $TICDIR"
else
- echo "? tic could not build $TERMINFO"
- exit 1
+ failed "$tic_path could not build $TICDIR"
fi
fi
+# Check if we are using symbolic links, or just pretending.
+case "@LN_S@" in
+cp\ *)
+ OLD_DIR="$TICDIR"
+ echo "** assuming we cannot make symbolic links to a directory"
+ ;;
+*)
+ echo "** assuming we can make symbolic links to a directory"
+ ;;
+esac
+
+
# Make a symbolic link to provide compatibility with applications that expect
# to find terminfo under /usr/lib. That is, we'll _try_ to do that. Not
# all systems support symbolic links, and those that do provide a variety
# of options for 'test'.
-if test "$TICDIR" != "$TERMINFO" ; then
- ( rm -f "$TICDIR" 2>/dev/null )
- if ( cd "$TICDIR" 2>/dev/null )
+if test "$OLD_DIR" != "$TICDIR" ; then
+ ( rm -f "$OLD_DIR" 2>/dev/null )
+ if ( cd "$OLD_DIR" 2>/dev/null )
then
- cd "$TICDIR" || exit
- TICDIR=`pwd`
- if test "$TICDIR " != "$TERMINFO "; then
+ cd "$OLD_DIR" || exit
+ OLD_DIR=`pwd`
+ if test "$OLD_DIR " != "$TICDIR "; then
# Well, we tried. Some systems lie to us, so the
# installer will have to double-check.
- echo "Verify if $TICDIR and $TERMINFO are the same."
- echo "The new terminfo is in $TERMINFO; the other should be a link to it."
- echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
+ echo "Verify if $OLD_DIR and $TICDIR are the same."
+ echo "The new terminfo is in $TICDIR; the other should be a link to it."
+ echo "Otherwise, remove $OLD_DIR and link it to $TICDIR."
fi
else
- cd ${DESTDIR}$prefix || exit
+ cd "${INSTALL_PREFIX}" || exit
# Construct a symbolic link that only assumes $ticdir has the
# same $prefix as the other installed directories.
- RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'`
- if test "$RELATIVE" != "$ticdir" ; then
- RELATIVE=../`echo $ticdir|sed -e 's%^'$prefix'/%%' -e 's%^/%%'`
+ SOURCE=`echo "$ticdir"|sed -e 's%^'"$prefix"'/%%'`
+ if test "$SOURCE" != "$ticdir" ; then
+ SOURCE=../`echo "$ticdir"|sed -e 's%^'"$prefix"'/%%' -e 's%^/%%'`
fi
- if ( @LN_S@ "$RELATIVE" "$TICDIR" )
+ test -d lib || mkdir lib
+ cd lib || exit
+ TARGET=`pwd`/terminfo
+ if ( @LN_S@ "$SOURCE" terminfo )
then
- echo "** sym-linked $TICDIR for compatibility"
+ echo "** sym-linked $TARGET for compatibility"
else
- echo "** could not sym-link $TICDIR for compatibility"
+ echo "** could not sym-link $TARGET for compatibility"
fi
fi
fi
-# vile:shmode
+# vile:shmode ts=4 sw=4