sgpemv2/m4/compilerflags.m4

61 lines
1.9 KiB
Plaintext

dnl **************************************************
dnl Copyright (C) 2004 Matteo Settenvini
dnl **************************************************
dnl ---------- AC_CHECK_CXXFLAG ---------------------
dnl This macro checks if a particular flag for the
dnl C++ compiler works. If it is so, it puts the flag
dnl into the first macro parameter.
dnl Example of usage : AC_CHECK_CXXFLAG([CXXFLAGS],[Wall])
dnl -------------------------------------------------
AC_DEFUN([AC_CHECK_CXXFLAG],
[ if test -z "$1" -o -z "$2"; then
AC_MSG_FAILURE([Wrong parameters passed to the m4 macro.
Please contact the package mantainer.])
fi
AC_REQUIRE([AC_PROG_CXX])dnl
AC_MSG_CHECKING([whether $CXX supports the -$2 flag])
ac_check_cxxflags=$CXXFLAGS
CXXFLAGS="-$2"
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
AC_LANG_PROGRAM([], [return 0;]),
[AC_MSG_RESULT([yes])
CXXFLAGS="$ac_check_cxxflags"
$1="-$2 $[$1]" ],
[AC_MSG_RESULT([no])
CXXFLAGS=$ac_check_cxxflags ]
)
AC_LANG_POP
])dnl ------- AC_CHECK_CXXFLAG ----------------------
dnl ---------- AC_CHECK_CFLAG ---------------------
dnl This macro checks if a particular flag for the
dnl C compiler works. If it is so, it adds the flag
dnl into the first macro parameter.
dnl Example of usage : AC_CHECK_CFLAG([CFLAGS],[Wall])
dnl -------------------------------------------------
AC_DEFUN([AC_CHECK_CFLAG],
[ if test -z "$1" -o -z "$2"; then
AC_MSG_FAILURE([Wrong parameters passed to the m4 macro.
Please contact the package mantainer.])
fi
AC_REQUIRE([AC_PROG_CC])dnl
AC_MSG_CHECKING([whether $CC supports the -$2 flag])
ac_check_cflags=$CFLAGS
CFLAGS="-$2"
AC_LANG_PUSH([C])
AC_COMPILE_IFELSE(
AC_LANG_PROGRAM([], [return 0;]),
[AC_MSG_RESULT([yes])
CFLAGS="$ac_check_cflags"
$1="-$2 $[$1]" ],
[AC_MSG_RESULT([no])
CFLAGS=$ac_check_cflags ]
)
AC_LANG_POP
])dnl ------- AC_CHECK_CFLAG ----------------------