1# putenv.m4 serial 24 2dnl Copyright (C) 2002-2020 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Jim Meyering. 8dnl 9dnl Check whether putenv ("FOO") removes FOO from the environment. 10dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that. 11 12AC_DEFUN([gl_FUNC_PUTENV], 13[ 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], 18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[ 19 /* Put it in env. */ 20 if (putenv ("CONFTEST_putenv=val")) 21 return 1; 22 23 /* Try to remove it. */ 24 if (putenv ("CONFTEST_putenv")) 25 return 2; 26 27 /* Make sure it was deleted. */ 28 if (getenv ("CONFTEST_putenv") != 0) 29 return 3; 30 31 return 0; 32 ]])], 33 gl_cv_func_svid_putenv=yes, 34 gl_cv_func_svid_putenv=no, 35 dnl When crosscompiling, assume putenv is broken. 36 [case "$host_os" in 37 # Guess yes on glibc systems. 38 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;; 39 # Guess yes on musl systems. 40 *-musl*) gl_cv_func_svid_putenv="guessing yes" ;; 41 # Guess no on native Windows. 42 mingw*) gl_cv_func_svid_putenv="guessing no" ;; 43 # If we don't know, obey --enable-cross-guesses. 44 *) gl_cv_func_svid_putenv="$gl_cross_guess_normal" ;; 45 esac 46 ]) 47 ]) 48 case "$gl_cv_func_svid_putenv" in 49 *yes) ;; 50 *) 51 REPLACE_PUTENV=1 52 ;; 53 esac 54]) 55 56# Prerequisites of lib/putenv.c. 57AC_DEFUN([gl_PREREQ_PUTENV], 58[ 59 AC_CHECK_DECLS([_putenv]) 60]) 61