acsfs.m4
来自「基于DHT的对等协议」· M4 代码 · 共 2,148 行 · 第 1/4 页
M4
2,148 行
dnl $Id: acinclude.m4 1754 2006-05-19 20:59:19Z max $dnldnl Find full path to programdnlAC_DEFUN([SFS_PATH_PROG],[AC_PATH_PROG(PATH_[]translit($1, [-a-z.], [_A-Z_]), $1,,$2[]ifelse($2,,,:)/usr/bin:/bin:/sbin:/usr/sbin:/usr/etc:/usr/libexec:/usr/ucb:/usr/bsd:/usr/5bin:$PATH:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin)if test "$PATH_[]translit($1, [-a-z.], [_A-Z_])"; then AC_DEFINE_UNQUOTED(PATH_[]translit($1, [-a-z.], [_A-Z_]), "$PATH_[]translit($1, [-a-z.], [_A-Z_])", Full path of $1 command)fi])dnldnl File path to cppdnlAC_DEFUN([SFS_PATH_CPP],[AC_PATH_PROG(_PATH_CPP, cpp,,/usr/ccs/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/etc:/usr/libexec:/lib:/usr/lib:/usr/ucb:/usr/bsd:/usr/5bin:$PATH:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin)if test -z "$_PATH_CPP"; then if test "$GCC" = yes; then _PATH_CPP=`$CC -print-prog-name=cpp` else _PATH_CPP=`gcc -print-prog-name=cpp 2> /dev/null` fifitest -x "$_PATH_CPP" || unset _PATH_CPPif test -z "$_PATH_CPP"; then AC_MSG_ERROR(Cannot find path for cpp)fiAC_DEFINE_UNQUOTED(PATH_CPP, "$_PATH_CPP", Path for the C preprocessor command)])dnldnl How to get BSD-like df outputdnlAC_DEFUN([SFS_PATH_DF],[SFS_PATH_PROG(df, /usr/ucb:/usr/bsd:/usr/local/bin)AC_CACHE_CHECK(if [$PATH_DF] needs -k for BSD-formatted output, sfs_cv_df_dash_k,sfs_cv_df_dash_k=no[test "`$PATH_DF . | sed -e '2,$d;/Mounted on/d'`" \ && test "`$PATH_DF -k . | sed -ne '2,$d;/Mounted on/p'`" \ && sfs_cv_df_dash_k=yes])if test $sfs_cv_df_dash_k = yes; then AC_DEFINE(DF_NEEDS_DASH_K, 1, Define if you must run \"df -k\" to get BSD-formatted output)fi])dnldnl Check for declarationsdnl SFS_CHECK_DECL(symbol, headers-to-try, headers-to-include)dnlAC_DEFUN([SFS_CHECK_DECL],[AC_CACHE_CHECK(for a declaration of $1, sfs_cv_$1_decl,dnl for hdr in [patsubst(builtin(shift, $@), [,], [ ])]; do for hdr in $2; do if test -z "${sfs_cv_$1_decl}"; thendnl AC_HEADER_EGREP($1, $hdr, sfs_cv_$1_decl=yes) AC_TRY_COMPILE(patsubst($3, [\([^ ]+\) *], [#include <\1>])[#include <$hdr>], &$1;, sfs_cv_$1_decl=yes) fi done test -z "${sfs_cv_$1_decl+set}" && sfs_cv_$1_decl=no)if test "$sfs_cv_$1_decl" = no; then AC_DEFINE_UNQUOTED(NEED_[]translit($1, [a-z], [A-Z])_DECL, 1, Define if system headers do not declare $1.)fi])dnldnl Check if lsof keeps a device cachednlAC_DEFUN([SFS_LSOF_DEVCACHE],[if test "$PATH_LSOF"; then AC_CACHE_CHECK(if lsof supports a device cache, sfs_cv_lsof_devcache, if $PATH_LSOF -h 2>&1 | fgrep -e -D > /dev/null; then sfs_cv_lsof_devcache=yes else sfs_cv_lsof_devcache=no fi) if test "$sfs_cv_lsof_devcache" = yes; then AC_DEFINE(LSOF_DEVCACHE, 1, Define is lsof supports the -D option) fifi])dnldnl Posix time subroutinednlAC_DEFUN([SFS_TIME_CHECK],[AC_CACHE_CHECK($3, sfs_cv_time_check_$1,AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h>#elif defined (HAVE_SYS_TIME_H)# include <sys/time.h>#else /* !TIME_WITH_SYS_TIME && !HAVE_SYS_TIME_H */# include <time.h>#endif /* !TIME_WITH_SYS_TIME && !HAVE_SYS_TIME_H */], $2, sfs_cv_time_check_$1=yes, sfs_cv_time_check_$1=no))if test "$sfs_cv_time_check_$1" = yes; then AC_DEFINE($1, 1, $4)fi])dnldnl Posix time stuffdnlAC_DEFUN([SFS_TIMESPEC],[AC_CHECK_HEADERS(sys/time.h)AC_HEADER_TIMEAC_CHECK_FUNCS(clock_gettime)SFS_TIME_CHECK(HAVE_CLOCK_GETTIME_DECL, int (*x) () = &clock_gettime;, for a declaration of clock_gettime, Define if system headers declare clock_gettime.)SFS_TIME_CHECK(HAVE_TIMESPEC, int x = sizeof (struct timespec), for struct timespec, Define if sys/time.h defines a struct timespec.)dnl AC_EGREP_HEADER(clock_gettime, sys/time.h,dnl AC_DEFINE(HAVE_CLOCK_GETTIME_DECL, 1,dnl Define if system header files declare clock_gettime.))dnl AC_EGREP_HEADER(timespec, sys/time.h,dnl AC_DEFINE(HAVE_TIMESPEC, 1,dnl Define if sys/time.h defines a struct timespec.))])dnldnl Find the crypt functiondnlAC_DEFUN([SFS_FIND_CRYPT],[AC_SUBST(LIBCRYPT)AC_CHECK_FUNC(crypt)if test $ac_cv_func_crypt = no; then AC_CHECK_LIB(crypt, crypt, LIBCRYPT="-lcrypt")fi])dnldnl Find the setusercontext functiondnlAC_DEFUN([SFS_CHECK_SETUSERCONTEXT],[AC_SUBST(SETUSERCONTEXTLIB)AC_CHECK_FUNC(setusercontext)if test "$ac_cv_func_setusercontext" = no; then AC_CHECK_LIB(setusercontext, util, SETUSERCONTEXTLIB="-lutil")fiif test "$ac_cv_func_setusercontext" = yes; then AC_CHECK_HEADERS(login_cap.h) AC_DEFINE(HAVE_SETUSERCONTEXT, 1, Define if you have the setusercontext function)fi])dnldnl Find pty functionsdnlAC_DEFUN([SFS_PTYLIB],[AC_SUBST(PTYLIB)AC_CHECK_FUNCS(_getpty)AC_CHECK_FUNCS(openpty)if test $ac_cv_func_openpty = no; then AC_CHECK_LIB(util, openpty, PTYLIB="-lutil" AC_DEFINE(HAVE_OPENPTY, 1, Define if you have the openpty function.))fiif test "$ac_cv_func_openpty" = yes -o "$ac_cv_lib_util_openpty" = yes; then AC_CHECK_HEADERS(util.h libutil.h)fiAC_CHECK_HEADERS(pty.h)AC_CACHE_CHECK(for BSD-style utmp slots, ac_cv_have_ttyent, AC_EGREP_HEADER(getttyent, ttyent.h, ac_cv_have_ttyent=yes, ac_cv_have_ttyent=no))if test "$ac_cv_have_ttyent" = yes; then AC_DEFINE(USE_TTYENT, 1, Define if utmp must be managed with BSD-style ttyent functions)fiAC_MSG_CHECKING(for pseudo ttys)if test -c /dev/ptmx && test -c /dev/pts/0then AC_DEFINE(HAVE_DEV_PTMX, 1, Define if you have SYSV-style /dev/ptmx and /dev/pts/.) AC_MSG_RESULT(streams ptys)elseif test -c /dev/pts && test -c /dev/ptcthen AC_DEFINE(HAVE_DEV_PTS_AND_PTC, 1, Define if you have /dev/pts and /dev/ptc devices (as in AIX).) AC_MSG_RESULT(/dev/pts and /dev/ptc)else AC_MSG_RESULT(bsd-style ptys)fifi])dnldnl SFS_TRY_RESOLV_LIB(library)dnl see if -llibrary is needed to get res_mkquerydnlAC_DEFUN([SFS_TRY_RESOLV_LIB],[reslib="$1"if test -z "$reslib"; then resdesc="standard C library"else resdesc="lib$reslib"fiAC_CACHE_CHECK(for resolver functions in [$resdesc], sfs_cv_reslib_lib$1,[sfs_try_resolv_lib_save_LIBS="$LIBS"if test x"$reslib" != x; then LIBS="$LIBS -l$reslib"fiAC_LINK_IFELSE([#include "confdefs.h"#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#if HAVE_ARPA_NAMESER_COMPAT_H#include <arpa/nameser_compat.h>#else /* !HAVE_ARPA_NAMESER_COMPAT_H */#include <arpa/nameser.h>#endif /* !HAVE_ARPA_NAMESER_COMPAT_H */#include <resolv.h>intmain (int argc, char **argv){ res_mkquery (0, 0, 0, 0, 0, 0, 0, 0, 0); return 0;}], sfs_cv_reslib_lib$1=yes, sfs_cv_reslib_lib$1=no)LIBS="$sfs_try_resolv_lib_save_LIBS"])if test "$sfs_cv_reslib_lib$1" = yes -a "$reslib"; then LIBS="$LIBS -l$reslib"fi])dnldnl Use -lresolv only if we need itdnlAC_DEFUN([SFS_FIND_RESOLV],[AC_CHECK_HEADERS(arpa/nameser_compat.h)if test "$ac_cv_header_arpa_nameser_compat_h" = yes; then nameser_header=arpa/nameser_compat.helse nameser_header=arpa/nameser.hfidnl AC_CHECK_FUNC(res_mkquery)dnl if test "$ac_cv_func_res_mkquery" != yes; thendnl AC_CHECK_LIB(resolv, res_mkquery)dnl if test "$ac_cv_lib_resolv_res_mkquery" = no; thendnl AC_CHECK_LIB(resolv, __res_mkquery)dnl fidnl fiSFS_TRY_RESOLV_LIB([])if test "$sfs_cv_reslib_lib" = no; then SFS_TRY_RESOLV_LIB(resolv)fidnl See if the resolv functions are actually declaredSFS_CHECK_DECL(res_init, resolv.h, sys/types.h sys/socket.h netinet/in.h $nameser_header)SFS_CHECK_DECL(res_mkquery, resolv.h, sys/types.h sys/socket.h netinet/in.h $nameser_header)SFS_CHECK_DECL(dn_skipname, resolv.h, sys/types.h sys/socket.h netinet/in.h $nameser_header)SFS_CHECK_DECL(dn_expand, resolv.h, sys/types.h sys/socket.h netinet/in.h $nameser_header)])dnldnl Check if first element in grouplist is egiddnlAC_DEFUN([SFS_CHECK_EGID_IN_GROUPLIST],[AC_TYPE_GETGROUPSAC_CACHE_CHECK(if egid is first element of grouplist, sfs_cv_egid_in_grouplist,AC_TRY_RUN([changequote changequote([[,]])#include <sys/types.h>#include <unistd.h>#include <netinet/in.h>#include <rpc/rpc.h>#include "confdefs.h"static intgetint (void *_p){ unsigned char *p = _p; return p[0]<<24 | p[1]<<16 | p[2]<<8 | p[3];}intmain (int argc, char **argv){ AUTH *a; GETGROUPS_T gids[24]; int n, xn; char buf[408]; char *p; XDR x; /* Must hard-code OSes with egid in grouplist *and* broken RPC lib */#if __FreeBSD__ || __APPLE__ return 0;#endif n = getgroups (24, gids); if (n <= 0) return 1; a = authunix_create_default (); xdrmem_create (&x, buf, sizeof (buf), XDR_ENCODE); if (!auth_marshall (a, &x)) return 1; if (getint (buf) != AUTH_UNIX) return 1; p = buf + 12; /* Skip auth flavor, length, timestamp */ p += getint (p) + 7 & ~3; /* Skip machine name */ p += 8; /* Skip uid & gid */ xn = getint (p); /* Length of grouplist in auth_unix */ return n != xn + 1;}changequote([,])], sfs_cv_egid_in_grouplist=yes, sfs_cv_egid_in_grouplist=no))if test $sfs_cv_egid_in_grouplist = yes; then AC_DEFINE(HAVE_EGID_IN_GROUPLIST, 1, Define if the first element of a grouplist is the effective gid)fi])dnldnl Check for struct passwd fieldsdnlAC_DEFUN([SFS_PASSWD_FIELD],[AC_CACHE_CHECK(for $1 in struct passwd, sfs_cv_passwd_$1,AC_TRY_COMPILE([#include <sys/types.h>#include <pwd.h>], [ struct passwd *pw; pw->$1;], sfs_cv_passwd_$1=yes, sfs_cv_passwd_$1=no))if test "$sfs_cv_passwd_$1" = yes; then AC_DEFINE(HAVE_PASSWD_[]translit($1, [a-z ], [A-Z_]), 1, Define if struct passwd has $1 field)fi])dnldnl Check if putenv copies argumentsdnlAC_DEFUN([SFS_PUTENV_COPY],[AC_CACHE_CHECK(if putenv() copies its argument, sfs_cv_putenv_copy,AC_TRY_RUN([changequote`'changequote([[,]])#include <stdlib.h>char var[] = "V=0";intmain (int argc, char **argv){ char *v; putenv (var); var[2] = '1'; v = getenv (var); return *v != '0';}changequote([,])], sfs_cv_putenv_copy=yes, sfs_cv_putenv_copy=no, sfs_cv_putenv_copy=no))if test $sfs_cv_putenv_copy = yes; then AC_DEFINE(PUTENV_COPIES_ARGUMENT, 1, Define if putenv makes a copy of its argument)fi])dnldnl Check for wide selectdnlAC_DEFUN([SFS_CHECK_WIDE_SELECT],[AC_CACHE_CHECK(for wide select, sfs_cv_wideselect,fdlim_h=${srcdir}/fdlim.htest -f ${srcdir}/async/fdlim.h && fdlim_h=${srcdir}/async/fdlim.htest -f ${srcdir}/libasync/fdlim.h && fdlim_h=${srcdir}/libasync/fdlim.hAC_TRY_RUN([changequote changequote([[,]])#include <stdio.h>#include <fcntl.h>#include <stdlib.h>#include "${fdlim_h}"struct timeval ztv;intmain (){ int pfd[2]; int rfd, wfd; int maxfd; int i; fd_set *rfdsp, *wfdsp; maxfd = fdlim_get (1); fdlim_set (maxfd, 1); maxfd = fdlim_get (0); if (maxfd <= FD_SETSIZE) { printf ("[small fd limit anyway] "); exit (1); } if (pipe (pfd) < 0) exit (1);#ifdef F_DUPFD if ((rfd = fcntl (pfd[0], F_DUPFD, maxfd - 2)) < 0) exit (1); if ((wfd = fcntl (pfd[1], F_DUPFD, maxfd - 1)) < 0) exit (1);#else /* !F_DUPFD */ if ((rfd = dup2 (pfd[0], maxfd - 2)) < 0) exit (1); if ((wfd = dup2 (pfd[1], maxfd - 1)) < 0) exit (1);#endif /* !F_DUPFD */ rfdsp = malloc (1 + (maxfd/8)); for (i = 0; i < 1 + (maxfd/8); i++) ((char *) rfdsp)[i] = '\0'; wfdsp = malloc (1 + (maxfd/8)); for (i = 0; i < 1 + (maxfd/8); i++) ((char *) wfdsp)[i] = '\0'; FD_SET (rfd, rfdsp); FD_SET (wfd, wfdsp); if (select (maxfd, rfdsp, wfdsp, NULL, &ztv) < 0) exit (1); if (FD_ISSET (wfd, wfdsp) && !FD_ISSET (rfd, rfdsp)) exit (0); else exit (1);}changequote([,])],sfs_cv_wideselect=yes, sfs_cv_wideselect=no, sfs_cv_wideselect=no))if test $sfs_cv_wideselect = yes; then AC_DEFINE(HAVE_WIDE_SELECT, 1, Define if select can take file descriptors >= FD_SETSIZE)fi])dnldnl Check for 64-bit off_tdnlAC_DEFUN([SFS_CHECK_OFF_T_64],[AC_CACHE_CHECK(for 64-bit off_t, sfs_cv_off_t_64,AC_TRY_COMPILE([#include <unistd.h>#include <sys/types.h>],[switch (0) case 0: case (sizeof (off_t) <= 4):;], sfs_cv_off_t_64=no, sfs_cv_off_t_64=yes))if test $sfs_cv_off_t_64 = yes; then AC_DEFINE(HAVE_OFF_T_64, 1, Define if off_t is 64 bits wide.)fi])dnldnl Check for typednlAC_DEFUN([SFS_CHECK_TYPE],[AC_CACHE_CHECK(for $1, sfs_cv_type_[]translit($1, [ ], [_]),AC_TRY_COMPILE([#include <stddef.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#ifdef HAVE_RPC_RPC_H#include <rpc/rpc.h>#endif$2],[sizeof($1);], sfs_cv_type_[]translit($1, [ ], [_])=yes, sfs_cv_type_[]translit($1, [ ], [_])=no))if test $sfs_cv_type_[]translit($1, [ ], [_]) = yes; then AC_DEFINE(HAVE_[]translit($1, [a-z ], [A-Z_]), 1, Define if system headers declare a $1 type.)fi])dnldnl Check if system defines u_int64_t as an unsigned long longdnlAC_DEFUN([SFS_CHECK_U_INT64],[AC_CHECK_SIZEOF(long, 4)AC_CHECK_SIZEOF(long long, 0)SFS_CHECK_TYPE(u_int64_t)AC_CACHE_CHECK(whether u_int64_t is an unsigned long long, sfs_cv_u_int64_t_is_long_long,if test 8 -gt "$ac_cv_sizeof_long"; then sfs_cv_u_int64_t_is_long_long=yeselif test yes != "$sfs_cv_type_u_int64_t"; then sfs_cv_u_int64_t_is_long_long=yeselse AC_COMPILE_IFELSE([#include <stddef.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#ifdef HAVE_RPC_RPC_H#include <rpc/rpc.h>#endifvoid f (u_int64_t val);voidf (unsigned long long val){}], sfs_cv_u_int64_t_is_long_long=yes, sfs_cv_u_int64_t_is_long_long=no)fi)if test yes = "$sfs_cv_u_int64_t_is_long_long"; thenAC_DEFINE(U_INT64_T_IS_LONG_LONG, 1, Define if system header files typedef u_int64_t as unsigned long long)fi])dnldnl Check for struct cmsghdr (for passing file descriptors)dnlAC_DEFUN([SFS_CHECK_FDPASS],[AC_CACHE_CHECK(for fd passing with msg_accrights in msghdr, sfs_cv_accrights,AC_TRY_COMPILE([#include <sys/types.h>#include <sys/socket.h>],[struct msghdr mh;mh.msg_accrights = 0;], sfs_cv_accrights=yes, sfs_cv_accrights=no))AC_CACHE_CHECK(for fd passing with struct cmsghdr, sfs_cv_cmsghdr,if test "$sfs_cv_accrights" != "yes"; thenAC_TRY_COMPILE([#include <sys/types.h>#include <sys/socket.h>],[struct msghdr mh;struct cmsghdr cmh;mh.msg_control = (void *) &cmh;], sfs_cv_cmsghdr=yes, sfs_cv_cmsghdr=no)else sfs_cv_cmsghdr=no
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?