source: git/m4/flags.m4 @ 9f7665

spielwiese
Last change on this file since 9f7665 was 9f7665, checked in by Oleksandr Motsak <motsak@…>, 10 years ago
Removed HAVE_CONFIG guards fix: fixed the inclusion of configure-generated *config.h's
  • Property mode set to 100644
File size: 4.7 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 AX_APPEND_COMPILE_FLAGS([-fexceptions -frtti], [POLYMAKE_CXXFLAGS])
101 AC_LANG_POP([C++])
102
103 AX_APPEND_LINK_FLAGS(${FLAGS})
104
105 AC_SUBST(POLYMAKE_CXXFLAGS)
106
107 if test "x${ENABLE_DEBUG}" == xyes; then
108  DBGFLAGS="-g -ftrapv -fdiagnostics-show-option -Wall -Wextra"
109  #  -pedantic too strict ??? -Wvla -Wno-long-long ???
110  AC_LANG_PUSH([C])
111  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CFLAGS])
112  AC_LANG_POP([C])
113  AC_LANG_PUSH([C++])
114  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CXXFLAGS])
115  AC_LANG_POP([C++])
116  AX_APPEND_LINK_FLAGS(${DBGFLAGS})
117 fi
118
119 ## for clang: -Wunneeded-internal-declaration
120
121 if test "x${ENABLE_OPTIMIZATION}" != xno; then
122  OPTFLAGS="-O3 -Wno-unused-function -Wno-trigraphs -Wno-unused-parameter -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"
123  #  -O3 - crashes gcc???!!! 
124  # -fpermissive 
125  AC_LANG_PUSH([C])
126  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CFLAGS])
127  AC_LANG_POP([C])
128  AC_LANG_PUSH([C++])
129  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CXXFLAGS])
130#   AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space], [CXXFLAGS])
131###  AX_APPEND_COMPILE_FLAGS([-fno-implicit-templates], [CXXFLAGS]) # problems due to STL
132  AC_LANG_POP([C++])
133  AX_APPEND_LINK_FLAGS(${OPTFLAGS})
134#  AX_APPEND_LINK_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space])
135###  AX_APPEND_LINK_FLAGS([-fno-implicit-templates]) # see above :(
136#  AX_APPEND_LINK_FLAGS([ ])
137 fi
138
139 FLAGS2="-Qunused-arguments"
140 AC_LANG_PUSH([C])
141 AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CFLAGS])
142 AC_LANG_POP([C])
143 
144 AC_LANG_PUSH([C++])
145 AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CXXFLAGS])
146 AC_LANG_POP([C++])
147
148 AX_APPEND_LINK_FLAGS(${FLAGS2})
149
150# SING_SHOW_FLAGS([before PROG_C_CC])
151
152
153AC_PROG_CC
154AC_PROG_CXX
155])
Note: See TracBrowser for help on using the repository browser.