2 dnl Copyright (C) 2008 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.
7 dnl From Simon Josefsson
10 # Initializes WARN_CFLAGS variable.
11 AC_DEFUN([gl_WARN_INIT],
12 [AC_SUBST([WARN_CFLAGS])dnl
13 AC_ARG_VAR([WARN_CFLAGS], [C compiler warning flags])
16 # gl_AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
17 # ----------------------------------------------------
18 # Provide the functionality of AS_VAR_IF if Autoconf does not have it.
20 [m4_copy([AS_VAR_IF], [gl_AS_VAR_IF])],
21 [m4_define([gl_AS_VAR_IF],
22 [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
24 # gl_AS_VAR_APPEND(VAR, VALUE)
25 # ----------------------------
26 # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
27 m4_ifdef([AS_VAR_APPEND],
28 [m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
29 [m4_define([gl_AS_VAR_APPEND],
30 [AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
32 # gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
33 # ------------------------------------------------
34 # Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
35 # gl_WARN_ADD([-Wparentheses]).
36 AC_DEFUN([gl_WARN_ADD],
37 [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
38 AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
41 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
42 [AS_VAR_SET([gl_Warn], [yes])],
43 [AS_VAR_SET([gl_Warn], [no])])
46 AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
47 gl_AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])])
48 AS_VAR_POPDEF([gl_Flags])dnl
49 AS_VAR_POPDEF([gl_Warn])dnl
50 AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])dnl