## hostafs - A lightweight AFS server ## ## Copyright (c) 1998-1999, 2002 Carnegie Mellon University ## All Rights Reserved. ## ## Permission to use, copy, modify and distribute this software and its ## documentation is hereby granted, provided that both the copyright ## notice and this permission notice appear in all copies of the ## software, derivative works or modified versions, and any portions ## thereof, and that both notices appear in supporting documentation. ## ## CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" ## CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR ## ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ## ## Carnegie Mellon requests users of this software to return to ## ## Software Distribution Coordinator or Software_Distribution@CS.CMU.EDU ## School of Computer Science ## Carnegie Mellon University ## Pittsburgh PA 15213-3890 ## ## any improvements or extensions that they make and grant Carnegie Mellon ## the rights to redistribute these changes. ## ## acinclude.m4 - a few of our own tests AC_DEFUN([AC_PROG_CC_GNU],) # CMUCS_GETMNTENT # Figure out whether we have getmntent and where it is defined. # Figure out how many arguments getmntent takes and how to call it. # Figure out whether we need to use setmntent/endmntent or fopen/fclose # May define HAVE_GETMNTENT, HAVE_GETMNTENT2, and HAVE_SETMNTENT AC_DEFUN([CMUCS_GETMNTENT], [AC_FUNC_GETMNTENT if test $ac_cv_func_getmntent = yes ; then AC_CHECK_HEADERS([sys/mnttab.h mntent.h]) AC_CHECK_TYPES([struct mntent, struct mnttab],,, [#if HAVE_SYS_MNTTAB_H #include #endif #if HAVE_MNTENT_H #include #endif ]) AC_CHECK_FUNCS([setmntent]) AC_CACHE_CHECK([whether getmntent takes two arguments], [ac_cv_func_getmntent_2],[ # try compiling with 2 args AC_TRY_COMPILE( [#include #if HAVE_SYS_MNTTAB_H #include #endif #if HAVE_MNTENT_H #include #endif ],[getmntent(0,0);] [ac_func_getmntent_2=yes], [ac_func_getmntent_2=no]) # try compiling with 1 arg AC_TRY_COMPILE( [#include #if HAVE_SYS_MNTTAB_H #include #endif #if HAVE_MNTENT_H #include #endif ],[getmntent(0);] [ac_func_getmntent_1=yes], [ac_func_getmntent_1=no]) # if they agree, then the compiler likes us case $ac_func_getmntent_1:$ac_func_getmntent_2 in yes:no) ac_cv_func_getmntent_2=no;; no:yes) ac_cv_func_getmntent_2=yes;; *) AC_TRY_RUN([ /* Check whether getmntent takes one or two arguments * If it takes a second argument, it is a pointer to a structure * to fill in, and the return value is 0 on success, and non-0 * on EOF or an error. If only one argument is used, the return * value is a structure pointer, or 0 on EOF or error. * So, the test is to open a random file, seek to EOF, and then * see whether we get 0 or non-0 on a call to getmntent. */ #include #if HAVE_SYS_MNTTAB_H #include #endif #if HAVE_MNTENT_H #include #endif #if !HAVE_STRUCT_MNTENT #if HAVE_STRUCT_MNTTAB #define mntent mnttab #endif #endif int main () { struct mntent me; FILE *F; int fd; fd = open("conftest.data", O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) exit(99); close(fd); #if HAVE_SETMNTENT F = setmntent("conftest.data", "r"); #else F = fopen("conftest.data", "r"); #endif if (!F) exit(99); if (getmntent(F, &me)) /* 2 arguments */ exit(0); exit(1); } ],[ac_cv_func_getmntent_2=yes], [ac_cv_func_getmntent_2=no], [AC_MSG_ERROR([cannot check getmntent if cross-compiling])]) ;; esac ]) if test $ac_cv_func_getmntent_2 = yes; then AC_DEFINE([HAVE_GETMNTENT2], 1, [Define if the 'getmntent' function takes 2 arguments.]) fi fi ])