574092bb2586ef8593ff7819d21728f3c53d9ce6
[deliverable/binutils-gdb.git] / gnulib / import / m4 / mkdir.m4
1 # serial 11
2
3 # Copyright (C) 2001, 2003-2004, 2006, 2008-2016 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_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15 AC_CHECK_HEADERS_ONCE([unistd.h])
16 AC_CACHE_CHECK([whether mkdir handles trailing slash],
17 [gl_cv_func_mkdir_trailing_slash_works],
18 [rm -rf conftest.dir
19 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
20 # include <sys/types.h>
21 # include <sys/stat.h>
22 ]], [return mkdir ("conftest.dir/", 0700);])],
23 [gl_cv_func_mkdir_trailing_slash_works=yes],
24 [gl_cv_func_mkdir_trailing_slash_works=no],
25 [case "$host_os" in
26 # Guess yes on glibc systems.
27 *-gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing yes" ;;
28 # If we don't know, assume the worst.
29 *) gl_cv_func_mkdir_trailing_slash_works="guessing no" ;;
30 esac
31 ])
32 rm -rf conftest.dir
33 ]
34 )
35 case "$gl_cv_func_mkdir_trailing_slash_works" in
36 *yes) ;;
37 *)
38 REPLACE_MKDIR=1
39 ;;
40 esac
41
42 AC_CACHE_CHECK([whether mkdir handles trailing dot],
43 [gl_cv_func_mkdir_trailing_dot_works],
44 [rm -rf conftest.dir
45 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
46 # include <sys/types.h>
47 # include <sys/stat.h>
48 ]], [return !mkdir ("conftest.dir/./", 0700);])],
49 [gl_cv_func_mkdir_trailing_dot_works=yes],
50 [gl_cv_func_mkdir_trailing_dot_works=no],
51 [case "$host_os" in
52 # Guess yes on glibc systems.
53 *-gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;;
54 # If we don't know, assume the worst.
55 *) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;;
56 esac
57 ])
58 rm -rf conftest.dir
59 ]
60 )
61 case "$gl_cv_func_mkdir_trailing_dot_works" in
62 *yes) ;;
63 *)
64 REPLACE_MKDIR=1
65 AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly
66 creates a directory given with a trailing dot component.])
67 ;;
68 esac
69 ])
This page took 0.032559 seconds and 3 git commands to generate.