733a496426a76fca29507ef5652357a1212d0876
[gnulib.git] / m4 / putenv.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl If you use this macro in a package, you should
5 dnl add the following two lines to acconfig.h:
6 dnl  /* Define to rpl_putenv if the replacement function should be used.  */
7 dnl  #undef putenv
8 dnl
9
10 AC_DEFUN(jm_FUNC_PUTENV,
11 [AC_CACHE_CHECK([for SVID conformant putenv], jm_cv_func_svid_putenv,
12   [AC_TRY_RUN([
13     int
14     main ()
15     {
16       /* Put it in env.  */
17       if (putenv ("CONFTEST_putenv=val"))
18         exit (1);
19
20       /* Try to remove it.  */
21       if (putenv ("CONFTEST_putenv"))
22         exit (1);
23
24       /* Make sure it was deleted.  */
25       if (getenv ("CONFTEST_putenv") != 0)
26         exit (1);
27
28       exit (0);
29     }
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     LIBOBJS="$LIBOBJS putenv.o"
38     AC_DEFINE_UNQUOTED(putenv, rpl_putenv)
39   fi
40 ])