3 dnl Copyright (C) 2002-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
10 dnl Check whether putenv ("FOO") removes FOO from the environment.
11 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
13 AC_DEFUN([gl_FUNC_PUTENV],
15 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
18 [gl_cv_func_svid_putenv],
25 if (putenv ("CONFTEST_putenv=val"))
28 /* Try to remove it. */
29 if (putenv ("CONFTEST_putenv"))
32 /* Make sure it was deleted. */
33 if (getenv ("CONFTEST_putenv") != 0)
38 [gl_cv_func_svid_putenv=yes],
39 [gl_cv_func_svid_putenv=no],
40 [dnl When crosscompiling, assume putenv is broken.
42 # Guess yes on glibc systems.
43 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
44 # Guess yes on musl systems.
45 *-musl* | midipix*) gl_cv_func_svid_putenv="guessing yes" ;;
46 # Guess no on native Windows.
47 mingw* | windows*) gl_cv_func_svid_putenv="guessing no" ;;
48 # If we don't know, obey --enable-cross-guesses.
49 *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
53 case "$gl_cv_func_svid_putenv" in
61 # Prerequisites of lib/putenv.c.
62 AC_DEFUN([gl_PREREQ_PUTENV],
64 AC_CHECK_DECLS_ONCE([_putenv])