26763: fix problem on failed cd -s to relative path
[zsh.git] / aczsh.m4
blobc362761314f826335be547ea47ea618891874e27
1 dnl
2 dnl  Autconf tests for zsh.
3 dnl
4 dnl  Copyright (c) 1995-1997 Richard Coleman
5 dnl  All rights reserved.
6 dnl
7 dnl  Permission is hereby granted, without written agreement and without
8 dnl  license or royalty fees, to use, copy, modify, and distribute this
9 dnl  software and to distribute modified versions of this software for any
10 dnl  purpose, provided that the above copyright notice and the following
11 dnl  two paragraphs appear in all copies of this software.
12 dnl
13 dnl  In no event shall Richard Coleman or the Zsh Development Group be liable
14 dnl  to any party for direct, indirect, special, incidental, or consequential
15 dnl  damages arising out of the use of this software and its documentation,
16 dnl  even if Richard Coleman and the Zsh Development Group have been advised of
17 dnl  the possibility of such damage.
18 dnl
19 dnl  Richard Coleman and the Zsh Development Group specifically disclaim any
20 dnl  warranties, including, but not limited to, the implied warranties of
21 dnl  merchantability and fitness for a particular purpose.  The software
22 dnl  provided hereunder is on an "as is" basis, and Richard Coleman and the
23 dnl  Zsh Development Group have no obligation to provide maintenance,
24 dnl  support, updates, enhancements, or modifications.
25 dnl
27 dnl
28 dnl zsh_64_BIT_TYPE
29 dnl   Check whether the first argument works as a 64-bit type.
30 dnl   If there is a non-zero third argument, we just assume it works
31 dnl   when we're cross compiling.  This is to allow a type to be
32 dnl   specified directly as --enable-lfs="long long".
33 dnl   Sets the variable given in the second argument to the first argument
34 dnl   if the test worked, `no' otherwise.  Be careful testing this, as it
35 dnl   may produce two words `long long' on an unquoted substitution.
36 dnl   Also check that the compiler does not mind it being cast to int.
37 dnl   This macro does not produce messages as it may be run several times
38 dnl   before finding the right type.
39 dnl
41 AC_DEFUN(zsh_64_BIT_TYPE,
42 [AC_TRY_RUN([
43 #ifdef HAVE_SYS_TYPES_H
44 #include <sys/types.h>
45 #endif
47 main()
49   $1 foo = 0; 
50   int bar = (int) foo;
51   return sizeof($1) != 8;
53 ], $2="$1", $2=no,
54   [if test x$3 != x ; then
55     $2="$1"
56   else
57     $2=no
58   fi])
62 dnl
63 dnl zsh_SHARED_FUNCTION
64 dnl
65 dnl This is just a frontend to zsh_SHARED_SYMBOL
66 dnl
67 dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]])
68 dnl
70 AC_DEFUN(zsh_SHARED_FUNCTION,
71 [zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)])
73 dnl
74 dnl zsh_SHARED_VARIABLE
75 dnl
76 dnl This is just a frontend to zsh_SHARED_SYMBOL
77 dnl
78 dnl Usage: zsh_SHARED_VARIABLE(name[,type])
79 dnl
81 AC_DEFUN(zsh_SHARED_VARIABLE,
82 [zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])])
84 dnl
85 dnl zsh_SHARED_SYMBOL
86 dnl   Check whether symbol is available in static or shared library
87 dnl
88 dnl   On some systems, static modifiable library symbols (such as environ)
89 dnl   may appear only in statically linked libraries.  If this is the case,
90 dnl   then two shared libraries that reference the same symbol, each linked
91 dnl   with the static library, could be given distinct copies of the symbol.
92 dnl
93 dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address)
94 dnl Sets zsh_cv_shared_$1 cache variable to yes/no
95 dnl
97 AC_DEFUN(zsh_SHARED_SYMBOL,
98 [AC_CACHE_CHECK([if $1 is available in shared libraries],
99 zsh_cv_shared_$1,
100 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
101     us=_
102 else
103     us=
105 echo '
106 void *zsh_getaddr1()
108 #ifdef __CYGWIN__
109         __attribute__((__dllimport__))  
110 #endif
111         extern $2;
112         return $3;
114 ' > conftest1.c
115 sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c
116 if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
117 AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
118 AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
119 AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
120     AC_TRY_RUN([
121 #ifdef HPUXDYNAMIC
122 #include <dl.h>
123 #define RTLD_LAZY BIND_DEFERRED
124 #define RTLD_GLOBAL DYNAMIC_PATH
126 char *zsh_gl_sym_addr ;
128 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
129 #define dlclose(handle) shl_unload((shl_t)(handle))
130 #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)
131 #define dlerror() 0
132 #else
133 #ifdef HAVE_DLFCN_H
134 #include <dlfcn.h>
135 #else
136 #include <sys/types.h>
137 #include <nlist.h>
138 #include <link.h>
139 #endif
140 #endif
141 #ifndef RTLD_LAZY
142 #define RTLD_LAZY 1
143 #endif
144 #ifndef RTLD_GLOBAL
145 #define RTLD_GLOBAL 0
146 #endif
148 main()
150     void *handle1, *handle2;
151     void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();
152     void *sym1, *sym2;
153     handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
154     if(!handle1) exit(1);
155     handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
156     if(!handle2) exit(1);
157     zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
158     zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");
159     sym1 = zsh_getaddr1();
160     sym2 = zsh_getaddr2();
161     if(!sym1 || !sym2) exit(1);
162     if(sym1 != sym2) exit(1);
163     dlclose(handle1);
164     handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
165     if(!handle1) exit(1);
166     zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
167     sym1 = zsh_getaddr1();
168     if(!sym1) exit(1);
169     if(sym1 != sym2) exit(1);
170     exit(0);
172 ], [zsh_cv_shared_$1=yes],
173 [zsh_cv_shared_$1=no],
174 [zsh_cv_shared_$1=no]
176 else
177     zsh_cv_shared_$1=no
183 dnl zsh_SYS_DYNAMIC_CLASH
184 dnl   Check whether symbol name clashes in shared libraries are acceptable.
187 AC_DEFUN(zsh_SYS_DYNAMIC_CLASH,
188 [AC_CACHE_CHECK([if name clashes in shared objects are OK],
189 zsh_cv_sys_dynamic_clash_ok,
190 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
191     us=_
192 else
193     us=
195 echo 'int fred () { return 42; }' > conftest1.c
196 echo 'int fred () { return 69; }' > conftest2.c
197 if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
198 AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
199 AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
200 AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
201     AC_TRY_RUN([
202 #ifdef HPUXDYNAMIC
203 #include <dl.h>
204 #define RTLD_LAZY BIND_DEFERRED
205 #define RTLD_GLOBAL DYNAMIC_PATH
207 char *zsh_gl_sym_addr ;
209 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
210 #define dlclose(handle) shl_unload((shl_t)(handle))
211 #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)
212 #define dlerror() 0
213 #else
214 #ifdef HAVE_DLFCN_H
215 #include <dlfcn.h>
216 #else
217 #include <sys/types.h>
218 #include <nlist.h>
219 #include <link.h>
220 #endif
221 #endif
222 #ifndef RTLD_LAZY
223 #define RTLD_LAZY 1
224 #endif
225 #ifndef RTLD_GLOBAL
226 #define RTLD_GLOBAL 0
227 #endif
230 main()
232     void *handle1, *handle2;
233     int (*fred1)(), (*fred2)();
234     handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
235     if(!handle1) exit(1);
236     handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
237     if(!handle2) exit(1);
238     fred1 = (int (*)()) dlsym(handle1, "${us}fred");
239     fred2 = (int (*)()) dlsym(handle2, "${us}fred");
240     if(!fred1 || !fred2) exit(1);
241     exit((*fred1)() != 42 || (*fred2)() != 69);
243 ], [zsh_cv_sys_dynamic_clash_ok=yes],
244 [zsh_cv_sys_dynamic_clash_ok=no],
245 [zsh_cv_sys_dynamic_clash_ok=no]
247 else
248     zsh_cv_sys_dynamic_clash_ok=no
251 if test "$zsh_cv_sys_dynamic_clash_ok" = yes; then
252     AC_DEFINE(DYNAMIC_NAME_CLASH_OK)
257 dnl zsh_SYS_DYNAMIC_GLOBAL
258 dnl   Check whether symbols in one dynamically loaded library are
259 dnl   available to another dynamically loaded library.
262 AC_DEFUN(zsh_SYS_DYNAMIC_GLOBAL,
263 [AC_CACHE_CHECK([for working RTLD_GLOBAL],
264 zsh_cv_sys_dynamic_rtld_global,
265 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
266     us=_
267 else
268     us=
270 echo 'int fred () { return 42; }' > conftest1.c
271 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c
272 if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
273 AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
274 AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
275 AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
276     AC_TRY_RUN([
277 #ifdef HPUXDYNAMIC
278 #include <dl.h>
279 #define RTLD_LAZY BIND_DEFERRED
280 #define RTLD_GLOBAL DYNAMIC_PATH
282 char *zsh_gl_sym_addr ;
284 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
285 #define dlclose(handle) shl_unload((shl_t)(handle))
286 #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)
287 #define dlerror() 0
288 #else
289 #ifdef HAVE_DLFCN_H
290 #include <dlfcn.h>
291 #else
292 #include <sys/types.h>
293 #include <nlist.h>
294 #include <link.h>
295 #endif
296 #endif
297 #ifndef RTLD_LAZY
298 #define RTLD_LAZY 1
299 #endif
300 #ifndef RTLD_GLOBAL
301 #define RTLD_GLOBAL 0
302 #endif
304 main()
306     void *handle;
307     int (*barneysym)();
308     handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
309     if(!handle) exit(1);
310     handle = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
311     if(!handle) exit(1);
312     barneysym = (int (*)()) dlsym(handle, "${us}barney");
313     if(!barneysym) exit(1);
314     exit((*barneysym)() != 69);
316 ], [zsh_cv_sys_dynamic_rtld_global=yes],
317 [zsh_cv_sys_dynamic_rtld_global=no],
318 [zsh_cv_sys_dynamic_rtld_global=no]
320 else
321     zsh_cv_sys_dynamic_rtld_global=no
327 dnl zsh_SYS_DYNAMIC_EXECSYMS
328 dnl   Check whether symbols in the executable are available to dynamically
329 dnl   loaded libraries.
332 AC_DEFUN(zsh_SYS_DYNAMIC_EXECSYMS,
333 [AC_CACHE_CHECK([whether symbols in the executable are available],
334 zsh_cv_sys_dynamic_execsyms,
335 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
336     us=_
337 else
338     us=
340 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest1.c
341 if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
342 AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
343     save_ldflags=$LDFLAGS
344     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
345     AC_TRY_RUN([
346 #ifdef HPUXDYNAMIC
347 #include <dl.h>
348 #define RTLD_LAZY BIND_DEFERRED
349 #define RTLD_GLOBAL DYNAMIC_PATH
351 char *zsh_gl_sym_addr ;
353 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
354 #define dlclose(handle) shl_unload((shl_t)(handle))
355 #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)
356 #define dlerror() 0
357 #else
358 #ifdef HAVE_DLFCN_H
359 #include <dlfcn.h>
360 #else
361 #include <sys/types.h>
362 #include <nlist.h>
363 #include <link.h>
364 #endif
365 #endif
366 #ifndef RTLD_LAZY
367 #define RTLD_LAZY 1
368 #endif
369 #ifndef RTLD_GLOBAL
370 #define RTLD_GLOBAL 0
371 #endif
373 main()
375     void *handle;
376     int (*barneysym)();
377     handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
378     if(!handle) exit(1);
379     barneysym = (int (*)()) dlsym(handle, "${us}barney");
380     if(!barneysym) exit(1);
381     exit((*barneysym)() != 69);
384 int fred () { return 42; }
385 ], [zsh_cv_sys_dynamic_execsyms=yes],
386 [zsh_cv_sys_dynamic_execsyms=no],
387 [zsh_cv_sys_dynamic_execsyms=no]
389     LDFLAGS=$save_ldflags
390 else
391     zsh_cv_sys_dynamic_execsyms=no
397 dnl zsh_SYS_DYNAMIC_STRIP_EXE
398 dnl   Check whether it is safe to strip executables.
401 AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_EXE,
402 [AC_REQUIRE([zsh_SYS_DYNAMIC_EXECSYMS])
403 AC_CACHE_CHECK([whether executables can be stripped],
404 zsh_cv_sys_dynamic_strip_exe,
405 [if test "$zsh_cv_sys_dynamic_execsyms" != yes; then
406     zsh_cv_sys_dynamic_strip_exe=yes
407 elif
408     if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
409         us=_
410     else
411         us=
412     fi
413     echo 'extern int fred(); int barney() { return fred() + 27; }' > conftest1.c
414     AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
415     AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
416     save_ldflags=$LDFLAGS
417     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -s"
418     AC_TRY_RUN([
419 #ifdef HPUXDYNAMIC
420 #include <dl.h>
421 #define RTLD_LAZY BIND_DEFERRED
422 #define RTLD_GLOBAL DYNAMIC_PATH
424 char *zsh_gl_sym_addr ;
426 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
427 #define dlclose(handle) shl_unload((shl_t)(handle))
428 #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)
429 #define dlerror() 0
430 #else
431 #ifdef HAVE_DLFCN_H
432 #include <dlfcn.h>
433 #else
434 #include <sys/types.h>
435 #include <nlist.h>
436 #include <link.h>
437 #endif
438 #endif
439 #ifndef RTLD_LAZY
440 #define RTLD_LAZY 1
441 #endif
442 #ifndef RTLD_GLOBAL
443 #define RTLD_GLOBAL 0
444 #endif
446 main()
448     void *handle;
449     int (*barneysym)();
450     handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
451     if(!handle) exit(1);
452     barneysym = (int (*)()) dlsym(handle, "${us}barney");
453     if(!barneysym) exit(1);
454     exit((*barneysym)() != 69);
457 int fred () { return 42; }
458 ], [zsh_cv_sys_dynamic_strip_exe=yes],
459 [zsh_cv_sys_dynamic_strip_exe=no],
460 [zsh_cv_sys_dynamic_strip_exe=no]
462     LDFLAGS=$save_ldflags
463 else
464     zsh_cv_sys_dynamic_strip_exe=no
470 dnl zsh_SYS_DYNAMIC_STRIP_EXE
471 dnl   Check whether it is safe to strip dynamically loaded libraries.
474 AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_LIB,
475 [AC_CACHE_CHECK([whether libraries can be stripped],
476 zsh_cv_sys_dynamic_strip_lib,
477 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
478     us=_
479 else
480     us=
482 echo 'int fred () { return 42; }' > conftest1.c
483 if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
484 AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AC_FD_CC); then
485     AC_TRY_RUN([
486 #ifdef HPUXDYNAMIC
487 #include <dl.h>
488 #define RTLD_LAZY BIND_DEFERRED
489 #define RTLD_GLOBAL DYNAMIC_PATH
491 char *zsh_gl_sym_addr ;
493 #define dlopen(file,mode) (void *)shl_load((file), (mode), (long) 0)
494 #define dlclose(handle) shl_unload((shl_t)(handle))
495 #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)
496 #define dlerror() 0
497 #else
498 #ifdef HAVE_DLFCN_H
499 #include <dlfcn.h>
500 #else
501 #include <sys/types.h>
502 #include <nlist.h>
503 #include <link.h>
504 #endif
505 #endif
506 #ifndef RTLD_LAZY
507 #define RTLD_LAZY 1
508 #endif
509 #ifndef RTLD_GLOBAL
510 #define RTLD_GLOBAL 0
511 #endif
513 main()
515     void *handle;
516     int (*fredsym)();
517     handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
518     if(!handle) exit(1);
519     fredsym = (int (*)()) dlsym(handle, "${us}fred");
520     if(!fredsym) exit(1);
521     exit((*fredsym)() != 42);
523 ], [zsh_cv_sys_dynamic_strip_lib=yes],
524 [zsh_cv_sys_dynamic_strip_lib=no],
525 [zsh_cv_sys_dynamic_strip_lib=no]
527 else
528     zsh_cv_sys_dynamic_strip_lib=no
534 dnl zsh_PATH_UTMP(filename)
535 dnl   Search for a specified utmp-type file.
538 AC_DEFUN(zsh_PATH_UTMP,
539 [AC_CACHE_CHECK([for $1 file], [zsh_cv_path_$1],
540 [for dir in /etc /usr/etc /var/adm /usr/adm /var/run /var/log ./conftest; do
541   zsh_cv_path_$1=${dir}/$1
542   test -f $zsh_cv_path_$1 && break
543   zsh_cv_path_$1=no
544 done
546 AH_TEMPLATE([PATH_]translit($1, [a-z], [A-Z])[_FILE],
547 [Define to be location of ]$1[ file.])
548 if test $zsh_cv_path_$1 != no; then
549   AC_DEFINE_UNQUOTED([PATH_]translit($1, [a-z], [A-Z])[_FILE],
550   "$zsh_cv_path_$1")
555 dnl zsh_TYPE_EXISTS(#includes, type name)
556 dnl   Check whether a specified type exists.
559 AC_DEFUN(zsh_TYPE_EXISTS,
560 [AC_CACHE_CHECK([for $2], [zsh_cv_type_exists_[]translit($2, [ ], [_])],
561 [AC_TRY_COMPILE([$1], [$2 testvar;],
562 [zsh_cv_type_exists_[]translit($2, [ ], [_])=yes],
563 [zsh_cv_type_exists_[]translit($2, [ ], [_])=no])
565 AH_TEMPLATE([HAVE_]translit($2, [ a-z], [_A-Z]),
566 [Define to 1 if ]$2[ is defined by a system header])
567 if test $zsh_cv_type_exists_[]translit($2, [ ], [_]) = yes; then
568   AC_DEFINE([HAVE_]translit($2, [ a-z], [_A-Z]))
573 dnl zsh_STRUCT_MEMBER(#includes, type name, member name)
574 dnl   Check whether a specified aggregate type exists and contains
575 dnl   a specified member.
578 AC_DEFUN(zsh_STRUCT_MEMBER,
579 [AC_CACHE_CHECK([for $3 in $2], [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3],
580 [AC_TRY_COMPILE([$1], [$2 testvar; testvar.$3;],
581 [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=yes],
582 [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=no])
584 AH_TEMPLATE([HAVE_]translit($2_$3, [ a-z], [_A-Z]),
585 [Define if your system's ]$2[ has a member named ]$3[.])
586 if test $zsh_cv_struct_member_[]translit($2, [ ], [_])_$3 = yes; then
587   AC_DEFINE([HAVE_]translit($2_$3, [ a-z], [_A-Z]))
592 dnl zsh_ARG_PROGRAM
593 dnl   Handle AC_ARG_PROGRAM substitutions into other zsh configure macros.
594 dnl   After processing this macro, the configure script may refer to
595 dnl   and $tzsh_name, and @tzsh@ is defined for make substitutions.
598 AC_DEFUN(zsh_ARG_PROGRAM,
599 [AC_ARG_PROGRAM
600 # Un-double any \ or $ (doubled by AC_ARG_PROGRAM).
601 cat <<\EOF_SED > conftestsed
602 s,\\\\,\\,g; s,\$\$,$,g
603 EOF_SED
604 zsh_transform_name=`echo "${program_transform_name}" | sed -f conftestsed`
605 rm -f conftestsed
606 tzsh_name=`echo zsh | sed -e "${zsh_transform_name}"`
607 # Double any \ or $ in the transformed name that results.
608 cat <<\EOF_SED >> conftestsed
609 s,\\,\\\\,g; s,\$,$$,g
610 EOF_SED
611 tzsh=`echo ${tzsh_name} | sed -f conftestsed`
612 rm -f conftestsed
613 AC_SUBST(tzsh)dnl
616 AC_DEFUN(zsh_COMPILE_FLAGS,
617     [AC_ARG_ENABLE(cppflags,
618         AC_HELP_STRING([--enable-cppflags=...], [specify C preprocessor flags]),
619         if test "$enableval" = "yes"
620         then CPPFLAGS="$1"
621         else CPPFLAGS="$enable_cppflags"
622         fi)
623     AC_ARG_ENABLE(cflags,
624         AC_HELP_STRING([--enable-cflags=...], [specify C compiler flags]),
625         if test "$enableval" = "yes"
626         then CFLAGS="$2"
627         else CFLAGS="$enable_cflags"
628         fi)
629     AC_ARG_ENABLE(ldflags,
630         AC_HELP_STRING([--enable-ldflags=...], [specify linker flags]),
631         if test "$enableval" = "yes"
632         then LDFLAGS="$3"
633         else LDFLAGS="$enable_ldflags"
634         fi)
635     AC_ARG_ENABLE(libs,
636         AC_HELP_STRING([--enable-libs=...], [specify link libraries]),
637         if test "$enableval" = "yes"
638         then LIBS="$4"
639         else LIBS="$enable_libs"
640         fi)])
642 dnl 
643 dnl zsh_CHECK_SOCKLEN_T
645 dnl     check type of third argument of some network functions; currently
646 dnl     tested are size_t *, unsigned long *, int *.
647 dnl     call the result ZSOCKLEN_T since some systems have SOCKLEN_T already
649 AC_DEFUN([zsh_CHECK_SOCKLEN_T],[
650   AC_CACHE_CHECK(
651     [base type of the third argument to accept],
652     [zsh_cv_type_socklen_t],
653     [zsh_cv_type_socklen_t=
654     for zsh_type in socklen_t int "unsigned long" size_t ; do
655       AC_TRY_COMPILE(
656         [#include <sys/types.h>
657          #include <sys/socket.h>],
658         [extern int accept (int, struct sockaddr *, $zsh_type *);],
659         [zsh_cv_type_socklen_t="$zsh_type"; break],
660         []
661       )
662     done
663     if test -z "$zsh_cv_type_socklen_t"; then
664       zsh_cv_type_socklen_t=int
665     fi]
666   )
667   AC_DEFINE_UNQUOTED([ZSOCKLEN_T], [$zsh_cv_type_socklen_t],
668   [Define to the base type of the third argument of accept])]
671 dnl Check for limit $1 e.g. RLIMIT_RSS.
672 AC_DEFUN(zsh_LIMIT_PRESENT,
673 [AH_TEMPLATE([HAVE_]$1,
674 [Define to 1 if ]$1[ is present (whether or not as a macro).])
675 AC_CACHE_CHECK([for limit $1],
676 zsh_cv_have_$1,
677 [AC_TRY_COMPILE([
678 #include <sys/types.h>
679 #ifdef HAVE_SYS_TIME_H
680 #include <sys/time.h>
681 #endif
682 #include <sys/resource.h>],
683 [$1],
684   zsh_cv_have_$1=yes,
685   zsh_cv_have_$1=no)])
687 if test $zsh_cv_have_$1 = yes; then
688   AC_DEFINE(HAVE_$1)
689 fi])