source: git/m4/flags.m4 @ f30df9

spielwiese
Last change on this file since f30df9 was f30df9, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
More fixes/improvements to BS (m4/*.m4)
  • Property mode set to 100644
File size: 3.9 KB
RevLine 
[7d160bb]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 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
[e681f3]75# else
76#  AC_DEFINE([OM_NDEBUG],1,"Disable OM Debug")
77#  AC_DEFINE([NDEBUG],1,"Disable Debug")
[7d160bb]78 fi
79
80# SING_SHOW_FLAGS([checking flags....])
81
82 FLAGS="-pipe"
83 AC_LANG_PUSH([C])
84 AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CFLAGS])
85 AC_LANG_POP([C])
86 
87 AC_LANG_PUSH([C++])
88 AX_APPEND_COMPILE_FLAGS(${FLAGS}, [CXXFLAGS])
89 AC_LANG_POP([C++])
90
91 AX_APPEND_LINK_FLAGS(${FLAGS})
92 
93 if test "x${ENABLE_DEBUG}" == xyes; then
[ee15d5]94  DBGFLAGS="-g -O0 -ftrapv -fdiagnostics-show-option -Wall -Wextra"
95  #  -pedantic too strict ??? -Wvla -Wno-long-long ???
[7d160bb]96  AC_LANG_PUSH([C])
97  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CFLAGS])
98  AC_LANG_POP([C])
99  AC_LANG_PUSH([C++])
100  AX_APPEND_COMPILE_FLAGS(${DBGFLAGS}, [CXXFLAGS])
101  AC_LANG_POP([C++])
102  AX_APPEND_LINK_FLAGS(${DBGFLAGS})
103 fi
104 
[99b54a]105 if test "x${ENABLE_OPTIMIZATION}" != xno; then
[f30df9]106  OPTFLAGS="-DOM_NDEBUG -DNDEBUG -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"
[7d160bb]107  #  -O3 - crashes gcc???!!! 
[75c73d]108  # -fpermissive
[7d160bb]109  AC_LANG_PUSH([C])
110  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CFLAGS])
111  AC_LANG_POP([C])
112  AC_LANG_PUSH([C++])
113  AX_APPEND_COMPILE_FLAGS(${OPTFLAGS}, [CXXFLAGS])
[75c73d]114#   AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space], [CXXFLAGS])
115###  AX_APPEND_COMPILE_FLAGS([-fno-implicit-templates], [CXXFLAGS]) # problems due to STL
[7d160bb]116  AC_LANG_POP([C++])
117  AX_APPEND_LINK_FLAGS(${OPTFLAGS})
[75c73d]118#  AX_APPEND_LINK_FLAGS([-fno-threadsafe-statics -fno-enforce-eh-specs -fconserve-space])
119###  AX_APPEND_LINK_FLAGS([-fno-implicit-templates]) # see above :(
[ce9bfe]120#  AX_APPEND_LINK_FLAGS([ ])
[7d160bb]121 fi
122
[ea5f3f6]123
[7d160bb]124# SING_SHOW_FLAGS([before PROG_C_CC])
125
[ea5f3f6]126AC_PROG_CC
127AC_PROG_CXX
[7d160bb]128])
Note: See TracBrowser for help on using the repository browser.