Imported Upstream version 3.2.2
[debian/gnuradio] / config / lf_warnings.m4
1 dnl Copyright (C) 1988 Eleftherios Gkioulekas <lf@amath.washington.edu>
2 dnl Copyright (C) 2009 Free Software Foundation, Inc.
3 dnl  
4 dnl This program is free software; you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation; either version 3 of the License, or
7 dnl (at your option) any later version.
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., 51 Franklin Street, Boston, MA 02110-1301, USA.
17 dnl 
18 dnl As a special exception to the GNU General Public License, if you 
19 dnl distribute this file as part of a program that contains a configuration 
20 dnl script generated by Autoconf, you may include it under the same 
21 dnl distribution terms that you use for the rest of that program.
22
23 # --------------------------------------------------------------------------
24 # Check whether the C++ compiler accepts a certain flag
25 # If it does it adds the flag to lf_CXXFLAGS
26 # If it does not then it returns an error to lf_ok
27 # Usage:
28 #   LF_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...)
29 # -------------------------------------------------------------------------
30
31 AC_DEFUN([LF_CHECK_CXX_FLAG],[
32   echo 'void f(){}' > conftest.cc
33   for i in $1
34   do
35     AC_MSG_CHECKING([whether $CXX accepts $i])
36     if test -z "`${CXX} $i -c conftest.cc 2>&1`"
37     then
38       lf_CXXFLAGS="${lf_CXXFLAGS} $i"
39       AC_MSG_RESULT(yes)
40     else
41       AC_MSG_RESULT(no)
42     fi
43   done
44   rm -f conftest.cc conftest.o
45   AC_SUBST(lf_CXXFLAGS)
46 ])
47
48 # --------------------------------------------------------------------------
49 # Check whether the C compiler accepts a certain flag
50 # If it does it adds the flag to lf_CFLAGS
51 # If it does not then it returns an error to lf_ok
52 # Usage:
53 #  LF_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...)
54 # -------------------------------------------------------------------------
55
56 AC_DEFUN([LF_CHECK_CC_FLAG],[
57   echo 'void f(){}' > conftest.c
58   for i in $1
59   do
60     AC_MSG_CHECKING([whether $CC accepts $i])
61     if test -z "`${CC} $i -c conftest.c 2>&1`"
62     then
63       lf_CFLAGS="${lf_CFLAGS} $i"
64       AC_MSG_RESULT(yes)
65     else
66       AC_MSG_RESULT(no)
67     fi
68   done
69   rm -f conftest.c conftest.o
70   AC_SUBST(lf_CFLAGS)
71 ])
72
73 # --------------------------------------------------------------------------
74 # Check whether the Fortran compiler accepts a certain flag
75 # If it does it adds the flag to lf_FFLAGS
76 # If it does not then it returns an error to lf_ok
77 # Usage:
78 #  LF_CHECK_F77_FLAG(-flag1 -flag2 -flag3 ...)
79 # -------------------------------------------------------------------------
80
81 AC_DEFUN([LF_CHECK_F77_FLAG],[
82   cat << EOF > conftest.f
83 c....:++++++++++++++++++++++++
84       PROGRAM MAIN
85       PRINT*,'Hello World!'
86       END
87 EOF
88   for i in $1
89   do
90     AC_MSG_CHECKING([whether $F77 accepts $i])
91     if test -z "`${F77} $i -c conftest.f 2>&1`"
92     then
93       lf_FFLAGS="${lf_FFLAGS} $i"
94       AC_MSG_RESULT(yes)  
95     else
96       AC_MSG_RESULT(no)
97     fi
98   done
99   rm -f conftest.f conftest.o
100   AC_SUBST(lf_FFLAGS)
101 ])
102
103 # ----------------------------------------------------------------------
104 # Enable compiler warnings. 
105 # Call this command AFTER you have configured ALL your compilers. 
106 # ----------------------------------------------------------------------
107
108 AC_DEFUN([LF_SET_WARNINGS],[
109   dnl Warnings for the two main compilers
110   dnl add -Wextra when you're got time to fix a bunch of them ;-)
111   cc_warning_flags="-Wall -Werror-implicit-function-declaration"
112   cxx_warning_flags="-Wall -Woverloaded-virtual"
113   if test -n "${CC}"
114   then
115     LF_CHECK_CC_FLAG($cc_warning_flags)
116   fi
117   if test -n "${CXX}" 
118   then
119     LF_CHECK_CXX_FLAG($cxx_warning_flags)
120   fi
121 ])