]> www.ginac.de Git - cln.git/blob - m4/cc.m4
* m4/cc.m4: Emit a warning if g++ is used and optimization turned off.
[cln.git] / m4 / cc.m4
1 dnl The CLN manual says that without CFLAGS or CXXFLAGS being set compilation
2 dnl will happen with -O.  However, AC_PROG_CC and AC_PROG_CXX set CFLAGS and
3 dnl CXXFLAGS to "-g -O2", which produces way too large binaries.
4
5
6 dnl Wrapper around AC_PROG_CC setting CFLAGS to plain "-O" as opposed to
7 dnl "-g -O2" for the GNU compiler (unless CFLAGS was set before).
8 AC_DEFUN([CL_PROG_CC],
9 [cl_test_CFLAGS=${CFLAGS+set}
10 # Make sure this macro does not come after AC_PROG_CC.
11 # Otherwise CFLAGS would already be set.
12 AC_BEFORE([$0],[AC_PROG_CC])dnl
13 AC_PROG_CC([$1])
14 if test "$cl_test_CFLAGS" != set && test "$ac_compiler_gnu" = yes; then
15     CFLAGS="-O"
16 fi
17 ])
18
19
20 dnl Wrapper around AC_PROG_CXX setting CXXFLAGS to plain "-O" as opposed to
21 dnl "-g -O2" for the GNU compiler (unless CXXFLAGS was set before).  Also
22 dnl emits a warning if G++ is used and optimization turned off.
23 AC_DEFUN([CL_PROG_CXX],
24 [cl_test_CXXFLAGS=${CXXFLAGS+set}
25 # Make sure this macro does not come after AC_PROG_CXX.
26 # Otherwise CXXFLAGS would already be set.
27 AC_BEFORE([$0],[AC_PROG_CXX])dnl
28 AC_PROG_CXX([$1])
29 if test "$ac_compiler_gnu" = yes; then
30   if test "$cl_test_CXXFLAGS" != set; then
31     # User has not set CXXFLAGS.
32     CXXFLAGS="-O"
33   else
34     # Warn if optimization has been turned off with GCC.
35     # Optimization is used for module ordering.
36     case $CXXFLAGS in
37       [ *\ -O | -O | -O\ * | *\ -O\ * | -O[!0]* | *\ -O[!0]*) ;; ]
38       *) AC_MSG_WARN([Optimization turned off. I recommend you unset CXXFLAGS.]);;
39     esac
40   fi
41 fi
42 ])