Merge branch 'singlecompression' into single
[kai/samba-autobuild/.git] / replace / repdir.m4
1 AC_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 #
13 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
14 AC_CHECK_FUNCS(getdirentries)
15 AC_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
24 AC_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         ])
32 AC_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 ])
41 fi
42 if 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
47 fi
48
49 #
50 # try to replace with getdents() if needed
51 #
52 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
53 AC_CHECK_FUNCS(getdents)
54 AC_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 ])
64 fi
65 if 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
70 fi
71
72 AC_MSG_CHECKING([a usable readdir()])
73 if test x"$libreplace_cv_READDIR_NEEDED" = x"yes"; then
74         AC_MSG_RESULT(no)
75         AC_MSG_WARN([the provided readdir() is broken])
76 else
77         AC_MSG_RESULT(yes)
78 fi