2 dnl Copyright (C) 2002-2020 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.
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.
12 AC_DEFUN([gl_FUNC_PUTENV],
14 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
15 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16 AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
17 [gl_cv_func_svid_putenv],
24 if (putenv ("CONFTEST_putenv=val"))
27 /* Try to remove it. */
28 if (putenv ("CONFTEST_putenv"))
31 /* Make sure it was deleted. */
32 if (getenv ("CONFTEST_putenv") != 0)
37 [gl_cv_func_svid_putenv=yes],
38 [gl_cv_func_svid_putenv=no],
39 [dnl When crosscompiling, assume putenv is broken.
41 # Guess yes on glibc systems.
42 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
43 # Guess yes on musl systems.
44 *-musl*) gl_cv_func_svid_putenv="guessing yes" ;;
45 # Guess no on native Windows.
46 mingw*) gl_cv_func_svid_putenv="guessing no" ;;
47 # If we don't know, obey --enable-cross-guesses.
48 *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
52 case "$gl_cv_func_svid_putenv" in
60 # Prerequisites of lib/putenv.c.
61 AC_DEFUN([gl_PREREQ_PUTENV],
63 AC_CHECK_DECLS([_putenv])