]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/run_tic.in
ncurses 5.7 - patch 20110212
[ncurses.git] / misc / run_tic.in
1 #!@SHELL@
2 # $Id: run_tic.in,v 1.29 2010/10/23 20:49:04 tom Exp $
3 ##############################################################################
4 # Copyright (c) 1998-2009,2010 Free Software Foundation, Inc.                #
5 #                                                                            #
6 # Permission is hereby granted, free of charge, to any person obtaining a    #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation  #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the  #
12 # following conditions:                                                      #
13 #                                                                            #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software.                        #
16 #                                                                            #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23 # DEALINGS IN THE SOFTWARE.                                                  #
24 #                                                                            #
25 # Except as contained in this notice, the name(s) of the above copyright     #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written               #
28 # authorization.                                                             #
29 ##############################################################################
30 #
31 # Author: Thomas E. Dickey 1996-on
32 #
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 # Assumes:
37 #       The leaf directory names (lib, tabset, terminfo)
38 #
39 echo '** Building terminfo database, please wait...'
40 #
41 # The script is designed to be run from the misc/Makefile as
42 #       make install.data
43
44 : ${suffix:=@PROG_EXT@}
45 : ${DESTDIR:=@DESTDIR@}
46 : ${prefix:=@prefix@}
47 : ${exec_prefix:=@exec_prefix@}
48 : ${bindir:=@bindir@}
49 : ${top_srcdir:=@top_srcdir@}
50 : ${srcdir:=@srcdir@}
51 : ${datadir:=@datadir@}
52 : ${TIC_PATH:=@TIC_PATH@}
53 : ${ticdir:=@TERMINFO@}
54 : ${source:=@TERMINFO_SRC@}
55 : ${LN_S:="@LN_S@"}
56 : ${cross_compiling:=no}
57 : ${ext_funcs:=@NCURSES_EXT_FUNCS@}
58
59 test -z "${DESTDIR}" && DESTDIR=
60
61 # Allow tic to run either from the install-path, or from the build-directory.
62 # Do not do this if we appear to be cross-compiling.  In that case, we rely
63 # on the host's copy of tic to compile the terminfo database.
64 if test "x$cross_compiling" = "xno"
65 then
66         if test -f ../progs/tic$suffix
67         then
68                 case "$PATH" in
69                 @PATH_SEPARATOR@*)
70                         PATH=../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir$PATH
71                         ;;
72                 *)
73                         PATH=../progs@PATH_SEPARATOR@../lib@PATH_SEPARATOR@${DESTDIR}$bindir@PATH_SEPARATOR@$PATH
74                         ;;
75                 esac
76                 export PATH
77                 SHLIB="sh $srcdir/shlib"
78                 TIC_PATH="$SHLIB tic"
79         elif test "$TIC_PATH" = unknown
80         then
81                 echo '? no tic program found'
82                 exit 1
83         fi
84 else
85         # Cross-compiling, so don't set PATH or run shlib.
86         SHLIB=
87         # reset $suffix, since it applies to the target, not the build platform.
88         suffix=
89 fi
90
91
92 # set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
93 # the PATH we just set.
94 SHLIB_PATH=$PATH
95 export SHLIB_PATH
96
97 # set a variable to simplify environment update in shlib
98 SHLIB_HOST=@host_os@
99 export SHLIB_HOST
100
101 # don't use user's TERMINFO variable
102 TERMINFO=${DESTDIR}$ticdir ; export TERMINFO
103 umask 022
104
105 # Construct the name of the old (obsolete) pathname, e.g., /usr/lib/terminfo.
106 TICDIR=`echo $TERMINFO | sed -e 's%/share/\([^/]*\)$%/lib/\1%'`
107
108 # Remove the old terminfo stuff; we don't care if it existed before, and it
109 # would generate a lot of confusing error messages if we tried to overwrite it.
110 # We explicitly remove its contents rather than the directory itself, in case
111 # the directory is actually a symbolic link.
112 ( test -d "$TERMINFO" && cd $TERMINFO && rm -fr ? 2>/dev/null )
113
114 if test "$ext_funcs" = 1 ; then
115 cat <<EOF
116 Running $TIC_PATH to install $TERMINFO ...
117
118         You may see messages regarding extended capabilities, e.g., AX.
119         These are extended terminal capabilities which are compiled
120         using
121                 tic -x
122         If you have ncurses 4.2 applications, you should read the INSTALL
123         document, and install the terminfo without the -x option.
124
125 EOF
126 if ( $TIC_PATH -x -s -o $TERMINFO $source )
127 then
128         echo '** built new '$TERMINFO
129 else
130         echo '? tic could not build '$TERMINFO
131         exit 1
132 fi
133 else
134 cat <<EOF
135 Running $TIC_PATH to install $TERMINFO ...
136
137         You may see messages regarding unknown capabilities, e.g., AX.
138         These are extended terminal capabilities which may be compiled
139         using
140                 tic -x
141         If you have ncurses 4.2 applications, you should read the INSTALL
142         document, and install the terminfo without the -x option.
143
144 EOF
145 if ( $TIC_PATH -s -o $TERMINFO $source )
146 then
147         echo '** built new '$TERMINFO
148 else
149         echo '? tic could not build '$TERMINFO
150         exit 1
151 fi
152 fi
153
154 # Make a symbolic link to provide compatibility with applications that expect
155 # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
156 # all systems support symbolic links, and those that do provide a variety
157 # of options for 'test'.
158 if test "$TICDIR" != "$TERMINFO" ; then
159         ( rm -f $TICDIR 2>/dev/null )
160         if ( cd $TICDIR 2>/dev/null )
161         then
162                 cd $TICDIR
163                 TICDIR=`pwd`
164                 if test $TICDIR != $TERMINFO ; then
165                         # Well, we tried.  Some systems lie to us, so the
166                         # installer will have to double-check.
167                         echo "Verify if $TICDIR and $TERMINFO are the same."
168                         echo "The new terminfo is in $TERMINFO; the other should be a link to it."
169                         echo "Otherwise, remove $TICDIR and link it to $TERMINFO."
170                 fi
171         else
172                 cd ${DESTDIR}$prefix
173                 # Construct a symbolic link that only assumes $ticdir has the
174                 # same $prefix as the other installed directories.
175                 RELATIVE=`echo $ticdir|sed -e 's%^'$prefix'/%%'`
176                 if test "$RELATIVE" != "$ticdir" ; then
177                         RELATIVE=../`echo $ticdir|sed -e 's%^'$prefix'/%%' -e 's%^/%%'`
178                 fi
179                 if ( @LN_S@ $RELATIVE $TICDIR )
180                 then
181                         echo '** sym-linked '$TICDIR' for compatibility'
182                 else
183                         echo '** could not sym-link '$TICDIR' for compatibility'
184                 fi
185         fi
186 fi
187 # vile:shmode