summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-02 16:04:07 +0200
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-08-28 18:45:00 +0100
commitf9073d5defa6f30bb8b364c3a56c53a60eb0b0dd (patch)
tree8cfd9a65528999d5682ac13a2136eea5b4b8c7d2
parentefd34adf8b6d73f14c13fd87183983c576ea215c (diff)
downloadgnome-common-f9073d5defa6f30bb8b364c3a56c53a60eb0b0dd.tar.gz
macros2: Deprecate GNOME_DEBUG_CHECK
The autoconf-archive AX_DEBUG_CHECK macro should be used instead, or the macro contents should just be substituted into configure.ac directly, since it’s so simple. https://bugzilla.gnome.org/show_bug.cgi?id=729403
-rw-r--r--macros2/Makefile.am13
-rw-r--r--macros2/ax_check_enable_debug.m4113
-rw-r--r--macros2/gnome-common.m417
3 files changed, 130 insertions, 13 deletions
diff --git a/macros2/Makefile.am b/macros2/Makefile.am
index 07781be..bdc2354 100644
--- a/macros2/Makefile.am
+++ b/macros2/Makefile.am
@@ -5,9 +5,18 @@ GNOME2_MACROS = \
gnome-compiler-flags.m4 \
gnome-code-coverage.m4
-EXTRA_DIST = $(GNOME2_MACROS) gnome-autogen.sh
+# Macros copied from the autoconf-archive.
+# http://www.gnu.org/software/autoconf-archive/
+# these should be dropped as soon as the deprecated GNOME2_MACROS which use them
+# are removed. Until then, they should be kept up to date, and all changes to
+# them submitted upstream.
+AUTOCONF_ARCHIVE_MACROS = \
+ ax_check_enable_debug.m4 \
+ $(NULL)
+
+EXTRA_DIST = $(GNOME2_MACROS) $(AUTOCONF_ARCHIVE_MACROS) gnome-autogen.sh
aclocaldir = $(datadir)/aclocal
-aclocal_DATA = $(GNOME2_MACROS)
+aclocal_DATA = $(GNOME2_MACROS) $(AUTOCONF_ARCHIVE_MACROS)
bin_SCRIPTS = gnome-autogen.sh
diff --git a/macros2/ax_check_enable_debug.m4 b/macros2/ax_check_enable_debug.m4
new file mode 100644
index 0000000..37add91
--- /dev/null
+++ b/macros2/ax_check_enable_debug.m4
@@ -0,0 +1,113 @@
+# ===========================================================================
+# http://autoconf-archive.cryp.to/ax_check_enable_debug.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# Check for the presence of an --enable-debug option to configure and
+# allow/avoid compiled debugging flags appropriately.
+#
+# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no],
+# [ENABLE DEBUG VARIABLES …],
+# [DISABLE DEBUG VARIABLES NDEBUG …])
+#
+# DESCRIPTION
+#
+# Check for the presence of an --enable-debug option to configure, with the
+# specified default value used when the option is not present. Return the
+# value in the variable $ax_enable_debug.
+#
+# Specifying 'yes' adds '-g -O0' to the compilation flags for all languages.
+# Specifying 'info' adds '-g' to the compilation flags. Specifying 'profile'
+# adds '-g -pg' to the compilation flags and '-pg' to the linking flags.
+# Otherwise, nothing is added.
+#
+# Define the variables listed in the second argument if debug is enabled,
+# defaulting to no variables. Defines the variables listed in the third
+# argument if debug is disabled, defaulting to NDEBUG. All lists of
+# variables should be space-separated.
+#
+# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
+# Should be invoked prior to any AC_PROG_* compiler checks.
+#
+# LAST MODIFICATION
+#
+# 2014-05-12
+#
+# COPYLEFT
+#
+# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
+# Copyright © 2014 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
+ AC_BEFORE([$0],[AC_PROG_CC])dnl
+ AC_BEFORE([$0],[AC_PROG_CXX])dnl
+ AC_BEFORE([$0],[AC_PROG_F77])dnl
+ AC_BEFORE([$0],[AC_PROG_FC])dnl
+
+ AC_MSG_CHECKING(whether to enable debugging)
+
+ m4_define(ax_enable_debug_default,[m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))])
+ m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
+ m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
+
+ AC_ARG_ENABLE(debug,
+ [AS_HELP_STRING([--enable-debug]@<:@=ax_enable_debug_default@:>@,[compile with debugging; one of yes/info/profile/no])],
+ [],enable_debug=ax_enable_debug_default)
+ if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "x"; then
+ AC_MSG_RESULT(yes)
+ CFLAGS="${CFLAGS} -g -O0"
+ CXXFLAGS="${CXXFLAGS} -g -O0"
+ FFLAGS="${FFLAGS} -g -O0"
+ FCFLAGS="${FCFLAGS} -g -O0"
+ OBJCFLAGS="${OBJCFLAGS} -g -O0"
+
+ dnl Define various variables if debugging is enabled.
+ m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])
+ else
+ if test "x$enable_debug" = "xinfo"; then
+ AC_MSG_RESULT(info)
+ CFLAGS="${CFLAGS} -g"
+ CXXFLAGS="${CXXFLAGS} -g"
+ FFLAGS="${FFLAGS} -g"
+ FCFLAGS="${FCFLAGS} -g"
+ OBJCFLAGS="${OBJCFLAGS} -g"
+ elif test "x$enable_debug" = "xprofile"; then
+ AC_MSG_RESULT(profile)
+ CFLAGS="${CFLAGS} -g -pg"
+ CXXFLAGS="${CXXFLAGS} -g -pg"
+ FFLAGS="${FFLAGS} -g -pg"
+ FCFLAGS="${FCFLAGS} -g -pg"
+ OBJCFLAGS="${OBJCFLAGS} -g -pg"
+ LDFLAGS="${LDFLAGS} -pg"
+ else
+ AC_MSG_RESULT(no)
+ dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
+ dnl by setting any unset environment flag variables
+ if test "x${CFLAGS+set}" != "xset"; then
+ CFLAGS=""
+ fi
+ if test "x${CXXFLAGS+set}" != "xset"; then
+ CXXFLAGS=""
+ fi
+ if test "x${FFLAGS+set}" != "xset"; then
+ FFLAGS=""
+ fi
+ if test "x${FCFLAGS+set}" != "xset"; then
+ FCFLAGS=""
+ fi
+ if test "x${OBJCFLAGS+set}" != "xset"; then
+ OBJCFLAGS=""
+ fi
+ fi
+
+ dnl Define various variables if debugging is disabled.
+ dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
+ m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])
+ fi
+ ax_enable_debug=$enable_debug
+])
diff --git a/macros2/gnome-common.m4 b/macros2/gnome-common.m4
index dac50c4..aae4c23 100644
--- a/macros2/gnome-common.m4
+++ b/macros2/gnome-common.m4
@@ -23,18 +23,13 @@ AU_DEFUN([GNOME_COMMON_INIT],
in your top-level Makefile.am, instead, where "m4" is the macro directory set
with AC_CONFIG_MACRO_DIR() in your configure.ac]])
-AC_DEFUN([GNOME_DEBUG_CHECK],
+AU_DEFUN([GNOME_DEBUG_CHECK],
[
- AC_ARG_ENABLE([debug],
- AC_HELP_STRING([--enable-debug],
- [turn on debugging]),,
- [enable_debug=no])
-
- if test x$enable_debug = xyes ; then
- AC_DEFINE(GNOME_ENABLE_DEBUG, 1,
- [Enable additional debugging at the expense of performance and size])
- fi
-])
+ AX_CHECK_ENABLE_DEBUG([no],[GNOME_ENABLE_DEBUG])
+],
+[[$0: This macro is deprecated. You should use AX_CHECK_ENABLE_DEBUG instead and
+replace uses of GNOME_ENABLE_DEBUG with ENABLE_DEBUG.
+See: https://savannah.gnu.org/patch/?8452]])
dnl GNOME_MAINTAINER_MODE_DEFINES ()
dnl define DISABLE_DEPRECATED