~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to m4/fcntl.m4

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-10-19 00:00:09 UTC
  • mfrom: (2.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20111019000009-8p33w3wz4b1rdri0
Tags: 1.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add wget-udeb to ship wget.gnu as alternative to busybox wget
    implementation.
  - Depend on libssl-dev 0.9.8k-7ubuntu4 (LP: #503339)
* Dropped changes, superseded in Debian:
  - Keep build dependencies in main:
    + debian/control: remove info2man build-dep
    + debian/patches/series: disable wget-infopod_generated_manpage
  - Mark wget Multi-Arch: foreign, so packages that aren't of the same arch
    can depend on it.
* Pass --with-ssl=openssl; we don't want to use gnutls, there's no udeb for
  it.
* Add a second build pass for the udeb, so we can build without libidn.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# fcntl.m4 serial 5
 
2
dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
3
dnl This file is free software; the Free Software Foundation
 
4
dnl gives unlimited permission to copy and/or distribute it,
 
5
dnl with or without modifications, as long as this notice is preserved.
 
6
 
 
7
# For now, this module ensures that fcntl()
 
8
# - supports F_DUPFD correctly
 
9
# - supports or emulates F_DUPFD_CLOEXEC
 
10
# - supports F_GETFD
 
11
# Still to be ported to mingw:
 
12
# - F_SETFD
 
13
# - F_GETFL, F_SETFL
 
14
# - F_GETOWN, F_SETOWN
 
15
# - F_GETLK, F_SETLK, F_SETLKW
 
16
AC_DEFUN([gl_FUNC_FCNTL],
 
17
[
 
18
  dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
 
19
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
20
  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
 
21
  AC_REQUIRE([AC_CANONICAL_HOST])
 
22
  AC_CHECK_FUNCS_ONCE([fcntl])
 
23
  if test $ac_cv_func_fcntl = no; then
 
24
    gl_REPLACE_FCNTL
 
25
  else
 
26
    dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
 
27
    dnl haiku alpha 2 F_DUPFD has wrong errno
 
28
    AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
 
29
      [gl_cv_func_fcntl_f_dupfd_works],
 
30
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
31
#include <fcntl.h>
 
32
#include <errno.h>
 
33
]], [[int result = 0;
 
34
      if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
 
35
      if (errno != EINVAL) result |= 2;
 
36
      return result;
 
37
         ]])],
 
38
         [gl_cv_func_fcntl_f_dupfd_works=yes],
 
39
         [gl_cv_func_fcntl_f_dupfd_works=no],
 
40
         [# Guess that it works on glibc systems
 
41
          case $host_os in #((
 
42
            *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
 
43
            *)      gl_cv_func_fcntl_f_dupfd_works="guessing no";;
 
44
          esac])])
 
45
    case $gl_cv_func_fcntl_f_dupfd_works in
 
46
      *yes) ;;
 
47
      *) gl_REPLACE_FCNTL
 
48
        AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
 
49
          behavior does not match POSIX]) ;;
 
50
    esac
 
51
 
 
52
    dnl Many systems lack F_DUPFD_CLOEXEC
 
53
    AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
 
54
      [gl_cv_func_fcntl_f_dupfd_cloexec],
 
55
      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
56
#include <fcntl.h>
 
57
#ifndef F_DUPFD_CLOEXEC
 
58
choke me
 
59
#endif
 
60
         ]])],
 
61
         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
62
#ifdef __linux__
 
63
/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
 
64
   it to support the semantics on older kernels that failed with EINVAL.  */
 
65
choke me
 
66
#endif
 
67
           ]])],
 
68
           [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
 
69
           [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
 
70
         [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
 
71
    if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
 
72
      gl_REPLACE_FCNTL
 
73
      dnl No witness macro needed for this bug.
 
74
    fi
 
75
  fi
 
76
  dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
 
77
  dnl to keep fchdir's bookkeeping up-to-date.
 
78
  m4_ifdef([gl_FUNC_FCHDIR], [
 
79
    gl_TEST_FCHDIR
 
80
    if test $HAVE_FCHDIR = 0; then
 
81
      gl_REPLACE_FCNTL
 
82
    fi
 
83
  ])
 
84
])
 
85
 
 
86
AC_DEFUN([gl_REPLACE_FCNTL],
 
87
[
 
88
  AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
 
89
  AC_CHECK_FUNCS_ONCE([fcntl])
 
90
  if test $ac_cv_func_fcntl = no; then
 
91
    HAVE_FCNTL=0
 
92
  else
 
93
    REPLACE_FCNTL=1
 
94
  fi
 
95
])