1#exported variables 2_readline_list="readline readline_version readline_enabledp CPPF_defined \ 3rl_library_version rl_fake_library_version rl_history 4rl_refresh_line_oldproto rl_appendchar rl_message \ 5rl_save_prompt rl_fake_save_prompt _rl_save_prompt\ 6rl_genericbind rl_bind_key_in_map 7rl_attempted_completion_over rl_completion_query_items \ 8rl_completion_matches rl_completion_func_t \ 9RLINCLUDE RLLIBS" 10 11readline= 12if test -n "$with_readline"; then 13 with_readline_lib="$with_readline_lib $with_readline/lib" 14 with_readline_include="$with_readline_include $with_readline/include/readline" 15fi 16if test -z "$without_readline"; then 17 readline_add="$GP_READLINE $TOP/readline-$osname-$arch $TOP/readline" 18 pth="$with_readline_lib $readline_add $libpth" 19 lib=readline; . ./locatelib 20 rl_fullname=$try 21fi 22 23if test -n "$readline"; then 24# Readline -- Headers 25 incpth="`echo $C_INCLUDE_PATH | sed -e \"s%\([^$dir_sep]*\)$dir_sep*%\1 \1/readline %g\"`" 26 case "$osname" in 27 os2);; 28 cygwin*) incpth="$incpth\ 29 $cygtop/usr/local/include/readline\ 30 $cygtop/usr/local/include\ 31 $cygtop/usr/include/readline\ 32 $cygtop/usr/include\ 33 $cygtop/H-${arch}-cygwin32/${arch}-cygwin32/include\ 34 ";; 35 *) incpth="$incpth\ 36 /usr/local/include/readline\ 37 /usr/include/readline\ 38 /opt/include/readline\ 39 /opt/local/include/readline\ 40 /opt/gnu/include/readline\ 41 /usr/unsupported/include/readline\ 42 /usr/local/include\ 43 /usr/include\ 44 /opt/include\ 45 /opt/local/include\ 46 /opt/gnu/include\ 47 ";; 48 esac 49 pth="$with_readline_include $readline_add $incpth" 50 x=`./locate 'readline.h' '' $pth` 51 CPPF_defined= 52 case $x in 53 ?:/*|/*) rl_include=`dirname $x` 54 echo ..."Found readline header in $rl_include" 55 if (test -r "$rl_include/history.h"); then 56 echo ..."Found history header in $rl_include" 57 rl_history=yes 58 else 59 echo ..."No history header in $rl_include" 60 fi 61 if (grep CPPFunction $x > /dev/null 2>&1); then CPPF_defined=yes; fi 62 if (grep rl_message $x > /dev/null 2>&1); then rl_message=yes; fi 63 if (grep rl_completion_matches $x > /dev/null 2>&1); then 64 rl_completion_matches=yes; 65 fi 66 if (grep rl_completion_func_t $x > /dev/null 2>&1); then 67 rl_completion_func_t=yes; 68 fi 69 if (grep "rl_refresh_line *()" $x > /dev/null 2>&1); then 70 rl_refresh_line_oldproto=yes 71 fi 72 if (grep rl_completion_append_character $x > /dev/null 2>&1); then 73 rl_appendchar=yes 74 fi 75 if (grep rl_generic_bind $x > /dev/null 2>&1); then 76 rl_genericbind=yes 77 fi 78 if (grep rl_attempted_completion_over $x > /dev/null 2>&1); then 79 rl_attempted_completion_over=yes; 80 fi 81 if (grep rl_completion_query_items $x > /dev/null 2>&1); then 82 rl_completion_query_items=yes; 83 fi 84 if (grep rl_bind_key_in_map $x > /dev/null 2>&1); then 85 rl_bind_key_in_map=yes; 86 fi 87 if (grep rl_library_version $x > /dev/null 2>&1); then 88 rl_library_version=yes; 89 rl_extra_flags="-DHAS_RL_LIBRARY_VERSION" 90 fi 91 if (grep rl_save_prompt $x > /dev/null 2>&1); then 92 rl_save_prompt=yes; 93 else # might be defined but not declared (old readline) 94 lib=$rl_fullname; sym=rl_save_prompt; . ./locatesymbol 95 _rl_save_prompt=$try 96 fi;; 97 *) echo ..."But no header file has been found" 98 readline=;; 99 esac 100fi 101 102if test -n "$readline"; then 103 pth="$libpth" 104# Readline -- Allocation 105 lib=$rl_fullname; sym=alloca; . ./locatesymbol 106 if test -n "$try"; then # alloca needed 107 lib=iberty; . ./locatelib 108 rl_liberty="$try" 109 fi 110# Readline -- TermCap 111 lib=$rl_fullname; sym=tgetent; . ./locatesymbol 112 need_tgetent="$try" 113 if test -n "$need_tgetent"; then 114 opth=$pth; pth="$with_ncurses_lib $libpth" 115 lib=ncurses; . ./locatelib 116 if test -n "$try"; then # ncurses found. Does it contain tgetent ? 117 lib=$try; . ./locatesymbol 118 fi 119 pth=$opth 120 if test -n "$try"; then 121 rl_ncurses=$ncurses 122 need_tgetent= 123 else # give termcap a try 124 lib=termcap; . ./locatelib 125 if test -n "$try"; then 126 rl_termcap=$termcap 127 need_tgetent= 128 fi 129 fi 130 fi 131# Readline -- CFLAGS 132 if (echo $rl_include | grep "readline$" > /dev/null); then 133 rl_include=`dirname $rl_include` 134 RLINCLUDE="-I$rl_include" 135 else # in case headers are not installed correctly 136 RLINCLUDE="-I$rl_include -DREADLINE_LIBRARY" 137 fi 138 RLLIBS="-L$readline -lreadline" 139 if test -n "$rl_ncurses"; then 140 echo ..."Library ncurses needed by readline" 141 RLLIBS="$RLLIBS -L$rl_ncurses -lncurses" 142 fi 143 if test -n "$rl_termcap"; then 144 echo ..."Library termcap needed by readline" 145 RLLIBS="$RLLIBS -L$rl_termcap -ltermcap" 146 fi 147 if test -n "$rl_liberty"; then 148 echo ..."Library liberty needed by readline" 149 RLLIBS="$RLLIBS -L$rl_liberty -liberty" 150 fi 151# Readline -- last chance for tgetent 152 if test -n "$need_tgetent"; then # try to compile anyway (in libc?) 153 list=readline; extra_flags="$RLLIBS $RLINCLUDE"; ./look 154 if test "$has_readline" = no; then 155 echo "cannot use readline: please install libncurses or libtermcap." 156 readline= 157 fi 158 fi 159fi 160 161if test -n "$readline"; then 162 exe=$osname-$arch-rlv$$ 163 $CC $extraflag $rl_extra_flags $RLINCLUDE -o $exe rl_version.c $RLLIBS 2> /dev/null 164 if test -r $exe; then 165 readline_version=`env LD_LIBRARY_PATH="$LD_LIBRARY_PATH$dir_sep$readline" $exe`; 166 else 167 readline_version="?.?"; 168 fi 169 rm -f $exe $exe$exe_suff; 170 case "$readline_version" in 171 *Editline*|*EditLine*) readline= 172 echo "###" 173 echo "### Editline wrapper detected, building without readline support" 174 echo "###";; 175 \?.\?) readline= 176 echo "###" 177 echo "### Readline library detected, but does not seem to work" 178 echo "###";; 179 esac 180fi 181 182if test -n "$readline"; then 183 if test -z "$rl_library_version"; then 184 echo "!!! Possible mismatch between readline headers and library:" 185 echo "!!! header is apparently for v1.0, library reports $readline_version!" 186 case "$readline_version" in 187 # rl_save_prompt was not in 2.1, is in 4.1; do not know more... 188 4.[1-9]*|[5-9]*) rl_fake_save_prompt=yes;; 189 esac 190 readline_version="1.0=Header/$readline_version=Lib" 191 rl_fake_library_version=yes 192 fi 193 if test -z "$rl_appendchar"; then 194 echo ..."Library readline does not have completion_append_char" 195 fi 196 if test -z "$rl_genericbind"; then 197 echo ..."Library readline does not have rl_generic_bind" 198 fi 199 if test -z "$rl_completion_query_items"; then 200 echo ..."Library readline does not have rl_completion_query_items" 201 fi 202 if test -z "$rl_bind_key_in_map"; then 203 echo ..."Library readline does not have rl_bind_key_in_map" 204 fi 205 if test -z "$rl_attempted_completion_over"; then 206 echo ..."Library readline does not have rl_attempted_completion_over" 207 fi 208 if test -z "$rl_save_prompt"; then 209 echo ..."Library readline does not have rl_save_prompt" 210 if test -n "$_rl_save_prompt"; then 211 echo ......"but it has _rl_save_prompt" 212 if test -n "$rl_fake_save_prompt"; then 213 echo ........."but due to library mismatch we fake rl_save_prompt" 214 rl_save_prompt=yes 215 fi 216 fi 217 fi 218 219 if test "$fastread" != yes; then 220 cat << EOM 221========================================================================== 222GNU readline provides line editing in the gp shell, with history and 223context-dependant completions. You should really answer 'yes' to the 224following question, unless you are trying to overcome a problem in 225the default build. 226EOM 227 echo $n "Do you want to use GNU readline library within GP ? $c" 228 rep='y n'; dflt=y; . ./myread 229 case $ans in 230 n) readline=;; 231 esac 232 fi 233fi 234 235if test -z "$readline"; then 236 echo "### Building without GNU readline support" 237 RLLIBS= 238 RLINCLUDE= 239else 240 echo "Using GNU readline, version $readline_version" 241 readline_enabledp="t"; 242fi 243