* fsusage.m4 (gl_STATFS_TRUNCATES): Avoid unused variable.
[gnulib.git] / m4 / putenv.m4
1 # putenv.m4 serial 12
2 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 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 [AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
14   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[
15     /* Put it in env.  */
16     if (putenv ("CONFTEST_putenv=val"))
17       return 1;
18
19     /* Try to remove it.  */
20     if (putenv ("CONFTEST_putenv"))
21       return 1;
22
23     /* Make sure it was deleted.  */
24     if (getenv ("CONFTEST_putenv") != 0)
25       return 1;
26
27     return 0;
28               ])],
29              jm_cv_func_svid_putenv=yes,
30              jm_cv_func_svid_putenv=no,
31              dnl When crosscompiling, assume putenv is broken.
32              jm_cv_func_svid_putenv=no)
33   ])
34   if test $jm_cv_func_svid_putenv = no; then
35     AC_LIBOBJ(putenv)
36     AC_DEFINE(putenv, rpl_putenv,
37       [Define to rpl_putenv if the replacement function should be used.])
38   fi
39 ])