Blame m4/putenv.m4

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