]> ncurses.scripts.mit.edu Git - ncurses.git/blob - sysdeps/unix/sysv/linux/run_tic.sh
ncurses 4.2
[ncurses.git] / sysdeps / unix / sysv / linux / run_tic.sh
1 #!/bin/sh
2 ##############################################################################
3 # Copyright (c) 1998 Free Software Foundation, Inc.                          #
4 #                                                                            #
5 # Permission is hereby granted, free of charge, to any person obtaining a    #
6 # copy of this software and associated documentation files (the "Software"), #
7 # to deal in the Software without restriction, including without limitation  #
8 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
9 # with modifications, sublicense, and/or sell copies of the Software, and to #
10 # permit persons to whom the Software is furnished to do so, subject to the  #
11 # following conditions:                                                      #
12 #                                                                            #
13 # The above copyright notice and this permission notice shall be included in #
14 # all copies or substantial portions of the Software.                        #
15 #                                                                            #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
19 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
22 # DEALINGS IN THE SOFTWARE.                                                  #
23 #                                                                            #
24 # Except as contained in this notice, the name(s) of the above copyright     #
25 # holders shall not be used in advertising or otherwise to promote the sale, #
26 # use or other dealings in this Software without prior written               #
27 # authorization.                                                             #
28 ##############################################################################
29 #
30 # Author: Thomas E. Dickey <dickey@clark.net> 1996
31 #
32 # $Id: run_tic.sh,v 1.9 1998/02/11 12:14:03 tom Exp $
33 # This script is used to install terminfo.src using tic.  We use a script
34 # because the path checking is too awkward to do in a makefile.
35 #
36 # Parameters:
37 #       $1 = the common object directory.
38 #       $2 = source-directory, i.e., $(srcdir)
39 #       $3 = destination-directory path, i.e., $(ticdir)
40 #       $4 = install-prefix, if any
41 #
42 # Assumes:
43 #       The leaf directory names (bin, lib, shared, tabset, terminfo)
44 #
45 echo '** Building terminfo database, please wait...'
46 #
47 # Parameter parsing is primarily for debugging.  The script is designed to
48 # be run from the misc/Makefile as
49 #       make install.data
50
51 prefix=/usr
52 if test $# != 0 ; then
53         common_objpfx=$1
54         shift
55 fi
56
57 if test $# != 0 ; then
58         srcdir=$1
59         shift
60 else
61         srcdir=.
62 fi
63
64 if test $# != 0 ; then
65         ticdir=$1
66         shift
67 else
68         ticdir=$prefix/share/terminfo
69 fi
70
71 if test $# != 0 ; then
72         IP=$1
73         shift
74 else
75         IP=""
76 fi
77
78 TERMINFO=$IP$ticdir ; export TERMINFO
79 umask 022
80
81 # Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
82 TICDIR=`echo $TERMINFO | sed -e 's/\/share\//\/lib\//'`
83
84 # Remove the old terminfo stuff; we don't care if it existed before, and it
85 # would generate a lot of confusing error messages if we tried to overwrite it.
86 # We explicitly remove its contents rather than the directory itself, in case
87 # the directory is actually a symbolic link.
88 ( rm -fr $TERMINFO/[0-9A-Za-z] 2>/dev/null )
89
90 # If we're not installing into /usr/share/, we'll have to adjust the location
91 # of the tabset files in terminfo.src (which are in a parallel directory).
92 TABSET=`echo $ticdir | sed -e 's/\/terminfo$/\/tabset/'`
93 SRC=$srcdir/terminfo.src
94 if test "x$TABSET" != "x/usr/share/tabset" ; then
95         echo '** adjusting tabset paths'
96         TMP=${TMPDIR-/tmp}/$$
97         sed -e s:/usr/share/tabset:$TABSET:g $SRC >$TMP
98         trap "rm -f $TMP" 0 1 2 5 15
99         SRC=$TMP
100 fi
101
102 LD_LIBRARY_PATH=$common_objpfx:$common_objpfx/nss:$common_objpfx/ncurses \
103         $common_objpfx/elf/ld.so \
104         $common_objpfx/ncurses/tic -s $SRC
105 if [ $? = 0 ]
106 then
107         echo '** built new '$TERMINFO
108 else
109         echo '? tic could not build '$TERMINFO
110         exit 1
111 fi
112
113 # Make a symbolic link to provide compatibility with applications that expect
114 # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
115 # all systems support symbolic links, and those that do provide a variety
116 # of options for 'test'.
117 if test "$TICDIR" != "$TERMINFO" ; then
118         ( rm -f $TICDIR 2>/dev/null )
119         if ( cd $TICDIR 2>/dev/null )
120         then
121                 cd $TICDIR
122                 TICDIR=`pwd`
123                 if test $TICDIR != $TERMINFO ; then
124                         # Well, we tried.  Some systems lie to us, so the
125                         # installer will have to double-check.
126                         echo "Verify if $TICDIR and $TERMINFO are the same."
127                         echo "The new terminfo is in $TERMINFO; the other should be a link to it."
128                         echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
129                 fi
130         else
131                 cd $IP$prefix
132                 # Construct a symbolic link that only assumes $ticdir has the
133                 # same $prefix as the other installed directories.
134                 RELATIVE=`echo $ticdir|sed -e 's:^'$prefix'/::'`
135                 if test "$RELATIVE" != "$ticdir" ; then
136                         RELATIVE=../`echo $ticdir|sed -e 's:^'$prefix'/::' -e 's:^/::'`
137                 fi
138                 if ( ln -s $RELATIVE $TICDIR )
139                 then
140                         echo '** linked '$TICDIR' for compatibility'
141                 fi
142         fi
143 fi