~ubuntu-branches/ubuntu/utopic/gettext/utopic

« back to all changes in this revision

Viewing changes to gettext-runtime/gnulib-m4/setenv.m4

  • Committer: Colin Watson
  • Date: 2010-08-01 21:36:08 UTC
  • mfrom: (2.1.10 sid)
  • Revision ID: cjwatson@canonical.com-20100801213608-yy7vkm8lpatep3ci
merge from Debian 0.18.1.1-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# setenv.m4 serial 8
2
 
dnl Copyright (C) 2001-2004, 2006-2007 Free Software Foundation, Inc.
 
1
# setenv.m4 serial 16
 
2
dnl Copyright (C) 2001-2004, 2006-2010 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.
6
6
 
7
7
AC_DEFUN([gl_FUNC_SETENV],
8
8
[
9
 
  AC_CHECK_FUNCS_ONCE([setenv])
10
 
  if test $ac_cv_func_setenv = no; then
 
9
  AC_REQUIRE([gl_FUNC_SETENV_SEPARATE])
 
10
  if test $HAVE_SETENV$REPLACE_SETENV != 10; then
11
11
    AC_LIBOBJ([setenv])
12
 
    gl_PREREQ_SETENV
13
12
  fi
14
13
])
15
14
 
16
15
# Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
17
16
AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
18
17
[
 
18
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
19
19
  AC_CHECK_FUNCS_ONCE([setenv])
 
20
  if test $ac_cv_func_setenv = no; then
 
21
    HAVE_SETENV=0
 
22
  else
 
23
    AC_CACHE_CHECK([whether setenv validates arguments],
 
24
      [gl_cv_func_setenv_works],
 
25
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
26
       #include <stdlib.h>
 
27
       #include <errno.h>
 
28
       #include <string.h>
 
29
      ]], [[
 
30
       if (setenv ("", "", 0) != -1) return 1;
 
31
       if (errno != EINVAL) return 2;
 
32
       if (setenv ("a", "=", 1) != 0) return 3;
 
33
       if (strcmp (getenv ("a"), "=") != 0) return 4;
 
34
      ]])],
 
35
      [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
 
36
      [gl_cv_func_setenv_works="guessing no"])])
 
37
    if test "$gl_cv_func_setenv_works" != yes; then
 
38
      REPLACE_SETENV=1
 
39
      AC_LIBOBJ([setenv])
 
40
    fi
 
41
  fi
20
42
  gl_PREREQ_SETENV
21
43
])
22
44
 
23
45
AC_DEFUN([gl_FUNC_UNSETENV],
24
46
[
 
47
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
25
48
  AC_CHECK_FUNCS([unsetenv])
26
49
  if test $ac_cv_func_unsetenv = no; then
 
50
    HAVE_UNSETENV=0
27
51
    AC_LIBOBJ([unsetenv])
28
52
    gl_PREREQ_UNSETENV
29
53
  else
30
 
    AC_CACHE_CHECK([for unsetenv() return type], gt_cv_func_unsetenv_ret,
 
54
    dnl Some BSDs return void, failing to do error checking.
 
55
    AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
31
56
      [AC_TRY_COMPILE([#include <stdlib.h>
32
57
extern
33
58
#ifdef __cplusplus
40
65
#endif
41
66
], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')])
42
67
    if test $gt_cv_func_unsetenv_ret = 'void'; then
43
 
      AC_DEFINE(VOID_UNSETENV, 1, [Define if unsetenv() returns void, not int.])
 
68
      AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void
 
69
       instead of int.])
 
70
      REPLACE_UNSETENV=1
 
71
      AC_LIBOBJ([unsetenv])
44
72
    fi
45
 
  fi
46
 
])
47
73
 
48
 
# Check if a variable is properly declared.
49
 
# gt_CHECK_VAR_DECL(includes,variable)
50
 
AC_DEFUN([gt_CHECK_VAR_DECL],
51
 
[
52
 
  define([gt_cv_var], [gt_cv_var_]$2[_declaration])
53
 
  AC_MSG_CHECKING([if $2 is properly declared])
54
 
  AC_CACHE_VAL(gt_cv_var, [
55
 
    AC_TRY_COMPILE([$1
56
 
      extern struct { int foo; } $2;],
57
 
      [$2.foo = 1;],
58
 
      gt_cv_var=no,
59
 
      gt_cv_var=yes)])
60
 
  AC_MSG_RESULT($gt_cv_var)
61
 
  if test $gt_cv_var = yes; then
62
 
    AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_DECL], 1,
63
 
              [Define if you have the declaration of $2.])
 
74
    dnl Solaris 10 unsetenv does not remove all copies of a name.
 
75
    AC_CACHE_CHECK([whether unsetenv works on duplicates],
 
76
      [gl_cv_func_unsetenv_works],
 
77
      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
78
       #include <stdlib.h>
 
79
      ]], [[
 
80
       char entry[] = "b=2";
 
81
       if (putenv ((char *) "a=1")) return 1;
 
82
       if (putenv (entry)) return 2;
 
83
       entry[0] = 'a';
 
84
       unsetenv ("a");
 
85
       if (getenv ("a")) return 3;
 
86
      ]])],
 
87
      [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no],
 
88
      [gl_cv_func_unsetenv_works="guessing no"])])
 
89
    if test "$gl_cv_func_unsetenv_works" != yes; then
 
90
      REPLACE_UNSETENV=1
 
91
      AC_LIBOBJ([unsetenv])
 
92
    fi
64
93
  fi
65
94
])
66
95
 
68
97
AC_DEFUN([gl_PREREQ_SETENV],
69
98
[
70
99
  AC_REQUIRE([AC_FUNC_ALLOCA])
71
 
  AC_CHECK_HEADERS_ONCE(unistd.h)
72
 
  AC_CHECK_HEADERS(search.h)
73
 
  AC_CHECK_FUNCS(tsearch)
74
 
  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
 
100
  AC_REQUIRE([gl_ENVIRON])
 
101
  AC_CHECK_HEADERS_ONCE([unistd.h])
 
102
  AC_CHECK_HEADERS([search.h])
 
103
  AC_CHECK_FUNCS([tsearch])
75
104
])
76
105
 
77
106
# Prerequisites of lib/unsetenv.c.
78
107
AC_DEFUN([gl_PREREQ_UNSETENV],
79
108
[
80
 
  AC_CHECK_HEADERS_ONCE(unistd.h)
81
 
  gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
 
109
  AC_REQUIRE([gl_ENVIRON])
 
110
  AC_CHECK_HEADERS_ONCE([unistd.h])
82
111
])