Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | #!@SHELL@ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | # $Id: run_tic.in,v 1.40 2022/07/16 19:37:03 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 3 | ############################################################################## |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 4 | # Copyright 2019-2020,2022 Thomas E. Dickey # |
| 5 | # Copyright 2000-2012,2017 Free Software Foundation, Inc. # |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | # |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 32 | # Author: Thomas E. Dickey 1996-on |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | # |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 40 | echo "** Building terminfo database, please wait..." |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 41 | # |
| 42 | # The script is designed to be run from the misc/Makefile as |
| 43 | # make install.data |
| 44 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 | : "${cross_compiling:=no}" |
| 58 | : "${ext_funcs:=@NCURSES_EXT_FUNCS@}" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 59 | |
| 60 | test -z "${DESTDIR}" && DESTDIR= |
| 61 | |
| 62 | # Allow tic to run either from the install-path, or from the build-directory. |
| 63 | # Do not do this if we appear to be cross-compiling. In that case, we rely |
| 64 | # on the host's copy of tic to compile the terminfo database. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 65 | if test "x$cross_compiling" = "xno" |
| 66 | then |
| 67 | if test -f ../progs/tic$suffix |
| 68 | then |
| 69 | case "$PATH" in |
| 70 | \@PATH_SEPARATOR@*) |
| 71 | PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir$PATH" |
| 72 | ;; |
| 73 | *) |
| 74 | PATH="../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir@PATH_SEPARATOR@$PATH" |
| 75 | ;; |
| 76 | esac |
| 77 | export PATH |
| 78 | if test @DFT_LWR_MODEL@ = shared |
| 79 | then |
| 80 | SHLIB="sh $srcdir/shlib" |
| 81 | TIC_PATH="$SHLIB tic" |
| 82 | else |
| 83 | TIC_PATH="tic" |
| 84 | fi |
| 85 | elif test "$TIC_PATH" = unknown |
| 86 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 87 | echo "? no tic program found" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 88 | exit 1 |
| 89 | fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 90 | else |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 91 | # Cross-compiling, so don't set PATH or run shlib. |
| 92 | SHLIB= |
| 93 | # reset $suffix, since it applies to the target, not the build platform. |
| 94 | suffix= |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 95 | fi |
| 96 | |
| 97 | |
| 98 | # set another env var that doesn't get reset when `shlib' runs, so `shlib' uses |
| 99 | # the PATH we just set. |
| 100 | SHLIB_PATH=$PATH |
| 101 | export SHLIB_PATH |
| 102 | |
| 103 | # set a variable to simplify environment update in shlib |
| 104 | SHLIB_HOST=@host_os@ |
| 105 | export SHLIB_HOST |
| 106 | |
| 107 | # don't use user's TERMINFO variable |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 108 | unset TERMINFO_DIRS |
| 109 | TERMINFO="${DESTDIR}$ticdir" ; export TERMINFO |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 110 | umask 022 |
| 111 | |
| 112 | # Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 113 | TICDIR=`echo "$TERMINFO" | sed -e 's%/share/\([^/]*\)$%/lib/\1%'` |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 115 | # Parent directory may not exist, which would confuse the install for hashed |
| 116 | # database. Fix. |
| 117 | PARENT=`echo "$TERMINFO" | sed -e 's%/[^/]*$%%'` |
| 118 | if test -n "$PARENT" |
| 119 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 120 | mkdir -p "$PARENT" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 121 | fi |
| 122 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 123 | # Remove the old terminfo stuff; we don't care if it existed before, and it |
| 124 | # would generate a lot of confusing error messages if we tried to overwrite it. |
| 125 | # We explicitly remove its contents rather than the directory itself, in case |
| 126 | # the directory is actually a symbolic link. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 127 | if test -d "$TERMINFO" |
| 128 | then |
| 129 | ( cd "$TERMINFO" && rm -fr ./? 2>/dev/null ) |
| 130 | elif test -f "$TERMINFO.db" |
| 131 | then |
| 132 | ( rm -f "$TERMINFO.db" 2>/dev/null ) |
| 133 | fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 134 | |
| 135 | if test "$ext_funcs" = 1 ; then |
| 136 | cat <<EOF |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 137 | Running $TIC_PATH to install $TERMINFO ... |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 138 | |
| 139 | You may see messages regarding extended capabilities, e.g., AX. |
| 140 | These are extended terminal capabilities which are compiled |
| 141 | using |
| 142 | tic -x |
| 143 | If you have ncurses 4.2 applications, you should read the INSTALL |
| 144 | document, and install the terminfo without the -x option. |
| 145 | |
| 146 | EOF |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 147 | $TIC_PATH -V |
| 148 | if ( $TIC_PATH -x -s -o "$TERMINFO" $source ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 149 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 150 | echo "** built new $TERMINFO" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 151 | else |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 152 | echo "? tic could not build $TERMINFO" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 153 | exit 1 |
| 154 | fi |
| 155 | else |
| 156 | cat <<EOF |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 157 | Running $TIC_PATH to install $TERMINFO ... |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 158 | |
| 159 | You may see messages regarding unknown capabilities, e.g., AX. |
| 160 | These are extended terminal capabilities which may be compiled |
| 161 | using |
| 162 | tic -x |
| 163 | If you have ncurses 4.2 applications, you should read the INSTALL |
| 164 | document, and install the terminfo without the -x option. |
| 165 | |
| 166 | EOF |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 167 | $TIC_PATH -V |
| 168 | if ( $TIC_PATH -s -o "$TERMINFO" $source ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 169 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 170 | echo "** built new $TERMINFO" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 171 | else |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 172 | echo "? tic could not build $TERMINFO" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 173 | exit 1 |
| 174 | fi |
| 175 | fi |
| 176 | |
| 177 | # Make a symbolic link to provide compatibility with applications that expect |
| 178 | # to find terminfo under /usr/lib. That is, we'll _try_ to do that. Not |
| 179 | # all systems support symbolic links, and those that do provide a variety |
| 180 | # of options for 'test'. |
| 181 | if test "$TICDIR" != "$TERMINFO" ; then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 182 | ( rm -f "$TICDIR" 2>/dev/null ) |
| 183 | if ( cd "$TICDIR" 2>/dev/null ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 184 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 185 | cd "$TICDIR" || exit |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 186 | TICDIR=`pwd` |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 187 | if test "$TICDIR " != "$TERMINFO "; then |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 188 | # Well, we tried. Some systems lie to us, so the |
| 189 | # installer will have to double-check. |
| 190 | echo "Verify if $TICDIR and $TERMINFO are the same." |
| 191 | echo "The new terminfo is in $TERMINFO; the other should be a link to it." |
| 192 | echo "Otherwise, remove $TICDIR and link it to $TERMINFO." |
| 193 | fi |
| 194 | else |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 195 | cd ${DESTDIR}$prefix || exit |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 196 | # Construct a symbolic link that only assumes $ticdir has the |
| 197 | # same $prefix as the other installed directories. |
| 198 | RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'` |
| 199 | if test "$RELATIVE" != "$ticdir" ; then |
| 200 | RELATIVE=../`echo $ticdir|sed -e 's%^'$prefix'/%%' -e 's%^/%%'` |
| 201 | fi |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 202 | if ( @LN_S@ "$RELATIVE" "$TICDIR" ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 203 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 204 | echo "** sym-linked $TICDIR for compatibility" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 205 | else |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 206 | echo "** could not sym-link $TICDIR for compatibility" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 207 | fi |
| 208 | fi |
| 209 | fi |
| 210 | # vile:shmode |