26746: tweak history modifier completion
[zsh.git] / configure.ac
blobfb145ef3e33ddc465bc13a5f0ba5afc84c153a2d
1 dnl
2 dnl  configure.ac: Configure template for zsh.
3 dnl  Process this file with autoconf to produce a configure script.
4 dnl
5 dnl  Copyright (c) 1995-1997 Richard Coleman
6 dnl  All rights reserved.
7 dnl
8 dnl  Permission is hereby granted, without written agreement and without
9 dnl  license or royalty fees, to use, copy, modify, and distribute this
10 dnl  software and to distribute modified versions of this software for any
11 dnl  purpose, provided that the above copyright notice and the following
12 dnl  two paragraphs appear in all copies of this software.
13 dnl
14 dnl  In no event shall Richard Coleman or the Zsh Development Group be liable
15 dnl  to any party for direct, indirect, special, incidental, or consequential
16 dnl  damages arising out of the use of this software and its documentation,
17 dnl  even if Richard Coleman and the Zsh Development Group have been advised of
18 dnl  the possibility of such damage.
19 dnl
20 dnl  Richard Coleman and the Zsh Development Group specifically disclaim any
21 dnl  warranties, including, but not limited to, the implied warranties of
22 dnl  merchantability and fitness for a particular purpose.  The software
23 dnl  provided hereunder is on an "as is" basis, and Richard Coleman and the
24 dnl  Zsh Development Group have no obligation to provide maintenance,
25 dnl  support, updates, enhancements, or modifications.
26 dnl
28 AC_INIT(Src/zsh.h)
29 AC_PREREQ(2.53b)
30 AC_CONFIG_HEADER(config.h)
32 dnl What version of zsh are we building ?
33 . ${srcdir}/Config/version.mk
34 echo "configuring for zsh $VERSION"
36 dnl ----------------------------------------------
37 dnl CHECK FOR MACHINE/VENDOR/OPERATING SYSTEM TYPE
38 dnl ----------------------------------------------
39 dnl Find out machine type, vendor, and operating system
40 dnl What type of host is this?
41 AC_CANONICAL_HOST
42 AC_DEFINE_UNQUOTED(MACHTYPE, "$host_cpu",
43 [Define to be the machine type (microprocessor class or machine model).])
44 AC_DEFINE_UNQUOTED(VENDOR,   "$host_vendor",
45 [Define to be a string corresponding the vendor of the machine.])
46 AC_DEFINE_UNQUOTED(OSTYPE,   "$host_os",
47 [Define to be the name of the operating system.])
49 dnl -----------------------------
50 dnl CHECKING COMMAND LINE OPTIONS
51 dnl -----------------------------
52 dnl Handle --program-prefix, --program-suffix, etc.
53 zsh_ARG_PROGRAM
55 dnl Handle setting of compile flags (CPPFLAGS, CFLAGS, LDFLAGS, LIBS).
56 zsh_COMPILE_FLAGS($CPPFLAGS, $CFLAGS, $LDFLAGS, $LIBS)
58 dnl Do you want to debug zsh?
59 ifdef([zsh-debug],[undefine([zsh-debug])])dnl
60 AH_TEMPLATE([DEBUG],
61 [Define to 1 if you want to debug zsh.])
62 AC_ARG_ENABLE(zsh-debug,
63 AC_HELP_STRING([--enable-zsh-debug], [compile with debug code and debugger symbols]),
64 [if test x$enableval = xyes; then
65   AC_DEFINE(DEBUG)
66 fi])
68 dnl Do you want zsh memory allocation routines.
69 ifdef([zsh-mem],[undefine([zsh-mem])])dnl
70 AH_TEMPLATE([ZSH_MEM],
71 [Define to 1 if you want to use zsh's own memory allocation routines])
72 AC_ARG_ENABLE(zsh-mem,
73 AC_HELP_STRING([--enable-zsh-mem], [compile with zsh memory allocation routines]),
74 [if test x$enableval = xyes; then
75   AC_DEFINE(ZSH_MEM)
76 fi])
78 dnl Do you want to debug zsh memory allocation routines.
79 ifdef([zsh-mem-debug],[undefine([zsh-mem-debug])])dnl
80 AH_TEMPLATE([ZSH_MEM_DEBUG],
81 [Define to 1 if you want to debug zsh memory allocation routines.])
82 AC_ARG_ENABLE(zsh-mem-debug,
83 AC_HELP_STRING([--enable-zsh-mem-debug], [debug zsh memory allocation routines]),
84 [if test x$enableval = xyes; then
85   AC_DEFINE(ZSH_MEM_DEBUG)
86 fi])
88 dnl Do you want to print warnings when errors in memory allocation.
89 AH_TEMPLATE([ZSH_MEM_WARNING],
90 [Define to 1 if you want to turn on warnings of memory allocation errors])
91 ifdef([zsh-mem-warning],[undefine([zsh-mem-warning])])dnl
92 AC_ARG_ENABLE(zsh-mem-warning,
93 AC_HELP_STRING([--enable-zsh-mem-warning], [print warnings for errors in memory allocation]),
94 [if test x$enableval = xyes; then
95   AC_DEFINE(ZSH_MEM_WARNING)
96 fi])
98 dnl Do you want to turn on error checking for free().
99 ifdef([zsh-secure-free],[undefine([zsh-secure-free])])dnl
100 AH_TEMPLATE([ZSH_SECURE_FREE],
101 [Define to 1 if you want to turn on memory checking for free().])
102 AC_ARG_ENABLE(zsh-secure-free,
103 AC_HELP_STRING([--enable-zsh-secure-free], [turn on error checking for free()]),
104 [if test x$enableval = xyes; then
105   AC_DEFINE(ZSH_SECURE_FREE)
106 fi])
108 dnl Do you want debugging information on internal hash tables.
109 dnl This turns on the `hashinfo' builtin command.
110 ifdef([zsh-hash-debug],[undefine([zsh-hash-debug])])dnl
111 AH_TEMPLATE([ZSH_HASH_DEBUG],
112 [Define to 1 if you want to get debugging information on internal
113  hash tables.  This turns on the `hashinfo' builtin.])
114 AC_ARG_ENABLE(zsh-hash-debug,
115 AC_HELP_STRING([--enable-zsh-hash-debug], [turn on debugging of internal hash tables]),
116 [if test x$enableval = xyes; then
117   AC_DEFINE(ZSH_HASH_DEBUG)
118 fi])
120 dnl Pathnames for global zsh scripts
121 ifdef([etcdir],[undefine([etcdir])])dnl
122 AC_ARG_ENABLE(etcdir,
123 AC_HELP_STRING([--enable-etcdir=DIR], [the default directory for global zsh scripts]),
124 [etcdir="$enableval"], [etcdir=/etc])
126 ifdef([zshenv],[undefine([zshenv])])dnl
127 AC_ARG_ENABLE(zshenv,
128 AC_HELP_STRING([--enable-zshenv=FILE], [the full pathname of the global zshenv script]),
129 [zshenv="$enableval"],
130 [if test "x$etcdir" = xno; then
131   zshenv=no
132 else
133   zshenv="$etcdir/zshenv"
134 fi])
135 AH_TEMPLATE([GLOBAL_ZSHENV],
136 [The global file to source absolutely first whenever zsh is run;
137  if undefined, don't source anything.])
138 if test "x$zshenv" != xno; then
139   AC_DEFINE_UNQUOTED(GLOBAL_ZSHENV, "$zshenv")
142 ifdef([zshrc],[undefine([zshrc])])dnl
143 AC_ARG_ENABLE(zshrc,
144 AC_HELP_STRING([--enable-zshrc=FILE], [the full pathname of the global zshrc script]),
145 [zshrc="$enableval"],
146 [if test "x$etcdir" = xno; then
147   zshrc=no
148 else
149   zshrc="$etcdir/zshrc"
150 fi])
151 AH_TEMPLATE([GLOBAL_ZSHRC],
152 [The global file to source whenever zsh is run;
153  if undefined, don't source anything])
154 if test "x$zshrc" != xno; then
155   AC_DEFINE_UNQUOTED(GLOBAL_ZSHRC, "$zshrc")
158 ifdef([zprofile],[undefine([zprofile])])dnl
159 AC_ARG_ENABLE(zprofile,
160 AC_HELP_STRING([--enable-zprofile=FILE], [the full pathname of the global zprofile script]),
161 [zprofile="$enableval"],
162 [if test "x$etcdir" = xno; then
163   zprofile=no
164 else
165   zprofile="$etcdir/zprofile"
166 fi])
167 AH_TEMPLATE([GLOBAL_ZPROFILE],
168 [The global file to source whenever zsh is run as a login shell,
169  before zshrc is read; if undefined, don't source anything.])
170 if test "x$zprofile" != xno; then
171   AC_DEFINE_UNQUOTED(GLOBAL_ZPROFILE, "$zprofile")
174 ifdef([zlogin],[undefine([zlogin])])dnl
175 AC_ARG_ENABLE(zlogin,
176 AC_HELP_STRING([--enable-zlogin=FILE], [the full pathname of the global zlogin script]),
177 [zlogin="$enableval"],
178 [if test "x$etcdir" = xno; then
179   zlogin=no
180 else
181   zlogin="$etcdir/zlogin"
182 fi])
183 AH_TEMPLATE([GLOBAL_ZLOGIN],
184 [The global file to source whenever zsh is run as a login shell;
185  if undefined, don't source anything])
186 if test "x$zlogin" != xno; then
187   AC_DEFINE_UNQUOTED(GLOBAL_ZLOGIN, "$zlogin")
190 ifdef([zlogout],[undefine([zlogout])])dnl
191 AC_ARG_ENABLE(zlogout,
192 AC_HELP_STRING([--enable-zlogout=FILE], [the full pathname of the global zlogout script]),
193 [zlogout="$enableval"],
194 [if test "x$etcdir" = xno; then
195   zlogout=no
196 else
197   zlogout="$etcdir/zlogout"
198 fi])
199 AH_TEMPLATE([GLOBAL_ZLOGOUT],
200 [The global file to source whenever zsh was run as a login shell.
201  This is sourced right before exiting.  If undefined, don't source
202  anything.])
203 if test "x$zlogout" != xno; then
204   AC_DEFINE_UNQUOTED(GLOBAL_ZLOGOUT, "$zlogout")
207 AC_SUBST(zshenv)dnl
208 AC_SUBST(zshrc)dnl
209 AC_SUBST(zprofile)dnl
210 AC_SUBST(zlogin)dnl
211 AC_SUBST(zlogout)dnl
213 dnl Do you want dynamically loaded binary modules.
214 ifdef([dynamic],[undefine([dynamic])])dnl
215 AC_ARG_ENABLE(dynamic,
216 AC_HELP_STRING([--disable-dynamic], [turn off dynamically loaded binary modules]),
217 [dynamic="$enableval"], [dynamic=yes])
219 dnl Do you want to disable restricted on r* commands
220 ifdef([restricted-r],[undefine([restricted-r])])dnl
221 AH_TEMPLATE([RESTRICTED_R],
222 [Undefine this if you don't want to get a restricted shell
223  when zsh is exec'd with basename that starts with r.
224  By default this is defined.])
225 AC_ARG_ENABLE(restricted-r,
226 AC_HELP_STRING([--disable-restricted-r], [turn off r* invocation for restricted shell]),
227 [if test x$enableval = xyes; then
228   AC_DEFINE(RESTRICTED_R)
229 fi],
230 AC_DEFINE(RESTRICTED_R)
233 dnl Do you want to disable use of locale functions
234 AH_TEMPLATE([CONFIG_LOCALE],
235 [Undefine if you don't want local features.  By default this is defined.])
236 AC_ARG_ENABLE([locale],
237 AC_HELP_STRING([--disable-locale], [turn off locale features]),
238 [if test x$enableval = xyes; then
239   AC_DEFINE(CONFIG_LOCALE)
240 fi],
241 AC_DEFINE(CONFIG_LOCALE)
244 dnl Do you want to compile as K&R C.
245 AC_ARG_ENABLE(ansi2knr,
246 AC_HELP_STRING([--enable-ansi2knr], [translate source to K&R C before compiling]),
247 [ansi2knr="$enableval"], [ansi2knr=default])
249 ifdef([fndir],[undefine([fndir])])dnl
250 AC_ARG_ENABLE(fndir,
251 AC_HELP_STRING([--enable-fndir=DIR], [the directory in which to install functions]),
252 dnl ${VERSION} to be determined at compile time.
253 [if test x$enableval = xyes; then
254   fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions
255 else
256   fndir="$enableval"
257 fi], [fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions])
259 ifdef([sitefndir],[undefine([sitefndir])])dnl
260 AC_ARG_ENABLE(site-fndir,
261 AC_HELP_STRING([--enable-site-fndir=DIR], [same for site functions (not version specific)]),
262 [if test x$enableval = xyes; then
263   sitefndir=${datadir}/${tzsh_name}/site-functions
264 else
265   sitefndir="$enableval"
266 fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
268 ifdef([function_subdirs],[undefine([function_subdirs])])
269 AC_ARG_ENABLE(function-subdirs,
270 AC_HELP_STRING([--enable-function-subdirs], [install functions in subdirectories]))
272 if test "x${enable_function_subdirs}" != x &&
273   test "x${enable_function_subdirs}" != xno; then
274   FUNCTIONS_SUBDIRS=yes
275 else
276   FUNCTIONS_SUBDIRS=no
279 AC_SUBST(fndir)dnl
280 AC_SUBST(sitefndir)dnl
281 AC_SUBST(FUNCTIONS_SUBDIRS)dnl
283 dnl Directories for scripts such as newuser.
285 ifdef([scriptdir],[undefine([scriptdir])])dnl
286 AC_ARG_ENABLE(scriptdir,
287 AC_HELP_STRING([--enable-scriptdir=DIR], [the directory in which to install scripts]),
288 dnl ${VERSION} to be determined at compile time.
289 [if test x$enableval = xyes; then
290   scriptdir=${datadir}/${tzsh_name}/'${VERSION}'/scripts
291 else
292   scriptdir="$enableval"
293 fi], [scriptdir=${datadir}/${tzsh_name}/'${VERSION}'/scripts])
295 ifdef([sitescriptdir],[undefine([sitescriptdir])])dnl
296 AC_ARG_ENABLE(site-scriptdir,
297 AC_HELP_STRING([--enable-site-scriptdir=DIR], [same for site scripts (not version specific)]),
298 [if test x$enableval = xyes; then
299   sitescriptdir=${datadir}/${tzsh_name}/scripts
300 else
301   sitescriptdir="$enableval"
302 fi], [sitescriptdir=${datadir}/${tzsh_name}/scripts])
304 AC_SUBST(scriptdir)dnl
305 AC_SUBST(sitescriptdir)dnl
307 AH_TEMPLATE([CUSTOM_PATCHLEVEL],
308 [Define to a custom value for the ZSH_PATCHLEVEL parameter])
309 AC_ARG_ENABLE(custom-patchlevel,
310 AC_HELP_STRING([--enable-custom-patchlevel], [set a custom ZSH_PATCHLEVEL value]),
311 [if test x$enableval != x && test x$enableval != xno; then
312   AC_DEFINE_UNQUOTED([CUSTOM_PATCHLEVEL], ["$enableval"])
313 fi])
315 dnl Do you want maildir support?
316 ifdef([maildir_support],[undefine([maildir_support])])dnl
317 AH_TEMPLATE([MAILDIR_SUPPORT],
318 [Define for Maildir support])
319 AC_ARG_ENABLE(maildir-support,
320 AC_HELP_STRING([--enable-maildir-support], [enable maildir support in MAIL and MAILPATH]),
321 [if test x$enableval = xyes; then
322   AC_DEFINE(MAILDIR_SUPPORT)
323 fi])
325 dnl Do you want to set a maximum function depth?
326 ifdef([max_function_depth],[undefine([max_function_depth])])dnl
327 AH_TEMPLATE([MAX_FUNCTION_DEPTH],
328 [Define for function depth limits])
329 AC_ARG_ENABLE(max-function-depth,
330 AC_HELP_STRING([--enable-max-function-depth=MAX], [limit function depth to MAX, default 1000]),
331 [if test x$enableval = xyes; then
332   AC_DEFINE(MAX_FUNCTION_DEPTH, 1000)
333 elif test x$enableval != xno; then
334   AC_DEFINE_UNQUOTED(MAX_FUNCTION_DEPTH, $enableval)
335 fi],
336 [AC_DEFINE(MAX_FUNCTION_DEPTH, 1000)]
339 ifdef([default_readnullcmd],[undefine([default_readnullcmd])])dnl
340 AH_TEMPLATE([DEFAULT_READNULLCMD],
341 [Define default pager used by readnullcmd])
342 AC_ARG_ENABLE(readnullcmd,
343 AC_HELP_STRING([--enable-readnullcmd=PAGER], [pager used when READNULLCMD is not set]),
344 [if test x$enableval = xyes; then
345   AC_DEFINE(DEFAULT_READNULLCMD,"more")
346 elif test x$enableval != xno; then
347   AC_DEFINE_UNQUOTED(DEFAULT_READNULLCMD,"$enableval")
348 fi],
349 [AC_DEFINE(DEFAULT_READNULLCMD,"more")]
352 dnl Do you want to look for pcre support?
353 AC_ARG_ENABLE(pcre,
354 AC_HELP_STRING([--enable-pcre],
355 [enable the search for the pcre library (may create run-time library dependencies)]))
357 dnl Do you want to look for capability support?
358 AC_ARG_ENABLE(cap,
359 AC_HELP_STRING([--enable-cap],
360 [enable the search for POSIX capabilities (may require additional headers to be added by hand)]))
362 AC_ARG_ENABLE(gdbm,
363 AC_HELP_STRING([--disable-gdbm], [turn off search for gdbm library]),
364 [gdbm="$enableval"], [gdbm=yes])
366 dnl ------------------
367 dnl CHECK THE COMPILER
368 dnl ------------------
369 dnl We want these before the checks, so the checks can modify their values.
370 test -z "${CFLAGS+set}"  && CFLAGS=  auto_cflags=1
371 test -z "${LDFLAGS+set}" && LDFLAGS= auto_ldflags=1
373 AC_PROG_CC
375 dnl Check for large file support.
377 dnl Gross hack for ReliantUNIX - GCC does not understand getconf options
378 dnl For now just disable LFS in this case
379 dnl Any takers?
380 if test "$host" = mips-sni-sysv4 && test -n "$GCC"; then
381   : 
382 else
383   AC_SYS_LARGEFILE
386 dnl if the user hasn't specified CFLAGS, then
387 dnl   if compiler is gcc, then use -O2 and some warning flags
388 dnl   else use -O
389 if test -n "$auto_cflags" && test ."$ansi2knr" != .yes; then
390   if test "${enable_zsh_debug}" = yes; then
391     if test -n "$GCC"; then
392       CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -ggdb"
393     else
394       CFLAGS="$CFLAGS -g"
395     fi
396   else
397     if test -n "$GCC"; then
398       CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -O2"
399     else
400       CFLAGS="$CFLAGS -O"
401     fi
402   fi
404 if test -n "$auto_ldflags"; then
405   case "${enable_zsh_debug}$host_os" in
406     yesaix*|yeshpux*|yesnetbsd*|yesopenbsd*) ;;  # "ld -g" is not valid on these systems
407     darwin*) LDFLAGS=-Wl,-x ;;
408     yes*)    LDFLAGS=-g ;;
409     *)       LDFLAGS=-s ;;
410   esac
413 dnl ----------
414 dnl SCO KLUDGE
415 dnl ----------
416 dnl Sco doesn't define any useful compiler symbol,
417 dnl so we will check for sco and define __sco if
418 dnl found.
419 case "$host_os" in
420   sco*) CFLAGS="-D__sco $CFLAGS" ;;
421 esac
423 sed=':1
424      s/ -s / /g
425      t1
426      s/^ *//
427      s/ *$//'
429 case " $LDFLAGS " in
430   *" -s "*) strip_exeldflags=true strip_libldflags=true
431     LDFLAGS=`echo " $LDFLAGS " | sed "$sed"` ;;
432   *) strip_exeldflags=false strip_libldflags=false ;;
433 esac
435 case " ${EXELDFLAGS+$EXELDFLAGS }" in
436   " ") ;;
437   *" -s "*) strip_exeldflags=true
438     EXELDFLAGS=`echo " $EXELDFLAGS " | sed "$sed"` ;;
439   *) strip_exeldflags=false ;;
440 esac
442 case " ${LIBLDFLAGS+$LIBLDFLAGS }" in
443   " ") ;;
444   *" -s "*) strip_libldflags=true
445     LIBLDFLAGS=`echo " $LIBLDFLAGS " | sed "$sed"` ;;
446   *) strip_libldflags=false ;;
447 esac
449 AC_SUBST(CFLAGS)dnl
450 AC_SUBST(LDFLAGS)dnl
451 AC_SUBST(EXELDFLAGS)dnl
452 AC_SUBST(LIBLDFLAGS)dnl
454 AC_PROG_CPP                 dnl Figure out how to run C preprocessor.
455 AC_PROG_GCC_TRADITIONAL     dnl Do we need -traditional flag for gcc.
456 AC_C_CONST                  dnl Does compiler support `const'.
458 dnl Default preprocessing on Mac OS X produces warnings
459 case "$host_os" in
460   darwin*) CPP="$CPP -traditional-cpp" ;;
461 esac
463 fp_PROG_CC_STDC
464 AC_MSG_CHECKING([whether to use prototypes])
465 if test ."$ansi2knr" = .yes || test ."$ansi2knr" = .no; then
466   msg="(overridden) "
467 else
468   msg=
469   if test ."$fp_cv_prog_cc_stdc" = .no; then
470     ansi2knr=yes
471   else
472     ansi2knr=no
473   fi
475 AH_TEMPLATE([PROTOTYPES],
476 [Define to 1 if ANSI function prototypes are usable.])
477 if test "$ansi2knr" = yes; then
478   AC_MSG_RESULT(${msg}no)
479   U=_
480 else
481   AC_MSG_RESULT(${msg}yes)
482   AC_DEFINE(PROTOTYPES)
483   U=
485 AC_SUBST(U)
487 AC_FUNC_ALLOCA              dnl Check how to get `alloca'.
489 dnl If the compiler supports union initialisation
490 AC_CACHE_CHECK(if the compiler supports union initialisation,
491 zsh_cv_c_have_union_init,
492 [AC_TRY_COMPILE([union{void *p;long l;}u={0};], [u.l=1;],
493   zsh_cv_c_have_union_init=yes,
494   zsh_cv_c_have_union_init=no)])
495 AH_TEMPLATE([HAVE_UNION_INIT],
496 [Define to 1 if the compiler can initialise a union.])
497 if test x$zsh_cv_c_have_union_init = xyes; then
498   AC_DEFINE(HAVE_UNION_INIT)
501 dnl  Checking if compiler correctly cast signed to unsigned.
502 AC_CACHE_CHECK(if signed to unsigned casting is broken,
503 zsh_cv_c_broken_signed_to_unsigned_casting,
504 [AC_TRY_RUN([main(){return((int)(unsigned char)((char) -1) == 255);}],
505   zsh_cv_c_broken_signed_to_unsigned_casting=yes,
506   zsh_cv_c_broken_signed_to_unsigned_casting=no,
507   zsh_cv_c_broken_signed_to_unsigned_casting=no)])
508 AH_TEMPLATE([BROKEN_SIGNED_TO_UNSIGNED_CASTING],
509 [Define to 1 if compiler incorrectly cast signed to unsigned.])
510 if test x$zsh_cv_c_broken_signed_to_unsigned_casting = xyes; then
511   AC_DEFINE(BROKEN_SIGNED_TO_UNSIGNED_CASTING)
514 dnl Checking if the compiler supports variable-length arrays
515 AC_CACHE_CHECK(if the compiler supports variable-length arrays,
516 zsh_cv_c_variable_length_arrays,
517 [AC_TRY_COMPILE([int foo(), n;], [int i[foo()], a[n+1];],
518   zsh_cv_c_variable_length_arrays=yes,
519   zsh_cv_c_variable_length_arrays=no)])
520 AH_TEMPLATE([HAVE_VARIABLE_LENGTH_ARRAYS],
521 [Define to 1 if compiler supports variable-length arrays])
522 if test x$zsh_cv_c_variable_length_arrays = xyes; then
523   AC_DEFINE(HAVE_VARIABLE_LENGTH_ARRAYS)
526 dnl ------------------
527 dnl CHECK FOR PROGRAMS
528 dnl ------------------
529 AC_PROG_MAKE_SET            dnl Does make define $MAKE
530 AC_PROG_INSTALL             dnl Check for BSD compatible `install'
531 AC_PROG_AWK                 dnl Check for mawk,gawk,nawk, then awk.
532 AC_PROG_LN                  dnl Check for working ln, for "make install"
533 AC_PROG_EGREP               dnl sets $EGREP to grep -E or egrep
534 AC_CHECK_PROGS([YODL], [yodl], [: yodl])
535 AC_CHECK_PROGS([PDFETEX], [pdfetex], [: pdfetex])
536 AC_CHECK_PROGS([TEXI2PDF], [texi2pdf], [])
537 AC_CHECK_PROGS([ANSI2KNR], [ansi2knr], [: ansi2knr])
539 if test x"$ansi2knr" = xyes && test x"$ANSI2KNR" = x": ansi2knr"; then
540     echo "----------"
541     echo "configure fatal error:"
542     echo "ansi2knr was specified (--enable-ansi2knr) but the program could not be found."
543     echo "Either remove the configure option if it is not required or build the ansi2knr"
544     echo "program before reconfiguring Zsh.  The source code for ansi2knr is also"
545     echo "available in the GPL directory on Zsh distribution sites."
546     exit 1
549 dnl ------------------
550 dnl CHECK HEADER FILES
551 dnl ------------------
552 AC_HEADER_DIRENT
553 AC_HEADER_STDC
554 AC_HEADER_TIME
555 AC_HEADER_STAT
556 AC_HEADER_SYS_WAIT
558 oldcflags="$CFLAGS"
559 if test x$enable_pcre = xyes; then
560 AC_CHECK_PROG([PCRECONF], pcre-config, pcre-config)
561 dnl Typically (meaning on this single RedHat 9 box in front of me)
562 dnl pcre-config --cflags produces a -I output which needs to go into
563 dnl CPPFLAGS else configure's preprocessor tests don't pick it up,
564 dnl producing a warning.
565 if test "x$ac_cv_prog_PCRECONF" = xpcre-config; then
566   CPPFLAGS="$CPPFLAGS `pcre-config --cflags`"
570 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/select.h termcap.h termio.h \
571                  termios.h sys/param.h sys/filio.h string.h memory.h \
572                  limits.h fcntl.h libc.h sys/utsname.h sys/resource.h \
573                  locale.h errno.h stdio.h stdarg.h varargs.h stdlib.h \
574                  unistd.h sys/capability.h \
575                  utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \
576                  netinet/in_systm.h pcre.h langinfo.h wchar.h stddef.h \
577                  sys/stropts.h iconv.h ncurses.h ncursesw/ncurses.h \
578                  ncurses/ncurses.h)
579 if test x$dynamic = xyes; then
580   AC_CHECK_HEADERS(dlfcn.h)
581   AC_CHECK_HEADERS(dl.h)
584 dnl Some SCO systems cannot include both sys/time.h and sys/select.h
585 AH_TEMPLATE([TIME_H_SELECT_H_CONFLICTS],
586 [Define if sys/time.h and sys/select.h cannot be both included.])
587 if test x$ac_cv_header_sys_time_h = xyes && test x$ac_cv_header_sys_select_h = xyes; then
588   AC_CACHE_CHECK(for conflicts in sys/time.h and sys/select.h,
589   zsh_cv_header_time_h_select_h_conflicts,
590   [AC_TRY_COMPILE([#include <sys/time.h>
591 #include <sys/select.h>], [int i;],
592   zsh_cv_header_time_h_select_h_conflicts=no,
593   zsh_cv_header_time_h_select_h_conflicts=yes)])
594   if test x$zsh_cv_header_time_h_select_h_conflicts = xyes; then
595     AC_DEFINE(TIME_H_SELECT_H_CONFLICTS)
596   fi
599 AH_TEMPLATE([GWINSZ_IN_SYS_IOCTL],
600 [Define if TIOCGWINSZ is defined in sys/ioctl.h but not in termios.h.])
601 if test x$ac_cv_header_termios_h = xyes; then
602   AC_CACHE_CHECK(TIOCGWINSZ in termios.h,
603   zsh_cv_header_termios_h_tiocgwinsz,
604   [AC_TRY_LINK([
605 #ifdef HAVE_SYS_TYPES_H
606 # include <sys/types.h>
607 #endif
608 #include <termios.h>],
609   [int x = TIOCGWINSZ;],
610   zsh_cv_header_termios_h_tiocgwinsz=yes,
611   zsh_cv_header_termios_h_tiocgwinsz=no)])
612 else
613   zsh_cv_header_termios_h_tiocgwinsz=no
615 if test x$zsh_cv_header_termios_h_tiocgwinsz = xno; then
616   AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h,
617   zsh_cv_header_sys_ioctl_h_tiocgwinsz,
618   [AC_TRY_LINK([
619 #ifdef HAVE_SYS_TYPES_H
620 # include <sys/types.h>
621 #endif
622 #include <sys/ioctl.h>],
623   [int x = TIOCGWINSZ;],
624   zsh_cv_header_sys_ioctl_h_tiocgwinsz=yes,
625   zsh_cv_header_sys_ioctl_h_tiocgwinsz=no)])
626   if test x$zsh_cv_header_sys_ioctl_h_tiocgwinsz = xyes; then
627     AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
628   fi
631 AH_TEMPLATE([WINSIZE_IN_PTEM],
632 [Define if your should include sys/stream.h and sys/ptem.h.])
633 AC_CACHE_CHECK(for streams headers including struct winsize,
634 ac_cv_winsize_in_ptem,
635 [AC_TRY_COMPILE([#include <sys/stream.h>
636 #include <sys/ptem.h>],
637 [struct winsize wsz],
638 ac_cv_winsize_in_ptem=yes,
639 ac_cv_winsize_in_ptem=no)])
640 if test x$ac_cv_winsize_in_ptem = xyes; then
641   AC_DEFINE(WINSIZE_IN_PTEM)
644 dnl -------------------
645 dnl CHECK FOR LIBRARIES
646 dnl -------------------
648 dnl On some systems, modules need to be linked against libc explicitly,
649 dnl in case they require objects that exist only in the static version
650 dnl and might not be compiled into the zsh executable.
651 dnl On ReliantUNIX -lc better be the last library, else funny things
652 dnl may happen.
653 AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"])
655 AC_CHECK_LIB(m, pow)
657 dnl Various features of ncurses depend on having the right header
658 dnl (the system's own curses.h may well not be good enough).
659 dnl So don't search for ncurses unless we found the header.
660 if test x$ac_cv_header_ncurses_h = xyes || test x$ac_cv_header_ncurses_ncurses_h = xyes || test x$ac_cv_header_ncursesw_ncurses_h = xyes; then
661   ncursesw_test=ncursesw
662   ncurses_test=ncurses
663 else
664   ncursesw_test=
665   ncurses_test=
668 dnl Prefer BSD termcap library to SysV curses library, except on certain
669 dnl SYSV-derived systems.  However, if we find terminfo and termcap
670 dnl stuff in the same library we will use that; typically this
671 dnl is ncurses or curses.
672 dnl On HPUX, Hcurses is reported to work better than curses.
673 dnl Prefer ncurses to curses on all systems.  tinfo isn't very common now.
674 AC_ARG_WITH(term-lib,
675 AC_HELP_STRING([--with-term-lib=LIBS], [search space-separated LIBS for terminal handling]),
676 [if test "x$withval" != xno && test "x$withval" != x ; then
677   termcap_curses_order="$withval"
678   AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order])
679 else
680   termcap_curses_order="$ncursesw_test tinfo termcap $ncurses_test curses"
681 fi],
682 [case "$host_os" in
683   hpux10.*|hpux11.*|solaris*)
684    termcap_curses_order="Hcurses $ncursesw_test $ncurses_test curses termcap" ;;
685   *)
686    termcap_curses_order="$ncursesw_test tinfo termcap $ncurses_test curses" ;;
687 esac])dnl
689 AH_TEMPLATE([ZSH_NO_XOPEN],
690 [Define if _XOPEN_SOURCE_EXTENDED should not be defined to avoid clashes])
691 AC_CACHE_CHECK(if _XOPEN_SOURCE_EXTENDED should not be defined,
692 zsh_cv_no_xopen,
693 [[case "$host_os" in
694   *openbsd*|*freebsd5*|*freebsd6.[012]*|*aix*)
695   zsh_cv_no_xopen=yes
696   ;;
697   *)
698   zsh_cv_no_xopen=no
699   ;;
700 esac]])
701 if test x$zsh_cv_no_xopen = xyes; then
702   AC_DEFINE(ZSH_NO_XOPEN)
705 dnl Check for tigetflag (terminfo) before tgetent (termcap).
706 dnl That's so that on systems where termcap and [n]curses are
707 dnl both available and both contain termcap functions, while
708 dnl only [n]curses contains terminfo functions, we only link against
709 dnl [n]curses.
710 AC_SEARCH_LIBS(tigetflag, [$termcap_curses_order])
711 AC_SEARCH_LIBS(tgetent, [$termcap_curses_order],
712   true,
713   AC_MSG_FAILURE(["No terminal handling library was found on your system.
714 This is probably a library called 'curses' or 'ncurses'.  You may
715 need to install a package called 'curses-devel' or 'ncurses-devel' on your
716 system."], 255))
717 AC_CHECK_HEADERS(curses.h, [],
718 [AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris,
719 AC_TRY_COMPILE([#include <curses.h>], [],
720 [ac_cv_header_curses_h=yes
721 ac_cv_header_curses_solaris=yes],
722 ac_cv_header_curses_h=no
723 ac_cv_header_curses_solaris=no))
724 if test x$ac_cv_header_curses_solaris = xyes; then
725 AC_DEFINE(HAVE_CURSES_H)
726 fi])
728 dnl If our terminal library is not ncurses, don't try including
729 dnl any ncurses headers.
730 AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses,
731 [case $LIBS in
732   *-lncurses*)
733   zsh_cv_ignore_ncurses=no
734   ;;
735   *)
736   zsh_cv_ignore_ncurses=yes
737   ;;
738 esac])
740 AC_SEARCH_LIBS(getpwnam, nsl)
742 dnl I am told that told that unicos reqire these for nis_list
743 if test `echo $host_os | sed 's/^\(unicos\).*/\1/'` = unicos; then
744   LIBS="-lcraylm -lkrb -lnisdb -lnsl -lrpcsvc $LIBS"
747 if test "x$dynamic" = xyes; then
748   AC_CHECK_LIB(dl, dlopen)
751 if test x$enable_cap = xyes; then
752   AC_CHECK_LIB(cap, cap_get_proc)
755 AC_CHECK_LIB(socket, socket)
756 AC_CHECK_LIB(bind, gethostbyname2)
758 case $LIBS in
759   *-lbind*)
760   AC_CHECK_HEADERS(bind/netdb.h)
761   ;;
762 esac
764 dnl ---------------
765 dnl CHECK FOR ICONV
766 dnl ---------------
768 dnl Find iconv. It may be in libiconv and may be iconv() or libiconv()
769 if test "x$ac_cv_header_iconv_h" = "xyes"; then
770   AC_CHECK_FUNC(iconv, ac_found_iconv=yes, ac_found_iconv=no)
771   if test "x$ac_found_iconv" = "xno"; then
772     AC_CHECK_LIB(iconv, iconv, ac_found_iconv=yes)
773     if test "x$ac_found_iconv" = "xno"; then
774       AC_CHECK_LIB(iconv, libiconv, ac_found_iconv=yes)
775     fi
776     if test "x$ac_found_iconv" != "xno"; then
777       LIBS="-liconv $LIBS"
778     fi
779   else
780     dnl Handle case where there is a native iconv but iconv.h is from libiconv
781     AC_CHECK_DECL(_libiconv_version,
782       [ AC_CHECK_LIB(iconv, libiconv, LIBS="-liconv $LIBS") ],,
783       [ #include <iconv.h> ])
784   fi
786 AH_TEMPLATE([ICONV_FROM_LIBICONV],
787 [Define to 1 if iconv() is linked from libiconv])
788 if test "x$ac_found_iconv" = xyes; then
789   AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
790   AC_TRY_LINK([#include <iconv.h>],
791     [int myversion = _libiconv_version],
792     AC_DEFINE(ICONV_FROM_LIBICONV), )
795 dnl Check if iconv uses const in prototype declaration
796 if test "x$ac_found_iconv" = "xyes"; then
797   AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const,
798     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
799         #include <iconv.h>]],
800         [[#ifdef __cplusplus
801           "C"
802           #endif
803           #if defined(__STDC__) || defined(__cplusplus)
804           size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
805           #else
806           size_t iconv();
807           #endif]])],
808       [ac_cv_iconv_const=],
809       [ac_cv_iconv_const=const])])
810   AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const,
811     [Define as const if the declaration of iconv() needs const.])
814 if test x$enable_pcre = xyes; then
815 dnl pcre-config should probably be employed here
816 dnl AC_SEARCH_LIBS(pcre_compile, pcre)
817   LIBS="`pcre-config --libs` $LIBS"
820 dnl ---------------------
821 dnl CHECK TERMCAP LIBRARY
822 dnl ---------------------
823 dnl Checks for external variable ospeed in the termcap library.
824 AC_CACHE_CHECK(if an include file defines ospeed,
825 zsh_cv_decl_ospeed_include_defines,
826 [AC_TRY_LINK(
827 [#include <sys/types.h>
828 #if HAVE_TERMIOS_H
829 #include <termios.h>
830 #endif
831 #if HAVE_TERMCAP_H
832 #include <termcap.h>
833 #endif], [ospeed = 0;],
834 zsh_cv_decl_ospeed_include_defines=yes,
835 zsh_cv_decl_ospeed_include_defines=no)])
837 if test x$zsh_cv_decl_ospeed_include_defines = xno; then
838   AC_CACHE_CHECK(if you must define ospeed,
839   zsh_cv_decl_ospeed_must_define,
840   [AC_TRY_LINK( ,[extern short ospeed; ospeed = 0;],
841   zsh_cv_decl_ospeed_must_define=yes,
842   zsh_cv_decl_ospeed_must_define=no)])
845 AH_TEMPLATE([HAVE_OSPEED],
846 [Define to 1 if your termcap library has the ospeed variable])
847 AH_TEMPLATE([MUST_DEFINE_OSPEED],
848 [Define to 1 if you have ospeed, but it is not defined in termcap.h])
849 if test x$zsh_cv_decl_ospeed_include_defines = xyes; then
850   AC_DEFINE(HAVE_OSPEED)
851 elif test x$zsh_cv_decl_ospeed_must_define = xyes; then
852   AC_DEFINE(HAVE_OSPEED)
853   AC_DEFINE(MUST_DEFINE_OSPEED)
856 if test x$gdbm != xno; then
857   AC_CHECK_HEADERS(gdbm.h)
858   AC_CHECK_LIB(gdbm, gdbm_open)
861 AC_CHECK_HEADERS(sys/xattr.h)
863 dnl --------------
864 dnl CHECK TYPEDEFS
865 dnl --------------
867 AC_TYPE_SIGNAL
868 AC_TYPE_PID_T
869 AC_TYPE_OFF_T
870 AC_CHECK_TYPE(ino_t, unsigned long)
871 AC_TYPE_MODE_T
872 AC_TYPE_UID_T
873 AC_TYPE_SIZE_T
875 dnl ------------------------------------------------
876 dnl Check size of long and try to find a 64-bit type
877 dnl ------------------------------------------------
878 dnl AC_CHECK_SIZEOF is no good, because we need the result here,
879 dnl and that doesn't seem to define a shell parameter.
880 AC_CACHE_CHECK(if long is 64 bits, zsh_cv_long_is_64_bit,
881 [AC_TRY_RUN([int main() { return sizeof(long) < 8; }],
882 zsh_cv_long_is_64_bit=yes,
883 zsh_cv_long_is_64_bit=no,
884 zsh_cv_long_is_64_bit=no)])
886 AH_TEMPLATE([ino_t],
887 [Define to `unsigned long' if <sys/types.h> doesn't define.])
888 AH_TEMPLATE([LONG_IS_64_BIT],
889 [Definitions used when a long is less than eight byte, to try to
890  provide some support for eight byte operations.
892  Note that ZSH_64_BIT_TYPE, OFF_T_IS_64_BIT, INO_T_IS_64_BIT do *not* get
893  defined if long is already 64 bits, since in that case no special handling
894  is required.
896  Define to 1 if long is 64 bits])
897 AH_TEMPLATE([ZSH_64_BIT_TYPE],
898 [Define to a 64 bit integer type if there is one, but long is shorter.])
899 AH_TEMPLATE([ZSH_64_BIT_UTYPE],
900 [Define to an unsigned variant of ZSH_64_BIT_TYPE if that is defined.])
901 AH_TEMPLATE([OFF_T_IS_64_BIT],
902 [Define to 1 if off_t is 64 bit (for large file support)])
903 AH_TEMPLATE([INO_T_IS_64_BIT],
904 [Define to 1 if ino_t is 64 bit (for large file support).])
905 if test x$zsh_cv_long_is_64_bit = xyes; then
906   AC_DEFINE(LONG_IS_64_BIT)
907 else
908   AC_CACHE_CHECK(if off_t is 64 bit, zsh_cv_off_t_is_64_bit,
909   [AC_TRY_RUN([
910 #include <sys/types.h>
912 main() { return sizeof(off_t) < 8; }
914   zsh_cv_off_t_is_64_bit=yes,
915   zsh_cv_off_t_is_64_bit=no,
916   zsh_cv_off_t_is_64_bit=no)])
917   if test x$zsh_cv_off_t_is_64_bit = xyes; then
918     AC_DEFINE(OFF_T_IS_64_BIT)
919   fi
921   AC_CACHE_CHECK(if ino_t is 64 bit, zsh_cv_ino_t_is_64_bit,
922   [AC_TRY_RUN([
923 #include <sys/types.h>
925 main() { return sizeof(ino_t) < 8; }
927   zsh_cv_ino_t_is_64_bit=yes,
928   zsh_cv_ino_t_is_64_bit=no,
929   zsh_cv_ino_t_is_64_bit=no)])
930   if test x$zsh_cv_ino_t_is_64_bit = xyes; then
931     AC_DEFINE(INO_T_IS_64_BIT)
932   fi
934   if test x$enable_largefile != xno -o x$zsh_cv_off_t_is_64_bit = xyes \
935   -o $zsh_cv_ino_t_is_64_bit = yes; then
936     AC_CACHE_CHECK(if compiler has a 64 bit type, zsh_cv_64_bit_type,
937     [zsh_64_BIT_TYPE(long long, zsh_cv_64_bit_type)
938      if test "$zsh_cv_64_bit_type" = no; then
939        zsh_64_BIT_TYPE(quad_t, zsh_cv_64_bit_type)
940      fi
941      if test "$zsh_cv_64_bit_type" = no; then
942        zsh_64_BIT_TYPE(__int64_t, zsh_cv_64_bit_type)
943      fi
944      dnl As a last resort, if we know off_t has 64 bits, use that as
945      dnl the 64-bit integer type.  I don't dare try ino_t since there's
946      dnl probably nothing to stop that being unsigned.
947      if test "$zsh_cv_64_bit_type" = no &&
948         test "$zsh_cv_off_t_is_64_bit" = yes; then
949        zsh_64_BIT_TYPE(off_t, zsh_cv_64_bit_type)
950      fi])
951     if test "$zsh_cv_64_bit_type" != no; then
952       AC_DEFINE_UNQUOTED(ZSH_64_BIT_TYPE, $zsh_cv_64_bit_type)
954       dnl Handle cases where unsigned type cannot be simply
955       dnl `unsigned ZSH_64_BIT_TYPE'.  More tests may be required.
956       AC_CACHE_CHECK(for a corresponding unsigned 64 bit type,
957       zsh_cv_64_bit_utype,
958       [zsh_64_BIT_TYPE(unsigned $zsh_cv_64_bit_type, zsh_cv_64_bit_utype,
959        force)
960        if test "$zsh_cv_64_bit_utype" = no; then
961          zsh_64_BIT_TYPE(__uint64_t, zsh_cv_64_bit_utype)
962        fi])
963       if test "$zsh_cv_64_bit_utype" != no; then
964         AC_DEFINE_UNQUOTED(ZSH_64_BIT_UTYPE, $zsh_cv_64_bit_utype)
965       fi
966     fi
967   fi
970 dnl Check for sigset_t.  Currently I'm looking in
971 dnl <sys/types.h> and <signal.h>.  Others might need
972 dnl to be added.
973 AC_CACHE_CHECK(for sigset_t, zsh_cv_type_sigset_t,
974 [AC_TRY_COMPILE(
975 [#include <sys/types.h>
976 #include <signal.h>], [sigset_t tempsigset;],
977   zsh_cv_type_sigset_t=yes, zsh_cv_type_sigset_t=no)])
978 AH_TEMPLATE([sigset_t],
979 [Define to `unsigned int' if <sys/types.h> or <signal.h> doesn't define])
980 if test x$zsh_cv_type_sigset_t = xno; then
981   AC_DEFINE(sigset_t, unsigned int)
984 dnl check structures for high resolution timestamps
985 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec,
986                   struct stat.st_atimespec.tv_nsec,
987                   struct stat.st_atimensec,
988                   struct stat.st_mtim.tv_nsec,
989                   struct stat.st_mtimespec.tv_nsec,
990                   struct stat.st_mtimensec,
991                   struct stat.st_ctim.tv_nsec,
992                   struct stat.st_ctimespec.tv_nsec,
993                   struct stat.st_ctimensec])
995 dnl Check for struct timezone since some old SCO versions do not define it
996 zsh_TYPE_EXISTS([
997 #ifdef HAVE_SYS_TIME_H
998 # include <sys/time.h>
999 #endif
1000 ], struct timezone)
1002 dnl Check for utmp structures, for watch
1003 zsh_TYPE_EXISTS([
1004 #ifdef HAVE_SYS_TYPES_H
1005 # include <sys/types.h>
1006 #endif
1007 #ifdef HAVE_UTMP_H
1008 # include <utmp.h>
1009 #endif
1010 ], struct utmp)
1011 zsh_TYPE_EXISTS([
1012 #ifdef HAVE_SYS_TYPES_H
1013 # include <sys/types.h>
1014 #endif
1015 #ifdef HAVE_UTMPX_H
1016 # include <utmpx.h>
1017 #endif
1018 ], struct utmpx)
1020 dnl Check contents of utmp structures
1021 zsh_STRUCT_MEMBER([
1022 #ifdef HAVE_SYS_TYPES_H
1023 # include <sys/types.h>
1024 #endif
1025 #ifdef HAVE_UTMP_H
1026 # include <utmp.h>
1027 #endif
1028 ], struct utmp, ut_host)
1029 zsh_STRUCT_MEMBER([
1030 #ifdef HAVE_SYS_TYPES_H
1031 # include <sys/types.h>
1032 #endif
1033 #ifdef HAVE_UTMPX_H
1034 # include <utmpx.h>
1035 #endif
1036 ], struct utmpx, ut_host)
1037 zsh_STRUCT_MEMBER([
1038 #ifdef HAVE_SYS_TYPES_H
1039 # include <sys/types.h>
1040 #endif
1041 #ifdef HAVE_UTMPX_H
1042 # include <utmpx.h>
1043 #endif
1044 ], struct utmpx, ut_xtime)
1045 zsh_STRUCT_MEMBER([
1046 #ifdef HAVE_SYS_TYPES_H
1047 # include <sys/types.h>
1048 #endif
1049 #ifdef HAVE_UTMPX_H
1050 # include <utmpx.h>
1051 #endif
1052 ], struct utmpx, ut_tv)
1054 dnl Check for inode numbers in directory entry structures
1055 zsh_STRUCT_MEMBER([
1056 #ifdef HAVE_SYS_TYPES_H
1057 # include <sys/types.h>
1058 #endif
1059 #ifdef HAVE_DIRENT_H
1060 # include <dirent.h>
1061 #endif
1062 ], struct dirent, d_ino)
1063 zsh_STRUCT_MEMBER([
1064 #ifdef HAVE_SYS_TYPES_H
1065 # include <sys/types.h>
1066 #endif
1067 #ifdef HAVE_DIRENT_H
1068 # include <dirent.h>
1069 #endif
1070 ], struct dirent, d_stat)
1071 zsh_STRUCT_MEMBER([
1072 #ifdef HAVE_SYS_TYPES_H
1073 # include <sys/types.h>
1074 #endif
1075 #ifdef HAVE_SYS_NDIR_H
1076 # include <sys/ndir.h>
1077 #endif
1078 #ifdef HAVE_SYS_DIR_H
1079 # include <sys/dir.h>
1080 #endif
1081 #ifdef HAVE_NDIR_H
1082 # include <ndir.h>
1083 #endif
1084 ], struct direct, d_ino)
1085 zsh_STRUCT_MEMBER([
1086 #ifdef HAVE_SYS_TYPES_H
1087 # include <sys/types.h>
1088 #endif
1089 #ifdef HAVE_SYS_NDIR_H
1090 # include <sys/ndir.h>
1091 #endif
1092 #ifdef HAVE_SYS_DIR_H
1093 # include <sys/dir.h>
1094 #endif
1095 #ifdef HAVE_NDIR_H
1096 # include <ndir.h>
1097 #endif
1098 ], struct direct, d_stat)
1100 dnl Check IPv6 socket address structure type
1101 zsh_STRUCT_MEMBER([
1102 #ifdef HAVE_SYS_TYPES_H
1103 # include <sys/types.h>
1104 #endif
1105 #include <netinet/in.h>
1106 ], struct sockaddr_in6, sin6_scope_id)
1108 dnl Check for h_errno external variable
1109 AH_TEMPLATE([USE_LOCAL_H_ERRNO],
1110 [Define to 1 if h_errno is not defined by the system.])
1111 AC_CACHE_CHECK(if we need our own h_errno,
1112   zsh_cv_decl_h_errno_use_local,
1113   [AC_TRY_LINK( ,[extern int h_errno; h_errno = 0;],
1114   zsh_cv_decl_h_errno_use_local=no,
1115   zsh_cv_decl_h_errno_use_local=yes)])
1117 if test x$zsh_cv_decl_h_errno_use_local = xyes; then
1118   AC_DEFINE(USE_LOCAL_H_ERRNO)
1121 dnl ---------------
1122 dnl CHECK FUNCTIONS
1123 dnl ---------------
1125 dnl need to integrate this function
1126 dnl AC_FUNC_STRFTIME
1128 AC_CHECK_FUNCS(strftime strptime mktime timelocal \
1129                difftime gettimeofday \
1130                select poll \
1131                readlink faccessx fchdir ftruncate \
1132                fstat lstat lchown fchown fchmod \
1133                fseeko ftello \
1134                mkfifo _mktemp mkstemp \
1135                waitpid wait3 \
1136                sigaction sigblock sighold sigrelse sigsetmask sigprocmask \
1137                killpg setpgid setpgrp tcsetpgrp tcgetattr nice \
1138                gethostname gethostbyname2 getipnodebyname \
1139                inet_aton inet_pton inet_ntop \
1140                getlogin getpwent getpwnam getpwuid getgrgid getgrnam \
1141                initgroups nis_list \
1142                setuid seteuid setreuid setresuid setsid \
1143                memcpy memmove strstr strerror strtoul \
1144                getrlimit getrusage \
1145                setlocale \
1146                uname \
1147                signgam \
1148                putenv getenv setenv unsetenv xw\
1149                brk sbrk \
1150                pathconf sysconf \
1151                tgetent tigetflag tigetnum tigetstr setupterm initscr \
1152                getcchar setcchar waddwstr wget_wch win_wch use_default_colors \
1153                pcre_compile pcre_study pcre_exec \
1154                nl_langinfo \
1155                erand48 open_memstream \
1156                wctomb iconv \
1157                grantpt unlockpt ptsname \
1158                htons ntohs \
1159                regcomp regexec regerror regfree \
1160                gdbm_open getxattr)
1161 AC_FUNC_STRCOLL
1163 if test x$enable_cap = xyes; then
1164   AC_CHECK_FUNCS(cap_get_proc)
1167 dnl  Check if tgetent accepts NULL (and will allocate its own termcap buffer)
1168 dnl  Some termcaps reportedly accept a zero buffer, but then dump core
1169 dnl  in tgetstr().
1170 dnl  Under Cygwin test program crashes but exit code is still 0. So,
1171 dnl  we test for a file that porgram should create
1172 AH_TEMPLATE([TGETENT_ACCEPTS_NULL],
1173 [Define to 1 if tgetent() accepts NULL as a buffer.])
1174 AC_CACHE_CHECK(if tgetent accepts NULL,
1175 zsh_cv_func_tgetent_accepts_null,
1176 [AC_TRY_RUN([
1177 main()
1179     char buf[4096];
1180     int r1 = tgetent(buf, "vt100");
1181     int r2 = tgetent((char*)0,"vt100");
1182     if (r1 >= 0 && r1 == r2) {
1183         char tbuf[1024], *u;
1184         u = tbuf;
1185         tgetstr("cl", &u);
1186         creat("conftest.tgetent", 0640);
1187     }
1188     exit((r1 != r2) || r2 == -1);
1191   if test -f conftest.tgetent; then
1192     zsh_cv_func_tgetent_accepts_null=yes
1193   else
1194     zsh_cv_func_tgetent_accepts_null=no
1195   fi,
1196   zsh_cv_func_tgetent_accepts_null=no,
1197   zsh_cv_func_tgetent_accepts_null=no)])
1198 if test x$zsh_cv_func_tgetent_accepts_null = xyes; then
1199   AC_DEFINE(TGETENT_ACCEPTS_NULL)
1201 AC_CACHE_CHECK(if tgetent returns 0 on success,
1202 zsh_cv_func_tgetent_zero_success,
1203 [AC_TRY_RUN([
1204 main()
1206     char buf[4096];
1207     int r1 = tgetent(buf, "!@#$%^&*");
1208     int r2 = tgetent(buf, "vt100");
1209     if (r1 < 0 && r2 == 0) {
1210         char tbuf[1024], *u;
1211         u = tbuf;
1212         tgetstr("cl", &u);
1213         creat("conftest.tgetent0", 0640);
1214     }
1215     exit(r1 == r2);
1218   if test -f conftest.tgetent0; then
1219     zsh_cv_func_tgetent_zero_success=yes
1220   else
1221     zsh_cv_func_tgetent_zero_success=no
1222   fi,
1223   zsh_cv_func_tgetent_zero_success=no,
1224   zsh_cv_func_tgetent_zero_success=no)])
1225 AH_TEMPLATE([TGETENT_SUCCESS],
1226 [Define to what tgetent() returns on success (0 on HP-UX X/Open curses).])
1227 if test x$zsh_cv_func_tgetent_zero_success = xyes; then
1228   AC_DEFINE(TGETENT_SUCCESS, 0)
1229 else
1230   AC_DEFINE(TGETENT_SUCCESS, 1)
1233 AC_FUNC_MMAP
1234 if test x$ac_cv_func_mmap_fixed_mapped = xyes; then
1235   AC_CHECK_FUNCS(munmap msync)
1238 if test x$ac_cv_func_setpgrp = xyes; then
1239   AC_FUNC_GETPGRP
1240 else
1241   dnl If there is no setpgrp, the test for getpgrp(void) will fail
1242   dnl because the program will not compile.  However, in that case
1243   dnl we can be reasonably confident we are not dealing with a
1244   dnl Berkeleyesque system, so assume getpgrp does take void.
1245   ac_cv_func_getpgrp_void=yes
1246   AC_DEFINE(GETPGRP_VOID)
1249 if test x$dynamic = xyes; then
1250   AC_CHECK_FUNCS(dlopen dlerror dlsym dlclose load loadquery loadbind unload \
1251                 shl_load shl_unload shl_findsym)
1254 AH_TEMPLATE([XATTR_EXTRA_ARGS],
1255 Define if getxattr() etc. require additional MacOS-style arguments)
1256 if test x$ac_cv_func_getxattr = xyes && test x$ac_cv_header_sys_xattr_h = xyes
1257 then
1258   AC_CACHE_CHECK(if getxattr etc. are Linux-like,
1259   zsh_cv_getxattr_linux,
1260   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1261 #include <sys/xattr.h>]],
1262   [[
1263   (void)listxattr("", 0, 0);
1264   (void)getxattr("", "", 0, 0);
1265   (void)setxattr("", "", "", 0, 0);
1266   (void)removexattr("", "");
1267   ]])],
1268   [zsh_cv_getxattr_linux=yes],
1269   [zsh_cv_getxattr_linux=no])])
1271   if test x$zsh_cv_getxattr_linux != xyes; then
1272     AC_CACHE_CHECK(if getxattr etc. are MAC-like,
1273     zsh_cv_getxattr_mac,
1274     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1275 #include <sys/xattr.h>]],
1276     [[(void)listxattr("", 0, 0, 0);
1277     (void)getxattr("", "", 0, 0, 0, 0);
1278     (void)setxattr("", "", "", 0, 0, 0);
1279     (void)removexattr("", "", 0);]])],
1280     [zsh_cv_getxattr_mac=yes],
1281     [zsh_cv_getxattr_mac=no])])
1283     if test x$zsh_cv_getxattr_mac = xyes; then
1284       AC_DEFINE(XATTR_EXTRA_ARGS)
1285     fi
1286   fi
1289 AC_CACHE_CHECK(if getxattr etc. are usable,
1290 zsh_cv_use_xattr,
1291 [if test x$zsh_cv_getxattr_linux = xyes || test x$zsh_cv_getxattr_mac = xyes
1292 then
1293 zsh_cv_use_xattr=yes
1294 else
1295 zsh_cv_use_xattr=no
1296 fi])
1298 dnl -------------
1299 dnl CHECK SIGNALS
1300 dnl -------------
1301 dnl What style of signal do you have (POSIX, BSD, or SYSV)?
1302 AH_TEMPLATE([POSIX_SIGNALS],
1303 [Define to 1 if you use POSIX style signal handling.])
1304 AH_TEMPLATE([BSD_SIGNALS],
1305 [Define to 1 if you use BSD style signal handling (and can block signals).])
1306 AH_TEMPLATE([SYSV_SIGNALS],
1307 [Define to 1 if you use SYS style signal handling (and can block signals).])
1308 AH_TEMPLATE([NO_SIGNAL_BLOCKING],
1309 [Define to 1 if you have no signal blocking at all (bummer).])
1310 AC_MSG_CHECKING(what style of signals to use)
1311 if test x$ac_cv_func_sigaction = xyes && test x$ac_cv_func_sigprocmask = xyes; then
1312   signals_style=POSIX_SIGNALS
1313   AC_DEFINE(POSIX_SIGNALS)
1314 elif test x$ac_cv_func_sigblock = xyes && test x$ac_cv_func_sigsetmask = xyes; then
1315   signals_style=BSD_SIGNALS
1316   AC_DEFINE(BSD_SIGNALS)
1317 elif test x$ac_cv_func_sighold = xyes && test x$ac_cv_func_sigrelse = xyes; then
1318   signals_style=SYSV_SIGNALS
1319   AC_DEFINE(SYSV_SIGNALS)
1320 else
1321   signals_style=NO_SIGNAL_BLOCKING
1322   AC_DEFINE(NO_SIGNAL_BLOCKING)
1324 AC_DEFINE_UNQUOTED($signals_style)
1325 AC_MSG_RESULT($signals_style)
1327 dnl Where is <signal.h> located?  Needed as input for signals.awk
1328 AC_CACHE_CHECK(where signal.h is located, zsh_cv_path_signal_h,
1329 [dnl Look at the output from the preprocessor.
1330 dnl We should get lines of the form `# 1 "/usr/include/signal.h"'
1331 dnl The following assumes the real definitions are in a file which
1332 dnl contains the name `sig'; we could relax this if necessary,
1333 dnl but then you can get a rather long list of files to test.
1334 dnl The backslash substitution is to persuade cygwin to cough up
1335 dnl slashes rather than doubled backslashes in the path.
1336 echo "#include <signal.h>" > nametmp.c
1337 sigfile_list="`$CPP nametmp.c |
1338 sed -n -e 's/^#line[    ].*\"\(.*\)\"/\1/p' \
1339        -e 's/^#[        ].*\"\(.*\)\"/\1/p' |
1340 sed 's/\\\\\\\\/\//g' |
1341 $AWK '{ if ($1 ~ /sig/) files[[$1]] = $1 }
1342   END { for (var in files) print var }'`"
1343 rm -f nametmp.c
1344 if test -z "$sigfile_list"; then
1345   dnl In case we don't get the stuff from the preprocesor, use the old
1346   dnl list of standard places.
1347   sigfile_list="/usr/include/sys/iso/signal_iso.h
1348 /usr/include/bsd/sys/signal.h
1349 /usr/include/signum.h
1350 /usr/include/asm/signum.h
1351 /usr/include/asm/signal.h
1352 /usr/include/linux/signal.h
1353 /usr/include/sys/signal.h
1354 /usr/include/bits/signum.h
1355 /dev/null"
1357 for SIGNAL_H in $sigfile_list
1359   dnl Try to make sure it doesn't get confused by files that don't
1360   dnl have real signal definitions in, but do #define SIG* by counting
1361   dnl the number of signals.  Maybe we could even check for e.g. SIGHUP?
1362   nsigs=`test -f $SIGNAL_H && \
1363   grep '#[      ]*define[       ][      ]*SIG[0-9A-Z]*[         ]*[0-9][0-9]*' $SIGNAL_H | \
1364   wc -l | sed 's/[      ]//g'`
1365   test "x$nsigs" != x && test "$nsigs" -ge 7 && break
1366 done
1367 if test x$SIGNAL_H = x"/dev/null"; then
1368   AC_MSG_ERROR(SIGNAL MACROS NOT FOUND:  please report to developers)
1370 zsh_cv_path_signal_h=$SIGNAL_H
1372 SIGNAL_H=$zsh_cv_path_signal_h
1373 AC_SUBST(SIGNAL_H)dnl
1375 dnl Where are error names located?  Needed as input for errnames1.awk
1376 AC_CACHE_CHECK(where error names are located, zsh_cv_path_errno_h,
1377 [dnl Look at the output from the preprocessor.
1378 dnl We should get lines of the form `# 1 "/usr/include/errno.h"'
1379 dnl The following assumes the real definitions are in a file which
1380 dnl contains the name `err'; we could relax this if necessary,
1381 dnl but then you can get a rather long list of files to test.
1382 dnl The backslash substitution is to persuade cygwin to cough up
1383 dnl slashes rather than doubled backslashes in the path.
1384 echo "#include <errno.h>" > nametmp.c
1385 errfile_list="`$CPP nametmp.c |
1386 sed -n -e 's/^#line[    ].*\"\(.*\)\"/\1/p' \
1387        -e 's/^#[        0-9].*\"\(.*\)\"/\1/p' |
1388 sed 's/\\\\\\\\/\//g' |
1389 $AWK '{ if ($1 ~ /err/) files[[$1]] = $1 }
1390   END { for (var in files) print var }'`"
1391 rm -f nametmp.c
1392 for ERRNO_TRY_H in $errfile_list /dev/null
1394   dnl Try to make sure it doesn't get confused by files that don't
1395   dnl have real error definitions in.  Count definitions to make sure.
1396   dnl Definitions of error numbers have become more and more general, so
1397   dnl make a list of files containing any definitions in and keep them all.
1398   dnl Careful with cut and paste in the pattern: the square brackets
1399   dnl must contain a space and a tab.
1400   nerrs=`test -f $ERRNO_TRY_H && \
1401   $EGREP '#[    ]*define[       ][      ]*E[0-9A-Z]*[   ]*(_HURD_ERRNO )?\(?[_A-Z0-9]' $ERRNO_TRY_H | \
1402   wc -l | sed 's/[      ]//g'`
1403   if test "x$nerrs" != x && test "$nerrs" -ge 1
1404   then
1405     ERRNO_H="$ERRNO_H $ERRNO_TRY_H"
1406   fi
1407 done
1408 if test x"$ERRNO_H" = x; then
1409   AC_MSG_ERROR(ERROR MACROS NOT FOUND:  please report to developers)
1411 zsh_cv_path_errno_h="$ERRNO_H"
1413 ERRNO_H="$zsh_cv_path_errno_h"
1414 AC_SUBST(ERRNO_H)dnl
1416 AC_CACHE_CHECK(location of curses header, zsh_cv_path_curses_header,
1417 [if test x$zsh_cv_ignore_ncurses = xyes; then
1418   if test x$ac_cv_header_curses_h = xyes; then
1419     zsh_cv_path_curses_header=curses.h
1420   else
1421     zsh_cv_path_curses_header=none
1422   fi
1423 elif test x$ac_cv_header_ncursesw_ncurses_h = xyes; then
1424   zsh_cv_path_curses_header=ncursesw/ncurses.h
1425 elif test x$ac_cv_header_ncurses_ncurses_h = xyes; then
1426   zsh_cv_path_curses_header=ncurses/ncurses.h
1427 elif test x$ac_cv_header_ncurses_h = xyes; then
1428   zsh_cv_path_curses_header=ncurses.h
1429 elif test x$ac_cv_header_curses_h = xyes; then
1430   zsh_cv_path_curses_header=curses.h
1431 else
1432   zsh_cv_path_curses_header=none
1433 fi])
1434 AH_TEMPLATE([ZSH_HAVE_CURSES_H],
1435 [Define to 1 if some variant of a curses header can be included])
1436 if test x$zsh_cv_path_curses_header != xnone; then
1437   AC_DEFINE(ZSH_HAVE_CURSES_H)
1438   ZSH_CURSES_H=$zsh_cv_path_curses_header
1439 else
1440   ZSH_CURSES_H=
1442 AC_SUBST(ZSH_CURSES_H)
1444 dnl Where are curses key definitions located?  Need for keypad() mode.
1445 AC_CACHE_CHECK(where curses key definitions are located, zsh_cv_path_curses_keys_h,
1446 [dnl This is an identical trick to errno.h, except we use ncurses.h
1447 dnl if we can.
1448 if test x$zsh_cv_path_curses_header = xnone; then
1449   echo >nametmp.c
1450 else
1451   echo "#include <$zsh_cv_path_curses_header>" >nametmp.c
1454 curses_list="`$CPP nametmp.c |
1455 sed -n -e 's/^#line[    ].*\"\(.*\)\"/\1/p' \
1456        -e 's/^#[        0-9].*\"\(.*\)\"/\1/p' |
1457 sed 's/\\\\\\\\/\//g' |
1458 $AWK '{ if ($1 ~ /\.h/) files[[$1]] = $1 }
1459   END { for (var in files) print var }'`"
1460 rm -f nametmp.c
1461 for CURSES_TRY_H in $curses_list /dev/null
1463   nkeys=`test -f $CURSES_TRY_H && \
1464   $EGREP '#[    ]*define[       ][      ]*KEY_' $CURSES_TRY_H | \
1465   wc -l | sed 's/[      ]//g'`
1466   if test "x$nkeys" != x && test "$nkeys" -ge 10
1467   then
1468     CURSES_KEYS_H=$CURSES_TRY_H
1469     break
1470   fi
1471 done
1472 zsh_cv_path_curses_keys_h="$CURSES_KEYS_H"
1474 CURSES_KEYS_H="$zsh_cv_path_curses_keys_h"
1475 AC_SUBST(CURSES_KEYS_H)dnl
1477 dnl See if there are variants of term.h.  For testing each one
1478 dnl we include the most likely variant of the curses header.
1479 AC_CHECK_HEADERS(ncursesw/term.h,
1480 true, true,
1481 [#include <ncursesw/ncurses.h>])
1482 AC_CHECK_HEADERS(ncurses/term.h,
1483 true, true,
1484 [#include <ncurses/ncurses.h>])
1485 AC_CHECK_HEADERS(term.h,
1486 true, true,
1487 [#include <curses.h>])
1489 dnl See if term.h is bundled along with the curses library we
1490 dnl are using.  If this isn't the default system curses, compilation
1491 dnl could barf unless we include from the right subdirectory.
1492 AC_CACHE_CHECK(where term.h is located, zsh_cv_path_term_header,
1493 [case x$zsh_cv_path_curses_header in
1494   xncursesw/*)
1495   if test x$ac_cv_header_ncursesw_term_h = xyes; then
1496     zsh_cv_path_term_header=ncursesw/term.h
1497   fi
1498   ;;
1499   xncurses/*)
1500   if test x$ac_cv_header_ncurses_term_h = xyes; then
1501     zsh_cv_path_term_header=ncurses/term.h
1502   fi
1503   ;;
1504 esac
1505 if test x$zsh_cv_path_term_header = x; then
1506   if test x$ac_cv_header_term_h = xyes; then
1507     zsh_cv_path_term_header=term.h
1508   else
1509     zsh_cv_path_term_header=none
1510   fi
1511 fi])
1513 AH_TEMPLATE([ZSH_HAVE_TERM_H],
1514 [Define to 1 if some variant of term.h can be included])
1515 AH_TEMPLATE([HAVE_BOOLCODES],
1516 [Define if you have the termcap boolcodes symbol.])
1517 AH_TEMPLATE([HAVE_NUMCODES],
1518 [Define if you have the termcap numcodes symbol.])
1519 AH_TEMPLATE([HAVE_STRCODES],
1520 [Define if you have the termcap strcodes symbol.])
1521 AH_TEMPLATE([HAVE_BOOLNAMES],
1522 [Define if you have the terminfo boolnames symbol.])
1523 AH_TEMPLATE([HAVE_NUMNAMES],
1524 [Define if you have the terminfo numnames symbol.])
1525 AH_TEMPLATE([HAVE_STRNAMES],
1526 [Define if you have the terminfo strnames symbol.])
1528 if test x$zsh_cv_path_term_header != xnone; then
1529   AC_DEFINE(ZSH_HAVE_TERM_H)
1530   ZSH_TERM_H=$zsh_cv_path_term_header
1531   if test x$zsh_cv_path_curses_header != xnone; then
1532     term_includes="#include <$zsh_cv_path_curses_header>
1533 #include <$zsh_cv_path_term_header>"
1534   else
1535     term_includes="#include <$zsh_cv_path_term_header>"
1536   fi
1538   AC_MSG_CHECKING(if boolcodes is available)
1539   AC_TRY_LINK($term_includes, [char **test = boolcodes; puts(*test);],
1540   AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no)
1541   AC_MSG_RESULT($boolcodes)
1542   AC_MSG_CHECKING(if numcodes is available)
1543   AC_TRY_LINK($term_includes, [char **test = numcodes; puts(*test);],
1544   AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no)
1545   AC_MSG_RESULT($numcodes)
1546   AC_MSG_CHECKING(if strcodes is available)
1547   AC_TRY_LINK($term_includes, [char **test = strcodes; puts(*test);],
1548   AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no)
1549   AC_MSG_RESULT($strcodes)
1550   AC_MSG_CHECKING(if boolnames is available)
1551   AC_TRY_LINK($term_includes, [char **test = boolnames; puts(*test);],
1552   AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes, boolnames=no)
1553   AC_MSG_RESULT($boolnames)
1554   AC_MSG_CHECKING(if numnames is available)
1555   AC_TRY_LINK($term_includes, [char **test = numnames; puts(*test);],
1556   AC_DEFINE(HAVE_NUMNAMES) numnames=yes, numnames=no)
1557   AC_MSG_RESULT($numnames)
1558   AC_MSG_CHECKING(if strnames is available)
1559   AC_TRY_LINK($term_includes, [char **test = strnames; puts(*test);],
1560   AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no)
1561   AC_MSG_RESULT($strnames)
1562 else
1563   ZSH_TERM_H=
1565 AC_SUBST(ZSH_TERM_H)
1568 dnl -----------------------------------------------------
1569 dnl Look for the file containing the RLIMIT_* definitions
1570 dnl -----------------------------------------------------
1571 dnl CALL FOR MORE (FEWER?) LOCATIONS:  I've just copied the signal checking.
1572 AC_CACHE_CHECK(where the RLIMIT macros are located,zsh_cv_path_rlimit_h,
1573 [dnl Look at the output from the preprocessor.
1574 dnl Copied from the search for the signal names above.
1575 echo "#include <sys/resource.h>" >restmp.c
1576 resourcefile_list="`$CPP restmp.c |
1577 sed -n -e 's/^#line[    ].*\"\(.*\)\"/\1/p' \
1578        -e 's/^#[        ].*\"\(.*\)\"/\1/p' |
1579 sed 's/\\\\\\\\/\//g' |
1580 $AWK '{ if ($1 ~ /resource/) files[[$1]] = $1 }
1581   END { for (var in files) print var }'`"
1582 rm -f restmp.c
1583 if test -z "$resourcefile_list"; then
1584   dnl No list: look at standard places.
1585   resourcefile_list="/usr/include/bsd/sys/resource.h
1586 /usr/include/asm/resource.h
1587 /usr/include/linux/resource.h
1588 /usr/include/sys/resource.h
1589 /usr/include/bits/resource.h
1590 /usr/include/resourcebits.h"
1592 for RESOURCE_H in $resourcefile_list /dev/null;
1594   test -f $RESOURCE_H && \
1595   grep '#[      ]*define[       ][      ]*RLIMIT_[A-Z]*[        ]*[0-9A-Z][0-9]*' $RESOURCE_H > /dev/null && \
1596   break
1597 done
1598 zsh_cv_path_rlimit_h=$RESOURCE_H
1599 if test x$RESOURCE_H = x"/dev/null" && test x$ac_cv_func_getrlimit = xyes; then
1600   AC_MSG_WARN(RLIMIT MACROS NOT FOUND:  please report to developers)
1601 fi])
1602 RLIMITS_INC_H=$zsh_cv_path_rlimit_h
1603 if test "$RLIMITS_INC_H" = "/dev/null"; then
1604   RLIMITS_INC_H=''
1606 dnl rlimits.h only appears in dependencies if we are actually using it.
1607 dnl We are using it any time we have getrlimit, though if the macros were
1608 dnl not found we simply awk through /dev/null and fail to find them.
1609 dnl Thus, limit won't work, but at least the shell will compile.
1610 AC_SUBST(RLIMITS_INC_H)dnl
1612 dnl ------------------
1613 dnl rlimit type checks
1614 dnl ------------------
1615 AH_TEMPLATE([RLIM_T_IS_QUAD_T],
1616 [Define to 1 if struct rlimit uses quad_t.])
1617 AH_TEMPLATE([RLIM_T_IS_LONG_LONG],
1618 [Define to 1 if struct rlimit uses long long])
1619 AH_TEMPLATE([RLIM_T_IS_UNSIGNED],
1620 [Define to 1 if struct rlimit uses unsigned.])
1621 AH_TEMPLATE([rlim_t],
1622 [Define to the type used in struct rlimit.])
1623 DEFAULT_RLIM_T=long
1624 AC_CACHE_CHECK(if rlim_t is longer than a long,
1625 zsh_cv_rlim_t_is_longer,
1626 [AC_TRY_RUN([
1627 #ifdef HAVE_SYS_TIME_H
1628 #include <sys/time.h>
1629 #endif
1630 #include <sys/resource.h>
1631 main(){struct rlimit r;exit(sizeof(r.rlim_cur) <= sizeof(long));}],
1632 zsh_cv_rlim_t_is_longer=yes,
1633 zsh_cv_rlim_t_is_longer=no,
1634 zsh_cv_rlim_t_is_longer=yes)])
1635 if test x$zsh_cv_rlim_t_is_longer = xyes; then
1636   AC_CACHE_CHECK(if rlim_t is a quad,
1637   zsh_cv_rlim_t_is_quad_t,
1638   [AC_TRY_RUN([
1639 #ifdef HAVE_SYS_TIME_H
1640 #include <sys/time.h>
1641 #endif
1642 #include <stdio.h>
1643 #include <sys/resource.h>
1644 main() { 
1645   struct rlimit r;
1646   char buf[20];
1647   r.rlim_cur = 0;
1648   sprintf(buf, "%qd", r.rlim_cur);
1649   exit(strcmp(buf, "0"));
1651   zsh_cv_rlim_t_is_quad_t=yes,
1652   zsh_cv_rlim_t_is_quad_t=no,
1653   zsh_cv_rlim_t_is_quad_t=no)])
1654   if test x$zsh_cv_rlim_t_is_quad_t = xyes; then
1655     AC_DEFINE(RLIM_T_IS_QUAD_T)
1656     DEFAULT_RLIM_T=quad_t
1657   else
1658     AC_DEFINE(RLIM_T_IS_LONG_LONG)
1659     DEFAULT_RLIM_T='long long'
1660   fi
1661 else
1662   AC_CACHE_CHECK(if the rlim_t is unsigned,
1663   zsh_cv_type_rlim_t_is_unsigned,
1664   [AC_TRY_RUN([
1665 #ifdef HAVE_SYS_TIME_H
1666 #include <sys/time.h>
1667 #endif
1668 #include <sys/resource.h>
1669   main(){struct rlimit r;r.rlim_cur=-1;exit(r.rlim_cur<0);}],
1670   zsh_cv_type_rlim_t_is_unsigned=yes,
1671   zsh_cv_type_rlim_t_is_unsigned=no,
1672   zsh_cv_type_rlim_t_is_unsigned=no)])
1673   if test x$zsh_cv_type_rlim_t_is_unsigned = xyes; then
1674     AC_DEFINE(RLIM_T_IS_UNSIGNED)
1675     DEFAULT_RLIM_T="unsigned $DEFAULT_RLIM_T"
1676   fi
1679 AC_CACHE_CHECK(for rlim_t, zsh_cv_type_rlim_t,
1680 [AC_TRY_COMPILE([
1681 #include <sys/types.h>
1682 #ifdef HAVE_SYS_TIME_H
1683 #include <sys/time.h>
1684 #endif
1685 #include <sys/resource.h>],
1686 [rlim_t l;],
1687 zsh_cv_type_rlim_t=yes,
1688 zsh_cv_type_rlim_t=no)])
1689 if test x$zsh_cv_type_rlim_t = xno; then
1690   AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T)
1694 dnl On some systems the RLIMIT_* don't evaluate to integers at compile time
1695 dnl (they may be enums).  In this case we are not able to do preprocessor
1696 dnl comparisons and need our tests to determine what values exist and
1697 dnl if there are clashing definitions.
1699 zsh_LIMIT_PRESENT(RLIMIT_AIO_MEM)
1700 zsh_LIMIT_PRESENT(RLIMIT_AIO_OPS)
1701 zsh_LIMIT_PRESENT(RLIMIT_AS)
1702 zsh_LIMIT_PRESENT(RLIMIT_LOCKS)
1703 zsh_LIMIT_PRESENT(RLIMIT_MEMLOCK)
1704 zsh_LIMIT_PRESENT(RLIMIT_NPROC)
1705 zsh_LIMIT_PRESENT(RLIMIT_NOFILE)
1706 zsh_LIMIT_PRESENT(RLIMIT_PTHREAD)
1707 zsh_LIMIT_PRESENT(RLIMIT_RSS)
1708 zsh_LIMIT_PRESENT(RLIMIT_SBSIZE)
1709 zsh_LIMIT_PRESENT(RLIMIT_TCACHE)
1710 zsh_LIMIT_PRESENT(RLIMIT_VMEM)
1711 zsh_LIMIT_PRESENT(RLIMIT_SIGPENDING)
1712 zsh_LIMIT_PRESENT(RLIMIT_MSGQUEUE)
1713 zsh_LIMIT_PRESENT(RLIMIT_NICE)
1714 zsh_LIMIT_PRESENT(RLIMIT_RTPRIO)
1716 AH_TEMPLATE([RLIMIT_VMEM_IS_RSS],
1717 [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.])
1718 AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same,
1719 zsh_cv_rlimit_vmem_is_rss,
1720 [AC_TRY_RUN([
1721 #include <sys/types.h>
1722 #ifdef HAVE_SYS_TIME_H
1723 #include <sys/time.h>
1724 #endif
1725 #include <sys/resource.h>
1726 int main()
1728 int ret = 1;
1729 #if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_RSS)
1730 if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0;
1731 #endif
1732 return ret;
1734   zsh_cv_rlimit_vmem_is_rss=yes,
1735   zsh_cv_rlimit_vmem_is_rss=no,
1736   zsh_cv_rlimit_vmem_is_rss=no)])
1738 if test x$zsh_cv_rlimit_vmem_is_rss = xyes; then
1739   AC_DEFINE(RLIMIT_VMEM_IS_RSS)
1743 AH_TEMPLATE([RLIMIT_VMEM_IS_AS],
1744 [Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal.])
1745 AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same,
1746 zsh_cv_rlimit_vmem_is_as,
1747 [AC_TRY_RUN([
1748 #include <sys/types.h>
1749 #ifdef HAVE_SYS_TIME_H
1750 #include <sys/time.h>
1751 #endif
1752 #include <sys/resource.h>
1753 int main()
1755 int ret = 1;
1756 #if defined(HAVE_RLIMIT_VMEM) && defined(HAVE_RLIMIT_AS)
1757 if (RLIMIT_AS == RLIMIT_VMEM) ret = 0;
1758 #endif
1759 return ret;
1761   zsh_cv_rlimit_vmem_is_as=yes,
1762   zsh_cv_rlimit_vmem_is_as=no,
1763   zsh_cv_rlimit_vmem_is_as=no)])
1765 if test x$zsh_cv_rlimit_vmem_is_as = xyes; then
1766   AC_DEFINE(RLIMIT_VMEM_IS_AS)
1770 AH_TEMPLATE([RLIMIT_RSS_IS_AS],
1771 [Define to 1 if RLIMIT_RSS and RLIMIT_AS both exist and are equal.])
1772 AC_CACHE_CHECK(if RLIMIT_RSS and RLIMIT_AS are the same,
1773 zsh_cv_rlimit_rss_is_as,
1774 [AC_TRY_RUN([
1775 #include <sys/types.h>
1776 #ifdef HAVE_SYS_TIME_H
1777 #include <sys/time.h>
1778 #endif
1779 #include <sys/resource.h>
1780 int main()
1782 int ret = 1;
1783 #if defined(HAVE_RLIMIT_RSS) && defined(HAVE_RLIMIT_AS)
1784 if (RLIMIT_AS == RLIMIT_RSS) ret = 0;
1785 #endif
1786 return ret;
1788   zsh_cv_rlimit_rss_is_as=yes,
1789   zsh_cv_rlimit_rss_is_as=no,
1790   zsh_cv_rlimit_rss_is_as=no)])
1792 if test x$zsh_cv_rlimit_rss_is_as = xyes; then
1793   AC_DEFINE(RLIMIT_RSS_IS_AS)
1797 dnl --------------------------------------------
1798 dnl Check for members of struct rusage
1799 dnl --------------------------------------------
1800 if test x$ac_cv_func_getrusage = xyes; then
1801   AC_CHECK_MEMBERS([struct rusage.ru_maxrss,
1802                     struct rusage.ru_ixrss,
1803                     struct rusage.ru_idrss,
1804                     struct rusage.ru_isrss,
1805                     struct rusage.ru_minflt,
1806                     struct rusage.ru_majflt,
1807                     struct rusage.ru_nswap,
1808                     struct rusage.ru_inblock,
1809                     struct rusage.ru_oublock,
1810                     struct rusage.ru_msgsnd,
1811                     struct rusage.ru_msgrcv,
1812                     struct rusage.ru_nsignals,
1813                     struct rusage.ru_nvcsw,
1814                     struct rusage.ru_nivcsw],,,
1815 [#include <sys/types.h>
1816 #ifdef HAVE_SYS_TIME_H
1817 #include <sys/time.h>
1818 #endif
1819 #include <sys/resource.h>])
1823 dnl --------------------------------------------
1824 dnl CHECK FOR DEFAULT PATH (used for command -p)
1825 dnl --------------------------------------------
1826 AC_CACHE_VAL(zsh_cv_cs_path,
1827 [if getconf _CS_PATH >/dev/null 2>&1; then
1828   zsh_cv_cs_path=`getconf _CS_PATH`
1829 elif getconf CS_PATH >/dev/null 2>&1; then
1830   zsh_cv_cs_path=`getconf CS_PATH`
1831 else
1832   zsh_cv_cs_path="/bin:/usr/bin"
1833 fi])
1834 AC_DEFINE_UNQUOTED(DEFAULT_PATH, "$zsh_cv_cs_path",
1835 [The default path; used when running commands with command -p])
1838 dnl ----------------------------
1839 dnl CHECK FOR /dev/fd FILESYSTEM
1840 dnl ----------------------------
1841 dnl FreeBSD 5 only supports /dev/fd/0 to /dev/fd/2 without mounting
1842 dnl a special file system.  As zsh needs arbitrary /dev/fd (typically
1843 dnl >10) for its own use, we need to make sure higher fd's are available.
1844 dnl Since we're using the shell, we're restricted to 0 to 9 but 3 should
1845 dnl be good enough.
1846 AH_TEMPLATE([PATH_DEV_FD],
1847 [Define to the path of the /dev/fd filesystem.])
1848 AC_CACHE_CHECK(for /dev/fd filesystem, zsh_cv_sys_path_dev_fd,
1849 [if test "$host_os" = cygwin; then
1850 dnl In current (2008/12/01) versions of Cygwin these are present but don't
1851 dnl seem to work smoothly for process substitution; no great surprise
1852 dnl since getting processes to work at all on Cygwin is a big challenge.
1853 dnl We'll rely on FIFOs, since they do what we need.
1854 zsh_cv_sys_path_dev_fd=no
1855 else
1856 [for zsh_cv_sys_path_dev_fd in /proc/self/fd /dev/fd no; do
1857    test x`echo ok|(exec 3<&0; cat $zsh_cv_sys_path_dev_fd/3 2>/dev/null;)` = xok && break
1858  done]
1859 fi])
1860 if test x$zsh_cv_sys_path_dev_fd != xno; then
1861   AC_DEFINE_UNQUOTED(PATH_DEV_FD, "$zsh_cv_sys_path_dev_fd")
1864 dnl ---------------------------------
1865 dnl CHECK FOR RFS SUPERROOT DIRECTORY
1866 dnl ---------------------------------
1867 AC_CACHE_CHECK(for RFS superroot directory, zsh_cv_sys_superroot,
1868 [test -d /../.LOCALROOT && zsh_cv_sys_superroot=yes || zsh_cv_sys_superroot=no])
1869 AH_TEMPLATE([HAVE_SUPERROOT],
1870 [Define to 1 if you have RFS superroot directory.])
1871 if test x$zsh_cv_sys_superroot = xyes; then
1872   AC_DEFINE(HAVE_SUPERROOT)
1875 dnl CHECK FOR SYSTEMS REQUIRING GETCWD
1876 AC_CACHE_CHECK(whether we should use the native getcwd,
1877 zsh_cv_use_getcwd,
1878 [case "${host_cpu}-${host_vendor}-${host_os}" in
1879     *QNX*) zsh_cv_use_getcwd=yes ;;
1880     *) zsh_cv_use_getcwd=no ;;
1881  esac])
1882 AH_TEMPLATE([USE_GETCWD],
1883 [Define to 1 if you need to use the native getcwd.])
1884 if test x$zsh_cv_use_getcwd = xyes; then
1885   AC_DEFINE(USE_GETCWD)
1888 dnl CHECK FOR setproctitle() FOR jobs -Z / ARGV0
1889 AH_TEMPLATE([HAVE_SETPROCTITLE],
1890 [Define to 1 if the system supports `setproctitle' to change process name])
1891 AC_CHECK_FUNC(setproctitle,AC_DEFINE(HAVE_SETPROCTITLE),
1892 AC_SEARCH_LIBS(setproctitle,util,AC_DEFINE(HAVE_SETPROCTITLE)))
1894 dnl -------------
1895 dnl CHECK FOR NIS
1896 dnl -------------
1897 AH_TEMPLATE([HAVE_NIS],
1898 [Define to 1 if you have NIS.])
1899 AC_CACHE_CHECK(for NIS, zsh_cv_sys_nis,
1900 [test -f /usr/bin/ypcat && /usr/bin/ypcat passwd.byname > /dev/null 2>&1 && \
1901 zsh_cv_sys_nis=yes || zsh_cv_sys_nis=no])
1902 if test x$zsh_cv_sys_nis = xyes; then
1903   AC_DEFINE(HAVE_NIS)
1904 dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require
1905 dnl libnsl (Network Services Library) to find yp_all
1906   AC_SEARCH_LIBS(yp_all, nsl)
1909 dnl -----------------
1910 dnl CHECK FOR NISPLUS
1911 dnl -----------------
1912 AH_TEMPLATE([HAVE_NIS_PLUS],
1913 [Define to 1 if you have NISPLUS.])
1914 AC_CACHE_CHECK(for NIS+, zsh_cv_sys_nis_plus,
1915 [test x$ac_cv_func_nis_list = xyes && test -f /usr/bin/nisls && \
1916  /usr/bin/nisls > /dev/null 2>&1 && \
1917 zsh_cv_sys_nis_plus=yes || zsh_cv_sys_nis_plus=no])
1918 if test x$zsh_cv_sys_nis_plus = xyes; then
1919   AC_DEFINE(HAVE_NIS_PLUS)
1922 dnl ----------------------------------------
1923 dnl CHECK FOR LOCATION OF {U,W}TMP{,X} FILES
1924 dnl ----------------------------------------
1925 zsh_PATH_UTMP(utmp)
1926 zsh_PATH_UTMP(wtmp)
1927 zsh_PATH_UTMP(utmpx)
1928 zsh_PATH_UTMP(wtmpx)
1930 dnl -------------------
1931 dnl brk/sbrk PROTOTYPES
1932 dnl -------------------
1933 AC_CACHE_CHECK(for brk() prototype in <unistd.h>,
1934 zsh_cv_header_unistd_h_brk_proto,
1935 [AC_TRY_COMPILE([#include <unistd.h>
1936 double brk();], [int i;],
1937 zsh_cv_header_unistd_h_brk_proto=no, zsh_cv_header_unistd_h_brk_proto=yes)])
1938 AH_TEMPLATE([HAVE_BRK_PROTO],
1939 [Define to 1 if there is a prototype defined for brk() on your system.])
1940 if test x$zsh_cv_header_unistd_h_brk_proto = xyes; then
1941   AC_DEFINE(HAVE_BRK_PROTO)
1944 AC_CACHE_CHECK(for sbrk() prototype in <unistd.h>,
1945 zsh_cv_header_unistd_h_sbrk_proto,
1946 [AC_TRY_COMPILE([#include <unistd.h>
1947 double sbrk();], [int i;],
1948 zsh_cv_header_unistd_h_sbrk_proto=no, zsh_cv_header_unistd_h_sbrk_proto=yes)])
1949 AH_TEMPLATE([HAVE_SBRK_PROTO],
1950 [Define to 1 if there is a prototype defined for sbrk() on your system.])
1951 if test x$zsh_cv_header_unistd_h_sbrk_proto = xyes; then
1952   AC_DEFINE(HAVE_SBRK_PROTO)
1955 dnl -----------------------
1956 dnl mknod prototype for OSF
1957 dnl -----------------------
1958 AH_TEMPLATE([HAVE_MKNOD_PROTO],
1959 [Define to 1 if there is a prototype defined for mknod() on your system.])
1960 if test "$ac_cv_prog_cc_stdc" != no; then
1961   AC_CACHE_CHECK(for mknod prototype in <sys/stat.h>,
1962   zsh_cv_header_sys_stat_h_mknod_proto,
1963   [AC_TRY_COMPILE([#include <sys/stat.h>
1964    int mknod(double x);], [int i;],
1965   zsh_cv_header_sys_stat_h_mknod_proto=no,
1966   zsh_cv_header_sys_stat_h_mknod_proto=yes)])
1967   if test x$zsh_cv_header_sys_stat_h_mknod_proto = xyes; then
1968     AC_DEFINE(HAVE_MKNOD_PROTO)
1969   fi
1972 dnl ----------------------------------------
1973 dnl presence and location of ioctl prototype
1974 dnl ----------------------------------------
1975 AC_CACHE_CHECK(for ioctl prototype in <unistd.h> or <termios.h>,
1976 zsh_cv_header_unistd_h_termios_h_ioctl_proto,
1977 [AC_TRY_COMPILE([
1978 #ifdef HAVE_UNISTD_H
1979 # include <unistd.h>
1980 #endif
1981 #ifdef HAVE_TERMIOS_H
1982 # include <termios.h>
1983 #endif
1984 double ioctl();], [int i;],
1985 zsh_cv_header_unistd_h_termios_h_ioctl_proto=no,
1986 zsh_cv_header_unistd_h_termios_h_ioctl_proto=yes)])
1988 if test x$zsh_cv_header_unistd_h_termios_h_ioctl_proto = xno; then
1989   AC_CACHE_CHECK(for ioctl prototype in <sys/ioctl.h>,
1990   zsh_cv_header_sys_ioctl_h_ioctl_proto,
1991   [AC_TRY_COMPILE([#include <sys/ioctl.h>
1992   double ioctl();], [int i;],
1993   zsh_cv_header_sys_ioctl_h_ioctl_proto=no,
1994   zsh_cv_header_sys_ioctl_h_ioctl_proto=yes)])
1995 else
1996   zsh_cv_header_sys_ioctl_h_ioctl_proto=no
1999 AH_TEMPLATE([HAVE_IOCTL_PROTO],
2000 [Define to 1 if there is a prototype defined for ioctl() on your system.])
2001 if test x$zsh_cv_header_unistd_h_termios_h_ioctl_proto = xyes || \
2002    test x$zsh_cv_header_sys_ioctl_h_ioctl_proto = xyes; then
2003   AC_DEFINE(HAVE_IOCTL_PROTO)
2005 AH_TEMPLATE([IOCTL_IN_SYS_IOCTL],
2006 [Define to 1 if we must include <sys/ioctl.h> to get a prototype for ioctl().])
2007 if test x$zsh_cv_header_sys_ioctl_h_ioctl_proto = xyes; then
2008   AC_DEFINE(IOCTL_IN_SYS_IOCTL)
2011 dnl -------------------
2012 dnl select() defined in <sys/socket.h>, ie BeOS R4.51
2013 dnl -------------------
2014 AH_TEMPLATE([SELECT_IN_SYS_SOCKET_H],
2015 [Define to 1 if select() is defined in <sys/socket.h>, ie BeOS R4.51])
2016 if test x$ac_cv_header_sys_select_h != xyes; then
2017   AC_CACHE_CHECK(for select() in <sys/socket.h>,
2018   zsh_cv_header_socket_h_select_proto,
2019   [AC_TRY_COMPILE([#include <sys/socket.h>], [fd_set fd;],
2020   zsh_cv_header_socket_h_select_proto=yes, 
2021   zsh_cv_header_socket_h_select_proto=no)])
2022   if test x$zsh_cv_header_socket_h_select_proto = xyes; then
2023     AC_DEFINE(SELECT_IN_SYS_SOCKET_H)
2024   fi
2027 dnl -----------
2028 dnl named FIFOs
2029 dnl -----------
2031 dnl Named FIFOs work well enough on recent versions of Cygwin
2032 dnl to provide what we want.  Simply enable them.
2033 AC_CACHE_CHECK(if named FIFOs work,
2034 zsh_cv_sys_fifo,
2035 [if test "$host_os" = cygwin; then
2036 zsh_cv_sys_fifo=yes
2037 else
2038 AC_TRY_RUN([
2039 #include <fcntl.h>
2040 #include <signal.h>
2041 main()
2043     char c;
2044     int fd;
2045     int pid, ret;
2046     unlink("/tmp/fifo$$");
2047 #ifdef HAVE_MKFIFO
2048     if(mkfifo("/tmp/fifo$$", 0600) < 0)
2049 #else
2050     if(mknod("/tmp/fifo$$", 0010600, 0) < 0)
2051 #endif
2052         exit(1);
2053     pid = fork();
2054     if(pid < 0)
2055         exit(1);
2056     if(pid) {
2057         fd = open("/tmp/fifo$$", O_RDONLY);
2058         exit(fd < 0 || read(fd, &c, 1) != 1 || c != 'x');
2059     }
2060     fd = open("/tmp/fifo$$", O_WRONLY);
2061     ret = (fd < 0 || write(fd, "x", 1) < 1);
2062     unlink("/tmp/fifo$$");
2063     exit(ret);
2066   zsh_cv_sys_fifo=yes,
2067   zsh_cv_sys_fifo=no,
2068   zsh_cv_sys_fifo=yes)
2069 fi])
2070 AH_TEMPLATE([HAVE_FIFOS],
2071 [Define to 1 if system has working FIFOs.])
2072 if test x$zsh_cv_sys_fifo = xyes; then
2073   AC_DEFINE(HAVE_FIFOS)
2075 dnl ---------------------
2076 dnl echo style of /bin/sh
2077 dnl ---------------------
2078 AC_CACHE_CHECK(if echo in /bin/sh interprets escape sequences,
2079 zsh_cv_prog_sh_echo_escape,
2080 [if test "`/bin/sh -c \"echo '\\n'\"`" = "\\n"; then
2081   zsh_cv_prog_sh_echo_escape=no
2082 else
2083   zsh_cv_prog_sh_echo_escape=yes
2084 fi])
2085 AH_TEMPLATE([SH_USE_BSD_ECHO],
2086 [Define to 1 if /bin/sh does not interpret \ escape sequences.])
2087 if test x$zsh_cv_prog_sh_echo_escape = xno; then
2088   AC_DEFINE(SH_USE_BSD_ECHO)
2091 dnl -----------
2092 dnl test for whether link() works
2093 dnl for instance, BeOS R4.51 doesn't support hard links yet
2094 dnl -----------
2095 AC_CACHE_CHECK(if link() works,
2096 zsh_cv_sys_link,
2097 [AC_TRY_RUN([
2098 #include <unistd.h>
2099 #include <fcntl.h>
2100 main()
2102     int ret;
2103     char *tmpfile, *newfile;
2104     tmpfile="/tmp/zsh.linktest$$";
2105     newfile="/tmp/zsh.linktest2$$";
2106     unlink(tmpfile);
2107     unlink(newfile);
2108     if(creat(tmpfile, 0644) < 0)
2109         exit(1);
2110     ret = link(tmpfile, newfile);
2111     unlink(tmpfile);
2112     unlink(newfile);
2113     exit(ret<0);
2116   zsh_cv_sys_link=yes,
2117   zsh_cv_sys_link=no,
2118   zsh_cv_sys_link=yes)])
2119 AH_TEMPLATE([HAVE_LINK],
2120 [Define to 1 if system has working link().])
2121 if test x$zsh_cv_sys_link = xyes; then
2122   AC_DEFINE(HAVE_LINK)
2125 dnl -----------
2126 dnl test for whether kill(pid, 0) where pid doesn't exit
2127 dnl should set errno to ESRCH, but some like BeOS R4.51 set to EINVAL
2128 dnl -----------
2129 AC_CACHE_CHECK(if kill(pid, 0) returns ESRCH correctly,
2130 zsh_cv_sys_killesrch,
2131 [AC_TRY_RUN([
2132 #include <unistd.h>
2133 #include <signal.h>
2134 #include <errno.h>
2135 main()
2137     int pid = (getpid() + 10000) & 0xffffff;
2138     while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1;
2139     exit(errno!=ESRCH);
2142   zsh_cv_sys_killesrch=yes,
2143   zsh_cv_sys_killesrch=no,
2144   zsh_cv_sys_killesrch=yes)])
2145 AH_TEMPLATE([BROKEN_KILL_ESRCH],
2146 [Define to 1 if kill(pid, 0) doesn't return ESRCH, ie BeOS R4.51.])
2147 if test x$zsh_cv_sys_killesrch = xno; then
2148   AC_DEFINE(BROKEN_KILL_ESRCH)
2151 dnl -----------
2152 dnl if POSIX, test for working sigsuspend().
2153 dnl for instance, BeOS R4.51 is broken.
2154 dnl -----------
2155 AH_TEMPLATE([BROKEN_POSIX_SIGSUSPEND],
2156 Define to 1 if sigsuspend() is broken, ie BeOS R4.51.])
2157 if test x$signals_style = xPOSIX_SIGNALS; then
2158     AC_CACHE_CHECK(if POSIX sigsuspend() works,
2159     zsh_cv_sys_sigsuspend,
2160     [AC_TRY_RUN([
2161 #include <signal.h>
2162 #include <unistd.h>
2163 int child=0;
2164 void handler(sig)
2165     int sig;
2166 {if(sig==SIGCHLD) child=1;}
2167 main() {
2168     struct sigaction act;
2169     sigset_t set;
2170     int pid, ret;
2171     act.sa_handler = &handler;
2172     sigfillset(&act.sa_mask);
2173     act.sa_flags = 0;
2174     sigaction(SIGCHLD, &act, 0);
2175     sigfillset(&set);
2176     sigprocmask(SIG_SETMASK, &set, 0);
2177     pid=fork();
2178     if(pid==0) return 0;
2179     if(pid>0) {
2180     sigemptyset(&set);
2181         ret=sigsuspend(&set);
2182         exit(child==0);
2183     }
2186       zsh_cv_sys_sigsuspend=yes,
2187       zsh_cv_sys_sigsuspend=no,
2188       zsh_cv_sys_sigsuspend=yes)])
2189     if test x$zsh_cv_sys_sigsuspend = xno; then
2190       AC_DEFINE(BROKEN_POSIX_SIGSUSPEND)
2191     fi
2194 dnl -----------
2195 dnl if found tcsetpgrp, test to see if it actually works
2196 dnl for instance, BeOS R4.51 does not support it yet
2197 dnl -----------
2198 AH_TEMPLATE([BROKEN_TCSETPGRP],
2199 [Define to 1 if tcsetpgrp() doesn't work, ie BeOS R4.51.])
2200 AC_ARG_WITH(tcsetpgrp,
2201 AC_HELP_STRING([--with-tcsetpgrp], [assumes that tcsetpgrp() exists and works correctly]),[
2202 case "x$withval" in
2203     xyes) zsh_working_tcsetpgrp=yes;;
2204     xno)  zsh_working_tcsetpgrp=no;;
2205     *)    AC_ERROR([please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no]);;
2206 esac],[zsh_working_tcsetpgrp=check])
2207 if test "x$ac_cv_func_tcsetpgrp" = xyes; then
2208 case "x$zsh_working_tcsetpgrp" in
2209   xcheck)
2210     trap "" TTOU > /dev/null 2>&1 || :
2211     AC_CACHE_CHECK(if tcsetpgrp() actually works,
2212     zsh_cv_sys_tcsetpgrp,
2213     [AC_TRY_RUN([
2214 #include <sys/types.h>
2215 #include <unistd.h>
2216 #include <fcntl.h>
2217 main() {
2218     int fd;
2219     int ret;
2220     fd=open("/dev/tty", O_RDWR);
2221     if (fd < 0) exit(2);
2222     ret=tcsetpgrp(fd, tcgetpgrp(fd));
2223     if (ret < 0) exit(1);
2224     exit(0);
2227       zsh_cv_sys_tcsetpgrp=yes, [
2228 case $? in
2229     1) zsh_cv_sys_tcsetpgrp=no;;
2230     2) zsh_cv_sys_tcsetpgrp=notty;;
2231     *) zsh_cv_sys_tcsetpgrp=error;;
2232 esac
2233       ], zsh_cv_sys_tcsetpgrp=yes)])
2234     case "x$zsh_cv_sys_tcsetpgrp" in
2235       xno)    AC_DEFINE(BROKEN_TCSETPGRP);;
2236       xyes)   :;;
2237       xnotty) AC_MSG_ERROR([no controlling tty
2238 Try running configure with --with-tcsetpgrp or --without-tcsetpgrp]);;
2239       *)      AC_MSG_ERROR([unexpected return status]);;
2240     esac
2241     trap - TTOU > /dev/null 2>&1 || :
2242     ;;
2243   xyes) :;;
2244   xno)  AC_DEFINE(BROKEN_TCSETPGRP);;
2245   *)    AC_MSG_ERROR([unexpected value zsh_working_tcsetpgrp=$zsh_working_tcsetpgrp]);;
2246 esac
2249 dnl -----------
2250 dnl test for faked getpwnam() entry, ie a single entry returned for any username
2251 dnl for instance, BeOS R4.51 is not multiuser yet, and fakes getpwnam()
2252 dnl test by looking up two usernames that shouldn't succeed, and compare entry
2253 dnl -----------
2254 AH_TEMPLATE([GETPWNAM_FAKED],
2255 [Define to 1 if getpwnam() is faked, ie BeOS R4.51.])
2256 if test x$ac_cv_func_getpwnam = xyes; then
2257     AC_CACHE_CHECK(if getpwnam() is faked,
2258     zsh_cv_sys_getpwnam_faked,
2259     [AC_TRY_RUN([
2260 #include <pwd.h>
2261 main() {
2262     struct passwd *pw1, *pw2;
2263     char buf[1024], name[1024];
2264     sprintf(buf, "%d:%d", getpid(), rand());
2265     pw1=getpwnam(buf);
2266     if (pw1) strcpy(name, pw1->pw_name);
2267     sprintf(buf, "%d:%d", rand(), getpid());
2268     pw2=getpwnam(buf);
2269     exit(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name));
2272       zsh_cv_sys_getpwnam_faked=no,
2273       zsh_cv_sys_getpwnam_faked=yes,
2274       zsh_cv_sys_getpwnam_faked=no)])
2275     if test x$zsh_cv_sys_getpwnam_faked = xyes; then
2276       AC_DEFINE(GETPWNAM_FAKED)
2277     fi
2281 dnl ---------------
2282 dnl check for the type of third argument of accept
2283 dnl ---------------
2285 zsh_CHECK_SOCKLEN_T
2287 dnl ---------------
2288 dnl Check for pty multiplexer for use in pty module.
2289 dnl We need to open it read/write, so make sure it is writeable.
2290 dnl Yet another test which won't work when cross-compiling.
2291 dnl ---------------
2292 AC_CACHE_CHECK(if your system has /dev/ptmx,
2293 ac_cv_have_dev_ptmx,
2294 [if test -w /dev/ptmx; then
2295   ac_cv_have_dev_ptmx=yes
2296 else
2297   ac_cv_have_dev_ptmx=no
2298 fi])
2300 dnl --------
2301 dnl Check if the ptmx functions are usable.
2302 dnl We need to be able to find the prototypes, which may
2303 dnl require non-POSIX source definitions.  So test to see
2304 dnl if ptsname is correctly recognised as returning a char *.
2305 dnl We do this by making sure a program where ptsname() is declared
2306 dnl as returning int does *not* compile.
2307 dnl On Linux we need the XOPEN extensions.  The easiest way to get
2308 dnl these is by defining _GNU_SOURCE.
2309 dnl -------
2310 AH_TEMPLATE([USE_DEV_PTMX],
2311 [Define to 1 if all the kit for using /dev/ptmx for ptys is available.])
2312 if test x$ac_cv_have_dev_ptmx = xyes && \
2313    test x$ac_cv_func_grantpt = xyes && \
2314    test x$ac_cv_func_unlockpt = xyes && \
2315    test x$ac_cv_func_ptsname = xyes; then
2316    AC_CACHE_CHECK([if /dev/ptmx is usable],
2317    ac_cv_use_dev_ptmx,
2318    [AC_TRY_COMPILE([#ifdef __linux
2319 #define _GNU_SOURCE 1
2320 #endif
2321 #include <stdlib.h>
2322 int ptsname();], ,
2323    ac_cv_use_dev_ptmx=no,
2324    ac_cv_use_dev_ptmx=yes)])
2325    if test x$ac_cv_use_dev_ptmx = xyes; then
2326      AC_DEFINE(USE_DEV_PTMX)
2327    fi
2330 dnl -----------------
2331 dnl multibyte support
2332 dnl -----------------
2333 AC_ARG_ENABLE(multibyte,
2334 AC_HELP_STRING([--enable-multibyte], [support multibyte characters]),
2335 [zsh_cv_c_unicode_support=$enableval],
2336 [AC_CACHE_VAL(zsh_cv_c_unicode_support,
2337   AC_MSG_NOTICE([checking for functions supporting multibyte characters])
2338   [zfuncs_absent=
2339    for zfunc in iswalnum iswcntrl iswdigit iswgraph iswlower iswprint \
2340 iswpunct iswspace iswupper iswxdigit mbrlen mbrtowc towupper towlower \
2341 wcschr wcscpy wcslen wcsncmp wcsncpy wcrtomb wcwidth wmemchr wmemcmp \
2342 wmemcpy wmemmove wmemset; do
2343      AC_CHECK_FUNC($zfunc,
2344      [:], [zfuncs_absent="$zfuncs_absent $zfunc"])
2345     done
2346     if test x"$zfuncs_absent" = x; then
2347       AC_MSG_NOTICE([all functions found, multibyte support enabled])
2348       zsh_cv_c_unicode_support=yes
2349     else
2350       AC_MSG_NOTICE([missing functions, multibyte support disabled])
2351       zsh_cv_c_unicode_support=no
2352     fi
2353   ])
2355 AH_TEMPLATE([MULTIBYTE_SUPPORT],
2356 [Define to 1 if you want support for multibyte character sets.])
2357 AH_TEMPLATE([BROKEN_WCWIDTH],
2358 [Define to 1 if the wcwidth() function is present but broken.])
2359 if test x$zsh_cv_c_unicode_support = xyes; then
2360   AC_DEFINE(MULTIBYTE_SUPPORT)
2362   dnl Test for a wcwidth() implementation that gives the wrong width for
2363   dnl zero-width combining characters.
2364   dnl For the test we use a combining acute accent (\u0301).
2365   dnl We input it as UTF-8 since that is the standard we can rely
2366   dnl upon most:  we can't rely on a wchar_t being stored as a
2367   dnl Unicode code point on all systems.
2368   dnl The programme returns 0 only if all the conditions for brokenness
2369   dnl are met:
2370   dnl - the programme compiled, linked and ran
2371   dnl - we successfully set a UTF-8 locale
2372   dnl - the locale we set plausibly converted the UTF-8 string
2373   dnl   for a zero-width combining character (the only way to be
2374   dnl   100% sure would be to output it and ask if it looked right)
2375   dnl - the converted wide character gave a non-zero width.
2376   dnl locale -a is a fallback; on most systems we should find en_US.UTF-8.
2377   [locale_prog='char *my_locales[] = {
2378   "en_US.UTF-8", "en_GB.UTF-8", "en.UTF-8", '
2379   locale_prog="$locale_prog"`locale -a 2>/dev/null | \
2380     sed -e 's/utf8/UTF-8/' | grep UTF-8 | \
2381     while read line; do echo " \"$line\","; done;`
2382   locale_prog="$locale_prog 0 };
2383   #define _XOPEN_SOURCE
2384   #include <stdlib.h>
2385   #include <locale.h>
2386   #include <wchar.h>
2388   int main() {
2389     char **localep;
2390     char comb_acute_mb[] = { (char)0xcc, (char)0x81 };
2391     wchar_t wc;
2393     for (localep = my_locales; *localep; localep++)
2394       if (setlocale(LC_ALL, *localep) &&
2395           mbtowc(&wc, comb_acute_mb, 2) == 2)
2396           break;
2397     if (!*localep)
2398       return 1;
2399     if (wcwidth(wc) == 0)
2400       return 1;
2401     return 0;
2402   }
2403   "]
2405   AC_CACHE_CHECK(if the wcwidth() function is broken,
2406   zsh_cv_c_broken_wcwidth,
2407   [AC_TRY_RUN([$locale_prog],
2408   zsh_cv_c_broken_wcwidth=yes,
2409   zsh_cv_c_broken_wcwidth=no,
2410   zsh_cv_c_broken_wcwidth=no)])
2411   if test x$zsh_cv_c_broken_wcwidth = xyes; then
2412     AC_DEFINE(BROKEN_WCWIDTH)
2413   fi
2417 dnl static user lookup
2419 AC_ARG_ENABLE(dynamic-nss,
2420               AC_HELP_STRING([--disable-dynamic-nss], [do not call
2421                               functions that will require dynamic NSS
2422                               modules]),
2423 [zsh_cv_c_dynamic_nss=$enableval],
2426 AH_TEMPLATE([DISABLE_DYNAMIC_NSS],
2427 [Define to 1 if you want to avoid calling functions that will require
2428  dynamic NSS modules.])
2429 if test x$zsh_cv_c_dynamic_nss = xno; then
2430   AC_DEFINE(DISABLE_DYNAMIC_NSS)
2433 dnl ---------------
2434 dnl dynamic loading
2435 dnl ---------------
2436 AH_TEMPLATE([HPUXDYNAMIC],
2437 [Define to 1 if you want to use dynamically loaded modules on HPUX 10.])
2439 INSTLIB="install.bin-\$(L)"
2440 UNINSTLIB="uninstall.bin-\$(L)"
2441 LINKMODS=NOLINKMODS
2442 MOD_EXPORT=
2443 MOD_IMPORT_VARIABLE=
2444 MOD_IMPORT_FUNCTION=
2445 aixdynamic=no
2446 hpuxdynamic=no
2447 if test "$ac_cv_func_load"      = yes &&
2448    test "$ac_cv_func_unload"    = yes &&
2449    test "$ac_cv_func_loadbind"  = yes &&
2450    test "$ac_cv_func_loadquery" = yes; then
2451   dnl Force AIXDYNAMIC even on newer versions that have dl family
2452   if test "x$dynamic" = xyes; then
2453     aixdynamic=yes
2454   fi
2455 elif test "$ac_cv_func_dlopen"  != yes ||
2456      test "$ac_cv_func_dlsym"   != yes ||
2457      test "$ac_cv_func_dlerror" != yes; then
2458   if test "$ac_cv_func_shl_load" != yes ||
2459      test "$ac_cv_func_shl_unload" != yes ||
2460      test "$ac_cv_func_shl_findsym" != yes; then
2461     dynamic=no
2462   elif test "x$dynamic" = xyes; then
2463     hpuxdynamic=yes
2464     DL_EXT="${DL_EXT=sl}"
2465     dnl autoheader won't allow us to define anything which isn't
2466     dnl going into a header, and we can't undefine anything, so
2467     dnl just define this anyway and rely on the later tests to
2468     dnl define DYNAMIC or not.
2469     AC_DEFINE(HPUXDYNAMIC)dnl
2470   fi
2473 test -n "$GCC" && LDARG=-Wl,
2475 AH_TEMPLATE([DLSYM_NEEDS_UNDERSCORE],
2476 [Define to 1 if an underscore has to be prepended to dlsym() argument.])
2477 AH_TEMPLATE([DYNAMIC_NAME_CLASH_OK],
2478 [Define to 1 if multiple modules defining the same symbol are OK.])
2479 if test "x$aixdynamic" = xyes; then
2480   DL_EXT="${DL_EXT=so}"
2481   DLLD="${DLLD=$CC}"
2482   zsh_cv_func_dlsym_needs_underscore=no
2483   if test -n "$GCC"; then
2484     DLLDFLAGS=${DLLDFLAGS=-shared}
2485   else
2486     DLLDFLAGS=${DLLDFLAGS=-bM:SRE}
2487   fi
2488   DLLDFLAGS=${DLLDFLAGS=}
2489   EXTRA_LDFLAGS=${EXTRA_LDFLAGS=}
2490   EXPOPT=${LDARG}-bE:
2491   IMPOPT=${LDARG}-bI:
2492   zsh_cv_sys_dynamic_clash_ok="${zsh_cv_sys_dynamic_clash_ok=yes}"
2493   zsh_cv_sys_dynamic_rtld_global="${zsh_cv_sys_dynamic_rtld_global=yes}"
2494   zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=yes}"
2495   zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}"
2496   zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}"
2497   zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}"
2498 elif test "$host_os" = cygwin; then
2499   DL_EXT="${DL_EXT=dll}"
2500 ##DLLD="${DLLD=dllwrap}"
2501   DLLD="${DLLD=$CC}"
2502 ##DLLDFLAGS="${DLLDFLAGS=--export-all-symbols}"
2503   DLLDFLAGS=${DLLDFLAGS=-shared -Wl,--export-all-symbols}
2504   zsh_cv_func_dlsym_needs_underscore=no
2505   DLLDFLAGS=${DLLDFLAGS=}
2506   EXTRA_LDFLAGS=${EXTRA_LDFLAGS=}
2507   zsh_cv_sys_dynamic_clash_ok="${zsh_cv_sys_dynamic_clash_ok=no}"
2508   zsh_cv_sys_dynamic_rtld_global="${zsh_cv_sys_dynamic_rtld_global=yes}"
2509   zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}"
2510   zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}"
2511   zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}"
2512   #
2513   # THAT SUCKS! and must be changed
2514   #
2515   zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}"
2516   LINKMODS=LINKMODS
2517   MOD_EXPORT="__attribute__((__dllexport__))"
2518   MOD_IMPORT_VARIABLE="__attribute__((__dllimport__))"
2519   MOD_IMPORT_FUNCTION=
2520 elif test "x$dynamic" = xyes; then
2521   AC_CACHE_CHECK(if your system uses ELF binaries,
2522    zsh_cv_sys_elf,
2523    [AC_TRY_RUN([/* Test for whether ELF binaries are produced */
2524 #include <fcntl.h>
2525 #include <stdlib.h>
2526 main(argc, argv)
2527 int argc;
2528 char *argv[];
2530         char b[4];
2531         int i = open(argv[0],O_RDONLY);
2532         if(i == -1) 
2533                 exit(1); /* fail */
2534         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
2535                 exit(0); /* succeed (yes, it's ELF) */
2536         else
2537                 exit(1); /* fail */
2539   zsh_cv_sys_elf=yes,
2540   zsh_cv_sys_elf=no,
2541   zsh_cv_sys_elf=yes)])
2543   # We use [0-9]* in case statements, so need to change quoting
2544   changequote(, )
2546   DL_EXT="${DL_EXT=so}"
2547   if test x$zsh_cv_sys_elf = xyes; then
2548     case "$host" in
2549       mips-sni-sysv4*)
2550         # Forcibly set ld to native compiler to avoid obscure GCC problems
2551         DLLD="${DLLD=/usr/ccs/bin/cc}"
2552         DLLDARG="${LDARG}"
2553       ;;
2554       * )
2555         DLLD="${DLLD=$CC}"
2556         DLLDARG="${LDARG}"
2557       ;;
2558     esac
2559   else
2560     case "$host" in
2561       *openbsd*)
2562         case "$host_os" in
2563           openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
2564             DLLD="${DLLD=ld}"
2565           ;;
2566           *)
2567             DLLD="${DLLD=$CC}"
2568           ;;
2569         esac
2570         DLLDARG="${LDARG}"
2571       ;;
2572       *darwin*)
2573         DLLD="${DLLD=$CC}"
2574         DLLDARG=""
2575       ;;
2576       * )
2577         DLLD="${DLLD=ld}"
2578         DLLDARG=""
2579       ;;
2580     esac
2581   fi
2582   if test -n "$GCC"; then
2583     case "$host_os" in
2584       hpux*)   DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
2585       darwin*) DLCFLAGS="${DLCFLAGS=-fno-common}" ;;
2586       *)       DLCFLAGS="${DLCFLAGS=-fPIC}" ;;
2587     esac
2588   else
2589     case "$host_os" in
2590       hpux*)
2591         DLCFLAGS="${DLCFLAGS=+z}"
2592         DLLDFLAGS="${DLLDFLAGS=-b}"
2593       ;;
2594       sunos*)                DLCFLAGS="${DLCFLAGS=-pic}" ;;
2595       solaris*|sysv4*|esix*) DLCFLAGS="${DLCFLAGS=-KPIC}" ;;
2596     esac
2597   fi
2598   case "$host_os" in
2599     osf*) DLLDFLAGS="${DLLDFLAGS=-shared -expect_unresolved '*'}" ;;
2600     *freebsd*|linux*|irix*|gnu*|dragonfly*) DLLDFLAGS="${DLLDFLAGS=-shared}" ;;
2601     sunos*)       DLLDFLAGS="${DLLDFLAGS=-assert nodefinitions}" ;;
2602     sysv4*|esix*) DLLDFLAGS="${DLLDFLAGS=-G $ldflags}" ;;
2603     netbsd*)      DLLDFLAGS="${DLLDFLAGS=${DLLDARG}-x -shared --whole-archive}" ;;
2604     aix*)         DLLDFLAGS="${DLLDFLAGS=-G -bexpall -lc}" ;;
2605     solaris*|sysv4*|esix*) DLLDFLAGS="${DLLDFLAGS=-G}" ;;
2606     darwin*)      DLLDFLAGS="${DLLDFLAGS=-bundle -flat_namespace -undefined suppress}" ;;
2607     beos*|haiku*) DLLDFLAGS="${DLLDFLAGS=-nostart}" ;;
2608     openbsd*)
2609       if test x$zsh_cv_sys_elf = xyes; then
2610         DLLDFLAGS="${DLLDFLAGS=-shared -fPIC}"
2611       else
2612         case "$host_os" in
2613           openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
2614            DLLDFLAGS="${DLLDFLAGS=-Bshareable}"
2615           ;;
2616           *)
2617             DLLDFLAGS="${DLLDFLAGS=-shared -fPIC}"
2618           ;;
2619         esac
2620       fi
2621     ;;
2622   esac
2623   case "$host" in
2624     *-hpux*)  EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-Wl,-E}" ;;
2625     *openbsd*)
2626        if test x$zsh_cv_sys_elf = xyes; then
2627          EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-Wl,-E}"
2628        fi
2629     ;;
2630     mips-sni-sysv4)
2631       #
2632       # unfortunately, we have different compilers
2633       # that need different flags
2634       #
2635       if test -n "$GCC"; then
2636         sni_cc_version=GCC
2637       else
2638         sni_cc_version=`$CC -V 2>&1 | head -1`
2639       fi
2640       case "$sni_cc_version" in
2641         *CDS*|GCC )
2642          EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-Wl,-Blargedynsym}"
2643        ;;
2644        * )
2645          EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-LD-Blargedynsym}"
2646        ;;
2647       esac
2648     ;;
2649     *-beos*)
2650       # gcc on BeOS doesn't like -rdynamic...
2651       EXTRA_LDFLAGS="${EXTRA_LDFLAGS= }"
2652       # also, dlopen() at least in Zeta respects $LIBRARY_PATH, so needs %A added to it.
2653       export LIBRARY_PATH="$LIBRARY_PATH:%A/"
2654     ;;
2655     *-haiku*)
2656       # 
2657     ;;
2658   esac
2660   # Done with our shell code, so restore autotools quoting
2661   changequote([, ])
2663 AC_CACHE_CHECK(if we can use -rdynamic, zsh_cv_rdynamic_available,
2664 old_LDFLAGS="$LDFLAGS"
2665 LDFLAGS="$LDFLAGS -rdynamic"
2666 AC_TRY_LINK([], [], [zsh_cv_rdynamic_available=yes
2667 EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}"],
2668 [zsh_cvs_rdynamic_available=no])
2669 LDFLAGS="$old_LDFLAGS")
2670   AC_CACHE_CHECK(if your dlsym() needs a leading underscore,
2671    zsh_cv_func_dlsym_needs_underscore,
2672    [echo failed >conftestval && cat >conftest.c <<EOM
2673 fred () { }
2675     AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest.c 1>&AC_FD_CC) &&
2676     AC_TRY_COMMAND($DLLD $LDFLAGS $DLLDFLAGS -o conftest.$DL_EXT conftest.o 1>&AC_FD_CC) &&
2677     AC_TRY_RUN([
2678 #include <stdio.h>
2679 #ifdef HPUXDYNAMIC
2680 #include <dl.h>
2681 #define RTLD_LAZY BIND_DEFERRED
2682 #define RTLD_GLOBAL DYNAMIC_PATH
2684 char *zsh_gl_sym_addr ;
2686 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
2687 #define dlclose(handle) shl_unload((shl_t)(handle))
2688 #define dlsym(handle,name) (zsh_gl_sym_addr=0,shl_findsym((shl_t *)&(handle),name,TYPE_UNDEFINED,&zsh_gl_sym_addr), (void *)zsh_gl_sym_addr)
2689 #define dlerror() 0
2690 #else
2691 #ifdef HAVE_DLFCN_H
2692 #include <dlfcn.h>
2693 #else
2694 #include <sys/types.h>
2695 #include <nlist.h>
2696 #include <link.h>
2697 #endif
2698 #endif
2699 #ifndef RTLD_LAZY
2700 #define RTLD_LAZY 1
2701 #endif
2703 extern int fred() ;
2705 main()
2707     void * handle ;
2708     void * symbol ;
2709     FILE *f=fopen("conftestval", "w");
2710     if (!f) exit(1);
2711     handle = dlopen("./conftest.$DL_EXT", RTLD_LAZY) ;
2712     if (handle == NULL) {
2713         fprintf (f, "dlopen failed") ;
2714             exit(1);
2715     }
2716     symbol = dlsym(handle, "fred") ;
2717     if (symbol == NULL) {
2718                 /* try putting a leading underscore */
2719         symbol = dlsym(handle, "_fred") ;
2720         if (symbol == NULL) {
2721             fprintf (f, "dlsym failed") ;
2722                 exit(1);
2723                 }
2724         fprintf (f, "yes") ;
2725     }
2726     else
2727         fprintf (f, "no") ;
2728     exit(0);
2729 }], zsh_cv_func_dlsym_needs_underscore=`cat conftestval`,
2730     zsh_cv_func_dlsym_needs_underscore=failed
2731     dynamic=no,
2732     zsh_cv_func_dlsym_needs_underscore=no)])
2733   if test "x$zsh_cv_func_dlsym_needs_underscore" = xyes; then
2734     AC_DEFINE(DLSYM_NEEDS_UNDERSCORE)
2735   elif test "x$zsh_cv_func_dlsym_needs_underscore" != xno; then
2736     dnl Do not cache failed value
2737     unset zsh_cv_func_dlsym_needs_underscore
2738   fi
2741 if test "x$dynamic" = xyes; then
2742   zsh_SHARED_VARIABLE([environ], [char **])
2743   test "$zsh_cv_shared_environ" = yes || dynamic=no
2744   if test "$ac_cv_func_tgetent" = yes; then
2745     zsh_SHARED_FUNCTION([tgetent])
2746   fi
2747   if test "$ac_cv_func_tigetstr" = yes; then
2748     zsh_SHARED_FUNCTION([tigetstr])
2749   fi
2752 if test "x$dynamic" = xyes; then
2753   zsh_SYS_DYNAMIC_CLASH
2754   zsh_SYS_DYNAMIC_GLOBAL
2755   RTLD_GLOBAL_OK=$zsh_cv_sys_dynamic_rtld_global
2756   zsh_SYS_DYNAMIC_EXECSYMS
2757   if test "$zsh_cv_sys_dynamic_execsyms" != yes; then
2758     L=L
2759   fi
2760   zsh_SYS_DYNAMIC_STRIP_EXE
2761   zsh_SYS_DYNAMIC_STRIP_LIB
2762   if $strip_exeldflags && test "$zsh_cv_sys_dynamic_strip_exe" = yes; then
2763     EXELDFLAGS="$EXELDFLAGS -s"
2764   fi
2765   if $strip_libldflags && test "$zsh_cv_sys_dynamic_strip_lib" = yes; then
2766     LIBLDFLAGS="$LIBLDFLAGS -s"
2767   fi
2768   if test "$host_os" = cygwin; then
2769     INSTLIB="install.cygwin-lib"
2770     UNINSTLIB="uninstall.cygwin-lib"
2771   fi
2772 else
2773   $strip_exeldflags && EXELDFLAGS="$EXELDFLAGS -s"
2774   $strip_libldflags && LIBLDFLAGS="$LIBLDFLAGS -s"
2775   RTLD_GLOBAL_OK=no
2778 AH_TEMPLATE([DYNAMIC],
2779 [Define to 1 if you want to use dynamically loaded modules.])
2780 if test "x$dynamic" = xyes; then
2781   D=D
2782   AC_DEFINE(DYNAMIC)dnl
2783 else
2784   D=N
2787 AH_TEMPLATE([AIXDYNAMIC],
2788 [Define to 1 if you want to use dynamically loaded modules on AIX.])
2789 if test "x$aixdynamic" = xyes; then
2790   E=E
2791   AC_DEFINE(AIXDYNAMIC)dnl
2792 else
2793   E=N
2796 if test "x$zsh_cv_sys_dynamic_clash_ok" = xyes; then
2797   SHORTBOOTNAMES=yes
2798 else
2799   SHORTBOOTNAMES=no
2801 AC_SUBST(SHORTBOOTNAMES)
2803 AC_SUBST(INSTLIB)dnl
2804 AC_SUBST(UNINSTLIB)dnl
2806 if test "$host_os" = cygwin; then
2807   EXTRAZSHOBJS="$EXTRAZSHOBJS zsh.res.o"
2810 AC_DEFINE_UNQUOTED(DL_EXT, "$DL_EXT",
2811 [The extension used for dynamically loaded modules.])dnl
2812 AC_SUBST(D)dnl
2813 AC_SUBST(DL_EXT)dnl
2814 AC_SUBST(DLLD)dnl
2815 AC_SUBST(DLCFLAGS)dnl
2816 AC_SUBST(DLLDFLAGS)dnl
2817 AC_SUBST(E)dnl
2818 AC_SUBST(EXTRA_LDFLAGS)dnl
2819 AC_SUBST(EXPOPT)dnl
2820 AC_SUBST(IMPOPT)dnl
2821 AC_SUBST(L)dnl
2822 AC_SUBST(LINKMODS)dnl
2823 AC_SUBST(MOD_EXPORT)dnl
2824 AC_SUBST(MOD_IMPORT_VARIABLE)dnl
2825 AC_SUBST(MOD_IMPORT_FUNCTION)dnl
2826 AC_SUBST(EXTRAZSHOBJS)dnl
2828 # Generate config.modules.  We look for *.mdd files in first and second
2829 # level subdirectories.  Any existing line not containing 'auto=y' will be
2830 # retained, provided the .mdd file itself was found.
2831 CONFIG_MODULES=./config.modules
2832 cat <<EOM > ${CONFIG_MODULES}.sh
2833 srcdir="$srcdir"
2834 dynamic="$dynamic"
2835 CONFIG_MODULES="${CONFIG_MODULES}"
2837 cat <<\EOM >> ${CONFIG_MODULES}.sh
2838 echo "creating ${CONFIG_MODULES}"
2839 userlist=" "
2840 if test -f ${CONFIG_MODULES}; then
2841   userlist="`sed -e '/^#/d' -e '/auto=y/d' -e 's/ .*/ /' -e 's/^name=/ /' \
2842         ${CONFIG_MODULES}`"
2843   mv ${CONFIG_MODULES} ${CONFIG_MODULES}.old
2844 else
2845   # Save testing for existence each time.
2846   echo > ${CONFIG_MODULES}.old
2848 (echo "# Edit this file to change the way modules are loaded."
2849 echo "# The format is strict; do not break lines or add extra spaces."
2850 echo "# Run \`make prep' if you change anything here after compiling"
2851 echo "# (there is no need if you change this just after the first time"
2852 echo "# you run \`configure')."
2853 echo "#"
2854 echo "# Values of \`link' are \`static', \`dynamic' or \`no' to compile the"
2855 echo "# module into the shell, link it in at run time, or not use it at all."
2856 echo "# In the final case, no attempt will be made to compile it."
2857 echo "# Use \`static' or \`no' if you do not have dynamic loading."
2858 echo "#"
2859 echo "# Values of \`load' are \`yes' or \`no'; if yes, any builtins etc."
2860 echo "# provided by the module will be autoloaded by the main shell"
2861 echo "# (so long as \`link' is not set to \`no')."
2862 echo "#"
2863 echo "# Values of \`auto' are \`yes' or \`no'. configure sets the value to"
2864 echo "# \`yes'.  If you set it by hand to \`no', the line will be retained"
2865 echo "# when the file is regenerated in future."
2866 echo "#"
2867 echo "# Note that the \`functions' entry extends to the end of the line."
2868 echo "# It should not be quoted; it is used verbatim to find files to install."
2869 echo "#"
2870 echo "# You will need to run \`config.status --recheck' if you add a new"
2871 echo "# module."
2872 echo "#"
2873 echo "# You should not change the values for the pseudo-module zsh/main,"
2874 echo "# which is the main shell (apart from the functions entry)."
2876 dnl The autoconf macros are only available in configure, not
2877 dnl config.status, and only change when configure is rerun.
2878 dnl So we need to run the autoconf tests here and store the results.
2879 dnl We then generate config.modules, preserving any user-generated
2880 dnl information, from config.status.
2881 for modfile in `cd ${srcdir}; echo */*.mdd */*/*.mdd`; do
2882   name=
2883   link=
2884   load=
2885   functions=
2886   result=
2887   . ${srcdir}/$modfile
2888   if test x$name != x && test x"$link" != x; then
2889     case "$link" in
2890       *\ *) eval "link=\`$link\`"
2891             ;;
2892     esac
2893     case "${load}" in
2894       y*) load=" load=yes"
2895           ;;
2896       *) load=" load=no"
2897          ;;
2898     esac
2899     if test "x$functions" != x; then
2900       # N.B. no additional quotes
2901       f=" functions=$functions"
2902     else
2903       f=
2904     fi
2905     case "$link" in
2906       static) result="name=$name modfile=$modfile link=static auto=yes${load}$f"
2907               ;;
2908       dynamic) if test x$dynamic != xno; then
2909                   result="name=$name modfile=$modfile link=dynamic\
2910  auto=yes${load}$f"
2911                else
2912                  result="name=$name modfile=$modfile link=no\
2913  auto=yes load=no$f"
2914                fi
2915                ;;
2916       either) if test x$dynamic != xno; then
2917                 result="name=$name modfile=$modfile link=dynamic\
2918  auto=yes${load}$f"
2919               else
2920                 result="name=$name modfile=$modfile link=static\
2921  auto=yes${load}$f"
2922               fi
2923               ;;
2924        *) result="name=$name modfile=$modfile link=no auto=yes load=no$f"
2925           ;;
2926     esac
2927 dnl $result is the default output for config.modules.  We generate
2928 dnl code to check if we should use this.
2929 cat <<EOM >> ${CONFIG_MODULES}.sh
2930 case "\$userlist" in
2931   *" $name "*) grep "^name=$name " \${CONFIG_MODULES}.old;;
2932   *) echo "$result";;
2933 esac
2935   fi
2936 done
2937 cat <<\EOM >> ${CONFIG_MODULES}.sh
2938 ) >${CONFIG_MODULES}
2939 rm -f ${CONFIG_MODULES}.old
2942 dnl AH_TOP replaces the code which used to appear at the top
2943 dnl of acconfig.h.
2944 AH_TOP([/***** begin user configuration section *****/
2946 /* Define this to be the location of your password file */
2947 #define PASSWD_FILE "/etc/passwd"
2949 /* Define this to be the name of your NIS/YP password *
2950  * map (if applicable)                                */
2951 #define PASSWD_MAP "passwd.byname"
2953 /* Define to 1 if you want user names to be cached */
2954 #define CACHE_USERNAMES 1
2956 /* Define to 1 if system supports job control */
2957 #define JOB_CONTROL 1
2959 /* Define this if you use "suspended" instead of "stopped" */
2960 #define USE_SUSPENDED 1
2962 /* The default history buffer size in lines */
2963 #define DEFAULT_HISTSIZE 30
2965 /* The default editor for the fc builtin */
2966 #define DEFAULT_FCEDIT "vi"
2968 /* The default prefix for temporary files */
2969 #define DEFAULT_TMPPREFIX "/tmp/zsh"
2971 /***** end of user configuration section            *****/
2972 /***** shouldn't have to change anything below here *****/
2976 CLEAN_MK="${srcdir}/Config/clean.mk"
2977 CONFIG_MK="${srcdir}/Config/config.mk"
2978 dnl defs.mk is in the build tree, not the source tree
2979 DEFS_MK="Config/defs.mk"
2980 VERSION_MK="${srcdir}/Config/version.mk"
2982 AC_SUBST_FILE(CLEAN_MK)dnl
2983 AC_SUBST_FILE(CONFIG_MK)dnl
2984 AC_SUBST_FILE(DEFS_MK)dnl
2985 AC_SUBST_FILE(VERSION_MK)dnl
2987 AC_CONFIG_FILES(Config/defs.mk Makefile Doc/Makefile Etc/Makefile \
2988 Src/Makefile Test/Makefile)
2989 AC_CONFIG_COMMANDS([config.modules], [. ./config.modules.sh])
2990 AC_CONFIG_COMMANDS([stamp-h], [echo >stamp-h])
2992 AC_OUTPUT
2994 eval "zshbin1=${bindir}"
2995 eval "zshbin2=${zshbin1}"
2996 eval "zshman=${mandir}"
2997 eval "zshinfo=${infodir}"
2998 eval "zshfndir=${fndir}"
3000 echo "
3001 zsh configuration
3002 -----------------
3003 zsh version               : ${VERSION}
3004 host operating system     : ${host_cpu}-${host_vendor}-${host_os}
3005 source code location      : ${srcdir}
3006 compiler                  : ${CC}
3007 preprocessor flags        : ${CPPFLAGS}
3008 executable compiler flags : ${CFLAGS}"
3009 if test "x$dynamic" = xyes; then
3010   echo "\
3011 module compiler flags     : ${CFLAGS} ${DLCFLAGS}"
3013 echo "\
3014 executable linker flags   : ${LDFLAGS} ${EXELDFLAGS} ${EXTRA_LDFLAGS}"
3015 if test "x$dynamic" = xyes; then
3016   echo "\
3017 module linker flags       : ${LDFLAGS} ${LIBLDFLAGS} ${DLLDFLAGS}"
3019 echo "\
3020 library flags             : ${LIBS}
3021 installation basename     : ${tzsh_name}
3022 binary install path       : ${zshbin2}
3023 man page install path     : ${zshman}
3024 info install path         : ${zshinfo}"
3025 if test "$zshfndir" != no; then
3026   echo "functions install path    : ${zshfndir}"
3028 echo "See config.modules for installed modules and functions.
3031 case x$LIBS in
3032   *-lgdbm*)
3033   echo "WARNING: zsh will be linked against libgdbm.
3034 This means the binary is covered by the GNU General Public License.
3035 This does not affect the source code.
3036 Run configure with --disable-gdbm if required."
3037   ;;
3038 esac
3040 exit 0