3 # rlvers.sh -- run a program that prints out the readline version number
4 # using locally-installed readline libraries
9 trap 'rm -f /tmp/rlvers /tmp/rlvers.?' 0 1 2 3 6 15
13 RL_LIBDIR=/usr/local/lib
15 while [ $# -gt 0 ]; do
17 -C) shift ; CC="$1"; shift ;;
18 -L) shift ; RL_LIBDIR="$1" ; shift ;;
19 -v) shift ; verbose=y ;;
21 *) echo "${PROGNAME}: usage: $PROGNAME [-C compiler] [-L libdir] [-v]" >&2 ; exit 2;;
25 # if someone happened to install examples/rlversion, use it (it's not
26 # installed by default)
27 if test -f ${RL_LIBDIR}/rlversion ; then
28 if [ -n "$verbose" ]; then
29 echo "${PROGNAME}: using installed rlversion from ${RL_LIBDIR}/rlversion"
31 v=`${RL_LIBDIR}/rlversion 2>/dev/null`
33 unknown | "") echo 0 ;;
39 if [ -n "$verbose" ]; then
40 echo "${PROGNAME}: using ${RL_LIBDIR} to find libreadline"
41 echo "${PROGNAME}: attempting program compilation"
44 cat > /tmp/rlvers.c << EOF
46 extern char *rl_library_version;
50 printf("%s\n", rl_library_version ? rl_library_version : "0");
55 if eval ${CC} -L${RL_LIBDIR} -o /tmp/rlvers /tmp/rlvers.c -lreadline -ltermcap -lcurses;
59 if [ -n "$verbose" ] ; then
60 echo "${PROGNAME}: compilation failed: status $?"
61 echo "${PROGNAME}: using version 0"
67 unknown | "") echo 0 ;;