]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/run_tic.sh
ncurses 4.1
[ncurses.git] / misc / run_tic.sh
1 #!/bin/sh
2 ################################################################################
3 # Copyright 1996 by Thomas E. Dickey <dickey@clark.net>                        #
4 # All Rights Reserved.                                                         #
5 #                                                                              #
6 # Permission to use, copy, modify, and distribute this software and its        #
7 # documentation for any purpose and without fee is hereby granted, provided    #
8 # that the above copyright notice appear in all copies and that both that      #
9 # copyright notice and this permission notice appear in supporting             #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the        #
12 # software without specific, written prior permission. THE ABOVE LISTED        #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
19 # PERFORMANCE OF THIS SOFTWARE.                                                #
20 ################################################################################
21 # $Id: run_tic.sh,v 1.8 1996/12/01 05:10:08 tom Exp $
22 # This script is used to install terminfo.src using tic.  We use a script
23 # because the path checking is too awkward to do in a makefile.
24 #
25 # Parameters:
26 #       $1 = nominal directory in which to find 'tic', i.e., $(bindir).
27 #       $2 = source-directory, i.e., $(srcdir)
28 #       $3 = destination-directory path, i.e., $(ticdir)
29 #       $4 = install-prefix, if any
30 #
31 # Assumes:
32 #       The leaf directory names (bin, lib, shared, tabset, terminfo)
33 #
34 echo '** Building terminfo database, please wait...'
35 #
36 # Parameter parsing is primarily for debugging.  The script is designed to
37 # be run from the misc/Makefile as
38 #       make install.data
39 prefix=/usr/local
40 if test $# != 0 ; then
41         bindir=$1
42         shift
43         PREFIX=`echo $bindir | sed -e 's/\/bin$//'`
44         test -n "$PREFIX" && test "x$PREFIX" != "x$bindir" && prefix=$PREFIX
45 else
46         bindir=$prefix/bin
47 fi
48
49 if test $# != 0 ; then
50         srcdir=$1
51         shift
52 else
53         srcdir=.
54 fi
55
56 if test $# != 0 ; then
57         ticdir=$1
58         shift
59 else
60         ticdir=$prefix/share/terminfo
61 fi
62
63 if test $# != 0 ; then
64         IP=$1
65         shift
66 else
67         IP=""
68 fi
69
70 # Allow tic to run either from the install-path, or from the build-directory
71 case "$PATH" in
72 :*) PATH=../progs:$IP$bindir$PATH ;;
73 *) PATH=../progs:$IP$bindir:$PATH ;;
74 esac
75 export PATH
76 TERMINFO=$IP$ticdir ; export TERMINFO
77 umask 022
78
79 # Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
80 TICDIR=`echo $TERMINFO | sed -e 's/\/share\//\/lib\//'`
81
82 # Remove the old terminfo stuff; we don't care if it existed before, and it
83 # would generate a lot of confusing error messages if we tried to overwrite it.
84 # We explicitly remove its contents rather than the directory itself, in case
85 # the directory is actually a symbolic link.
86 ( rm -fr $TERMINFO/[0-9A-Za-z] 2>/dev/null )
87
88 # If we're not installing into /usr/share/, we'll have to adjust the location
89 # of the tabset files in terminfo.src (which are in a parallel directory).
90 TABSET=`echo $ticdir | sed -e 's/\/terminfo$/\/tabset/'`
91 SRC=$srcdir/terminfo.src
92 if test "x$TABSET" != "x/usr/share/tabset" ; then
93         echo '** adjusting tabset paths'
94         TMP=${TMPDIR-/tmp}/$$
95         sed -e s:/usr/share/tabset:$TABSET:g $SRC >$TMP
96         trap "rm -f $TMP" 0 1 2 5 15
97         SRC=$TMP
98 fi
99
100 if ( $srcdir/shlib tic -s $SRC )
101 then
102         echo '** built new '$TERMINFO
103 else
104         echo '? tic could not build '$TERMINFO
105         exit 1
106 fi
107
108 # Make a symbolic link to provide compatibility with applications that expect
109 # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
110 # all systems support symbolic links, and those that do provide a variety
111 # of options for 'test'.
112 if test "$TICDIR" != "$TERMINFO" ; then
113         ( rm -f $TICDIR 2>/dev/null )
114         if ( cd $TICDIR 2>/dev/null )
115         then
116                 cd $TICDIR
117                 TICDIR=`pwd`
118                 if test $TICDIR != $TERMINFO ; then
119                         # Well, we tried.  Some systems lie to us, so the
120                         # installer will have to double-check.
121                         echo "Verify if $TICDIR and $TERMINFO are the same."
122                         echo "The new terminfo is in $TERMINFO; the other should be a link to it."
123                         echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
124                 fi
125         else
126                 cd $IP$prefix
127                 # Construct a symbolic link that only assumes $ticdir has the
128                 # same $prefix as the other installed directories.
129                 RELATIVE=`echo $ticdir|sed -e 's:^'$prefix'/::'`
130                 if test "$RELATIVE" != "$ticdir" ; then
131                         RELATIVE=../`echo $ticdir|sed -e 's:^'$prefix'/::' -e 's:^/::'`
132                 fi
133                 if ( ln -s $RELATIVE $TICDIR )
134                 then
135                         echo '** linked '$TICDIR' for compatibility'
136                 fi
137         fi
138 fi