2 dnl configure.ac --- autoconf input file for gawk
4 dnl Copyright (C) 1995-2014 the Free Software Foundation, Inc.
6 dnl This file is part of GAWK, the GNU implementation of the
7 dnl AWK Programming Language.
9 dnl GAWK is free software; you can redistribute it and/or modify
10 dnl it under the terms of the GNU General Public License as published by
11 dnl the Free Software Foundation; either version 3 of the License, or
12 dnl (at your option) any later version.
14 dnl GAWK is distributed in the hope that it will be useful,
15 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 dnl GNU General Public License for more details.
19 dnl You should have received a copy of the GNU General Public License
20 dnl along with this program; if not, write to the Free Software
21 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 dnl Process this file with autoconf to produce a configure script.
26 AC_INIT([GNU Awk], 4.1.1, bug-gawk@gnu.org, gawk)
28 # This is a hack. Different versions of install on different systems
29 # are just too different. Chuck it and use install-sh.
31 # If the user supplies $INSTALL, figure they know what they're doing.
33 # With Autoconf 2.5x, this needs to come very early on, but *after*
34 # the INIT macro. Sigh.
36 if test "x$INSTALL" = "x"
38 INSTALL="$srcdir/install-sh -c"
43 AM_INIT_AUTOMAKE([1.13 dist-xz dist-lzip])
45 AC_CONFIG_MACRO_DIR([m4])
47 dnl Additional argument stuff
48 AC_ARG_WITH(whiny-user-strftime, [ --with-whiny-user-strftime Force use of included version of strftime for deficient systems],
49 if test "$withval" = yes
51 AC_DEFINE(USE_INCLUDED_STRFTIME, 1,
52 [force use of our version of strftime])
55 AC_ARG_ENABLE([lint], [ --disable-lint Disable gawk lint checking],
56 if test "$enableval" = no
58 AC_DEFINE(NO_LINT, 1, [disable lint checks])
63 AC_USE_SYSTEM_EXTENSIONS
65 dnl checks for programs
78 # This is mainly for my use during testing and development.
79 # Yes, it's a bit of a hack.
80 AC_MSG_CHECKING([for special development options])
81 if test -f $srcdir/.developing
83 # add other debug flags as appropriate, save GAWKDEBUG for emergencies
84 CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG"
85 if grep dbug $srcdir/.developing
87 CFLAGS="$CFLAGS -DDBUG"
88 LIBS="$LIBS dbug/libdbug.a"
90 # turn on compiler warnings if we're doing development
91 # enable debugging using macros also
94 CFLAGS="$CFLAGS -Wall -fno-builtin -g3 -gdwarf-2"
99 CFLAGS="$CFLAGS -DNDEBUG" # turn off assertions
104 # shared library suffix for dynamic loading:
105 AC_SUBST(acl_shlibext)
106 # default shared library location
107 AC_SUBST([pkgextensiondir], ['${pkglibdir}'])
109 dnl checks for systems
116 if test "$ISC" = 1 # will be set by test for ISC
118 dnl need -D_SYSV3 for ISC
119 CFLAGS="$CFLAGS -D_SYSV3"
122 dnl check for systems where libc is borked for regex handling
125 AC_DEFINE([LIBC_IS_BORKED], 1, [libc is broken for regex handling])
129 dnl Set the programming language for checks. Fortunately,
130 dnl this only needs to be set once, since everything is in C.
133 dnl initialize GNU gettext
134 AM_GNU_GETTEXT([external])
135 AM_GNU_GETTEXT_VERSION([0.18.1])
139 dnl checks for header files
140 AC_CHECK_HEADERS(arpa/inet.h fcntl.h limits.h locale.h libintl.h mcheck.h \
141 netdb.h netinet/in.h stdarg.h stddef.h string.h \
142 sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \
143 termios.h stropts.h wchar.h wctype.h)
149 if test "$ac_cv_header_string_h" = yes
151 AC_CHECK_HEADERS(memory.h)
153 AC_CHECK_HEADERS(strings.h)
156 dnl Check cross compiling
157 AM_CONDITIONAL([TEST_CROSS_COMPILE], [test "x$build_alias" != "x$host_alias"])
159 dnl checks for typedefs
164 AC_TYPE_LONG_LONG_INT
165 AC_TYPE_UNSIGNED_LONG_LONG_INT
168 AC_CHECK_TYPE(ssize_t, int)
169 AC_CHECK_SIZEOF(unsigned int)
170 AC_CHECK_SIZEOF(unsigned long)
171 dnl see if time_t is defined in <sys/types.h>
172 AC_TRY_COMPILE([#include <sys/types.h>],[
176 AC_DEFINE(TIME_T_IN_SYS_TYPES_H, 1,
177 [some systems define this type here]))
178 dnl check for wctype_t in <wctype.h>
179 AC_TRY_COMPILE([#include <wctype.h>],[
183 AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]))
184 dnl check for wint_t in <wctype.h>
185 AC_TRY_COMPILE([#include <wctype.h>],[
189 AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]))
190 dnl check for sockaddr_storage
191 AC_TRY_COMPILE([#include <sys/types.h>
192 #include <sys/socket.h>],[
193 struct sockaddr_storage foo;
195 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [newer systems define this type here]))
197 dnl Borrwed from rsync, thanks to to Jim Meyering.
199 dnl Check for socklen_t: historically on BSD it is an int, and in
200 dnl POSIX 1g it is a type of its own, but some platforms use different
201 dnl types for the argument to getsockopt, getpeername, etc. So we
202 dnl have to test to find something that will work.
204 dnl This is no good, because passing the wrong pointer on C compilers is
205 dnl likely to only generate a warning, not an error.
207 AC_DEFUN([TYPE_SOCKLEN_T],
209 AC_CHECK_TYPE([socklen_t], ,[
210 AC_MSG_CHECKING([for socklen_t equivalent])
211 AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
213 # Systems have either "struct sockaddr *" or
214 # "void *" as the second argument to getpeername
215 rsync_cv_socklen_t_equiv=
216 for arg2 in "struct sockaddr" void; do
217 for t in int size_t unsigned long "unsigned long"; do
219 #include <sys/types.h>
220 #include <sys/socket.h>
222 int getpeername (int, $arg2 *, $t *);
225 getpeername(0,0,&len);
227 rsync_cv_socklen_t_equiv="$t"
233 if test "x$rsync_cv_socklen_t_equiv" = x; then
234 dnl Some systems get this. Default to int. -- ADR
235 dnl AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
236 rsync_cv_socklen_t_equiv=int
239 AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
240 AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
241 [type to use in place of socklen_t if not defined])],
242 [#include <sys/types.h>
243 #include <sys/socket.h>])
247 dnl Check for C11 _Noreturn
250 dnl checks for functions
252 case "$ac_cv_func_working_mktime" in
253 yes) AC_DEFINE(HAVE_MKTIME, 1, [we have the mktime function])
257 AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo])],
258 [AC_CHECK_LIB(socket, getaddrinfo,
259 [AC_DEFINE(HAVE_GETADDRINFO, 1,
260 [have getaddrinfo])])])
262 AC_CHECK_LIB(m, fmod)
263 AC_CHECK_LIB(m, isinf)
264 AC_CHECK_LIB(m, ismod)
265 dnl Don't look for libsigsegv on OSF/1, gives us severe headaches
273 # Need the check for mkstemp and tmpfile for missing_d/snprintf.c.
274 AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \
275 isascii iswctype iswlower iswupper mbrlen \
276 memcmp memcpy memcpy_ulong memmove memset \
277 memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \
278 strerror strftime strncasecmp strcoll strtod strtoul \
279 system tmpfile towlower towupper tzset usleep wcrtomb \
281 dnl this check is for both mbrtowc and the mbstate_t type, which is good
284 dnl check for dynamic linking
285 dnl This is known to be very primitive
286 AC_ARG_ENABLE([extensions],
287 [AS_HELP_STRING([--disable-extensions], [disable dynamic extensions (default is detect)])])
288 if test "x$enable_extensions" != "xno"; then
289 extensions_supported=no
291 dnl On MirBSD (and probably other systems), don't even try.
293 mirbsd* | openedition*) # OS/390 z/OS POSIX layer
294 cat << \EOF > extension/Makefile
295 all dist check clean distclean install uninstall distcheck:
300 AC_CHECK_HEADER(dlfcn.h,
302 # Check this separately. Some systems have dlopen
303 # in libc. Notably freebsd and cygwin.
304 # HP-NSK has it in zrldsrl
305 AC_SEARCH_LIBS(dlopen, dl zrldsrl, gawk_have_dlopen=yes, gawk_have_dlopen=no)
306 # Only do DYNAMIC if we have the lib. z/OS (some versions) have
307 # the header but not the lib, apparently
308 if test "$gawk_have_dlopen" = yes
310 extensions_supported=yes
311 AC_DEFINE([DYNAMIC], 1, [dynamic loading is possible])
312 # Add -export-dynamic for old extensions. Only works for GCC
313 if test "$GCC" = yes; then
316 LDFLAGS="$LDFLAGS -export-dynamic"
325 if test "x$enable_extensions$extensions_supported" = "xyesno"; then
326 AC_MSG_ERROR([extension support requested, but unavailable])
328 enable_extensions=$extensions_supported
331 dnl check for how to use getpgrp
332 dnl have to hardwire it for VMS POSIX. Sigh.
333 dnl ditto for BeOS, OS/2, and MS-DOS.
335 vms*|beos*|os2*|msdos)
336 AC_DEFINE(GETPGRP_VOID, 1,
337 [Define to 1 if the getpgrp function requires zero arguments.])
343 dnl check for printf %F format
344 AC_MSG_CHECKING([for printf %F format])
353 sprintf(buf, "%F", 123.45);
355 if (strcmp(buf, "123.450000") == 0)
363 has_f_format=no dnl Cross-compiling, assuming the worst.
365 if test "$has_f_format" = yes; then
366 AC_DEFINE(PRINTF_HAS_F_FORMAT, 1, [Define to 1 if *printf supports %F format])
368 AC_MSG_RESULT($has_f_format)
370 dnl check for sockets
373 dnl check for readline support
376 dnl check for mpfr support
379 dnl checks for structure members
380 AC_CHECK_MEMBERS([struct stat.st_blksize])
384 dnl checks for compiler characteristics
391 AC_CONFIG_HEADERS([config.h:configh.in])
392 AH_BOTTOM([#include "custom.h"])
394 dnl Crude but small hack to make plug-ins work on Mac OS X
395 dnl We should really use the libtool value for shrext_cmds, but that
396 dnl is not available here, since we do not use libtool at the top level.
397 case $acl_shlibext in
398 dylib) GAWKLIBEXT=so ;; # MacOS uses .dylib for shared libraries, but libtool uses .so for modules
399 *) GAWKLIBEXT=$acl_shlibext ;;
403 AC_CONFIG_FILES(Makefile
408 if test "x$enable_extensions" = "xyes"; then
409 AC_CONFIG_SUBDIRS(extension)