1dnl
2dnl Configure script for readline library
3dnl
4dnl report bugs to chet@po.cwru.edu
5dnl
6dnl Process this file with autoconf to produce a configure script.
7
8# Copyright (C) 1987-2005 Free Software Foundation, Inc.
9
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2, or (at your option)
13# any later version.
14
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23# 02111-1307, USA.
24
25AC_REVISION([for Readline 5.2, version 2.61])
26
27AC_INIT(readline, 5.2, bug-readline@gnu.org)
28
29dnl make sure we are using a recent autoconf version
30AC_PREREQ(2.50)
31
32AC_CONFIG_SRCDIR(readline.h)
33AC_CONFIG_AUX_DIR(./support)
34AC_CONFIG_HEADERS(config.h)
35
36dnl update the value of RL_READLINE_VERSION in readline.h when this changes
37LIBVERSION=5.2
38
39AC_CANONICAL_HOST
40
41dnl configure defaults
42opt_curses=no
43opt_purify=no
44
45dnl arguments to configure
46AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
47AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
48
49if test "$opt_curses" = "yes"; then
50	prefer_curses=yes
51fi
52
53if test "$opt_purify" = yes; then
54	PURIFY="purify"
55else
56	PURIFY=
57fi
58
59dnl option parsing for optional features
60opt_multibyte=yes
61opt_static_libs=yes
62opt_shared_libs=yes
63
64AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
65AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
66AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
67
68if test $opt_multibyte = no; then
69AC_DEFINE(NO_MULTIBYTE_SUPPORT)
70fi
71
72dnl load up the cross-building cache file -- add more cases and cache
73dnl files as necessary
74
75dnl Note that host and target machine are the same, and different than the
76dnl build machine.
77
78CROSS_COMPILE=
79if test "x$cross_compiling" = "xyes"; then
80    case "${host}" in
81    *-cygwin*)
82        cross_cache=${srcdir}/cross-build/cygwin.cache
83        ;;
84    *-mingw*)
85        cross_cache=${srcdir}/cross-build/mingw.cache
86        ;;
87    i[[3456]]86-*-beos*)
88        cross_cache=${srcdir}/cross-build/x86-beos.cache
89        ;;
90    *)  echo "configure: cross-compiling for $host is not supported" >&2
91        ;;
92    esac
93    if test -n "${cross_cache}" && test -r "${cross_cache}"; then
94        echo "loading cross-build cache file ${cross_cache}"
95        . ${cross_cache}
96    fi
97    unset cross_cache
98    CROSS_COMPILE='-DCROSS_COMPILING'
99    AC_SUBST(CROSS_COMPILE)
100fi
101
102echo ""
103echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
104echo ""
105
106# We want these before the checks, so the checks can modify their values.
107test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
108
109AC_PROG_MAKE_SET
110AC_PROG_CC
111dnl AC_AIX
112AC_MINIX
113
114# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
115test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
116
117AC_PROG_GCC_TRADITIONAL
118AC_PROG_INSTALL
119AC_CHECK_PROG(AR, ar, , ar)
120dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
121dnl This allows people to set it when running configure or make
122test -n "$ARFLAGS" || ARFLAGS="cr"
123AC_PROG_RANLIB
124
125MAKE_SHELL=/bin/sh
126AC_SUBST(MAKE_SHELL)
127
128AC_C_CONST
129AC_C_PROTOTYPES
130AC_C_CHAR_UNSIGNED
131
132AC_TYPE_SIGNAL
133
134AC_TYPE_SIZE_T
135AC_CHECK_TYPE(ssize_t, int)
136
137AC_HEADER_STDC
138
139AC_HEADER_STAT
140AC_HEADER_DIRENT
141
142AC_CHECK_FUNCS(fcntl kill lstat)
143AC_CHECK_FUNCS(memmove putenv select setenv setlocale \
144		strcasecmp strpbrk tcgetattr vsnprintf)
145AC_CHECK_FUNCS(isascii isxdigit)
146AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
147
148AC_FUNC_STRCOLL
149
150AC_CHECK_HEADERS(fcntl.h unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
151		limits.h locale.h pwd.h memory.h termcap.h termios.h termio.h)
152AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h)
153
154AC_CHECK_HEADERS(sys/ptem.h,,,
155[[
156#if HAVE_SYS_STREAM_H
157#  include <sys/stream.h>
158#endif
159]])
160
161BASH_SYS_SIGNAL_VINTAGE
162BASH_SYS_REINSTALL_SIGHANDLERS
163
164BASH_FUNC_POSIX_SETJMP
165BASH_FUNC_LSTAT
166BASH_FUNC_STRCOLL
167BASH_FUNC_CTYPE_NONASCII
168
169BASH_CHECK_GETPW_FUNCS
170
171AC_HEADER_TIOCGWINSZ
172
173BASH_TYPE_SIGHANDLER
174BASH_HAVE_TIOCSTAT
175BASH_HAVE_FIONREAD
176BASH_CHECK_SPEED_T
177BASH_STRUCT_WINSIZE
178BASH_STRUCT_DIRENT_D_INO
179BASH_STRUCT_DIRENT_D_FILENO
180
181dnl yuck
182case "$host_os" in
183aix*)   prefer_curses=yes ;;
184esac
185BASH_CHECK_LIB_TERMCAP
186if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
187	if test "$prefer_curses" = yes; then
188		TERMCAP_LIB=-lcurses
189	else
190		TERMCAP_LIB=-ltermcap	#default
191	fi
192fi
193
194BASH_CHECK_MULTIBYTE
195
196case "$host_cpu" in
197*cray*)	LOCAL_CFLAGS=-DCRAY ;;
198*s390*) LOCAL_CFLAGS=-fsigned-char ;;
199esac
200
201case "$host_os" in
202isc*)	LOCAL_CFLAGS=-Disc386 ;;
203esac
204
205# shared library configuration section
206#
207# Shared object configuration section.  These values are generated by
208# ${srcdir}/support/shobj-conf
209#
210if test -f ${srcdir}/support/shobj-conf; then
211        AC_MSG_CHECKING(configuration for building shared libraries)
212        eval `TERMCAP_LIB=$TERMCAP_LIB ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
213
214#	case "$SHLIB_LIBS" in
215#	*curses*|*termcap*|*termlib*)	;;
216#	*)			SHLIB_LIBS="$SHLIB_LIBS $TERMCAP_LIB" ;;
217#	esac
218	
219        AC_SUBST(SHOBJ_CC)
220        AC_SUBST(SHOBJ_CFLAGS)
221        AC_SUBST(SHOBJ_LD)
222        AC_SUBST(SHOBJ_LDFLAGS)
223	AC_SUBST(SHOBJ_XLDFLAGS)
224        AC_SUBST(SHOBJ_LIBS)
225        AC_SUBST(SHOBJ_STATUS)
226	AC_SUBST(SHLIB_STATUS)
227	AC_SUBST(SHLIB_XLDFLAGS)
228	AC_SUBST(SHLIB_DOT)
229	AC_SUBST(SHLIB_LIBPREF)
230	AC_SUBST(SHLIB_LIBSUFF)
231	AC_SUBST(SHLIB_LIBVERSION)
232	AC_SUBST(SHLIB_DLLVERSION)
233	AC_SUBST(SHLIB_LIBS)
234        AC_MSG_RESULT($SHLIB_STATUS)
235
236	# SHLIB_STATUS is either `supported' or `unsupported'.  If it's
237	# `unsupported', turn off any default shared library building
238	if test "$SHLIB_STATUS" = 'unsupported'; then
239		opt_shared_libs=no
240	fi
241
242	# shared library versioning
243	# quoted for m4 so I can use character classes
244	SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
245	SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
246	AC_SUBST(SHLIB_MAJOR)
247	AC_SUBST(SHLIB_MINOR)
248fi
249
250if test "$opt_static_libs" = "yes"; then
251	STATIC_TARGET=static
252	STATIC_INSTALL_TARGET=install-static
253fi
254if test "$opt_shared_libs" = "yes"; then
255	SHARED_TARGET=shared
256	SHARED_INSTALL_TARGET=install-shared
257fi
258
259AC_SUBST(STATIC_TARGET)
260AC_SUBST(SHARED_TARGET)
261AC_SUBST(STATIC_INSTALL_TARGET)
262AC_SUBST(SHARED_INSTALL_TARGET)
263
264case "$host_os" in
265msdosdjgpp*)	BUILD_DIR=`pwd.exe` ;;	# to prevent //d/path/file
266*)		BUILD_DIR=`pwd` ;;
267esac
268
269case "$BUILD_DIR" in
270*\ *)	BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
271*)	;;
272esac
273
274AC_SUBST(PURIFY)
275AC_SUBST(BUILD_DIR)
276
277AC_SUBST(CFLAGS)
278AC_SUBST(LOCAL_CFLAGS)
279AC_SUBST(LOCAL_LDFLAGS)
280AC_SUBST(LOCAL_DEFS)
281
282AC_SUBST(AR)
283AC_SUBST(ARFLAGS)
284
285AC_SUBST(host_cpu)
286AC_SUBST(host_os)
287
288AC_SUBST(LIBVERSION)
289
290AC_SUBST(TERMCAP_LIB)
291
292AC_OUTPUT([Makefile doc/Makefile examples/Makefile shlib/Makefile],
293[
294# Makefile uses this timestamp file to record whether config.h is up to date.
295echo > stamp-h
296])
297