]> git.ipfire.org Git - thirdparty/util-linux.git/blob - m4/compiler.m4
Merge branch 'ioclt' of https://github.com/lanurmi/util-linux
[thirdparty/util-linux.git] / m4 / compiler.m4
1 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl From Simon Josefsson
7 dnl -- derivated from coreutils m4/warnings.m4
8
9 # UL_AS_VAR_APPEND(VAR, VALUE)
10 # ----------------------------
11 # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
12 m4_ifdef([AS_VAR_APPEND],
13 [m4_copy([AS_VAR_APPEND], [UL_AS_VAR_APPEND])],
14 [m4_define([UL_AS_VAR_APPEND],
15 [AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
16
17 # UL_ADD_WARN(COMPILER_OPTION [, VARNAME])
18 # ------------------------
19 # Adds parameter to WARN_CFLAGS (or to $VARNAME) if the compiler supports it.
20 AC_DEFUN([UL_WARN_ADD], [
21 m4_define([warnvarname], m4_default([$2],WARN_CFLAGS))
22 AS_VAR_PUSHDEF([ul_Warn], [ul_cv_warn_$1])dnl
23 AC_CACHE_CHECK([whether compiler handles $1], m4_defn([ul_Warn]), [
24 ul_save_CPPFLAGS="$CPPFLAGS"
25 CPPFLAGS="-Werror ${CPPFLAGS} $1"
26 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
27 [AS_VAR_SET(ul_Warn, [yes])],
28 [AS_VAR_SET(ul_Warn, [no])])
29 CPPFLAGS="$ul_save_CPPFLAGS"
30 ])
31 AS_VAR_IF(ul_Warn, [yes], [UL_AS_VAR_APPEND(warnvarname, [" $1"])])
32 ])
33