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.
7 dnl This file is offered as-is, without any warranty.
11 dnl Check whether putenv ("FOO") removes FOO from the environment.
12 dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
14 AC_DEFUN([gl_FUNC_PUTENV],
16 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
18 AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
19 [gl_cv_func_svid_putenv],
26 if (putenv ("CONFTEST_putenv=val"))
29 /* Try to remove it. */
30 if (putenv ("CONFTEST_putenv"))
33 /* Make sure it was deleted. */
34 if (getenv ("CONFTEST_putenv") != 0)
39 [gl_cv_func_svid_putenv=yes],
40 [gl_cv_func_svid_putenv=no],
41 [dnl When crosscompiling, assume putenv is broken.
43 # Guess yes on glibc systems.
44 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
45 # Guess yes on musl systems.
46 *-musl* | midipix*) gl_cv_func_svid_putenv="guessing yes" ;;
47 # Guess no on native Windows.
48 mingw* | windows*) gl_cv_func_svid_putenv="guessing no" ;;
49 # If we don't know, obey --enable-cross-guesses.
50 *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;;
54 case "$gl_cv_func_svid_putenv" in
62 # Prerequisites of lib/putenv.c.
63 AC_DEFUN([gl_PREREQ_PUTENV],
65 AC_CHECK_DECLS_ONCE([_putenv])