summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-10-05 18:38:21 +0200
committerWerner Koch <wk@gnupg.org>2017-10-05 18:38:21 +0200
commit7c48edad2c782f416854eaa5c03bcf546d68eae2 (patch)
tree62733b00a82ef1da83bee6c61f8f714c254f2430 /m4
parent17abc821778b2d1dc7ef765104ddd06e7df01190 (diff)
downloadlibgpg-error-7c48edad2c782f416854eaa5c03bcf546d68eae2.tar.gz
gpgscm: Add required configure checks.
* configure.ac: Add new checks. * m4/readline.m4: New. Taken from gnupg. * m4/Makefile.am (EXTRA_DIST): Add it. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'm4')
-rw-r--r--m4/Makefile.am2
-rw-r--r--m4/readline.m466
2 files changed, 67 insertions, 1 deletions
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 2f16e46..f92d115 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -1,3 +1,3 @@
EXTRA_DIST = inttypes-h.m4 lock.m4 visibility.m4 glibc2.m4 intmax.m4 longdouble.m4 longlong.m4 printf-posix.m4 signed.m4 size_max.m4 wchar_t.m4 wint_t.m4 xsize.m4 ac_prog_cc_for_build.m4 nls.m4 po.m4 codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4
-EXTRA_DIST += autobuild.m4 estream.m4
+EXTRA_DIST += autobuild.m4 estream.m4 readline.m4
diff --git a/m4/readline.m4 b/m4/readline.m4
new file mode 100644
index 0000000..0c9619d
--- /dev/null
+++ b/m4/readline.m4
@@ -0,0 +1,66 @@
+dnl Check for readline and dependencies
+dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+dnl
+dnl This file is free software, distributed under the terms of the GNU
+dnl General Public License. As a special exception to the GNU General
+dnl Public License, this file may be distributed as part of a program
+dnl that contains a configuration script generated by Autoconf, under
+dnl the same distribution terms as the rest of that program.
+dnl
+dnl Defines HAVE_LIBREADLINE to 1 if a working readline setup is
+dnl found, and sets @LIBREADLINE@ to the necessary libraries.
+
+
+AC_DEFUN([GNUPG_CHECK_READLINE],
+[
+ AC_ARG_WITH(readline,
+ AC_HELP_STRING([--with-readline=DIR],
+ [look for the readline library in DIR]),
+ [_do_readline=$withval],[_do_readline=yes])
+
+ gnupg_cv_have_readline=no
+ if test "$_do_readline" != "no" ; then
+ if test -d "$withval" ; then
+ CPPFLAGS="${CPPFLAGS} -I$withval/include"
+ LDFLAGS="${LDFLAGS} -L$withval/lib"
+ fi
+
+ for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do
+ _readline_save_libs=$LIBS
+ _combo="-lreadline${_termcap:+ $_termcap}"
+ LIBS="$LIBS $_combo"
+
+ AC_MSG_CHECKING([whether readline via \"$_combo\" is present and sane])
+
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+]],[[
+rl_completion_func_t *completer;
+add_history("foobar");
+rl_catch_signals=0;
+rl_inhibit_completion=0;
+rl_attempted_completion_function=NULL;
+rl_completion_matches(NULL,NULL);
+]])],[_found_readline=yes],[_found_readline=no])
+
+ AC_MSG_RESULT([$_found_readline])
+
+ LIBS=$_readline_save_libs
+
+ if test $_found_readline = yes ; then
+ AC_DEFINE(HAVE_LIBREADLINE,1,
+ [Define to 1 if you have a fully functional readline library.])
+ AC_SUBST(LIBREADLINE,$_combo)
+ gnupg_cv_have_readline=yes
+ break
+ fi
+ done
+
+ unset _termcap
+ unset _readline_save_libs
+ unset _combo
+ unset _found_readline
+ fi
+])dnl