1dnl 2dnl Autconf tests for zsh. 3dnl 4dnl Copyright (c) 1995-1997 Richard Coleman 5dnl All rights reserved. 6dnl 7dnl Permission is hereby granted, without written agreement and without 8dnl license or royalty fees, to use, copy, modify, and distribute this 9dnl software and to distribute modified versions of this software for any 10dnl purpose, provided that the above copyright notice and the following 11dnl two paragraphs appear in all copies of this software. 12dnl 13dnl In no event shall Richard Coleman or the Zsh Development Group be liable 14dnl to any party for direct, indirect, special, incidental, or consequential 15dnl damages arising out of the use of this software and its documentation, 16dnl even if Richard Coleman and the Zsh Development Group have been advised of 17dnl the possibility of such damage. 18dnl 19dnl Richard Coleman and the Zsh Development Group specifically disclaim any 20dnl warranties, including, but not limited to, the implied warranties of 21dnl merchantability and fitness for a particular purpose. The software 22dnl provided hereunder is on an "as is" basis, and Richard Coleman and the 23dnl Zsh Development Group have no obligation to provide maintenance, 24dnl support, updates, enhancements, or modifications. 25dnl 26 27dnl 28dnl zsh_64_BIT_TYPE 29dnl Check whether the first argument works as a 64-bit type. 30dnl If there is a non-zero third argument, we just assume it works 31dnl when we're cross compiling. This is to allow a type to be 32dnl specified directly as --enable-lfs="long long". 33dnl Sets the variable given in the second argument to the first argument 34dnl if the test worked, `no' otherwise. Be careful testing this, as it 35dnl may produce two words `long long' on an unquoted substitution. 36dnl Also check that the compiler does not mind it being cast to int. 37dnl This macro does not produce messages as it may be run several times 38dnl before finding the right type. 39dnl 40 41AC_DEFUN(zsh_64_BIT_TYPE, 42[AC_TRY_RUN([ 43#ifdef HAVE_SYS_TYPES_H 44#include <sys/types.h> 45#endif 46 47main() 48{ 49 $1 foo = 0; 50 int bar = (int) foo; 51 return sizeof($1) != 8; 52} 53], $2="$1", $2=no, 54 [if test x$3 != x ; then 55 $2="$1" 56 else 57 $2=no 58 fi]) 59]) 60 61 62dnl 63dnl zsh_SHARED_FUNCTION 64dnl 65dnl This is just a frontend to zsh_SHARED_SYMBOL 66dnl 67dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]]) 68dnl 69 70AC_DEFUN(zsh_SHARED_FUNCTION, 71[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)]) 72 73dnl 74dnl zsh_SHARED_VARIABLE 75dnl 76dnl This is just a frontend to zsh_SHARED_SYMBOL 77dnl 78dnl Usage: zsh_SHARED_VARIABLE(name[,type]) 79dnl 80 81AC_DEFUN(zsh_SHARED_VARIABLE, 82[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])]) 83 84dnl 85dnl zsh_SHARED_SYMBOL 86dnl Check whether symbol is available in static or shared library 87dnl 88dnl On some systems, static modifiable library symbols (such as environ) 89dnl may appear only in statically linked libraries. If this is the case, 90dnl then two shared libraries that reference the same symbol, each linked 91dnl with the static library, could be given distinct copies of the symbol. 92dnl 93dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address) 94dnl Sets zsh_cv_shared_$1 cache variable to yes/no 95dnl 96 97AC_DEFUN(zsh_SHARED_SYMBOL, 98[AC_CACHE_CHECK([if $1 is available in shared libraries], 99zsh_cv_shared_$1, 100[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then 101 us=_ 102else 103 us= 104fi 105echo ' 106void *zsh_getaddr1() 107{ 108#ifdef __CYGWIN__ 109 __attribute__((__dllimport__)) 110#endif 111 extern $2; 112 return $3; 113}; 114' > conftest1.c 115sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c 116if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) && 117AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) && 118AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) && 119AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then 120 AC_TRY_RUN([ 121#ifdef HPUX10DYNAMIC 122#include <dl.h> 123#define RTLD_LAZY BIND_DEFERRED 124#define RTLD_GLOBAL DYNAMIC_PATH 125 126char *zsh_gl_sym_addr ; 127 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 147 148main() 149{ 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); 171} 172], [zsh_cv_shared_$1=yes], 173[zsh_cv_shared_$1=no], 174[zsh_cv_shared_$1=no] 175) 176else 177 zsh_cv_shared_$1=no 178fi 179]) 180]) 181 182dnl 183dnl zsh_SYS_DYNAMIC_CLASH 184dnl Check whether symbol name clashes in shared libraries are acceptable. 185dnl 186 187AC_DEFUN(zsh_SYS_DYNAMIC_CLASH, 188[AC_CACHE_CHECK([if name clashes in shared objects are OK], 189zsh_cv_sys_dynamic_clash_ok, 190[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then 191 us=_ 192else 193 us= 194fi 195echo 'int fred () { return 42; }' > conftest1.c 196echo 'int fred () { return 69; }' > conftest2.c 197if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) && 198AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) && 199AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) && 200AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then 201 AC_TRY_RUN([ 202#ifdef HPUX10DYNAMIC 203#include <dl.h> 204#define RTLD_LAZY BIND_DEFERRED 205#define RTLD_GLOBAL DYNAMIC_PATH 206 207char *zsh_gl_sym_addr ; 208 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 228 229 230main() 231{ 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); 242} 243], [zsh_cv_sys_dynamic_clash_ok=yes], 244[zsh_cv_sys_dynamic_clash_ok=no], 245[zsh_cv_sys_dynamic_clash_ok=no] 246) 247else 248 zsh_cv_sys_dynamic_clash_ok=no 249fi 250]) 251if test "$zsh_cv_sys_dynamic_clash_ok" = yes; then 252 AC_DEFINE(DYNAMIC_NAME_CLASH_OK) 253fi 254]) 255 256dnl 257dnl zsh_SYS_DYNAMIC_GLOBAL 258dnl Check whether symbols in one dynamically loaded library are 259dnl available to another dynamically loaded library. 260dnl 261 262AC_DEFUN(zsh_SYS_DYNAMIC_GLOBAL, 263[AC_CACHE_CHECK([for working RTLD_GLOBAL], 264zsh_cv_sys_dynamic_rtld_global, 265[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then 266 us=_ 267else 268 us= 269fi 270echo 'int fred () { return 42; }' > conftest1.c 271echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c 272if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) && 273AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) && 274AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) && 275AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then 276 AC_TRY_RUN([ 277#ifdef HPUX10DYNAMIC 278#include <dl.h> 279#define RTLD_LAZY BIND_DEFERRED 280#define RTLD_GLOBAL DYNAMIC_PATH 281 282char *zsh_gl_sym_addr ; 283 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 303 304main() 305{ 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); 315} 316], [zsh_cv_sys_dynamic_rtld_global=yes], 317[zsh_cv_sys_dynamic_rtld_global=no], 318[zsh_cv_sys_dynamic_rtld_global=no] 319) 320else 321 zsh_cv_sys_dynamic_rtld_global=no 322fi 323]) 324]) 325 326dnl 327dnl zsh_SYS_DYNAMIC_EXECSYMS 328dnl Check whether symbols in the executable are available to dynamically 329dnl loaded libraries. 330dnl 331 332AC_DEFUN(zsh_SYS_DYNAMIC_EXECSYMS, 333[AC_CACHE_CHECK([whether symbols in the executable are available], 334zsh_cv_sys_dynamic_execsyms, 335[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then 336 us=_ 337else 338 us= 339fi 340echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest1.c 341if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) && 342AC_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 HPUX10DYNAMIC 347#include <dl.h> 348#define RTLD_LAZY BIND_DEFERRED 349#define RTLD_GLOBAL DYNAMIC_PATH 350 351char *zsh_gl_sym_addr ; 352 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 372 373main() 374{ 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); 382} 383 384int fred () { return 42; } 385], [zsh_cv_sys_dynamic_execsyms=yes], 386[zsh_cv_sys_dynamic_execsyms=no], 387[zsh_cv_sys_dynamic_execsyms=no] 388) 389 LDFLAGS=$save_ldflags 390else 391 zsh_cv_sys_dynamic_execsyms=no 392fi 393]) 394]) 395 396dnl 397dnl zsh_SYS_DYNAMIC_STRIP_EXE 398dnl Check whether it is safe to strip executables. 399dnl 400 401AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_EXE, 402[AC_REQUIRE([zsh_SYS_DYNAMIC_EXECSYMS]) 403AC_CACHE_CHECK([whether executables can be stripped], 404zsh_cv_sys_dynamic_strip_exe, 405[if test "$zsh_cv_sys_dynamic_execsyms" != yes; then 406 zsh_cv_sys_dynamic_strip_exe=yes 407elif 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 HPUX10DYNAMIC 420#include <dl.h> 421#define RTLD_LAZY BIND_DEFERRED 422#define RTLD_GLOBAL DYNAMIC_PATH 423 424char *zsh_gl_sym_addr ; 425 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 445 446main() 447{ 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); 455} 456 457int 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] 461) 462 LDFLAGS=$save_ldflags 463else 464 zsh_cv_sys_dynamic_strip_exe=no 465fi 466]) 467]) 468 469dnl 470dnl zsh_SYS_DYNAMIC_STRIP_EXE 471dnl Check whether it is safe to strip dynamically loaded libraries. 472dnl 473 474AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_LIB, 475[AC_CACHE_CHECK([whether libraries can be stripped], 476zsh_cv_sys_dynamic_strip_lib, 477[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then 478 us=_ 479else 480 us= 481fi 482echo 'int fred () { return 42; }' > conftest1.c 483if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) && 484AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AC_FD_CC); then 485 AC_TRY_RUN([ 486#ifdef HPUX10DYNAMIC 487#include <dl.h> 488#define RTLD_LAZY BIND_DEFERRED 489#define RTLD_GLOBAL DYNAMIC_PATH 490 491char *zsh_gl_sym_addr ; 492 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 512 513main() 514{ 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); 522} 523], [zsh_cv_sys_dynamic_strip_lib=yes], 524[zsh_cv_sys_dynamic_strip_lib=no], 525[zsh_cv_sys_dynamic_strip_lib=no] 526) 527else 528 zsh_cv_sys_dynamic_strip_lib=no 529fi 530]) 531]) 532 533dnl 534dnl zsh_PATH_UTMP(filename) 535dnl Search for a specified utmp-type file. 536dnl 537 538AC_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 544done 545]) 546AH_TEMPLATE([PATH_]translit($1, [a-z], [A-Z])[_FILE], 547[Define to be location of ]$1[ file.]) 548if test $zsh_cv_path_$1 != no; then 549 AC_DEFINE_UNQUOTED([PATH_]translit($1, [a-z], [A-Z])[_FILE], 550 "$zsh_cv_path_$1") 551fi 552]) 553 554dnl 555dnl zsh_TYPE_EXISTS(#includes, type name) 556dnl Check whether a specified type exists. 557dnl 558 559AC_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]) 564]) 565AH_TEMPLATE([HAVE_]translit($2, [ a-z], [_A-Z]), 566[Define to 1 if ]$2[ is defined by a system header]) 567if test $zsh_cv_type_exists_[]translit($2, [ ], [_]) = yes; then 568 AC_DEFINE([HAVE_]translit($2, [ a-z], [_A-Z])) 569fi 570]) 571 572dnl 573dnl zsh_STRUCT_MEMBER(#includes, type name, member name) 574dnl Check whether a specified aggregate type exists and contains 575dnl a specified member. 576dnl 577 578AC_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]) 583]) 584AH_TEMPLATE([HAVE_]translit($2_$3, [ a-z], [_A-Z]), 585[Define if your system's ]$2[ has a member named ]$3[.]) 586if test $zsh_cv_struct_member_[]translit($2, [ ], [_])_$3 = yes; then 587 AC_DEFINE([HAVE_]translit($2_$3, [ a-z], [_A-Z])) 588fi 589]) 590 591dnl 592dnl zsh_ARG_PROGRAM 593dnl Handle AC_ARG_PROGRAM substitutions into other zsh configure macros. 594dnl After processing this macro, the configure script may refer to 595dnl and $tzsh_name, and @tzsh@ is defined for make substitutions. 596dnl 597 598AC_DEFUN(zsh_ARG_PROGRAM, 599[AC_ARG_PROGRAM 600# Un-double any \ or $ (doubled by AC_ARG_PROGRAM). 601cat <<\EOF_SED > conftestsed 602s,\\\\,\\,g; s,\$\$,$,g 603EOF_SED 604zsh_transform_name=`echo "${program_transform_name}" | sed -f conftestsed` 605rm -f conftestsed 606tzsh_name=`echo zsh | sed -e "${zsh_transform_name}"` 607# Double any \ or $ in the transformed name that results. 608cat <<\EOF_SED >> conftestsed 609s,\\,\\\\,g; s,\$,$$,g 610EOF_SED 611tzsh=`echo ${tzsh_name} | sed -f conftestsed` 612rm -f conftestsed 613AC_SUBST(tzsh)dnl 614]) 615 616AC_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)]) 641 642dnl 643dnl zsh_CHECK_SOCKLEN_T 644dnl 645dnl check type of third argument of some network functions; currently 646dnl tested are size_t *, unsigned long *, int *. 647dnl call the result ZSOCKLEN_T since some systems have SOCKLEN_T already 648dnl 649AC_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])] 669) 670 671dnl Check for limit $1 e.g. RLIMIT_RSS. 672AC_DEFUN(zsh_LIMIT_PRESENT, 673[AH_TEMPLATE([HAVE_]$1, 674[Define to 1 if ]$1[ is present (whether or not as a macro).]) 675AC_CACHE_CHECK([for limit $1], 676zsh_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)]) 686 687if test $zsh_cv_have_$1 = yes; then 688 AC_DEFINE(HAVE_$1) 689fi]) 690 691