1dnl
2dnl configure.ac --- autoconf input file for gawk
3dnl
4dnl Copyright (C) 1995-2003 the Free Software Foundation, Inc.
5dnl
6dnl This file is part of GAWK, the GNU implementation of the
7dnl AWK Programming Language.
8dnl
9dnl GAWK is free software; you can redistribute it and/or modify
10dnl it under the terms of the GNU General Public License as published by
11dnl the Free Software Foundation; either version 2 of the License, or
12dnl (at your option) any later version.
13dnl
14dnl GAWK is distributed in the hope that it will be useful,
15dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17dnl GNU General Public License for more details.
18dnl
19dnl You should have received a copy of the GNU General Public License
20dnl along with this program; if not, write to the Free Software
21dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
22dnl
23
24dnl Process this file with autoconf to produce a configure script.
25
26dnl *** IMPORTANT ***: Fix version in both AC_INIT and AM_INIT_AUTOMAKE
27AC_INIT([GNU Awk], 3.1.3, bug-gawk@gnu.org, gawk)
28
29# This is a hack. Different versions of install on different systems
30# are just too different. Chuck it and use install-sh.
31#
32# If the user supplies $INSTALL, figure they know what they're doing.
33#
34# With Autoconf 2.5x, this needs to come very early on, but *after*
35# the INIT macro. Sigh.
36
37if test "x$INSTALL" = "x"
38then
39	INSTALL="$srcdir/install-sh -c"
40	export INSTALL
41fi
42
43AC_PREREQ(2.57)
44AC_CONFIG_HEADERS([config.h:configh.in], [cat $srcdir/custom.h >> config.h])
45AM_INIT_AUTOMAKE(gawk, 3.1.3)
46
47dnl Additional argument stuff
48AC_ARG_ENABLE(portals, [  --enable-portals	Enable /p as path prefix for portals],
49	if test "$enableval" = yes
50	then
51		AC_DEFINE(HAVE_PORTALS, 1, [we have portals on /p on this system])
52	fi
53)
54AC_ARG_WITH(whiny-user-strftime, [  --with-whiny-user-strftime	Force use of included version of strftime for deficient systems],
55	if test "$withval" = yes
56	then
57		AC_DEFINE(USE_INCLUDED_STRFTIME, 1,
58			  [force use of our version of strftime])
59	fi
60)
61AC_ARG_ENABLE([lint], [  --disable-lint	Disable gawk lint checking],
62	if test "$enableval" = no
63	then
64		AC_DEFINE(NO_LINT, 1, [disable lint checks])
65	fi
66)
67AC_ARG_ENABLE(switch, [  --enable-switch	Enable switch statements for awk programs],
68	if test "$enableval" = yes
69	then
70		AC_DEFINE(ALLOW_SWITCH, 1, [switch statements are enabled in awk programs])
71	fi
72)
73
74dnl checks for programs
75AC_PROG_EGREP
76AC_PROG_YACC
77AC_PROG_LN_S
78AC_PROG_CC
79AC_PROG_CPP
80AC_PROG_RANLIB
81
82AC_OBJEXT
83AC_EXEEXT
84
85AC_PROG_INSTALL
86
87AC_PROG_MAKE_SET
88
89# This is mainly for my use during testing and development.
90# Yes, it's a bit of a hack.
91AC_MSG_CHECKING([for special development options])
92if test -f $srcdir/.developing
93then
94	# add other debug flags as appropriate, save GAWKDEBUG for emergencies
95	CFLAGS="$CFLAGS -DARRAYDEBUG"
96	# turn on compiler warnings if we're doing development
97	if test "$GCC" = yes
98	then
99		CFLAGS="$CFLAGS -Wall"
100	fi
101	AC_MSG_RESULT([yes])
102else
103	AC_MSG_RESULT([no])
104fi
105
106AC_SUBST(CFLAGS)
107
108dnl checks for systems
109AC_AIX
110AC_ISC_POSIX
111AC_MINIX
112AC_SYS_LARGEFILE
113GAWK_AC_AIX_TWEAK
114GAWK_AC_LINUX_ALPHA
115
116if test "$ISC" = 1	# will be set by test for ISC
117then
118dnl	need -D_SYSV3 for ISC
119	CFLAGS="$CFLAGS -D_SYSV3"
120fi
121
122dnl check for C compiler for automake
123AM_PROG_CC_STDC
124AM_C_PROTOTYPES
125
126dnl Cygwin doesn't like to get libs with full paths
127dnl since that overrides linking against DLLs.
128case `(uname) 2> /dev/null` in
129*CYGWIN*)
130	with_libiconv_prefix=no
131	with_libintl_prefix=no
132	;;
133*)
134	;;
135esac
136
137dnl initialize GNU gettext
138AM_GNU_GETTEXT([no-libtool], [need-ngettext])
139AM_GNU_GETTEXT_VERSION(0.12.1)
140
141dnl checks for header files
142AC_HEADER_STDC
143AC_HEADER_SYS_WAIT
144AC_HEADER_TIME
145AC_CHECK_HEADERS(fcntl.h limits.h locale.h libintl.h mcheck.h \
146	netdb.h netinet/in.h  signum.h stdarg.h string.h \
147	sys/param.h sys/socket.h sys/time.h unistd.h \
148	termios.h stropts.h wchar.h wctype.h)
149
150if test "$ac_cv_header_string_h" = yes
151then
152	AC_CHECK_HEADERS(memory.h)
153else
154	AC_CHECK_HEADERS(strings.h)
155fi
156
157dnl checks for typedefs
158AC_TYPE_PID_T
159AC_TYPE_SIGNAL
160AC_SIZE_T
161AC_TYPE_GETGROUPS
162jm_AC_TYPE_LONG_LONG
163jm_AC_TYPE_UNSIGNED_LONG_LONG
164jm_AC_TYPE_INTMAX_T
165jm_AC_TYPE_UINTMAX_T
166AC_CHECK_TYPE(ssize_t, int)
167AC_EGREP_HEADER([int.*sprintf], stdio.h,
168	AC_DEFINE(SPRINTF_RET, int, [return type of sprintf]),
169	AC_DEFINE(SPRINTF_RET, char *))
170dnl see if time_t is defined in <sys/types.h>
171AC_TRY_COMPILE([#include <sys/types.h>],[
172	time_t foo;
173	foo = 0;
174],
175	AC_DEFINE(TIME_T_IN_SYS_TYPES_H, 1,
176		  [some systems define this type here]))
177
178dnl checks for functions
179AC_DEFINE(REGEX_MALLOC, 1, [use malloc instead of alloca in regex.c])
180AC_FUNC_VPRINTF
181GAWK_AC_FUNC_STRTOD_C89
182AC_FUNC_MKTIME
183case "$ac_cv_func_working_mktime" in
184yes)	AC_DEFINE(HAVE_MKTIME, 1, [we have the mktime function])
185	;;
186esac
187
188AC_CHECK_LIB(m, fmod)
189AC_CHECK_FUNCS(fmod getgrent getgroups grantpt mbrlen mbrtowc memcmp \
190		memcpy memset setlocale snprintf strchr strerror \
191		strftime strncasecmp strtod system tzset wcrtomb wcscoll)
192
193dnl check for dynamic linking
194dnl This is known to be very primitive
195AC_CHECK_HEADER(dlfcn.h,
196	[AC_DEFINE([DYNAMIC], 1, [dynamic loading is possible])
197	if test "$GCC" = yes
198	then
199		# Add others here as appropriate,
200		# one day use GNU libtool.
201		if uname | $EGREP -i 'linux|freebsd|cygwin' > /dev/null
202		then
203			LDFLAGS="$LDFLAGS -export-dynamic"
204		fi
205	fi
206
207	# Check this separately. Some systems have dlopen
208	# in libc. Notably freebsd and cygwin.
209	AC_CHECK_LIB(dl, dlopen)
210])
211
212dnl check for how to use getpgrp
213dnl have to hardwire it for VMS POSIX. Sigh.
214dnl ditto for BeOS, OS/2, and MS-DOS.
215case `(uname) 2> /dev/null` in
216*VMS*|*BeOS*|*OS/2*|*MS-DOS*)
217	AC_DEFINE(GETPGRP_VOID, 1,
218	  [Define to 1 if the getpgrp function requires zero arguments.])
219	;;
220*)	AC_FUNC_GETPGRP
221	;;
222esac
223
224dnl check for sockets
225GAWK_AC_LIB_SOCKETS
226
227dnl checks for structure members
228AC_STRUCT_ST_BLKSIZE
229AC_HEADER_TIME
230AC_STRUCT_TM
231AC_STRUCT_TIMEZONE
232
233dnl checks for compiler characteristics
234AC_C_CHAR_UNSIGNED
235AC_C_CONST
236AC_C_INLINE
237AC_C_STRINGIZE
238
239AC_OUTPUT(Makefile \
240	awklib/Makefile \
241	doc/Makefile \
242	intl/Makefile \
243	po/Makefile.in \
244	test/Makefile)
245