File: acinclude.m4

package info (click to toggle)
xscorch 0.2.1-1+nmu1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 4,548 kB
  • ctags: 3,494
  • sloc: ansic: 30,484; sh: 10,960; makefile: 482; perl: 16
file content (81 lines) | stat: -rw-r--r-- 2,758 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
dnl acinclude.m4
dnl Support functions for configure.in.
dnl
dnl These programs are free software; you can redistribute them and/or
dnl modify them under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2 of the
dnl License, or (at your option) any later version.
dnl
dnl These programs are distributed in the hope that they will be
dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty
dnl of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with these programs; if not, write to the Free Software Foundation,
dnl Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
dnl

dnl FC_CHECK_READLINE_RUNTIME(EXTRA-LIBS, ACTION-IF-FOUND)
dnl
dnl This tests whether readline works at runtime.  Here, "works"
dnl means "doesn't dump core", as some versions do if linked
dnl against wrong ncurses library.  Compiles with LIBS modified
dnl to include -lreadline and parameter EXTRA-LIBS.
dnl Should already have checked that header and library exist.
dnl
dnl If readline "works", or if cross-compiling, defines
dnl READLINE=1 and runs ACTION-IF-FOUND.  Otherwise prints
dnl a warning (and leaves READLINE untouched).
dnl
AC_DEFUN([FC_CHECK_READLINE_RUNTIME],
[AC_MSG_CHECKING(whether readline works at runtime)
templibs="$LIBS"
LIBS="-lreadline $1 $LIBS"
AC_TRY_RUN([
/*
 * testrl.c
 * File revision 0
 * Check to make sure that readline works at runtime.
 * (Specifically, some readline packages link against a wrong
 * version of ncurses library and dump core at runtime.)
 * (c) 2000 Jacob Lundberg, jacob(at)gnifty.net
 */

#include <stdio.h>
/* We assume that the presence of readline has already been verified. */
#include <readline/readline.h>
#include <readline/history.h>

/* Setup for readline. */
#define TMP_FILE "./conftest.readline.runtime"

static void handle_readline_input_callback(char *line) {
/* Generally taken from freeciv-1.11.4/server/sernet.c. */
   if(line) {
      if(*line)
         add_history(line);
      /* printf(line); */
   }
}
int main(void) {
/* Try to init readline and see if it barfs. */
   using_history();
   read_history(TMP_FILE);
   rl_initialize();
   rl_callback_handler_install("_ ", handle_readline_input_callback);
   rl_callback_handler_remove();  /* needed to re-set terminal */
   return(0);
}
],
[AC_MSG_RESULT(yes)
   READLINE="1"
   [$2]],
[AC_MSG_RESULT(no)
   AC_MSG_WARN(Readline fails at runtime and will not be used.)
   AC_MSG_WARN(You probably need to get a newer readline package.)],
[AC_MSG_RESULT(unknown: cross-compiling)
   READLINE="1"
   [$2]])
LIBS="$templibs"
])