Blame m4/minmax.m4

Packit Service a2489d
# minmax.m4 serial 4
Packit Service a2489d
dnl Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
AC_PREREQ([2.53])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_MINMAX],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_PREREQ_MINMAX])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
# Prerequisites of lib/minmax.h.
Packit Service a2489d
AC_DEFUN([gl_PREREQ_MINMAX],
Packit Service a2489d
[
Packit Service a2489d
  gl_MINMAX_IN_HEADER([limits.h])
Packit Service a2489d
  gl_MINMAX_IN_HEADER([sys/param.h])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl gl_MINMAX_IN_HEADER(HEADER)
Packit Service a2489d
dnl The parameter has to be a literal header name; it cannot be macro,
Packit Service a2489d
dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
Packit Service a2489d
dnl invocations with a literal macro name.)
Packit Service a2489d
AC_DEFUN([gl_MINMAX_IN_HEADER],
Packit Service a2489d
[
Packit Service a2489d
  m4_pushdef([header], AS_TR_SH([$1]))
Packit Service a2489d
  m4_pushdef([HEADER], AS_TR_CPP([$1]))
Packit Service a2489d
  AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
Packit Service a2489d
    [gl_cv_minmax_in_]header,
Packit Service a2489d
    [AC_COMPILE_IFELSE(
Packit Service a2489d
       [AC_LANG_PROGRAM(
Packit Service a2489d
          [[#include <$1>
Packit Service a2489d
            int x = MIN (42, 17);]],
Packit Service a2489d
          [[]])],
Packit Service a2489d
       [gl_cv_minmax_in_]header[=yes],
Packit Service a2489d
       [gl_cv_minmax_in_]header[=no])])
Packit Service a2489d
  if test $gl_cv_minmax_in_[]header = yes; then
Packit Service a2489d
    AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
Packit Service a2489d
      [Define to 1 if <$1> defines the MIN and MAX macros.])
Packit Service a2489d
  fi
Packit Service a2489d
  m4_popdef([HEADER])
Packit Service a2489d
  m4_popdef([header])
Packit Service a2489d
])