source: branches/samba-3.0/source/lib/replace/repdir.m4

Last change on this file was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 2.4 KB
Line 
1AC_CACHE_CHECK([for broken readdir],libreplace_cv_READDIR_NEEDED,[
2 AC_TRY_RUN([
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"])
8])
9
10#
11# try to replace with getdirentries() if needed
12#
13if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
14AC_CHECK_FUNCS(getdirentries)
15AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
16 [
17 return 0;
18 ],[
19 AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
20 ],[],[
21 #include <dirent.h>
22 ])
23
24AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
25 [
26 return 0;
27 ],[
28 AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
29 ],[],[
30 #include <dirent.h>
31 ])
32AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_cv_READDIR_GETDIRENTRIES,[
33 AC_TRY_RUN([
34#define _LIBREPLACE_REPLACE_H
35#include "$libreplacedir/repdir_getdirentries.c"
36#define test_readdir_os2_delete main
37#include "$libreplacedir/test/os2_delete.c"],
38 [libreplace_cv_READDIR_GETDIRENTRIES=yes],
39 [libreplace_cv_READDIR_GETDIRENTRIES=no])
40])
41fi
42if test x"$libreplace_cv_READDIR_GETDIRENTRIES" = x"yes"; then
43 AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
44 AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
45 LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o"
46 libreplace_cv_READDIR_NEEDED=no
47fi
48
49#
50# try to replace with getdents() if needed
51#
52if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
53AC_CHECK_FUNCS(getdents)
54AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_cv_READDIR_GETDENTS,[
55 AC_TRY_RUN([
56#define _LIBREPLACE_REPLACE_H
57#error _donot_use_getdents_replacement_anymore
58#include "$libreplacedir/repdir_getdents.c"
59#define test_readdir_os2_delete main
60#include "$libreplacedir/test/os2_delete.c"],
61 [libreplace_cv_READDIR_GETDENTS=yes],
62 [libreplace_cv_READDIR_GETDENTS=no])
63])
64fi
65if test x"$libreplace_cv_READDIR_GETDENTS" = x"yes"; then
66 AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
67 AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
68 LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o"
69 libreplace_cv_READDIR_NEEDED=no
70fi
71
72AC_MSG_CHECKING([a usable readdir()])
73if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
74 AC_MSG_RESULT(no)
75 AC_MSG_WARN([the provided readdir() is broken])
76else
77 AC_MSG_RESULT(yes)
78fi
Note: See TracBrowser for help on using the repository browser.