1 AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[
3 #define test_readdir_os2_delete main
4 #include "$libreplacedir/test/os2_delete.c"],
5 [libreplace_cv_READDIR_NEEDED=no],
6 [libreplace_cv_READDIR_NEEDED=yes],
7 [libreplace_cv_READDIR_NEEDED="assuming not"])
11 AC_HAVE_DECL(dirfd, [#include <dirent.h>])
14 # try to replace with getdirentries() if needed
16 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
17 AC_CHECK_FUNCS(getdirentries)
18 AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
22 AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
27 AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
31 AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
35 AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[
37 #define _LIBREPLACE_REPLACE_H
38 #include "$libreplacedir/repdir_getdirentries.c"
39 #define test_readdir_os2_delete main
40 #include "$libreplacedir/test/os2_delete.c"],
41 [libreplace_cv_READDIR_GETDIRENTRIES=yes],
42 [libreplace_cv_READDIR_GETDIRENTRIES=no])
45 if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then
46 AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
47 AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
48 LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/repdir_getdirentries.o"
49 libreplace_cv_READDIR_NEEDED=no
53 # try to replace with getdents() if needed
55 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
56 AC_CHECK_FUNCS(getdents)
57 AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[
59 #define _LIBREPLACE_REPLACE_H
60 #error _donot_use_getdents_replacement_anymore
61 #include "$libreplacedir/repdir_getdents.c"
62 #define test_readdir_os2_delete main
63 #include "$libreplacedir/test/os2_delete.c"],
64 [libreplace_cv_READDIR_GETDENTS=yes],
65 [libreplace_cv_READDIR_GETDENTS=no])
68 if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then
69 AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
70 AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
71 LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/repdir_getdents.o"
72 libreplace_cv_READDIR_NEEDED=no
75 AC_MSG_CHECKING([a usable readdir()])
76 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
78 AC_MSG_WARN([the provided readdir() is broken])