vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

ensc_cflags.m4 (3210B)


      1 dnl $Id$
      2 
      3 dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
      4 dnl  
      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.
      8 dnl  
      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.
     13 dnl  
     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.
     17 
     18 AC_DEFUN([__ENSC_CHECK_WARNFLAGS],
     19 [
     20 	warn_flags="-Werror -W"
     21 	AC_MSG_CHECKING([whether the $1-compiler accepts ${warn_flags}])
     22 	AC_LANG_PUSH($1)
     23 	__ensc_check_warnflags_old_CFLAGS="${$3}"
     24 	$3="$warn_flags"
     25 	AC_TRY_COMPILE([inline static void f(){}],
     26 		       [],
     27 		       [ensc_sys_compilerwarnflags_$2=${warn_flags}],
     28 		       [ensc_sys_compilerwarnflags_$2=])
     29 	AC_LANG_POP($1)
     30 	$3="$__ensc_check_warnflags_old_CFLAGS"
     31 
     32 	if test x"${ensc_sys_compilerwarnflags_$2}" = x; then
     33 		AC_MSG_RESULT([no])
     34 	else
     35 		AC_MSG_RESULT([yes])
     36 	fi
     37 ])
     38 
     39 AC_DEFUN([__ENSC_CHECK_WARNFLAGS_C],
     40 [
     41 	__ENSC_CHECK_WARNFLAGS(C, C, CFLAGS)
     42 ])
     43 
     44 AC_DEFUN([__ENSC_CHECK_WARNFLAGS_CXX],
     45 [
     46 	__ENSC_CHECK_WARNFLAGS(C++, CXX, CXXFLAGS)
     47 ])
     48 
     49 
     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
     54 # Usage:
     55 #   ENSC_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...)
     56 # -------------------------------------------------------------------------
     57 
     58 AC_DEFUN([ENSC_CHECK_CXX_FLAG],
     59 [
     60 	AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_CXX])
     61 
     62   echo 'void f(){}' > conftest.cc
     63   for i in $1
     64   do
     65     AC_MSG_CHECKING([whether $CXX accepts $i])
     66     if test -z "`${CXX} ${ensc_sys_compilerwarnflags_CXX} $i -c conftest.cc 2>&1`"
     67     then
     68       CXXFLAGS="${CXXFLAGS} $i"
     69       AC_MSG_RESULT(yes)
     70     else
     71       AC_MSG_RESULT(no)
     72     fi
     73   done
     74   rm -f conftest.cc conftest.o
     75 ])
     76 
     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
     81 # Usage:
     82 #  ENSC_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...)
     83 # -------------------------------------------------------------------------
     84 
     85 AC_DEFUN([ENSC_CHECK_CC_FLAG],
     86 [
     87 	AC_REQUIRE([__ENSC_CHECK_WARNFLAGS_C])
     88 
     89 echo 'void f(){}' > conftest.c
     90   for i in $1
     91   do
     92     AC_MSG_CHECKING([whether $CC accepts $i])
     93     if test -z "`${CC} ${ensc_sys_compilerwarnflags_C} $i -c conftest.c 2>&1`"
     94     then
     95       CFLAGS="${CFLAGS} $i"
     96       AC_MSG_RESULT(yes)
     97     else
     98       AC_MSG_RESULT(no)
     99     fi
    100   done
    101   rm -f conftest.c conftest.o
    102 ])
    103 
    104 AC_DEFUN([ENSC_CHECK_DEFAULT_FLAG],
    105 [
    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])
    109 
    110 		ensc_sys_default_flag=set
    111 	fi
    112 ])