AC_DEFUN(zsh_LARGE_FILE_SUPPORT,
[AC_MSG_CHECKING(whether large file support needs explicit enabling)
ac_getconfs=''
ac_result=yes
ac_set=''
ac_shellvars='CPPFLAGS LDFLAGS LIBS'
for ac_shellvar in $ac_shellvars; do
case $ac_shellvar in
CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
*) ac_lfsvar=LFS_$ac_shellvar ;;
esac
(getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
ac_getconf=`getconf $ac_lfsvar`
if test -n "$ac_getconf" && test "$ac_getconf" != "undefined"; then
eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
ac_getconfs=$ac_getconfs$ac_getconf
eval ac_test_$ac_shellvar="\$ac_getconf"
else
eval ac_test_$ac_shellvar="\$$ac_shellvar"
fi
done
case "$ac_result$ac_getconfs" in
yes) ac_result=no ;;
esac
case "$ac_result$ac_set" in
yes?*) test "x$ac_set" != "xLDFLAGS" -o "x$auto_ldflags" = x && {
ac_result="yes, but $ac_set is already set, so use its settings"
}
esac
AC_MSG_RESULT($ac_result)
case $ac_result in
yes)
for ac_shellvar in $ac_shellvars; do
case "`eval echo $ac_shellvar-\\\$ac_test_$ac_shellvar`" in
CPPFLAGS*-D_LARGEFILE_SOURCE*) eval $ac_shellvar=\$ac_test_$ac_shellvar
;;
CPPFLAGS*)
eval $ac_shellvar="\"-D_LARGEFILE_SOURCE \$ac_test_$ac_shellvar\""
;;
*) eval $ac_shellvar=\$ac_test_$ac_shellvar
esac
done ;;
esac
])
AC_DEFUN(zsh_64_BIT_TYPE,
[AC_TRY_RUN([
main()
{
$1 foo = 0;
int bar = (int) foo;
return sizeof($1) != 8;
}
], $2="$1", $2=no,
[if test x$3 != x ; then
$2="$1"
else
$2=no
fi])
])
AC_DEFUN(zsh_SHARED_FUNCTION,
[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)])
AC_DEFUN(zsh_SHARED_VARIABLE,
[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])])
AC_DEFUN(zsh_SHARED_SYMBOL,
[AC_CACHE_CHECK([if $1 is available in shared libraries],
zsh_cv_shared_$1,
[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo '
void *zsh_getaddr1()
{
__attribute__((__dllimport__))
extern $2;
return $3;
};
' > conftest1.c
sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c
if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle1, *handle2;
void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();
void *sym1, *sym2;
handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle1) exit(1);
handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle2) exit(1);
zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");
sym1 = zsh_getaddr1();
sym2 = zsh_getaddr2();
if(!sym1 || !sym2) exit(1);
if(sym1 != sym2) exit(1);
dlclose(handle1);
handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle1) exit(1);
zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
sym1 = zsh_getaddr1();
if(!sym1) exit(1);
if(sym1 != sym2) exit(1);
exit(0);
}
], [zsh_cv_shared_$1=yes],
[zsh_cv_shared_$1=no],
[zsh_cv_shared_$1=no]
)
else
zsh_cv_shared_$1=no
fi
])
])
AC_DEFUN(zsh_SYS_DYNAMIC_CLASH,
[AC_CACHE_CHECK([if name clashes in shared objects are OK],
zsh_cv_sys_dynamic_clash_ok,
[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo 'int fred () { return 42; }' > conftest1.c
echo 'int fred () { return 69; }' > conftest2.c
if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle1, *handle2;
int (*fred1)(), (*fred2)();
handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle1) exit(1);
handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle2) exit(1);
fred1 = (int (*)()) dlsym(handle1, "${us}fred");
fred2 = (int (*)()) dlsym(handle2, "${us}fred");
if(!fred1 || !fred2) exit(1);
exit((*fred1)() != 42 || (*fred2)() != 69);
}
], [zsh_cv_sys_dynamic_clash_ok=yes],
[zsh_cv_sys_dynamic_clash_ok=no],
[zsh_cv_sys_dynamic_clash_ok=no]
)
else
zsh_cv_sys_dynamic_clash_ok=no
fi
])
if test "$zsh_cv_sys_dynamic_clash_ok" = yes; then
AC_DEFINE(DYNAMIC_NAME_CLASH_OK)
fi
])
AC_DEFUN(zsh_SYS_DYNAMIC_GLOBAL,
[AC_CACHE_CHECK([for working RTLD_GLOBAL],
zsh_cv_sys_dynamic_rtld_global,
[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo 'int fred () { return 42; }' > conftest1.c
echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c
if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle;
int (*barneysym)();
handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle) exit(1);
handle = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle) exit(1);
barneysym = (int (*)()) dlsym(handle, "${us}barney");
if(!barneysym) exit(1);
exit((*barneysym)() != 69);
}
], [zsh_cv_sys_dynamic_rtld_global=yes],
[zsh_cv_sys_dynamic_rtld_global=no],
[zsh_cv_sys_dynamic_rtld_global=no]
)
else
zsh_cv_sys_dynamic_rtld_global=no
fi
])
])
AC_DEFUN(zsh_SYS_DYNAMIC_EXECSYMS,
[AC_CACHE_CHECK([whether symbols in the executable are available],
zsh_cv_sys_dynamic_execsyms,
[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest1.c
if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
save_ldflags=$LDFLAGS
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle;
int (*barneysym)();
handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle) exit(1);
barneysym = (int (*)()) dlsym(handle, "${us}barney");
if(!barneysym) exit(1);
exit((*barneysym)() != 69);
}
int fred () { return 42; }
], [zsh_cv_sys_dynamic_execsyms=yes],
[zsh_cv_sys_dynamic_execsyms=no],
[zsh_cv_sys_dynamic_execsyms=no]
)
LDFLAGS=$save_ldflags
else
zsh_cv_sys_dynamic_execsyms=no
fi
])
])
AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_EXE,
[AC_REQUIRE([zsh_SYS_DYNAMIC_EXECSYMS])
AC_CACHE_CHECK([whether executables can be stripped],
zsh_cv_sys_dynamic_strip_exe,
[if test "$zsh_cv_sys_dynamic_execsyms" != yes; then
zsh_cv_sys_dynamic_strip_exe=yes
elif
if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo 'extern int fred(); int barney() { return fred() + 27; }' > conftest1.c
AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
save_ldflags=$LDFLAGS
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -s"
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle;
int (*barneysym)();
handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle) exit(1);
barneysym = (int (*)()) dlsym(handle, "${us}barney");
if(!barneysym) exit(1);
exit((*barneysym)() != 69);
}
int fred () { return 42; }
], [zsh_cv_sys_dynamic_strip_exe=yes],
[zsh_cv_sys_dynamic_strip_exe=no],
[zsh_cv_sys_dynamic_strip_exe=no]
)
LDFLAGS=$save_ldflags
else
zsh_cv_sys_dynamic_strip_exe=no
fi
])
])
AC_DEFUN(zsh_SYS_DYNAMIC_STRIP_LIB,
[AC_CACHE_CHECK([whether libraries can be stripped],
zsh_cv_sys_dynamic_strip_lib,
[if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
us=_
else
us=
fi
echo 'int fred () { return 42; }' > conftest1.c
if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AC_FD_CC); then
AC_TRY_RUN([
char *zsh_gl_sym_addr ;
main()
{
void *handle;
int (*fredsym)();
handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
if(!handle) exit(1);
fredsym = (int (*)()) dlsym(handle, "${us}fred");
if(!fredsym) exit(1);
exit((*fredsym)() != 42);
}
], [zsh_cv_sys_dynamic_strip_lib=yes],
[zsh_cv_sys_dynamic_strip_lib=no],
[zsh_cv_sys_dynamic_strip_lib=no]
)
else
zsh_cv_sys_dynamic_strip_lib=no
fi
])
])
AC_DEFUN(zsh_PATH_UTMP,
[AC_CACHE_CHECK([for $1 file], [zsh_cv_path_$1],
[for dir in /etc /usr/etc /var/adm /usr/adm /var/run /var/log ./conftest; do
zsh_cv_path_$1=${dir}/$1
test -f $zsh_cv_path_$1 && break
zsh_cv_path_$1=no
done
])
AH_TEMPLATE([PATH_]translit($1, [a-z], [A-Z])[_FILE],
[Define to be location of ]$1[ file.])
if test $zsh_cv_path_$1 != no; then
AC_DEFINE_UNQUOTED([PATH_]translit($1, [a-z], [A-Z])[_FILE],
"$zsh_cv_path_$1")
fi
])
AC_DEFUN(zsh_TYPE_EXISTS,
[AC_CACHE_CHECK([for $2], [zsh_cv_type_exists_[]translit($2, [ ], [_])],
[AC_TRY_COMPILE([$1], [$2 testvar;],
[zsh_cv_type_exists_[]translit($2, [ ], [_])=yes],
[zsh_cv_type_exists_[]translit($2, [ ], [_])=no])
])
AH_TEMPLATE([HAVE_]translit($2, [ a-z], [_A-Z]),
[Define to 1 if ]$2[ is defined by a system header])
if test $zsh_cv_type_exists_[]translit($2, [ ], [_]) = yes; then
AC_DEFINE([HAVE_]translit($2, [ a-z], [_A-Z]))
fi
])
AC_DEFUN(zsh_STRUCT_MEMBER,
[AC_CACHE_CHECK([for $3 in $2], [zsh_cv_struct_member_[]translit($2, [ ], [_])_$3],
[AC_TRY_COMPILE([$1], [$2 testvar; testvar.$3;],
[zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=yes],
[zsh_cv_struct_member_[]translit($2, [ ], [_])_$3=no])
])
AH_TEMPLATE([HAVE_]translit($2_$3, [ a-z], [_A-Z]),
[Define if your system's ]$2[ has a member named ]$3[.])
if test $zsh_cv_struct_member_[]translit($2, [ ], [_])_$3 = yes; then
AC_DEFINE([HAVE_]translit($2_$3, [ a-z], [_A-Z]))
fi
])
AC_DEFUN(zsh_ARG_PROGRAM,
[AC_ARG_PROGRAM
cat <<\EOF_SED > conftestsed
s,\\\\,\\,g; s,\$\$,$,g
EOF_SED
zsh_transform_name=`echo "${program_transform_name}" | sed -f conftestsed`
rm -f conftestsed
tzsh_name=`echo zsh | sed -e "${zsh_transform_name}"`
cat <<\EOF_SED >> conftestsed
s,\\,\\\\,g; s,\$,$$,g
EOF_SED
tzsh=`echo ${tzsh_name} | sed -f conftestsed`
rm -f conftestsed
AC_SUBST(tzsh)])
AC_DEFUN(zsh_COMPILE_FLAGS,
[AC_ARG_ENABLE(cppflags,
AC_HELP_STRING([--enable-cppflags=...], [specify C preprocessor flags]),
if test "$enableval" = "yes"
then CPPFLAGS="$1"
else CPPFLAGS="$enable_cppflags"
fi)
AC_ARG_ENABLE(cflags,
AC_HELP_STRING([--enable-cflags=...], [specify C compiler flags]),
if test "$enableval" = "yes"
then CFLAGS="$2"
else CFLAGS="$enable_cflags"
fi)
AC_ARG_ENABLE(ldflags,
AC_HELP_STRING([--enable-ldflags=...], [specify linker flags]),
if test "$enableval" = "yes"
then LDFLAGS="$3"
else LDFLAGS="$enable_ldflags"
fi)
AC_ARG_ENABLE(libs,
AC_HELP_STRING([--enable-libs=...], [specify link libraries]),
if test "$enableval" = "yes"
then LIBS="$4"
else LIBS="$enable_libs"
fi)])
AC_DEFUN([zsh_CHECK_SOCKLEN_T],[
AC_CACHE_CHECK(
[base type of the third argument to accept],
[zsh_cv_type_socklen_t],
[zsh_cv_type_socklen_t=
for zsh_type in socklen_t int "unsigned long" size_t ; do
AC_TRY_COMPILE(
[ [extern int accept (int, struct sockaddr *, $zsh_type *);],
[zsh_cv_type_socklen_t="$zsh_type"; break],
[]
)
done
if test -z "$zsh_cv_type_socklen_t"; then
zsh_cv_type_socklen_t=int
fi]
)
AC_DEFINE_UNQUOTED([ZSOCKLEN_T], [$zsh_cv_type_socklen_t],
[Define to the base type of the third argument of accept])]
)
dnl Check for limit $1 e.g. RLIMIT_RSS.
AC_DEFUN(zsh_LIMIT_PRESENT,
[AH_TEMPLATE([HAVE_]$1,
[Define to 1 if ]$1[ is present (whether or not as a macro).])
AC_CACHE_CHECK([for limit $1],
zsh_cv_have_$1,
[AC_TRY_COMPILE([
#include <sys/types.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/resource.h>],
[$1],
zsh_cv_have_$1=yes,
zsh_cv_have_$1=no)])
if test $zsh_cv_have_$1 = yes; then
AC_DEFINE(HAVE_$1)
fi])