0c4aebf4a71f365ad976c52008a3e80aed47bede
[gnulib.git] / m4 / putenv.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl
5 dnl Check whether putenv ("FOO") removes FOO from the environment.
6 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
7 dnl
8 dnl If you use this macro in a package, you should
9 dnl add the following two lines to acconfig.h:
10 dnl  /* Define to rpl_putenv if the replacement function should be used.  */
11 dnl  #undef putenv
12 dnl
13
14 AC_DEFUN(jm_FUNC_PUTENV,
15 [AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
16   [AC_TRY_RUN([
17     int
18     main ()
19     {
20       /* Put it in env.  */
21       if (putenv ("CONFTEST_putenv=val"))
22         exit (1);
23
24       /* Try to remove it.  */
25       if (putenv ("CONFTEST_putenv"))
26         exit (1);
27
28       /* Make sure it was deleted.  */
29       if (getenv ("CONFTEST_putenv") != 0)
30         exit (1);
31
32       exit (0);
33     }
34               ],
35              jm_cv_func_svid_putenv=yes,
36              jm_cv_func_svid_putenv=no,
37              dnl When crosscompiling, assume putenv is broken.
38              jm_cv_func_svid_putenv=no)
39   ])
40   if test $jm_cv_func_svid_putenv = no; then
41     LIBOBJS="$LIBOBJS putenv.o"
42     AC_DEFINE_UNQUOTED(putenv, rpl_putenv)
43   fi
44 ])