10089
10089
AC_PREREQ([2.53])
10093
dnl XDT_FEATURE_DEBUG()
10092
dnl XDT_SUPPORTED_FLAGS(VAR, FLAGS)
10094
dnl For each token in FLAGS, checks to be sure the compiler supports
10095
dnl the flag, and if so, adds each one to VAR.
10097
AC_DEFUN([XDT_SUPPORTED_FLAGS],
10100
AC_MSG_CHECKING([if $CC supports $flag])
10101
saved_CFLAGS="$CFLAGS"
10102
CFLAGS="$CFLAGS $flag"
10103
AC_COMPILE_IFELSE([ ], [flag_supported=yes], [flag_supported=no])
10104
CFLAGS="$saved_CFLAGS"
10105
AC_MSG_RESULT([$flag_supported])
10107
if test "x$flag_supported" = "xyes"; then
10115
dnl XDT_FEATURE_DEBUG(default_level=minimum)
10095
10117
AC_DEFUN([XDT_FEATURE_DEBUG],
10119
dnl weird indentation to keep output indentation correct
10097
10120
AC_ARG_ENABLE([debug],
10098
AC_HELP_STRING([--enable-debug[=yes|no|full]], [Build with debugging support])
10099
AC_HELP_STRING([--disable-debug], [Include no debugging support [default]]),
10100
[], [enable_debug=no])
10121
AC_HELP_STRING([--enable-debug@<:@=no|minimum|yes|full@:>@],
10122
[Build with debugging support @<:@default=m4_default([$1], [minimum])@:>@])
10123
AC_HELP_STRING([--disable-debug], [Include no debugging support]),
10124
[enable_debug=$enableval], [enable_debug=m4_default([$1], [minimum])])
10102
10126
AC_MSG_CHECKING([whether to build with debugging support])
10103
if test x"$enable_debug" != x"no"; then
10127
if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
10104
10128
AC_DEFINE([DEBUG], [1], [Define for debugging support])
10106
if test x"$GCC" = x"yes"; then
10107
xdt_cv_additional_CFLAGS="-Wall"
10109
xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -DXFCE_DISABLE_DEPRECATED"
10130
xdt_cv_additional_CFLAGS="-DXFCE_DISABLE_DEPRECATED \
10132
-Wno-missing-field-initializers \
10133
-Wno-unused-parameter -Wold-style-definition \
10134
-Wdeclaration-after-statement \
10135
-Wmissing-declarations -Wredundant-decls \
10136
-Wmissing-noreturn -Wshadow -Wpointer-arith \
10137
-Wcast-align -Wformat-security \
10138
-Winit-self -Wmissing-include-dirs -Wundef \
10139
-Wmissing-format-attribute -Wnested-externs \
10141
CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
10111
10143
if test x"$enable_debug" = x"full"; then
10112
10144
AC_DEFINE([DEBUG_TRACE], [1], [Define for tracing support])
10113
if test x"$GCC" = x"yes"; then
10114
xdt_cv_additional_CFLAGS="-g3 -Werror $xdt_cv_additional_CFLAGS"
10145
xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -O0 -g3 -Werror"
10146
CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG"
10116
10147
AC_MSG_RESULT([full])
10118
if test x"$GCC" = x"yes"; then
10119
xdt_cv_additional_CFLAGS="-g $xdt_cv_additional_CFLAGS"
10149
xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -g"
10121
10150
AC_MSG_RESULT([yes])
10124
CFLAGS="$CFLAGS $xdt_cv_additional_CFLAGS"
10125
CXXFLAGS="$CXXFLAGS $xdt_cv_additional_CFLAGS"
10153
XDT_SUPPORTED_FLAGS([supported_CFLAGS], [$xdt_cv_additional_CFLAGS])
10155
ifelse([$CXX], , , [
10156
dnl FIXME: should test on c++ compiler, but the following line causes
10157
dnl autoconf errors for projects that don't check for a
10158
dnl c++ compiler at all.
10159
dnl AC_LANG_PUSH([C++])
10160
dnl XDT_SUPPORTED_FLAGS([supported_CXXFLAGS], [$xdt_cv_additional_CFLAGS])
10162
dnl instead, just use supported_CFLAGS...
10163
supported_CXXFLAGS="$supported_CFLAGS"
10166
CFLAGS="$CFLAGS $supported_CFLAGS"
10167
CXXFLAGS="$CXXFLAGS $supported_CXXFLAGS"
10127
AC_MSG_RESULT([no])
10169
CPPFLAGS="$CPPFLAGS -DNDEBUG"
10171
if test x"$enable_debug" = x"no"; then
10172
CPPFLAGS="$CPPFLAGS -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
10173
AC_MSG_RESULT([no])
10175
AC_MSG_RESULT([minimum])
10181
dnl XDT_FEATURE_VISIBILITY()
10183
dnl Checks to see if the compiler supports the 'visibility' attribute
10184
dnl If so, adds -DHAVE_GNUC_VISIBILTY to CPPFLAGS. Also sets the
10185
dnl automake conditional HAVE_GNUC_VISIBILITY.
10187
AC_DEFUN([XDT_FEATURE_VISIBILITY],
10189
AC_ARG_ENABLE([visibility],
10190
AC_HELP_STRING([--disable-visibility],
10191
[Don't use ELF visibility attributes]),
10192
[enable_visibility=$enableval], [enable_visibility=yes])
10193
have_gnuc_visibility=no
10194
if test "x$enable_visibility" != "xno"; then
10195
XDT_SUPPORTED_FLAGS([xdt_vis_test_cflags], [-Wall -Werror -Wno-unused-parameter])
10196
saved_CFLAGS="$CFLAGS"
10197
CFLAGS="$CFLAGS $xdt_vis_test_cflags"
10198
AC_MSG_CHECKING([whether $CC supports the GNUC visibility attribute])
10199
AC_COMPILE_IFELSE(AC_LANG_SOURCE(
10201
void test_default (void);
10202
void test_hidden (void);
10204
void __attribute__ ((visibility("default"))) test_default (void) {}
10205
void __attribute__ ((visibility("hidden"))) test_hidden (void) {}
10207
int main (int argc, char **argv) {
10214
have_gnuc_visibility=yes
10215
AC_MSG_RESULT([yes])
10218
AC_MSG_RESULT([no])
10220
CFLAGS="$saved_CFLAGS"
10223
if test "x$have_gnuc_visibility" = "xyes"; then
10224
CPPFLAGS="$CPPFLAGS -DHAVE_GNUC_VISIBILITY"
10225
XDT_SUPPORTED_FLAGS([xdt_vis_hidden_cflags], [-fvisibility=hidden])
10226
CFLAGS="$CFLAGS $xdt_vis_hidden_cflags"
10229
AM_CONDITIONAL([HAVE_GNUC_VISIBILITY], [test "x$have_gnuc_visibility" = "xyes"])
10232
dnl XDT_FEATURE_LINKER_OPTS
10234
dnl Checks for and enables any special linker optimizations.
10236
AC_DEFUN([XDT_FEATURE_LINKER_OPTS],
10238
AC_ARG_ENABLE([linker-opts],
10239
AC_HELP_STRING([--disable-linker-opts],
10240
[Disable linker optimizations]),
10241
[enable_linker_opts=$enableval], [enable_linker_opts=yes])
10243
if test "x$enable_linker_opts" != "xno"; then
10244
AC_MSG_CHECKING([whether $LD accepts --as-needed])
10245
case `$LD --as-needed -v 2>&1 </dev/null` in
10246
*GNU* | *'with BFD'*)
10247
LDFLAGS="$LDFLAGS -Wl,--as-needed"
10248
AC_MSG_RESULT([yes])
10251
AC_MSG_RESULT([no])
10254
AC_MSG_CHECKING([whether $LD accepts -O1])
10255
case `$LD -O1 -v 2>&1 </dev/null` in
10256
*GNU* | *'with BFD'*)
10257
LDFLAGS="$LDFLAGS -Wl,-O1"
10258
AC_MSG_RESULT([yes])
10261
AC_MSG_RESULT([no])
10133
10267
dnl BM_DEBUG_SUPPORT()