Update spec to require automake >= 1.13
[platform/upstream/gawk.git] / configure.ac
1 dnl
2 dnl configure.ac --- autoconf input file for gawk
3 dnl
4 dnl Copyright (C) 1995-2014 the Free Software Foundation, Inc.
5 dnl
6 dnl This file is part of GAWK, the GNU implementation of the
7 dnl AWK Programming Language.
8 dnl
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.
13 dnl
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.
18 dnl
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
22 dnl
23
24 dnl Process this file with autoconf to produce a configure script.
25
26 AC_INIT([GNU Awk], 4.1.1, bug-gawk@gnu.org, gawk)
27
28 # This is a hack. Different versions of install on different systems
29 # are just too different. Chuck it and use install-sh.
30 #
31 # If the user supplies $INSTALL, figure they know what they're doing.
32 #
33 # With Autoconf 2.5x, this needs to come very early on, but *after*
34 # the INIT macro. Sigh.
35
36 if test "x$INSTALL" = "x"
37 then
38         INSTALL="$srcdir/install-sh -c"
39         export INSTALL
40 fi
41
42 AC_PREREQ(2.69)
43 AM_INIT_AUTOMAKE([1.13 dist-xz dist-lzip])
44
45 AC_CONFIG_MACRO_DIR([m4])
46
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
50         then
51                 AC_DEFINE(USE_INCLUDED_STRFTIME, 1,
52                           [force use of our version of strftime])
53         fi
54 )
55 AC_ARG_ENABLE([lint], [  --disable-lint Disable gawk lint checking],
56         if test "$enableval" = no
57         then
58                 AC_DEFINE(NO_LINT, 1, [disable lint checks])
59         fi
60 )
61
62 AC_CANONICAL_HOST
63 AC_USE_SYSTEM_EXTENSIONS
64
65 dnl checks for programs
66 AC_PROG_EGREP
67 AC_PROG_YACC
68 AC_PROG_LN_S
69 AC_PROG_CC
70 AC_PROG_CPP
71
72 AC_OBJEXT
73 AC_EXEEXT
74
75 AC_PROG_INSTALL
76 AC_PROG_MAKE_SET
77
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
82 then
83         # add other debug flags as appropriate, save GAWKDEBUG for emergencies
84         CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG"
85         if grep dbug $srcdir/.developing
86         then
87                 CFLAGS="$CFLAGS -DDBUG"
88                 LIBS="$LIBS dbug/libdbug.a"
89         fi
90         # turn on compiler warnings if we're doing development
91         # enable debugging using macros also
92         if test "$GCC" = yes
93         then
94                 CFLAGS="$CFLAGS -Wall -fno-builtin -g3 -gdwarf-2"
95         fi
96         AC_MSG_RESULT([yes])
97 else
98         AC_MSG_RESULT([no])
99         CFLAGS="$CFLAGS -DNDEBUG"       # turn off assertions
100 fi
101
102 AC_SUBST(CFLAGS)
103
104 # shared library suffix for dynamic loading:
105 AC_SUBST(acl_shlibext)
106 # default shared library location
107 AC_SUBST([pkgextensiondir], ['${pkglibdir}'])
108
109 dnl checks for systems
110 AC_ZOS_USS
111 AC_ISC_POSIX
112 AC_SYS_LARGEFILE
113 GAWK_AC_AIX_TWEAK
114 GAWK_AC_LINUX_ALPHA
115
116 if test "$ISC" = 1      # will be set by test for ISC
117 then
118 dnl     need -D_SYSV3 for ISC
119         CFLAGS="$CFLAGS -D_SYSV3"
120 fi
121
122 dnl check for systems where libc is borked for regex handling
123 case $host_os in
124 mirbsd*)
125         AC_DEFINE([LIBC_IS_BORKED], 1, [libc is broken for regex handling])
126         ;;
127 esac
128
129 dnl Set the programming language for checks. Fortunately,
130 dnl this only needs to be set once, since everything is in C.
131 AC_LANG([C])
132
133 dnl initialize GNU gettext
134 AM_GNU_GETTEXT([external])
135 AM_GNU_GETTEXT_VERSION([0.18.1])
136 AM_LANGINFO_CODESET
137 gt_LC_MESSAGES
138
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)
144 AC_HEADER_STDC
145 AC_HEADER_STDBOOL
146 AC_HEADER_SYS_WAIT
147 AC_HEADER_TIME
148
149 if test "$ac_cv_header_string_h" = yes
150 then
151         AC_CHECK_HEADERS(memory.h)
152 else
153         AC_CHECK_HEADERS(strings.h)
154 fi
155
156 dnl Check cross compiling
157 AM_CONDITIONAL([TEST_CROSS_COMPILE], [test "x$build_alias" != "x$host_alias"])
158
159 dnl checks for typedefs
160 AC_TYPE_PID_T
161 AC_TYPE_SIGNAL
162 AC_SIZE_T
163 AC_TYPE_GETGROUPS
164 AC_TYPE_LONG_LONG_INT
165 AC_TYPE_UNSIGNED_LONG_LONG_INT
166 AC_TYPE_INTMAX_T
167 AC_TYPE_UINTMAX_T
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>],[
173         time_t foo;
174         foo = 0;
175 ],
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>],[
180         wctype_t foo;
181         foo = 0;
182 ],
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>],[
186         wint_t foo;
187         foo = 0;
188 ],
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;
194 ],
195         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [newer systems define this type here]))
196
197 dnl Borrwed from rsync, thanks to to Jim Meyering.
198
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.
203
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.
206
207 AC_DEFUN([TYPE_SOCKLEN_T],
208 [
209    AC_CHECK_TYPE([socklen_t], ,[
210       AC_MSG_CHECKING([for socklen_t equivalent])
211       AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
212       [
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
218                AC_TRY_COMPILE([
219 #include <sys/types.h>
220 #include <sys/socket.h>
221
222                   int getpeername (int, $arg2 *, $t *);
223                ],[
224                   $t len;
225                   getpeername(0,0,&len);
226                ],[
227                   rsync_cv_socklen_t_equiv="$t"
228                   break
229                ])
230             done
231          done
232
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
237          fi
238       ])
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>])
244 ])
245 TYPE_SOCKLEN_T
246
247 dnl Check for C11 _Noreturn
248 GAWK_AC_NORETURN
249
250 dnl checks for functions
251 AC_FUNC_MKTIME
252 case "$ac_cv_func_working_mktime" in
253 yes)    AC_DEFINE(HAVE_MKTIME, 1, [we have the mktime function])
254         ;;
255 esac
256
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])])])
261
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
266 case $host_os in
267 osf1)   : ;;
268 *)
269         gl_LIBSIGSEGV
270         ;;
271 esac
272
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 \
280         wcscoll wctype)
281 dnl this check is for both mbrtowc and the mbstate_t type, which is good
282 AC_FUNC_MBRTOWC
283
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
290
291         dnl On MirBSD (and probably other systems), don't even try.
292         case $host_os in
293         mirbsd* | openedition*) # OS/390 z/OS POSIX layer
294                 cat << \EOF > extension/Makefile
295 all dist check clean distclean install uninstall distcheck:
296         @exit 0
297 EOF
298                 ;;
299         *)
300         AC_CHECK_HEADER(dlfcn.h,
301                 [
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
309                 then
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
314                                 case $host_os in
315                                 linux*|freebsd*)
316                                         LDFLAGS="$LDFLAGS -export-dynamic"
317                                         ;;
318                                 esac
319                         fi
320                 fi
321         ])
322                 ;;
323         esac
324
325         if test "x$enable_extensions$extensions_supported" = "xyesno"; then
326                 AC_MSG_ERROR([extension support requested, but unavailable])
327         fi
328         enable_extensions=$extensions_supported
329 fi
330
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.
334 case $host_os in
335 vms*|beos*|os2*|msdos)
336         AC_DEFINE(GETPGRP_VOID, 1,
337           [Define to 1 if the getpgrp function requires zero arguments.])
338         ;;
339 *)      AC_FUNC_GETPGRP
340         ;;
341 esac
342
343 dnl check for printf %F format
344 AC_MSG_CHECKING([for printf %F format])
345 AC_RUN_IFELSE([
346 AC_LANG_SOURCE([
347 #include <stdio.h>
348
349 int main()
350 {
351         char buf[[100]];
352
353         sprintf(buf, "%F", 123.45);
354
355         if (strcmp(buf, "123.450000") == 0)
356                 return 0;
357         else
358                 return 1;
359 }
360 ])],
361         has_f_format=yes,
362         has_f_format=no,
363         has_f_format=no  dnl Cross-compiling, assuming the worst.
364 )
365 if test "$has_f_format" = yes; then
366         AC_DEFINE(PRINTF_HAS_F_FORMAT, 1, [Define to 1 if *printf supports %F format])
367 fi
368 AC_MSG_RESULT($has_f_format)
369
370 dnl check for sockets
371 GAWK_AC_LIB_SOCKETS
372
373 dnl check for readline support
374 GAWK_CHECK_READLINE
375
376 dnl check for mpfr support
377 GNUPG_CHECK_MPFR
378
379 dnl checks for structure members
380 AC_CHECK_MEMBERS([struct stat.st_blksize])
381 AC_STRUCT_TM
382 AC_STRUCT_TIMEZONE
383
384 dnl checks for compiler characteristics
385 AC_C_CHAR_UNSIGNED
386 AC_C_CONST
387 AC_C_RESTRICT
388 AC_C_INLINE
389 AC_C_STRINGIZE
390
391 AC_CONFIG_HEADERS([config.h:configh.in])
392 AH_BOTTOM([#include "custom.h"])
393
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 ;;
400 esac
401 AC_SUBST(GAWKLIBEXT)
402
403 AC_CONFIG_FILES(Makefile
404         awklib/Makefile
405         doc/Makefile
406         po/Makefile.in
407         test/Makefile)
408 if test "x$enable_extensions" = "xyes"; then
409         AC_CONFIG_SUBDIRS(extension)
410 fi
411 AC_OUTPUT