warnings.m4 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # warnings.m4 serial 7
  2. dnl Copyright (C) 2008-2013 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_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED],
  15. # [PROGRAM = AC_LANG_PROGRAM()])
  16. # -----------------------------------------------------------------
  17. # Check if the compiler supports OPTION when compiling PROGRAM.
  18. #
  19. # FIXME: gl_Warn must be used unquoted until we can assume Autoconf
  20. # 2.64 or newer.
  21. AC_DEFUN([gl_COMPILER_OPTION_IF],
  22. [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
  23. AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
  24. AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
  25. gl_save_compiler_FLAGS="$gl_Flags"
  26. gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $1"])
  27. AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
  28. [AS_VAR_SET(gl_Warn, [yes])],
  29. [AS_VAR_SET(gl_Warn, [no])])
  30. gl_Flags="$gl_save_compiler_FLAGS"
  31. ])
  32. AS_VAR_IF(gl_Warn, [yes], [$2], [$3])
  33. AS_VAR_POPDEF([gl_Flags])dnl
  34. AS_VAR_POPDEF([gl_Warn])dnl
  35. ])
  36. # gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
  37. # [PROGRAM = AC_LANG_PROGRAM()])
  38. # ---------------------------------------------
  39. # Adds parameter to WARN_CFLAGS if the compiler supports it when
  40. # compiling PROGRAM. For example, gl_WARN_ADD([-Wparentheses]).
  41. #
  42. # If VARIABLE is a variable name, AC_SUBST it.
  43. AC_DEFUN([gl_WARN_ADD],
  44. [gl_COMPILER_OPTION_IF([$1],
  45. [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
  46. [],
  47. [$3])
  48. m4_ifval([$2],
  49. [AS_LITERAL_IF([$2], [AC_SUBST([$2])])],
  50. [AC_SUBST([WARN_CFLAGS])])dnl
  51. ])
  52. # Local Variables:
  53. # mode: autoconf
  54. # End: