~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to m4/dirfd.m4

  • Committer: Steve Langasek
  • Date: 2012-06-29 02:07:40 UTC
  • mfrom: (4.1.9 sid)
  • Revision ID: steve.langasek@canonical.com-20120629020740-qqikrblzana08v2y
Merge version 1.5-1.1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# serial 17   -*- Autoconf -*-
 
1
# serial 22   -*- Autoconf -*-
2
2
 
3
3
dnl Find out how to get the file descriptor associated with an open DIR*.
4
4
 
5
 
# Copyright (C) 2001-2006, 2008-2010 Free Software Foundation, Inc.
 
5
# Copyright (C) 2001-2006, 2008-2012 Free Software Foundation, Inc.
6
6
# This file is free software; the Free Software Foundation
7
7
# gives unlimited permission to copy and/or distribute it,
8
8
# with or without modifications, as long as this notice is preserved.
12
12
AC_DEFUN([gl_FUNC_DIRFD],
13
13
[
14
14
  AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
15
 
  gl_REPLACE_DIRENT_H
16
15
 
17
16
  dnl Persuade glibc <dirent.h> to declare dirfd().
18
17
  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
19
18
 
20
 
  dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
21
 
  AC_REQUIRE([AC_PROG_CPP])
22
 
  AC_REQUIRE([AC_PROG_EGREP])
23
 
 
24
19
  AC_CHECK_FUNCS([dirfd])
25
20
  AC_CHECK_DECLS([dirfd], , ,
26
 
    [#include <sys/types.h>
27
 
     #include <dirent.h>])
 
21
    [[#include <sys/types.h>
 
22
      #include <dirent.h>]])
28
23
  if test $ac_cv_have_decl_dirfd = no; then
29
24
    HAVE_DECL_DIRFD=0
30
25
  fi
40
35
       gl_cv_func_dirfd_macro=yes,
41
36
       gl_cv_func_dirfd_macro=no)])
42
37
 
43
 
  # Use the replacement only if we have no function, macro,
44
 
  # or declaration with that name.
45
 
  if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \
46
 
      = no,no,no; then
47
 
    AC_REPLACE_FUNCS([dirfd])
48
 
    AC_CACHE_CHECK(
49
 
              [how to get the file descriptor associated with an open DIR*],
50
 
                   gl_cv_sys_dir_fd_member_name,
51
 
      [
52
 
        dirfd_save_CFLAGS=$CFLAGS
53
 
        for ac_expr in d_fd dd_fd; do
54
 
 
55
 
          CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
56
 
          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
57
 
             #include <sys/types.h>
58
 
             #include <dirent.h>]],
59
 
            [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
60
 
            [dir_fd_found=yes]
61
 
          )
62
 
          CFLAGS=$dirfd_save_CFLAGS
63
 
          test "$dir_fd_found" = yes && break
64
 
        done
65
 
        test "$dir_fd_found" = yes || ac_expr=no_such_member
66
 
 
67
 
        gl_cv_sys_dir_fd_member_name=$ac_expr
68
 
      ]
69
 
    )
70
 
    if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
71
 
      AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
72
 
        $gl_cv_sys_dir_fd_member_name,
73
 
        [the name of the file descriptor member of DIR])
 
38
  # Use the replacement only if we have no function or macro with that name.
 
39
  if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
 
40
    if test $ac_cv_have_decl_dirfd = yes; then
 
41
      # If the system declares dirfd already, let's declare rpl_dirfd instead.
 
42
      REPLACE_DIRFD=1
74
43
    fi
75
 
    AH_VERBATIM(DIR_TO_FD,
76
 
                [#ifdef DIR_FD_MEMBER_NAME
 
44
  fi
 
45
])
 
46
 
 
47
dnl Prerequisites of lib/dirfd.c.
 
48
AC_DEFUN([gl_PREREQ_DIRFD],
 
49
[
 
50
  AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*],
 
51
                 [gl_cv_sys_dir_fd_member_name],
 
52
    [
 
53
      dirfd_save_CFLAGS=$CFLAGS
 
54
      for ac_expr in d_fd dd_fd; do
 
55
 
 
56
        CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
 
57
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
58
           #include <sys/types.h>
 
59
           #include <dirent.h>]],
 
60
          [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
 
61
          [dir_fd_found=yes]
 
62
        )
 
63
        CFLAGS=$dirfd_save_CFLAGS
 
64
        test "$dir_fd_found" = yes && break
 
65
      done
 
66
      test "$dir_fd_found" = yes || ac_expr=no_such_member
 
67
 
 
68
      gl_cv_sys_dir_fd_member_name=$ac_expr
 
69
    ]
 
70
  )
 
71
  if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
 
72
    AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
 
73
      [$gl_cv_sys_dir_fd_member_name],
 
74
      [the name of the file descriptor member of DIR])
 
75
  fi
 
76
  AH_VERBATIM([DIR_TO_FD],
 
77
              [#ifdef DIR_FD_MEMBER_NAME
77
78
# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
78
79
#else
79
80
# define DIR_TO_FD(Dir_p) -1
80
81
#endif
81
82
])
82
 
  fi
83
83
])