3 dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; version 2 of the License.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 AC_DEFUN([__ENSC_CHECK_WARNFLAGS],
20 warn_flags="-Werror -W"
21 AC_MSG_CHECKING([whether the $1-compiler accepts ${warn_flags}])
23 __ensc_check_warnflags_old_CFLAGS="${$3}"
25 AC_TRY_COMPILE([inline static void f(){}],
27 [ensc_sys_compilerwarnflags_$2=${warn_flags}],
28 [ensc_sys_compilerwarnflags_$2=])
30 $3="$__ensc_check_warnflags_old_CFLAGS"
32 if test x"${ensc_sys_compilerwarnflags_$2}" = x; then
39 AC_DEFUN([__ENSC_CHECK_WARNFLAGS_C],
41 __ENSC_CHECK_WARNFLAGS(C, C, CFLAGS)
44 AC_DEFUN([__ENSC_CHECK_WARNFLAGS_CXX],
46 __ENSC_CHECK_WARNFLAGS(C++, CXX, CXXFLAGS)
50 # --------------------------------------------------------------------------
51 # Check whether the C++ compiler accepts a certain flag
52 # If it does it adds the flag to CXXFLAGS
53 # If it does not then it returns an error to lf_ok
55 # ENSC_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...)
56 # -------------------------------------------------------------------------
58 AC_DEFUN([ENSC_CHECK_CXX_FLAG],
60 AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_CXX])
62 echo 'void f(){}' > conftest.cc
65 AC_MSG_CHECKING([whether $CXX accepts $i])
66 if test -z "`${CXX} ${ensc_sys_compilerwarnflags_CXX} $i -c conftest.cc 2>&1`"
68 CXXFLAGS="${CXXFLAGS} $i"
74 rm -f conftest.cc conftest.o
77 # --------------------------------------------------------------------------
78 # Check whether the C compiler accepts a certain flag
79 # If it does it adds the flag to CFLAGS
80 # If it does not then it returns an error to lf_ok
82 # ENSC_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...)
83 # -------------------------------------------------------------------------
85 AC_DEFUN([ENSC_CHECK_CC_FLAG],
87 AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_C])
89 echo 'void f(){}' > conftest.c
92 AC_MSG_CHECKING([whether $CC accepts $i])
93 if test -z "`${CC} ${ensc_sys_compilerwarnflags_C} $i -c conftest.c 2>&1`"
101 rm -f conftest.c conftest.o
104 AC_DEFUN([ENSC_CHECK_DEFAULT_FLAG],
106 if test x"${ensc_sys_default_flag}" = x; then
107 ENSC_CHECK_CC_FLAG([-fmessage-length=0])
108 ENSC_CHECK_CXX_FLAG([-fmessage-length=0])
110 ensc_sys_default_flag=set