1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3#
4# Compile with debug symbols:
5#    CFLAGS="-ggdb -pedandic -O0" ./configure
6#    CFLAGS="-ggdb -Wall -Wextra -pedantic -O0" ./configure
7#
8# Use libtool (glibtool on OSX) to debug:
9#
10#    libtool --mode=execute gdb examples/tc1
11#
12# Run valgrind like this, but note
13# http://invisible-island.net/ncurses/ncurses.faq.html#config_leaks.
14#
15#    libtool --mode=execute valgrind --leak-check=full examples/tc1
16#
17# A valgrind suppressions file for ncurses is available at
18# http://www.opensource.apple.com/source/ncurses/ncurses-27/ncurses/misc/ncurses.supp
19#
20#    libtool --mode=execute valgrind --suppressions=ncurses.supp.txt --leak-check=full examples/tc1
21#
22# Verbose output can be enabled with
23#    "./configure --disable-silent-rules" or "make V=1"
24#
25
26AC_INIT([libedit],[EL_RELEASE],[],[libedit-EL_TIMESTAMP])
27AC_CONFIG_MACRO_DIRS([m4])
28AC_CONFIG_AUX_DIR([.])
29AC_CONFIG_SRCDIR([src/strlcat.c])
30AC_CONFIG_HEADERS([config.h])
31
32# features of Posix that are extensions to C (define _GNU_SOURCE)
33AC_USE_SYSTEM_EXTENSIONS
34
35AM_INIT_AUTOMAKE
36LT_INIT
37
38# libtool -version-info
39AC_SUBST(LT_VERSION, [0:51:0])
40
41m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
42
43# Checks for programs.
44AC_PROG_CC
45AC_PROG_LN_S
46AC_PROG_AWK
47EL_MANTYPE
48
49
50AC_CHECK_LIB(tinfo, tgetent,,
51  [AC_CHECK_LIB(terminfo, tgetent,,
52    [AC_CHECK_LIB(termcap, tgetent,,
53       [AC_CHECK_LIB(termlib, tgetent,,
54           [AC_CHECK_LIB(curses, tgetent,,
55               [AC_CHECK_LIB(ncurses, tgetent,,
56                   [AC_MSG_ERROR([libcurses or libncurses are required!])]
57               )]
58           )]
59       )]
60    )]
61  )]
62)
63
64
65### use option --enable-widec to turn on use of wide-character support
66EL_ENABLE_WIDEC
67
68AC_ARG_ENABLE(
69  [examples],
70  [AS_HELP_STRING([--enable-examples], [build the example programs [default=yes]])],
71  [enable_examples="$enableval"],
72  [enable_examples="yes"]
73)
74
75AM_CONDITIONAL(ENABLE_EXAMPLES, [test "$enable_examples" == "yes"])
76
77# Checks for header files.
78AC_HEADER_DIRENT
79AC_HEADER_SYS_WAIT
80AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stdlib.h string.h sys/ioctl.h sys/param.h unistd.h curses.h ncurses.h sys/cdefs.h termcap.h])
81
82AC_CHECK_HEADER([termios.h], [], [AC_MSG_ERROR([termios.h is required!])],[])
83
84## include curses.h to prevent "Present But Cannot Be Compiled"
85AC_CHECK_HEADERS([term.h],,,
86[[#if HAVE_CURSES_H
87# include <curses.h>
88#elif HAVE_NCURSES_H
89# include <ncurses.h>
90#endif
91]])
92
93# Check for dirent.d_namlen field explicitly
94# (This is a bit more straightforward than, if not quite as portable as,
95# the recipe given by the autoconf maintainers.)
96AC_CHECK_MEMBER(struct dirent.d_namlen,
97AC_DEFINE([HAVE_STRUCT_DIRENT_D_NAMLEN],[1],
98[Define to 1 if struct dirent has member d_namlen]),,
99[#if HAVE_DIRENT_H
100#include <dirent.h>
101#endif
102])
103
104# Checks for typedefs, structures, and compiler characteristics.
105AC_C_CONST
106AC_TYPE_PID_T
107AC_TYPE_SIZE_T
108AC_CHECK_TYPES([u_int32_t])
109
110# Checks for library functions.
111AC_FUNC_CLOSEDIR_VOID
112AC_FUNC_FORK
113AC_PROG_GCC_TRADITIONAL
114## _AIX is offended by rpl_malloc and rpl_realloc
115#AC_FUNC_MALLOC
116#AC_FUNC_REALLOC
117AC_FUNC_STAT
118AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid wcsdup strlcpy strlcat fgetln vis strvis strunvis __secure_getenv secure_getenv])
119
120# strlcpy
121AC_CHECK_FUNC(strlcpy, found_strlcpy=yes, found_strlcpy=no)
122AM_CONDITIONAL(HAVE_STRLCPY, [test "x$found_strlcpy" = xyes])
123
124# strlcat
125AC_CHECK_FUNC(strlcat, found_strlcat=yes, found_strlcat=no)
126AM_CONDITIONAL(HAVE_STRLCAT, [test "x$found_strlcat" = xyes])
127
128# vis
129AC_CHECK_FUNC(vis, found_vis=yes, found_vis=no)
130AM_CONDITIONAL(HAVE_VIS, [test "x$found_vis" = xyes])
131
132# unvis
133AC_CHECK_FUNC(unvis, found_unvis=yes, found_unvis=no)
134AM_CONDITIONAL(HAVE_UNVIS, [test "x$found_unvis" = xyes])
135
136
137EL_GETPW_R_POSIX
138EL_GETPW_R_DRAFT
139
140
141AH_BOTTOM([
142#include "sys.h"
143#define SCCSID
144#undef LIBC_SCCS
145#define lint
146])
147
148AC_CONFIG_FILES([Makefile
149                 libedit.pc
150                 src/Makefile
151                 doc/Makefile
152                 examples/Makefile])
153AC_OUTPUT
154