warnings.m4 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # warnings.m4 serial 5
  2. dnl Copyright (C) 2008-2012 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. dnl From Simon Josefsson
  7. # gl_AS_VAR_APPEND(VAR, VALUE)
  8. # ----------------------------
  9. # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
  10. m4_ifdef([AS_VAR_APPEND],
  11. [m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
  12. [m4_define([gl_AS_VAR_APPEND],
  13. [AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
  14. # gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
  15. # ------------------------------------------------
  16. # Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
  17. # gl_WARN_ADD([-Wparentheses]).
  18. AC_DEFUN([gl_WARN_ADD],
  19. dnl FIXME: gl_Warn must be used unquoted until we can assume
  20. dnl autoconf 2.64 or newer.
  21. [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
  22. AC_CACHE_CHECK([whether compiler handles $1], m4_defn([gl_Warn]), [
  23. gl_save_CPPFLAGS="$CPPFLAGS"
  24. CPPFLAGS="${CPPFLAGS} $1"
  25. AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
  26. [AS_VAR_SET(gl_Warn, [yes])],
  27. [AS_VAR_SET(gl_Warn, [no])])
  28. CPPFLAGS="$gl_save_CPPFLAGS"
  29. ])
  30. AS_VAR_IF(gl_Warn, [yes],
  31. [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
  32. AS_VAR_POPDEF([gl_Warn])dnl
  33. m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
  34. ])