1AC_INIT(editline, 1.17.1, https://github.com/troglobit/editline/issues)
2AC_CONFIG_AUX_DIR(aux)
3AM_INIT_AUTOMAKE([1.11 foreign dist-xz])
4AM_SILENT_RULES([yes])
5
6AC_CONFIG_MACRO_DIR([m4])
7AC_CONFIG_SRCDIR([src/editline.c])
8AC_CONFIG_HEADER([config.h])
9AC_CONFIG_FILES([Makefile libeditline.pc src/Makefile include/Makefile man/Makefile examples/Makefile])
10
11# Checks for programs.
12AC_PROG_CC
13AC_PROG_INSTALL
14
15# Checks for libraries.
16LT_INIT
17
18# Checks for header files.
19AC_HEADER_DIRENT
20AC_HEADER_STAT
21AC_HEADER_STDC
22# Check for malloc.h instead of AC_FUNC_MALLOC/REALLOC AIX and others
23# mess up the traditional malloc check.
24AC_CHECK_HEADERS([malloc.h signal.h stdlib.h string.h termcap.h termio.h termios.h sgtty.h unistd.h])
25
26# In termios.h or in sys/ioctl.g?
27AC_HEADER_TIOCGWINSZ
28
29# Overrides and types, should be a check.
30AC_DEFINE([SYS_UNIX], [1], [Default to UNIX backend, should be detected.])
31AC_TYPE_SIZE_T
32
33# Checks for library functions.
34AC_FUNC_CLOSEDIR_VOID
35AC_PROG_GCC_TRADITIONAL
36AC_FUNC_STAT
37AC_CHECK_FUNCS([strchr strdup strrchr tcgetattr perror])
38
39#
40# Available features
41#
42AC_ARG_ENABLE(unique-history,
43   [AS_HELP_STRING([--disable-unique-history],
44                   [Disable uniqify of scrollback. Default: duplicate entries are ignored. Use this to save dupes.])])
45
46AC_ARG_ENABLE(arrow-keys,
47   [AS_HELP_STRING([--disable-arrow-keys], [Disable ANSI arrow keys.])])
48
49AC_ARG_ENABLE(eof,
50   [AS_HELP_STRING([--disable-eof], [Disable default EOF (Ctrl-D) behavior.])])
51
52AC_ARG_ENABLE(sigint,
53   [AS_HELP_STRING([--disable-sigint], [Disable default SIGINT (Ctrl-C) behavior.])])
54
55AC_ARG_ENABLE(sigstop,
56   [AS_HELP_STRING([--enable-sigstop], [Enable SIGSTOP (Ctrl-Z) behavior.])])
57
58AC_ARG_ENABLE(terminal-bell,
59   [AS_HELP_STRING([--enable-terminal-bell], [Enable terminal bell on completion.])])
60
61AC_ARG_ENABLE(termcap,
62   AS_HELP_STRING([--enable-termcap], [Use termcap library to query terminal size.]))
63
64#
65# Check what features have been enabled
66#
67AS_IF([test "x$enable_unique_history" != "xno"],
68   AC_DEFINE(CONFIG_UNIQUE_HISTORY, 1, [Define to skip duplicate lines in the scrollback history.]))
69
70AS_IF([test "x$enable_terminal_bell" != "xno"],
71   AC_DEFINE(CONFIG_ANSI_ARROWS, 1, [Define to include ANSI arrow keys support.]))
72
73AS_IF([test "x$enable_eof" != "xno"],
74   AC_DEFINE(CONFIG_EOF, 1, [Define to enable EOF (Ctrl-D) key.]))
75
76AS_IF([test "x$enable_sigint" != "xno"],
77   AC_DEFINE(CONFIG_SIGINT, 1, [Define to enable SIGINT (Ctrl-C) key.]))
78
79AS_IF([test "x$enable_sigstop" = "xyes"],
80   AC_DEFINE(CONFIG_SIGSTOP, 1, [Define to enable SIGSTOP (Ctrl-Z) key.]))
81
82AS_IF([test "x$enable_terminal_bell" = "xyes"],
83   AC_DEFINE(CONFIG_TERMINAL_BELL, 1, [Define to enable terminal bell on completion.]))
84
85# Check for a termcap compatible library if enabled
86AS_IF([test "x$enable_termcap" = "xyes"],
87   AC_DEFINE(CONFIG_USE_TERMCAP, 1, [Define to use the termcap library for terminal size.])
88   AC_CHECK_LIB(terminfo, tgetent, , [
89      AC_CHECK_LIB(termcap, tgetent, , [
90         AC_CHECK_LIB(tinfo, tgetent, , [
91            AC_CHECK_LIB(curses, tgetent, , [
92               AC_CHECK_LIB(ncurses, tgetent, , [
93                  AC_MSG_ERROR([Cannot find a termcap capable library, try installing Ncurses.])])
94               ])
95            ])
96         ])
97      ]))
98
99# Generate all files
100AC_OUTPUT
101