]>
git.ipfire.org Git - thirdparty/bash.git/blob - support/rlvers.sh
3 # rlvers.sh -- run a program that prints out the readline version number
4 # using locally-installed readline libraries
14 RL_LIBDIR
=/usr
/local
/lib
15 RL_INCDIR
=/usr
/local
/include
17 TERMCAP_LIB
="-ltermcap"
19 # cannot rely on the presence of getopts
20 while [ $# -gt 0 ]; do
22 -C) shift ; CC
="$1"; shift ;;
23 -I) shift ; RL_INCDIR
="$1" ; shift ;;
24 -L) shift ; RL_LIBDIR
="$1" ; shift ;;
25 -T) shift ; TERMCAP_LIB
="$1" ; shift ;;
26 -v) shift ; verbose
=y
;;
28 *) echo "${PROGNAME}: usage: $PROGNAME [-C compiler] [-L libdir] [-v]" >&2 ; exit 2;;
32 # if someone happened to install examples/rlversion, use it (it's not
33 # installed by default)
34 if test -f ${RL_LIBDIR}/rlversion
; then
35 if [ -n "$verbose" ]; then
36 echo "${PROGNAME}: using installed rlversion from ${RL_LIBDIR}/rlversion"
38 v
=`${RL_LIBDIR}/rlversion 2>/dev/null`
40 unknown |
"") echo 0 ;;
46 if [ -n "$verbose" ]; then
47 echo "${PROGNAME}: using ${RL_LIBDIR} to find libreadline"
48 echo "${PROGNAME}: attempting program compilation"
51 # make $TDIR mode 0700
53 echo "${PROGNAME}: ${TDIR}: file exists" >&2
59 trap 'rm -f $TDIR/rlvers $TDIR/rlvers.? ; rmdir $TDIR' 0 1 2 3 6 15
61 cat > $TDIR/rlvers.c
<< EOF
63 extern char *rl_library_version;
67 printf("%s\n", rl_library_version ? rl_library_version : "0");
75 echo "${PROGNAME}: cannot cd to $TDIR" >&2
80 if eval ${CC} -L${RL_LIBDIR} -I${RL_INCDIR} -o $TDIR/rlvers $TDIR/rlvers.c -lreadline ${TERMCAP_LIB};
84 if [ -n "$verbose" ] ; then
85 echo "${PROGNAME}: compilation failed: status $?"
86 echo "${PROGNAME}: using version 0"
92 unknown |
"") echo 0 ;;