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

« back to all changes in this revision

Viewing changes to m4/dup2.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
#serial 14
 
2
dnl Copyright (C) 2002, 2005, 2007, 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
AC_DEFUN([gl_FUNC_DUP2],
 
8
[
 
9
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
 
10
  AC_REQUIRE([AC_CANONICAL_HOST])
 
11
  m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
 
12
    AC_CHECK_FUNCS_ONCE([dup2])
 
13
    if test $ac_cv_func_dup2 = no; then
 
14
      HAVE_DUP2=0
 
15
    fi
 
16
  ], [
 
17
    AC_DEFINE([HAVE_DUP2], [1], [Define to 1 if you have the 'dup2' function.])
 
18
  ])
 
19
  if test $HAVE_DUP2 = 1; then
 
20
    AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
 
21
      [AC_RUN_IFELSE([
 
22
         AC_LANG_PROGRAM([[#include <unistd.h>
 
23
#include <fcntl.h>
 
24
#include <errno.h>]],
 
25
           [int result = 0;
 
26
#ifdef FD_CLOEXEC
 
27
            if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
 
28
              result |= 1;
 
29
#endif
 
30
            if (dup2 (1, 1) == 0)
 
31
              result |= 2;
 
32
#ifdef FD_CLOEXEC
 
33
            if (fcntl (1, F_GETFD) != FD_CLOEXEC)
 
34
              result |= 4;
 
35
#endif
 
36
            close (0);
 
37
            if (dup2 (0, 0) != -1)
 
38
              result |= 8;
 
39
            /* Many gnulib modules require POSIX conformance of EBADF.  */
 
40
            if (dup2 (2, 1000000) == -1 && errno != EBADF)
 
41
              result |= 16;
 
42
            return result;
 
43
           ])
 
44
        ],
 
45
        [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
 
46
        [case "$host_os" in
 
47
           mingw*) # on this platform, dup2 always returns 0 for success
 
48
             gl_cv_func_dup2_works=no;;
 
49
           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
 
50
             gl_cv_func_dup2_works=no;;
 
51
           linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
 
52
                   # closed fd may yield -EBADF instead of -1 / errno=EBADF.
 
53
             gl_cv_func_dup2_works=no;;
 
54
           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
 
55
             gl_cv_func_dup2_works=no;;
 
56
           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
 
57
             gl_cv_func_dup2_works=no;;
 
58
           *) gl_cv_func_dup2_works=yes;;
 
59
         esac])
 
60
      ])
 
61
    if test "$gl_cv_func_dup2_works" = no; then
 
62
      REPLACE_DUP2=1
 
63
    fi
 
64
  fi
 
65
  dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
 
66
  dnl to keep fchdir's bookkeeping up-to-date.
 
67
  m4_ifdef([gl_FUNC_FCHDIR], [
 
68
    gl_TEST_FCHDIR
 
69
    if test $HAVE_FCHDIR = 0; then
 
70
      REPLACE_DUP2=1
 
71
    fi
 
72
  ])
 
73
])