"Fossies" - the Fresh Open Source Software Archive

Member "gawk-5.1.0/m4/readline.m4" (6 Feb 2020, 3284 Bytes) of package /linux/misc/gawk-5.1.0.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "readline.m4": 5.0.1_vs_5.1.0.

    1 dnl Check for readline and dependencies
    2 dnl Copyright (C) 2004, 2005, 2013, 2014 Free Software Foundation, Inc.
    3 dnl
    4 dnl This file is free software, distributed under the terms of the GNU
    5 dnl General Public License.  As a special exception to the GNU General
    6 dnl Public License, this file may be distributed as part of a program
    7 dnl that contains a configuration script generated by Autoconf, under
    8 dnl the same distribution terms as the rest of that program.
    9 dnl
   10 dnl Defines HAVE_LIBREADLINE to 1 if a working readline setup is
   11 dnl found, and sets @LIBREADLINE@ to the necessary libraries.
   12 dnl
   13 dnl Based upon GNUPG_CHECK_READLINE.  Many more years into the
   14 dnl twenty-first century, it is not enough to link a test program
   15 dnl with the readline library. On several systems, if readline is
   16 dnl not linked with the curses / termcap / whatever libraries, the
   17 dnl problem is only discovered at run time.  Isn't that special?
   18 
   19 AC_DEFUN([GAWK_CHECK_READLINE],
   20 [
   21   AC_ARG_WITH([readline],
   22      AC_HELP_STRING([--with-readline=DIR],
   23 	[look for the readline library in DIR]),
   24      [_do_readline=$withval],[_do_readline=yes])
   25 
   26   if test "$_do_readline" != "no" ; then
   27      if test -d "$withval" ; then
   28         CPPFLAGS="${CPPFLAGS} -I$withval/include"
   29         LDFLAGS="${LDFLAGS} -L$withval/lib"
   30      fi
   31 
   32      for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do
   33         _readline_save_libs=$LIBS
   34         _combo="-lreadline${_termcap:+ $_termcap}"
   35         LIBS="$LIBS $_combo"
   36 
   37         AC_MSG_CHECKING([whether readline via \"$_combo\" is present and sane])
   38 
   39 	AC_TRY_RUN(
   40 dnl source program:
   41 AC_LANG_SOURCE([[#include <stdio.h>
   42 #include <fcntl.h>
   43 #include <unistd.h>
   44 #include <readline/readline.h>
   45 #include <readline/history.h>
   46 
   47 int main(int argc, char **argv)
   48 {
   49 	int fd;
   50 	char *line;
   51 
   52 	close(0);
   53 	close(1);
   54 	fd = open("/dev/null", 2);	/* should get fd 0 */
   55 	dup(fd);
   56 	line = readline("giveittome> ");
   57 
   58 	/* some printfs don't handle NULL for %s */
   59 	printf("got <%s>\n", line ? line : "(NULL)");
   60 	return 0;
   61 }]]),
   62 dnl action if true:
   63             [_found_readline=yes],
   64 dnl action if false:
   65             [_found_readline=no],
   66 dnl action if cross compiling:
   67 		AC_TRY_LINK([#include <stdio.h>
   68 #include <readline/readline.h>
   69 #include <readline/history.h>],		dnl includes
   70 			dnl function body
   71 			[
   72 	int fd;
   73 	char *line;
   74 
   75 	close(0);
   76 	close(1);
   77 	fd = open("/dev/null", 2);	/* should get fd 0 */
   78 	dup(fd);
   79 	line = readline("giveittome> ");
   80 
   81 	/* some printfs don't handle NULL for %s */
   82 	printf("got <%s>\n", line ? line : "(NULL)");
   83 ],
   84 dnl action if found:
   85 			[_found_readline=yes],
   86 dnl action if not found:
   87 			[_found_readline=no]
   88 		)
   89 	)
   90 
   91         AC_MSG_RESULT([$_found_readline])
   92 
   93         LIBS=$_readline_save_libs
   94 
   95         if test $_found_readline = yes ; then
   96 	   case $host_os in
   97 	   *bsd* )	AC_CHECK_LIB(termcap, tgetent, _combo="$_combo -ltermcap")
   98 	  	 ;;
   99 	   esac
  100            AC_DEFINE(HAVE_LIBREADLINE,1,
  101 	      [Define to 1 if you have a fully functional readline library.])
  102            AC_SUBST(LIBREADLINE,$_combo)
  103 
  104 	   AC_CHECK_LIB(readline, history_list,
  105 		[AC_DEFINE(HAVE_HISTORY_LIST, 1, [Do we have history_list?])],
  106 		[],
  107 		[$_combo])
  108 
  109            break
  110         fi
  111      done
  112 
  113      unset _termcap
  114      unset _readline_save_libs
  115      unset _combo
  116      unset _found_readline
  117   fi
  118 ])dnl