]> ncurses.scripts.mit.edu Git - ncurses.git/blob - sysdeps/unix/sysv/linux/run_tic.sh
ncurses 4.1
[ncurses.git] / sysdeps / unix / sysv / linux / 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 1997/05/09 10:43:29 hjl 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 = the common object directory.
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
40 prefix=/usr
41 if test $# != 0 ; then
42         common_objpfx=$1
43         shift
44 fi
45
46 if test $# != 0 ; then
47         srcdir=$1
48         shift
49 else
50         srcdir=.
51 fi
52
53 if test $# != 0 ; then
54         ticdir=$1
55         shift
56 else
57         ticdir=$prefix/share/terminfo
58 fi
59
60 if test $# != 0 ; then
61         IP=$1
62         shift
63 else
64         IP=""
65 fi
66
67 TERMINFO=$IP$ticdir ; export TERMINFO
68 umask 022
69
70 # Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
71 TICDIR=`echo $TERMINFO | sed -e 's/\/share\//\/lib\//'`
72
73 # Remove the old terminfo stuff; we don't care if it existed before, and it
74 # would generate a lot of confusing error messages if we tried to overwrite it.
75 # We explicitly remove its contents rather than the directory itself, in case
76 # the directory is actually a symbolic link.
77 ( rm -fr $TERMINFO/[0-9A-Za-z] 2>/dev/null )
78
79 # If we're not installing into /usr/share/, we'll have to adjust the location
80 # of the tabset files in terminfo.src (which are in a parallel directory).
81 TABSET=`echo $ticdir | sed -e 's/\/terminfo$/\/tabset/'`
82 SRC=$srcdir/terminfo.src
83 if test "x$TABSET" != "x/usr/share/tabset" ; then
84         echo '** adjusting tabset paths'
85         TMP=${TMPDIR-/tmp}/$$
86         sed -e s:/usr/share/tabset:$TABSET:g $SRC >$TMP
87         trap "rm -f $TMP" 0 1 2 5 15
88         SRC=$TMP
89 fi
90
91 LD_LIBRARY_PATH=$common_objpfx:$common_objpfx/nss:$common_objpfx/ncurses \
92         $common_objpfx/elf/ld.so \
93         $common_objpfx/ncurses/tic -s $SRC
94 if [ $? = 0 ]
95 then
96         echo '** built new '$TERMINFO
97 else
98         echo '? tic could not build '$TERMINFO
99         exit 1
100 fi
101
102 # Make a symbolic link to provide compatibility with applications that expect
103 # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
104 # all systems support symbolic links, and those that do provide a variety
105 # of options for 'test'.
106 if test "$TICDIR" != "$TERMINFO" ; then
107         ( rm -f $TICDIR 2>/dev/null )
108         if ( cd $TICDIR 2>/dev/null )
109         then
110                 cd $TICDIR
111                 TICDIR=`pwd`
112                 if test $TICDIR != $TERMINFO ; then
113                         # Well, we tried.  Some systems lie to us, so the
114                         # installer will have to double-check.
115                         echo "Verify if $TICDIR and $TERMINFO are the same."
116                         echo "The new terminfo is in $TERMINFO; the other should be a link to it."
117                         echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
118                 fi
119         else
120                 cd $IP$prefix
121                 # Construct a symbolic link that only assumes $ticdir has the
122                 # same $prefix as the other installed directories.
123                 RELATIVE=`echo $ticdir|sed -e 's:^'$prefix'/::'`
124                 if test "$RELATIVE" != "$ticdir" ; then
125                         RELATIVE=../`echo $ticdir|sed -e 's:^'$prefix'/::' -e 's:^/::'`
126                 fi
127                 if ( ln -s $RELATIVE $TICDIR )
128                 then
129                         echo '** linked '$TICDIR' for compatibility'
130                 fi
131         fi
132 fi