8245d887064dd8c752bc64bea8046c4fcd14c91e
[gnulib.git] / m4 / mkdir-slash.m4
1 #serial 1
2
3 # On some systems, mkdir ("foo/", 0700) fails because of the trailing slash.
4 # On such systems, arrange to use a wrapper function that removes any
5 # trailing slashes.
6 AC_DEFUN([UTILS_FUNC_MKDIR_TRAILING_SLASH],
7 [dnl
8   AC_CACHE_CHECK([whether mkdir fails due to a trailing slash],
9     utils_cv_func_mkdir_trailing_slash_bug,
10     [
11       # Arrange for deletion of the temporary directory this test might create.
12       ac_clean_files="$ac_clean_files confdir-slash"
13       AC_TRY_RUN([
14 #       include <sys/types.h>
15 #       include <sys/stat.h>
16 #       include <stdlib.h>
17         int main ()
18         {
19           rmdir ("confdir-slash");
20           exit (mkdir ("confdir-slash/", 0700));
21         }
22         ],
23       utils_cv_func_mkdir_trailing_slash_bug=no,
24       utils_cv_func_mkdir_trailing_slash_bug=yes,
25       utils_cv_func_mkdir_trailing_slash_bug=yes
26       )
27     ]
28   )
29
30   if test $utils_cv_func_mkdir_trailing_slash_bug = yes; then
31     AC_LIBOBJ(mkdir)
32     AC_DEFINE_UNQUOTED(mkdir, rpl_mkdir,
33       [Define to rpl_mkdir if the replacement function should be used.])
34   fi
35 ])