3 # rlvers.sh -- run a program that prints out the readline version number
4 # using locally-installed readline libraries
12 RL_LIBDIR=/usr/local/lib
14 TERMCAP_LIB="-ltermcap"
16 while [ $# -gt 0 ]; do
18 -C) shift ; CC="$1"; shift ;;
19 -L) shift ; RL_LIBDIR="$1" ; shift ;;
20 -T) shift ; TERMCAP_LIB="$1" ; shift ;;
21 -v) shift ; verbose=y ;;
23 *) echo "${PROGNAME}: usage: $PROGNAME [-C compiler] [-L libdir] [-v]" >&2 ; exit 2;;
27 # if someone happened to install examples/rlversion, use it (it's not
28 # installed by default)
29 if test -f ${RL_LIBDIR}/rlversion ; then
30 if [ -n "$verbose" ]; then
31 echo "${PROGNAME}: using installed rlversion from ${RL_LIBDIR}/rlversion"
33 v=`${RL_LIBDIR}/rlversion 2>/dev/null`
35 unknown | "") echo 0 ;;
41 if [ -n "$verbose" ]; then
42 echo "${PROGNAME}: using ${RL_LIBDIR} to find libreadline"
43 echo "${PROGNAME}: attempting program compilation"
46 # make $TDIR mode 0700
48 echo "${PROGNAME}: ${TDIR}: file exists" >&2
54 trap 'rm -f $TDIR/rlvers $TDIR/rlvers.? ; rmdir $TDIR' 0 1 2 3 6 15
56 cat > $TDIR/rlvers.c << EOF
58 extern char *rl_library_version;
62 printf("%s\n", rl_library_version ? rl_library_version : "0");
67 if eval ${CC} -L${RL_LIBDIR} -o $TDIR/rlvers $TDIR/rlvers.c -lreadline ${TERMCAP_LIB};
71 if [ -n "$verbose" ] ; then
72 echo "${PROGNAME}: compilation failed: status $?"
73 echo "${PROGNAME}: using version 0"
79 unknown | "") echo 0 ;;