Blame m4/putenv.m4

Packit Service fdd496
# putenv.m4 serial 20
Packit Service fdd496
dnl Copyright (C) 2002-2017 Free Software Foundation, Inc.
Packit Service fdd496
dnl This file is free software; the Free Software Foundation
Packit Service fdd496
dnl gives unlimited permission to copy and/or distribute it,
Packit Service fdd496
dnl with or without modifications, as long as this notice is preserved.
Packit Service fdd496
Packit Service fdd496
dnl From Jim Meyering.
Packit Service fdd496
dnl
Packit Service fdd496
dnl Check whether putenv ("FOO") removes FOO from the environment.
Packit Service fdd496
dnl The putenv in libc on at least SunOS 4.1.4 does *not* do that.
Packit Service fdd496
Packit Service fdd496
AC_DEFUN([gl_FUNC_PUTENV],
Packit Service fdd496
[
Packit Service fdd496
  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
Packit Service fdd496
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service fdd496
  AC_CACHE_CHECK([for putenv compatible with GNU and SVID],
Packit Service fdd496
   [gl_cv_func_svid_putenv],
Packit Service fdd496
   [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[[
Packit Service fdd496
    /* Put it in env.  */
Packit Service fdd496
    if (putenv ("CONFTEST_putenv=val"))
Packit Service fdd496
      return 1;
Packit Service fdd496
Packit Service fdd496
    /* Try to remove it.  */
Packit Service fdd496
    if (putenv ("CONFTEST_putenv"))
Packit Service fdd496
      return 2;
Packit Service fdd496
Packit Service fdd496
    /* Make sure it was deleted.  */
Packit Service fdd496
    if (getenv ("CONFTEST_putenv") != 0)
Packit Service fdd496
      return 3;
Packit Service fdd496
Packit Service fdd496
    return 0;
Packit Service fdd496
              ]])],
Packit Service fdd496
             gl_cv_func_svid_putenv=yes,
Packit Service fdd496
             gl_cv_func_svid_putenv=no,
Packit Service fdd496
             dnl When crosscompiling, assume putenv is broken.
Packit Service fdd496
             [case "$host_os" in
Packit Service fdd496
                        # Guess yes on glibc systems.
Packit Service fdd496
                *-gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
Packit Service fdd496
                        # If we don't know, assume the worst.
Packit Service fdd496
                *)      gl_cv_func_svid_putenv="guessing no" ;;
Packit Service fdd496
              esac
Packit Service fdd496
             ])
Packit Service fdd496
   ])
Packit Service fdd496
  case "$gl_cv_func_svid_putenv" in
Packit Service fdd496
    *yes) ;;
Packit Service fdd496
    *)
Packit Service fdd496
      REPLACE_PUTENV=1
Packit Service fdd496
      ;;
Packit Service fdd496
  esac
Packit Service fdd496
])
Packit Service fdd496
Packit Service fdd496
# Prerequisites of lib/putenv.c.
Packit Service fdd496
AC_DEFUN([gl_PREREQ_PUTENV],
Packit Service fdd496
[
Packit Service fdd496
  AC_CHECK_DECLS([_putenv])
Packit Service fdd496
])