]> git.cworth.org Git - tar/blob - m4/mkdir.m4
upstream: Fix extraction of device nodes.
[tar] / m4 / mkdir.m4
1 # serial 9
2
3 # Copyright (C) 2001, 2003-2004, 2006, 2008-2010 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # On some systems, mkdir ("foo/", 0700) fails because of the trailing slash.
9 # On others, mkdir ("foo/./", 0700) mistakenly succeeds.
10 # On such systems, arrange to use a wrapper function.
11 AC_DEFUN([gl_FUNC_MKDIR],
12 [dnl
13   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14   AC_CHECK_HEADERS_ONCE([unistd.h])
15   AC_CACHE_CHECK([whether mkdir handles trailing slash],
16     [gl_cv_func_mkdir_trailing_slash_works],
17     [rm -rf conftest.dir
18       AC_RUN_IFELSE([AC_LANG_PROGRAM([[
19 #       include <sys/types.h>
20 #       include <sys/stat.h>
21 ]], [return mkdir ("conftest.dir/", 0700);])],
22       [gl_cv_func_mkdir_trailing_slash_works=yes],
23       [gl_cv_func_mkdir_trailing_slash_works=no],
24       [gl_cv_func_mkdir_trailing_slash_works="guessing no"])
25     rm -rf conftest.dir
26     ]
27   )
28   if test "$gl_cv_func_mkdir_trailing_slash_works" != yes; then
29     REPLACE_MKDIR=1
30     AC_LIBOBJ([mkdir])
31   fi
32
33   AC_CACHE_CHECK([whether mkdir handles trailing dot],
34     [gl_cv_func_mkdir_trailing_dot_works],
35     [rm -rf conftest.dir
36       AC_RUN_IFELSE([AC_LANG_PROGRAM([[
37 #       include <sys/types.h>
38 #       include <sys/stat.h>
39 ]], [return !mkdir ("conftest.dir/./", 0700);])],
40       [gl_cv_func_mkdir_trailing_dot_works=yes],
41       [gl_cv_func_mkdir_trailing_dot_works=no],
42       [gl_cv_func_mkdir_trailing_dot_works="guessing no"])
43     rm -rf conftest.dir
44     ]
45   )
46   if test "$gl_cv_func_mkdir_trailing_dot_works" != yes; then
47     REPLACE_MKDIR=1
48     AC_LIBOBJ([mkdir])
49     AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly
50       creates a directory given with a trailing dot component.])
51   fi
52 ])