1 | AC_DEFUN([SING_SHOW_FLAGS], [ |
---|
2 | |
---|
3 | echo "/* --------------- $1 --------------- */"; |
---|
4 | |
---|
5 | AC_MSG_CHECKING([ CFLAGS?..]) |
---|
6 | AC_MSG_RESULT(${CFLAGS:-unset}) |
---|
7 | AC_MSG_CHECKING([CXXFLAGS?..]) |
---|
8 | AC_MSG_RESULT(${CXXFLAGS:-unset}) |
---|
9 | AC_MSG_CHECKING([CPPFLAGS?..]) |
---|
10 | AC_MSG_RESULT(${CPPFLAGS:-unset}) |
---|
11 | AC_MSG_CHECKING([ DEFS?..]) |
---|
12 | AC_MSG_RESULT(${DEFS:-unset}) |
---|
13 | AC_MSG_CHECKING([ LDFLAGS?..]) |
---|
14 | AC_MSG_RESULT(${LDFLAGS:-unset}) |
---|
15 | AC_MSG_CHECKING([ LIBS?..]) |
---|
16 | AC_MSG_RESULT(${LIBS:-unset}) |
---|
17 | AC_MSG_CHECKING([ GCC?..]) |
---|
18 | AC_MSG_RESULT(${GCC:-unset}) |
---|
19 | AC_MSG_CHECKING([ CC?..]) |
---|
20 | AC_MSG_RESULT(${CC:-unset}) |
---|
21 | AC_MSG_CHECKING([ GXX?..]) |
---|
22 | AC_MSG_RESULT(${GXX:-unset}) |
---|
23 | AC_MSG_CHECKING([ CXX?..]) |
---|
24 | AC_MSG_RESULT(${CXX:-unset}) |
---|
25 | |
---|
26 | # echo "/* =============== $1 =============== */"; |
---|
27 | ]) |
---|
28 | |
---|
29 | AC_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 | |
---|
36 | AC_DEFUN([SING_CHECK_SET_ARGS], [ |
---|
37 | # SING_SHOW_FLAGS([Initial state?...])dnl |
---|
38 | |
---|
39 | ENABLE_DEBUG="no" |
---|
40 | ENABLE_OPTIMIZATION="yes" |
---|
41 | |
---|
42 | AC_ARG_ENABLE([debug], |
---|
43 | AS_HELP_STRING([--enable-debug], [build the debugging version of the libraries]), |
---|
44 | [if test "x$enableval" = "xyes"; then |
---|
45 | ENABLE_DEBUG="yes" |
---|
46 | fi]) |
---|
47 | |
---|
48 | AC_ARG_ENABLE([optimizationflags], |
---|
49 | AS_HELP_STRING([--disable-optimizationflags], [build the without default optimization flags]), |
---|
50 | [if test "x$enableval" = "xno"; then |
---|
51 | ENABLE_OPTIMIZATION="no" |
---|
52 | fi]) |
---|
53 | |
---|
54 | AC_MSG_CHECKING([debugging checks should be embedded]) |
---|
55 | if test "x${ENABLE_DEBUG}" != xyes; then |
---|
56 | AC_MSG_RESULT([no]) |
---|
57 | else |
---|
58 | AC_MSG_RESULT([yes]) |
---|
59 | fi |
---|
60 | |
---|
61 | AC_MSG_CHECKING([whether optimization flags should be used]) |
---|
62 | if test "x${ENABLE_OPTIMIZATION}" == xyes; then |
---|
63 | AC_MSG_RESULT([yes]) |
---|
64 | else |
---|
65 | AC_MSG_RESULT([no]) |
---|
66 | fi |
---|
67 | |
---|
68 | AM_CONDITIONAL(WANT_DEBUG, test x"${ENABLE_DEBUG}" == xyes) |
---|
69 | AM_CONDITIONAL(WANT_OPTIMIZATIONFLAGS, test x"${ENABLE_OPTIMIZATION}" != xno) |
---|
70 | |
---|
71 | if test "x${ENABLE_DEBUG}" == xyes; then |
---|
72 | if test "x${ENABLE_OPTIMIZATION}" == xyes; then |
---|
73 | AC_MSG_ERROR([Please note that you have enabled the debug and optimization flags, which may not work well together (try \`--disable-optimizationflags')!]) |
---|
74 | fi |
---|
75 | SINGULAR_CFLAGS="" |
---|
76 | else |
---|
77 | SINGULAR_CFLAGS="-DSING_NDEBUG -DOM_NDEBUG" |
---|
78 | # for now let '-DSING_NDEBUG -DOM_NDEBUG' be here... |
---|
79 | AC_DEFINE([OM_NDEBUG],1,"Disable OM Debug") |
---|
80 | AC_DEFINE([SING_NDEBUG],1,"Disable Singular Debug") |
---|
81 | fi |
---|
82 | |
---|
83 | AC_DEFINE_UNQUOTED([SINGULAR_CFLAGS],"$SINGULAR_CFLAGS",[SINGULAR_CFLAGS]) |
---|
84 | AC_SUBST(SINGULAR_CFLAGS) |
---|
85 | |
---|
86 | # SING_SHOW_FLAGS([checking flags....]) |
---|
87 | |
---|
88 | FLAGS="-pipe -fno-common" |
---|
89 | AC_LANG_PUSH([C]) |
---|
90 | AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CFLAGS]) |
---|
91 | AC_LANG_POP([C]) |
---|
92 | |
---|
93 | AC_LANG_PUSH([C++]) |
---|
94 | AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CXXFLAGS]) |
---|
95 | AX_APPEND_COMPILE_FLAGS([-fexceptions -frtti], [POLYMAKE_CXXFLAGS]) |
---|
96 | AC_LANG_POP([C++]) |
---|
97 | |
---|
98 | AX_APPEND_LINK_FLAGS(${FLAGS}) |
---|
99 | |
---|
100 | AC_SUBST(POLYMAKE_CXXFLAGS) |
---|
101 | |
---|
102 | if test "x${ENABLE_DEBUG}" == xyes; then |
---|
103 | DBGFLAGS="-g -ftrapv -fdiagnostics-show-option -Wall -Wextra" |
---|
104 | # -pedantic too strict ??? -Wvla -Wno-long-long ??? |
---|
105 | AC_LANG_PUSH([C]) |
---|
106 | AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CFLAGS]) |
---|
107 | AC_LANG_POP([C]) |
---|
108 | AC_LANG_PUSH([C++]) |
---|
109 | AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CXXFLAGS]) |
---|
110 | AC_LANG_POP([C++]) |
---|
111 | AX_APPEND_LINK_FLAGS(${DBGFLAGS}) |
---|
112 | fi |
---|
113 | |
---|
114 | ## for clang: -Wunneeded-internal-declaration |
---|
115 | |
---|
116 | if test "x${ENABLE_OPTIMIZATION}" != xno; then |
---|
117 | OPTFLAGS="-DHAVE_CONFIG_H -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" |
---|
118 | # -O3 - crashes gcc???!!! |
---|
119 | # -fpermissive |
---|
120 | AC_LANG_PUSH([C]) |
---|
121 | AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CFLAGS]) |
---|
122 | AC_LANG_POP([C]) |
---|
123 | AC_LANG_PUSH([C++]) |
---|
124 | AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CXXFLAGS]) |
---|
125 | # AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space], [CXXFLAGS]) |
---|
126 | ### AX_APPEND_COMPILE_FLAGS([-fno-implicit-templates], [CXXFLAGS]) # problems due to STL |
---|
127 | AC_LANG_POP([C++]) |
---|
128 | AX_APPEND_LINK_FLAGS(${OPTFLAGS}) |
---|
129 | # AX_APPEND_LINK_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space]) |
---|
130 | ### AX_APPEND_LINK_FLAGS([-fno-implicit-templates]) # see above :( |
---|
131 | # AX_APPEND_LINK_FLAGS([ ]) |
---|
132 | fi |
---|
133 | |
---|
134 | FLAGS2="-Qunused-arguments" |
---|
135 | AC_LANG_PUSH([C]) |
---|
136 | AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CFLAGS]) |
---|
137 | AC_LANG_POP([C]) |
---|
138 | |
---|
139 | AC_LANG_PUSH([C++]) |
---|
140 | AX_APPEND_COMPILE_FLAGS(${FLAGS2}, [CXXFLAGS]) |
---|
141 | AC_LANG_POP([C++]) |
---|
142 | |
---|
143 | AX_APPEND_LINK_FLAGS(${FLAGS2}) |
---|
144 | |
---|
145 | # SING_SHOW_FLAGS([before PROG_C_CC]) |
---|
146 | |
---|
147 | |
---|
148 | AC_PROG_CC |
---|
149 | AC_PROG_CXX |
---|
150 | ]) |
---|