source: git/m4/flags.m4 @ 8d1432e

spielwiese
Last change on this file since 8d1432e was b44baa, checked in by Hans Schönemann <hannes@…>, 8 years ago
fix for gcc 6.1: first approach
  • Property mode set to 100644
File size: 4.8 KB
Line 
1AC_DEFUN([SING_SHOW_FLAGS], [
2
3echo "/* --------------- $1 --------------- */";
4
5AC_MSG_CHECKING([  CFLAGS?..])
6AC_MSG_RESULT(${CFLAGS:-unset})
7AC_MSG_CHECKING([CXXFLAGS?..])
8AC_MSG_RESULT(${CXXFLAGS:-unset})
9AC_MSG_CHECKING([CPPFLAGS?..])
10AC_MSG_RESULT(${CPPFLAGS:-unset})
11AC_MSG_CHECKING([    DEFS?..])
12AC_MSG_RESULT(${DEFS:-unset})
13AC_MSG_CHECKING([ LDFLAGS?..])
14AC_MSG_RESULT(${LDFLAGS:-unset})
15AC_MSG_CHECKING([    LIBS?..])
16AC_MSG_RESULT(${LIBS:-unset})
17AC_MSG_CHECKING([     GCC?..])
18AC_MSG_RESULT(${GCC:-unset})
19AC_MSG_CHECKING([      CC?..])
20AC_MSG_RESULT(${CC:-unset})
21AC_MSG_CHECKING([     GXX?..])
22AC_MSG_RESULT(${GXX:-unset})
23AC_MSG_CHECKING([     CXX?..])
24AC_MSG_RESULT(${CXX:-unset})
25
26# echo "/* =============== $1 =============== */";
27])
28
29AC_DEFUN([SING_RESET_FLAGS], [
30 AC_MSG_WARN([Please note that we set empty defaults for \`CFLAGS' and \`CXXFLAGS' (instead of \`-g -O')])
31 : ${CFLAGS:=""}
32 : ${CXXFLAGS:=""}
33])
34
35
36AC_DEFUN([SING_CHECK_SET_ARGS], [
37#  SING_SHOW_FLAGS([Initial state?...])dnl
38
39 AC_ARG_ENABLE([debug],
40  AS_HELP_STRING([--enable-debug], [build the debugging version of the libraries]),
41  [ENABLE_DEBUG="$enableval"], [ENABLE_DEBUG=""])
42
43 AC_MSG_CHECKING([debugging checks should be embedded])
44 if test "x${ENABLE_DEBUG}" != xyes; then
45  AC_MSG_RESULT([no])
46 else
47  AC_MSG_RESULT([yes])
48 fi
49
50 AC_ARG_ENABLE([optimizationflags],
51  AS_HELP_STRING([--disable-optimizationflags], [build the without default optimization flags]),
52  [ENABLE_OPTIMIZATION="$enableval"], [ENABLE_OPTIMIZATION="yeah"])
53
54 if test "x${ENABLE_DEBUG}" = xyes; then
55  SINGULAR_CFLAGS=""
56  if test "x${ENABLE_OPTIMIZATION}" = xyeah; then
57   ENABLE_OPTIMIZATION="no"
58   AC_MSG_WARN([Please note that we disable implicit (default) optimization flags since you have enabled the debug flags... ])
59  fi
60 else
61  SINGULAR_CFLAGS="-DSING_NDEBUG -DOM_NDEBUG"
62  # for now let '-DSING_NDEBUG -DOM_NDEBUG' be here...
63  AC_DEFINE([OM_NDEBUG],1,"Disable OM Debug")
64  AC_DEFINE([SING_NDEBUG],1,"Disable Singular Debug")
65 fi
66
67 if test "x${ENABLE_OPTIMIZATION}" = xyeah; then
68   ENABLE_OPTIMIZATION="yes"
69 fi
70
71 if test "x${ENABLE_OPTIMIZATION}" = xyes; then
72  if test "x${ENABLE_DEBUG}" = xyes; then
73   AC_MSG_WARN([Please note that you will be using our optimization flags together with debug flags... ])
74  fi
75 fi
76
77 AC_MSG_CHECKING([whether optimization flags should be used])
78 if test "x${ENABLE_OPTIMIZATION}" = xyes; then
79  AC_MSG_RESULT([yes])
80 else
81  AC_MSG_RESULT([no])
82 fi
83
84
85 AM_CONDITIONAL(WANT_DEBUG, test x"${ENABLE_DEBUG}" = xyes)
86 AM_CONDITIONAL(WANT_OPTIMIZATIONFLAGS, test x"${ENABLE_OPTIMIZATION}" = xyes)
87
88 AC_DEFINE_UNQUOTED([SINGULAR_CFLAGS],"$SINGULAR_CFLAGS",[SINGULAR_CFLAGS])
89 AC_SUBST(SINGULAR_CFLAGS)
90
91# SING_SHOW_FLAGS([checking flags....])
92
93 FLAGS="-pipe -fno-common"
94 AC_LANG_PUSH([C])
95 AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CFLAGS])
96 AC_LANG_POP([C])
97
98 AC_LANG_PUSH([C++])
99 AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CXXFLAGS])
100
101 # separate parts of Singular have to be real C++ :)
102 FFLAGS="-fexceptions -frtti"
103 AX_APPEND_COMPILE_FLAGS(${FFLAGS}, [FEXCEPTIONSFRTTI_CXXFLAGS])
104 AC_SUBST(FEXCEPTIONSFRTTI_CXXFLAGS)
105
106 AC_LANG_POP([C++])
107
108 AX_APPEND_LINK_FLAGS(${FLAGS})
109
110 if test "x${ENABLE_DEBUG}" = xyes; then
111  DBGFLAGS="-g -ftrapv -fdiagnostics-show-option -Wall -Wextra"
112  #  -pedantic too strict ??? -Wvla -Wno-long-long ???
113  AC_LANG_PUSH([C])
114  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CFLAGS])
115  AC_LANG_POP([C])
116  AC_LANG_PUSH([C++])
117  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CXXFLAGS])
118  AC_LANG_POP([C++])
119  AX_APPEND_LINK_FLAGS(${DBGFLAGS})
120 fi
121
122 ## for clang: -Wunneeded-internal-declaration
123
124 if test "x${ENABLE_OPTIMIZATION}" != xno; then
125  OPTFLAGS="-O3 -Wno-unused-function -Wno-trigraphs -Wno-unused-parameter -Wunknown-pragmas -Wno-unused-variable -fomit-frame-pointer -fwrapv -fvisibility=default -finline-functions -fno-exceptions -fno-rtti -fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space -funroll-loops -fno-delete-null-pointer-checks"
126  #  -O3 - crashes gcc???!!!
127  # -fpermissive
128  AC_LANG_PUSH([C])
129  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CFLAGS])
130  AC_LANG_POP([C])
131  AC_LANG_PUSH([C++])
132  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CXXFLAGS])
133#   AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space], [CXXFLAGS])
134###  AX_APPEND_COMPILE_FLAGS([-fno-implicit-templates], [CXXFLAGS]) # problems due to STL
135  AC_LANG_POP([C++])
136  AX_APPEND_LINK_FLAGS(${OPTFLAGS})
137#  AX_APPEND_LINK_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space])
138###  AX_APPEND_LINK_FLAGS([-fno-implicit-templates]) # see above :(
139#  AX_APPEND_LINK_FLAGS([ ])
140 fi
141
142 FLAGS2="-Qunused-arguments"
143 AC_LANG_PUSH([C])
144 AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CFLAGS])
145 AC_LANG_POP([C])
146
147 AC_LANG_PUSH([C++])
148 AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CXXFLAGS])
149 AC_LANG_POP([C++])
150
151 AX_APPEND_LINK_FLAGS(${FLAGS2})
152
153# SING_SHOW_FLAGS([before PROG_C_CC])
154
155
156AC_PROG_CC
157AC_PROG_CXX
158])
Note: See TracBrowser for help on using the repository browser.