Introduced -devel and -extras subpackages for gawk
[platform/upstream/gawk.git] / configure.ac
1 dnl
2 dnl configure.ac --- autoconf input file for gawk
3 dnl
4 dnl Copyright (C) 1995-2012 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.0.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.68)
43 AM_INIT_AUTOMAKE([1.11 dist-xz])
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_USE_SYSTEM_EXTENSIONS
63
64 dnl checks for programs
65 AC_PROG_EGREP
66 AC_PROG_YACC
67 AC_PROG_LN_S
68 AC_PROG_CC
69 AC_PROG_CPP
70
71 AC_OBJEXT
72 AC_EXEEXT
73
74 AC_PROG_INSTALL
75 AC_PROG_MAKE_SET
76
77 # This is mainly for my use during testing and development.
78 # Yes, it's a bit of a hack.
79 AC_MSG_CHECKING([for special development options])
80 if test -f $srcdir/.developing
81 then
82         # add other debug flags as appropriate, save GAWKDEBUG for emergencies
83         CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG"
84         if grep dbug $srcdir/.developing
85         then
86                 CFLAGS="$CFLAGS -DDBUG"
87                 LIBS="$LIBS dbug/libdbug.a"
88         fi
89         # turn on compiler warnings if we're doing development
90         # enable debugging using macros also
91         if test "$GCC" = yes
92         then
93                 CFLAGS="$CFLAGS -Wall -fno-builtin -g3 -gdwarf-2"
94         fi
95         AC_MSG_RESULT([yes])
96 else
97         AC_MSG_RESULT([no])
98 fi
99
100 AC_SUBST(CFLAGS)
101
102 dnl checks for systems
103 AC_ZOS_USS
104 AC_ISC_POSIX
105 AC_SYS_LARGEFILE
106 GAWK_AC_AIX_TWEAK
107 GAWK_AC_LINUX_ALPHA
108
109 if test "$ISC" = 1      # will be set by test for ISC
110 then
111 dnl     need -D_SYSV3 for ISC
112         CFLAGS="$CFLAGS -D_SYSV3"
113 fi
114
115 dnl Set the programming language for checks. Fortunately,
116 dnl this only needs to be set once, since everything is in C.
117 AC_LANG([C])
118
119 dnl Cygwin doesn't like to get libs with full paths
120 dnl since that overrides linking against DLLs.
121 case `(uname) 2> /dev/null` in
122 *CYGWIN*)
123         with_libiconv_prefix=no
124         with_libintl_prefix=no
125         ;;
126 *)
127         ;;
128 esac
129
130 dnl initialize GNU gettext
131 AM_GNU_GETTEXT([external])
132 AM_GNU_GETTEXT_VERSION([0.18.1])
133 AM_LANGINFO_CODESET
134 gt_LC_MESSAGES
135
136 dnl checks for header files
137 AC_HEADER_STDC
138 AC_HEADER_SYS_WAIT
139 AC_HEADER_TIME
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
145 if test "$ac_cv_header_string_h" = yes
146 then
147         AC_CHECK_HEADERS(memory.h)
148 else
149         AC_CHECK_HEADERS(strings.h)
150 fi
151
152 dnl checks for typedefs
153 AC_TYPE_PID_T
154 AC_TYPE_SIGNAL
155 AC_SIZE_T
156 AC_TYPE_GETGROUPS
157 gl_AC_TYPE_LONG_LONG
158 gl_AC_TYPE_UNSIGNED_LONG_LONG
159 gl_AC_TYPE_INTMAX_T
160 gl_AC_TYPE_UINTMAX_T
161 AC_CHECK_TYPE(ssize_t, int)
162 AC_CHECK_SIZEOF(unsigned int)
163 AC_CHECK_SIZEOF(unsigned long)
164 dnl see if time_t is defined in <sys/types.h>
165 AC_TRY_COMPILE([#include <sys/types.h>],[
166         time_t foo;
167         foo = 0;
168 ],
169         AC_DEFINE(TIME_T_IN_SYS_TYPES_H, 1,
170                   [some systems define this type here]))
171 dnl check for wctype_t in <wctype.h>
172 AC_TRY_COMPILE([#include <wctype.h>],[
173         wctype_t foo;
174         foo = 0;
175 ],
176         AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]))
177 dnl check for wint_t in <wctype.h>
178 AC_TRY_COMPILE([#include <wctype.h>],[
179         wint_t foo;
180         foo = 0;
181 ],
182         AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]))
183 dnl check for sockaddr_storage
184 AC_TRY_COMPILE([#include <sys/types.h>
185 #include <sys/socket.h>],[
186         struct sockaddr_storage foo;
187 ],
188         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [newer systems define this type here]))
189
190 dnl Borrwed from rsync, thanks to to Jim Meyering.
191
192 dnl Check for socklen_t: historically on BSD it is an int, and in
193 dnl POSIX 1g it is a type of its own, but some platforms use different
194 dnl types for the argument to getsockopt, getpeername, etc.  So we
195 dnl have to test to find something that will work.
196
197 dnl This is no good, because passing the wrong pointer on C compilers is
198 dnl likely to only generate a warning, not an error.
199
200 AC_DEFUN([TYPE_SOCKLEN_T],
201 [
202    AC_CHECK_TYPE([socklen_t], ,[
203       AC_MSG_CHECKING([for socklen_t equivalent])
204       AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
205       [
206          # Systems have either "struct sockaddr *" or
207          # "void *" as the second argument to getpeername
208          rsync_cv_socklen_t_equiv=
209          for arg2 in "struct sockaddr" void; do
210             for t in int size_t unsigned long "unsigned long"; do
211                AC_TRY_COMPILE([
212 #include <sys/types.h>
213 #include <sys/socket.h>
214
215                   int getpeername (int, $arg2 *, $t *);
216                ],[
217                   $t len;
218                   getpeername(0,0,&len);
219                ],[
220                   rsync_cv_socklen_t_equiv="$t"
221                   break
222                ])
223             done
224          done
225
226          if test "x$rsync_cv_socklen_t_equiv" = x; then
227 dnl             Some systems get this. Default to int.  -- ADR
228 dnl            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
229                 rsync_cv_socklen_t_equiv=int
230          fi
231       ])
232       AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
233       AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
234                         [type to use in place of socklen_t if not defined])],
235       [#include <sys/types.h>
236 #include <sys/socket.h>])
237 ])
238 TYPE_SOCKLEN_T
239
240 dnl checks for functions
241 AC_FUNC_VPRINTF
242 AC_FUNC_MKTIME
243 case "$ac_cv_func_working_mktime" in
244 yes)    AC_DEFINE(HAVE_MKTIME, 1, [we have the mktime function])
245         ;;
246 esac
247
248 AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo])],
249               [AC_CHECK_LIB(socket, getaddrinfo,
250                             [AC_DEFINE(HAVE_GETADDRINFO, 1,
251                                        [have getaddrinfo])])])
252
253 AC_CHECK_LIB(m, fmod)
254 AC_CHECK_LIB(m, isinf)
255 AC_CHECK_LIB(m, ismod)
256 dnl Don't look for libsigsegv on OSF/1, gives us severe headaches
257 case `uname` in
258 OSF1)   : ;;
259 *)
260         gl_LIBSIGSEGV
261         ;;
262 esac
263
264 # Need the check for mkstemp and tmpfile for missing_d/snprintf.c.
265 AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \
266         isascii iswctype iswlower iswupper mbrlen \
267         memcmp memcpy memcpy_ulong memmove memset \
268         memset_ulong mkstemp setenv setlocale setsid snprintf strchr \
269         strerror strftime strncasecmp strcoll strtod strtoul \
270         system tmpfile towlower towupper tzset usleep wcrtomb \
271         wcscoll wctype)
272 dnl this check is for both mbrtowc and the mbstate_t type, which is good
273 AC_FUNC_MBRTOWC
274
275 dnl check for dynamic linking
276 dnl This is known to be very primitive
277 AC_CHECK_HEADER(dlfcn.h,
278         [AC_DEFINE([DYNAMIC], 1, [dynamic loading is possible])
279         if test "$GCC" = yes
280         then
281                 # Add others here as appropriate,
282                 # one day use GNU libtool.
283                 # 3/2010: Used to have cygwin here but removed since
284                 # we get complaints that -export-dynamic doesn't work.
285                 if uname | $EGREP -i 'linux|freebsd' > /dev/null
286                 then
287                         LDFLAGS="$LDFLAGS -export-dynamic"
288                 fi
289         fi
290
291         # Check this separately. Some systems have dlopen
292         # in libc. Notably freebsd and cygwin.
293         # HP-NSK has it in zrldsrl
294         AC_SEARCH_LIBS(dlopen, dl zrldsrl)
295 ])
296
297 dnl check for how to use getpgrp
298 dnl have to hardwire it for VMS POSIX. Sigh.
299 dnl ditto for BeOS, OS/2, and MS-DOS.
300 case `(uname) 2> /dev/null` in
301 *VMS*|*BeOS*|*OS/2*|*MS-DOS*)
302         AC_DEFINE(GETPGRP_VOID, 1,
303           [Define to 1 if the getpgrp function requires zero arguments.])
304         ;;
305 *)      AC_FUNC_GETPGRP
306         ;;
307 esac
308
309 dnl check for printf %F format
310 AC_MSG_CHECKING([for printf %F format])
311 AC_RUN_IFELSE([
312 AC_LANG_SOURCE([
313 #include <stdio.h>
314
315 int main()
316 {
317         char buf[[100]];
318
319         sprintf(buf, "%F", 123.45);
320
321         if (strcmp(buf, "123.450000") == 0)
322                 return 0;
323         else
324                 return 1;
325 }
326 ])],
327         has_f_format=yes,
328         has_f_format=no,
329         has_f_format=no  dnl Cross-compiling, assuming the worst.
330 )
331 if test "$has_f_format" = yes; then
332         AC_DEFINE(PRINTF_HAS_F_FORMAT, 1, [Define to 1 if *printf supports %F format])
333 fi
334 AC_MSG_RESULT($has_f_format)
335
336 dnl check for sockets
337 GAWK_AC_LIB_SOCKETS
338
339 dnl check for readline support
340 GNUPG_CHECK_READLINE
341
342 dnl checks for structure members
343 AC_STRUCT_ST_BLKSIZE
344 AC_HEADER_TIME
345 AC_STRUCT_TM
346 AC_STRUCT_TIMEZONE
347
348 dnl checks for compiler characteristics
349 AC_C_CHAR_UNSIGNED
350 AC_C_CONST
351 AC_C_RESTRICT
352 AC_C_INLINE
353 AC_C_STRINGIZE
354
355 AC_CONFIG_HEADERS([config.h:configh.in])
356 AH_BOTTOM([#include "custom.h"])
357
358 AC_CONFIG_FILES(Makefile
359         awklib/Makefile
360         doc/Makefile
361         po/Makefile.in
362         test/Makefile)
363 AC_OUTPUT