minmax.m4 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # minmax.m4 serial 2
  2. dnl Copyright (C) 2005 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_PREREQ(2.52)
  7. AC_DEFUN([gl_MINMAX],
  8. [
  9. AC_REQUIRE([gl_PREREQ_MINMAX])
  10. ])
  11. # Prerequisites of lib/minmax.h.
  12. AC_DEFUN([gl_PREREQ_MINMAX],
  13. [
  14. gl_MINMAX_IN_HEADER([limits.h])
  15. gl_MINMAX_IN_HEADER([sys/param.h])
  16. ])
  17. dnl gl_MINMAX_IN_HEADER(HEADER)
  18. dnl The parameter has to be a literal header name; it cannot be macro,
  19. dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
  20. dnl invocations with a literal macro name.)
  21. AC_DEFUN([gl_MINMAX_IN_HEADER],
  22. [
  23. m4_pushdef([header], AS_TR_SH([$1]))
  24. m4_pushdef([HEADER], AS_TR_CPP([$1]))
  25. AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
  26. [gl_cv_minmax_in_]header,
  27. [AC_TRY_COMPILE([#include <$1>
  28. int x = MIN (42, 17);], [],
  29. [gl_cv_minmax_in_]header[=yes],
  30. [gl_cv_minmax_in_]header[=no])])
  31. if test $gl_cv_minmax_in_[]header = yes; then
  32. AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
  33. [Define to 1 if <$1> defines the MIN and MAX macros.])
  34. fi
  35. m4_popdef([HEADER])
  36. m4_popdef([header])
  37. ])