~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to m4/unlink.m4

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# unlink.m4 serial 8
2
 
dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
1
# unlink.m4 serial 11
 
2
dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
8
8
[
9
9
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
10
  AC_REQUIRE([AC_CANONICAL_HOST])
 
11
  AC_CHECK_HEADERS_ONCE([unistd.h])
 
12
 
11
13
  dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug.
12
14
  AC_CACHE_CHECK([whether unlink honors trailing slashes],
13
15
    [gl_cv_func_unlink_honors_slashes],
18
20
     fi
19
21
     AC_RUN_IFELSE(
20
22
       [AC_LANG_PROGRAM(
21
 
         [[#include <unistd.h>
 
23
         [[#if HAVE_UNISTD_H
 
24
           # include <unistd.h>
 
25
           #else /* on Windows with MSVC */
 
26
           # include <io.h>
 
27
           #endif
22
28
           #include <errno.h>
23
29
         ]],
24
30
         [[int result = 0;
36
42
         ]])],
37
43
      [gl_cv_func_unlink_honors_slashes=yes],
38
44
      [gl_cv_func_unlink_honors_slashes=no],
39
 
      [gl_cv_func_unlink_honors_slashes="guessing no"])
 
45
      [case "$host_os" in
 
46
                 # Guess yes on glibc systems.
 
47
         *-gnu*) gl_cv_func_unlink_honors_slashes="guessing yes" ;;
 
48
                 # If we don't know, assume the worst.
 
49
         *)      gl_cv_func_unlink_honors_slashes="guessing no" ;;
 
50
       esac
 
51
      ])
40
52
     rm -f conftest.file conftest.lnk])
41
 
  dnl Detect MacOS X 10.5.6 bug: On read-write HFS mounts, unlink("..") or
 
53
  case "$gl_cv_func_unlink_honors_slashes" in
 
54
    *no)
 
55
      REPLACE_UNLINK=1
 
56
      ;;
 
57
  esac
 
58
 
 
59
  dnl Detect Mac OS X 10.5.6 bug: On read-write HFS mounts, unlink("..") or
42
60
  dnl unlink("../..") succeeds without doing anything.
43
61
  AC_CACHE_CHECK([whether unlink of a parent directory fails as it should],
44
62
    [gl_cv_func_unlink_parent_fails],
45
63
    [case "$host_os" in
46
64
       darwin*)
47
65
         dnl Try to unlink a subdirectory of /tmp, because /tmp is usually on a
48
 
         dnl HFS mount on MacOS X. Use a subdirectory, owned by the current
 
66
         dnl HFS mount on Mac OS X. Use a subdirectory, owned by the current
49
67
         dnl user, because otherwise unlink() may fail due to permissions
50
68
         dnl reasons, and because when running as root we don't want to risk
51
69
         dnl destroying the entire /tmp.
70
88
           AC_RUN_IFELSE(
71
89
             [AC_LANG_SOURCE([[
72
90
                #include <stdlib.h>
73
 
                #include <unistd.h>
 
91
                #if HAVE_UNISTD_H
 
92
                # include <unistd.h>
 
93
                #else /* on Windows with MSVC */
 
94
                # include <direct.h>
 
95
                # include <io.h>
 
96
                #endif
74
97
                int main ()
75
98
                {
76
99
                  int result = 0;
83
106
              ]])],
84
107
             [gl_cv_func_unlink_parent_fails=yes],
85
108
             [gl_cv_func_unlink_parent_fails=no],
86
 
             [gl_cv_func_unlink_parent_fails="guessing no"])
 
109
             [# If we don't know, assume the worst.
 
110
              gl_cv_func_unlink_parent_fails="guessing no"
 
111
             ])
87
112
           unset GL_SUBDIR_FOR_UNLINK
88
113
           rm -rf "$tmp"
89
114
         else
97
122
    ])
98
123
  case "$gl_cv_func_unlink_parent_fails" in
99
124
    *no)
 
125
      REPLACE_UNLINK=1
100
126
      AC_DEFINE([UNLINK_PARENT_BUG], [1],
101
127
        [Define to 1 if unlink() on a parent directory may succeed])
102
128
      ;;
103
129
  esac
104
 
  if test "$gl_cv_func_unlink_honors_slashes" != yes \
105
 
     || { case "$gl_cv_func_unlink_parent_fails" in
106
 
            *yes) false;;
107
 
            *no) true;;
108
 
          esac
109
 
        }; then
110
 
    REPLACE_UNLINK=1
111
 
  fi
112
130
])