Define the putenv substitute in <stdlib.h> rather than in <config.h>.
[gnulib.git] / m4 / putenv.m4
1 # putenv.m4 serial 13
2 dnl Copyright (C) 2002-2007 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 dnl From Jim Meyering.
8 dnl
9 dnl Check whether putenv ("FOO") removes FOO from the environment.
10 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
11
12 AC_DEFUN([gl_FUNC_PUTENV],
13 [
14   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
15   AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
16    [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[
17     /* Put it in env.  */
18     if (putenv ("CONFTEST_putenv=val"))
19       return 1;
20
21     /* Try to remove it.  */
22     if (putenv ("CONFTEST_putenv"))
23       return 1;
24
25     /* Make sure it was deleted.  */
26     if (getenv ("CONFTEST_putenv") != 0)
27       return 1;
28
29     return 0;
30               ])],
31              jm_cv_func_svid_putenv=yes,
32              jm_cv_func_svid_putenv=no,
33              dnl When crosscompiling, assume putenv is broken.
34              jm_cv_func_svid_putenv=no)
35    ])
36   if test $jm_cv_func_svid_putenv = no; then
37     REPLACE_PUTENV=1
38     AC_LIBOBJ(putenv)
39   fi
40 ])