Update m4 scripts

This commit is contained in:
Frank Denis 2017-03-22 14:21:07 +01:00
parent 2541886266
commit 528abd8bc9
5 changed files with 101 additions and 52 deletions

View File

@ -19,6 +19,8 @@
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given. # force the compiler to issue an error when a bad flag is given.
# #
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
# #
@ -38,7 +40,7 @@
# Public License for more details. # Public License for more details.
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# As a special exception, the respective Autoconf Macro's copyright owner # As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure # gives unlimited permission to copy, distribute and modify the configure
@ -53,7 +55,7 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 4 #serial 5
AC_DEFUN([AX_CHECK_COMPILE_FLAG], AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF

View File

@ -1,5 +1,5 @@
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_define.html # https://www.gnu.org/software/autoconf-archive/ax_check_define.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
@ -29,7 +29,7 @@
# Public License for more details. # Public License for more details.
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# As a special exception, the respective Autoconf Macro's copyright owner # As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure # gives unlimited permission to copy, distribute and modify the configure
@ -44,7 +44,7 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 8 #serial 9
AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE]) AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE])
AC_DEFUN([AC_CHECK_DEFINE],[ AC_DEFUN([AC_CHECK_DEFINE],[

View File

@ -1,10 +1,10 @@
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html # https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) # AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
# #
# DESCRIPTION # DESCRIPTION
# #
@ -19,6 +19,8 @@
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to # EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given. # issue an error when a bad flag is given.
# #
# INPUT gives an alternative input source to AC_LINK_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. # macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
# #
@ -38,7 +40,7 @@
# Public License for more details. # Public License for more details.
# #
# You should have received a copy of the GNU General Public License along # You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# As a special exception, the respective Autoconf Macro's copyright owner # As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure # gives unlimited permission to copy, distribute and modify the configure
@ -53,7 +55,7 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 4 #serial 5
AC_DEFUN([AX_CHECK_LINK_FLAG], AC_DEFUN([AX_CHECK_LINK_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF

View File

@ -82,7 +82,7 @@
# modified version of the Autoconf Macro, you may extend this special # modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well. # exception to the GPL to apply to your modified version as well.
#serial 23 #serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [ AC_DEFUN([AX_PTHREAD], [

View File

@ -1,22 +1,27 @@
# =========================================================================== # ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html # https://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
# =========================================================================== # ===========================================================================
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_VALGRIND_DFLT(memcheck|helgrind|drd|sgcheck, on|off)
# AX_VALGRIND_CHECK() # AX_VALGRIND_CHECK()
# #
# DESCRIPTION # DESCRIPTION
# #
# Checks whether Valgrind is present and, if so, allows running `make # AX_VALGRIND_CHECK checks whether Valgrind is present and, if so, allows
# check` under a variety of Valgrind tools to check for memory and # running `make check` under a variety of Valgrind tools to check for
# threading errors. # memory and threading errors.
# #
# Defines VALGRIND_CHECK_RULES which should be substituted in your # Defines VALGRIND_CHECK_RULES which should be substituted in your
# Makefile; and $enable_valgrind which can be used in subsequent configure # Makefile; and $enable_valgrind which can be used in subsequent configure
# output. VALGRIND_ENABLED is defined and substituted, and corresponds to # output. VALGRIND_ENABLED is defined and substituted, and corresponds to
# the value of the --enable-valgrind option, which defaults to being # the value of the --enable-valgrind option, which defaults to being
# enabled if Valgrind is installed and disabled otherwise. # enabled if Valgrind is installed and disabled otherwise. Individual
# Valgrind tools can be disabled via --disable-valgrind-<tool>, the
# default is configurable via the AX_VALGRIND_DFLT command or is to use
# all commands not disabled via AX_VALGRIND_DFLT. All AX_VALGRIND_DFLT
# calls must be made before the call to AX_VALGRIND_CHECK.
# #
# If unit tests are written using a shell script and automake's # If unit tests are written using a shell script and automake's
# LOG_COMPILER system, the $(VALGRIND) variable can be used within the # LOG_COMPILER system, the $(VALGRIND) variable can be used within the
@ -28,6 +33,7 @@
# #
# configure.ac: # configure.ac:
# #
# AX_VALGRIND_DFLT([sgcheck], [off])
# AX_VALGRIND_CHECK # AX_VALGRIND_CHECK
# #
# Makefile.am: # Makefile.am:
@ -40,9 +46,15 @@
# which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been # which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been
# configured with --enable-valgrind). Running `make check-valgrind` in # configured with --enable-valgrind). Running `make check-valgrind` in
# that directory will run the module's test suite (`make check`) once for # that directory will run the module's test suite (`make check`) once for
# each of the available Valgrind tools (out of memcheck, helgrind, drd and # each of the available Valgrind tools (out of memcheck, helgrind and drd)
# sgcheck), and will output results to test-suite-$toolname.log for each. # while the sgcheck will be skipped unless enabled again on the
# The target will succeed if there are zero errors and fail otherwise. # commandline with --enable-valgrind-sgcheck. The results for each check
# will be output to test-suite-$toolname.log. The target will succeed if
# there are zero errors and fail otherwise.
#
# Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in
# memcheck, helgrind, drd and sgcheck. These are useful because often only
# some of those tools can be ran cleanly on a codebase.
# #
# The macro supports running with and without libtool. # The macro supports running with and without libtool.
# #
@ -55,13 +67,23 @@
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 8 #serial 15
dnl Configured tools
m4_define([valgrind_tool_list], [[memcheck], [helgrind], [drd], [sgcheck]])
m4_set_add_all([valgrind_exp_tool_set], [sgcheck])
m4_foreach([vgtool], [valgrind_tool_list],
[m4_define([en_dflt_valgrind_]vgtool, [on])])
AC_DEFUN([AX_VALGRIND_DFLT],[
m4_define([en_dflt_valgrind_$1], [$2])
])dnl
AC_DEFUN([AX_VALGRIND_CHECK],[ AC_DEFUN([AX_VALGRIND_CHECK],[
dnl Check for --enable-valgrind dnl Check for --enable-valgrind
AC_ARG_ENABLE([valgrind], AC_ARG_ENABLE([valgrind],
[AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests (requires GNU make)])], [AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests (requires GNU make)])],
[enable_valgrind=$enableval],[enable_valgrind=no]) [enable_valgrind=$enableval],[enable_valgrind=])
AS_IF([test "$enable_valgrind" != "no"],[ AS_IF([test "$enable_valgrind" != "no"],[
# Check for Valgrind. # Check for Valgrind.
@ -81,22 +103,45 @@ AC_DEFUN([AX_VALGRIND_CHECK],[
AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind]) AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind])
# Check for Valgrind tools we care about. # Check for Valgrind tools we care about.
m4_define([valgrind_tool_list],[[memcheck], [helgrind], [drd], [exp-sgcheck]]) [valgrind_enabled_tools=]
AS_IF([test "$VALGRIND" != ""],[
m4_foreach([vgtool],[valgrind_tool_list],[ m4_foreach([vgtool],[valgrind_tool_list],[
m4_define([vgtooln],AS_TR_SH(vgtool)) AC_ARG_ENABLE([valgrind-]vgtool,
m4_define([ax_cv_var],[ax_cv_valgrind_tool_]vgtooln) m4_if(m4_defn([en_dflt_valgrind_]vgtool),[off],dnl
AC_CACHE_CHECK([for Valgrind tool ]vgtool,ax_cv_var,[ [AS_HELP_STRING([--enable-valgrind-]vgtool, [Whether to use ]vgtool[ during the Valgrind tests])],dnl
ax_cv_var= [AS_HELP_STRING([--disable-valgrind-]vgtool, [Whether to skip ]vgtool[ during the Valgrind tests])]),
AS_IF([`$VALGRIND --tool=vgtool --help >/dev/null 2>&1`],[ [enable_valgrind_]vgtool[=$enableval],
ax_cv_var="vgtool" [enable_valgrind_]vgtool[=])
AS_IF([test "$enable_valgrind" = "no"],[
enable_valgrind_]vgtool[=no],
[test "$enable_valgrind_]vgtool[" ]dnl
m4_if(m4_defn([en_dflt_valgrind_]vgtool), [off], [= "yes"], [!= "no"]),[
AC_CACHE_CHECK([for Valgrind tool ]vgtool,
[ax_cv_valgrind_tool_]vgtool,[
ax_cv_valgrind_tool_]vgtool[=no
m4_set_contains([valgrind_exp_tool_set],vgtool,
[m4_define([vgtoolx],[exp-]vgtool)],
[m4_define([vgtoolx],vgtool)])
AS_IF([`$VALGRIND --tool=]vgtoolx[ --help >/dev/null 2>&1`],[
ax_cv_valgrind_tool_]vgtool[=yes
]) ])
]) ])
AS_IF([test "$ax_cv_valgrind_tool_]vgtool[" = "no"],[
AC_SUBST([VALGRIND_HAVE_TOOL_]vgtooln,[$ax_cv_var]) AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
AC_MSG_ERROR([Valgrind does not support ]vgtool[; reconfigure with --disable-valgrind-]vgtool)
],[
enable_valgrind_]vgtool[=no
])
],[
enable_valgrind_]vgtool[=yes
]) ])
]) ])
AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
valgrind_enabled_tools="$valgrind_enabled_tools ]m4_bpatsubst(vgtool,[^exp-])["
])
AC_SUBST([ENABLE_VALGRIND_]vgtool,[$enable_valgrind_]vgtool)
])
AC_SUBST([valgrind_tools],["]m4_join([ ], valgrind_tool_list)["])
AC_SUBST([valgrind_enabled_tools],[$valgrind_enabled_tools])
[VALGRIND_CHECK_RULES=' [VALGRIND_CHECK_RULES='
# Valgrind check # Valgrind check
@ -118,7 +163,6 @@ VALGRIND_drd_FLAGS ?=
VALGRIND_sgcheck_FLAGS ?= VALGRIND_sgcheck_FLAGS ?=
# Internal use # Internal use
valgrind_tools = memcheck helgrind drd sgcheck
valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools))) valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools)))
valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS) valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS)
@ -129,6 +173,9 @@ valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS)
valgrind_quiet = $(valgrind_quiet_$(V)) valgrind_quiet = $(valgrind_quiet_$(V))
valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY)) valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY))
valgrind_quiet_0 = --quiet valgrind_quiet_0 = --quiet
valgrind_v_use = $(valgrind_v_use_$(V))
valgrind_v_use_ = $(valgrind_v_use_$(AM_DEFAULT_VERBOSITY))
valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%,%,$''@):;
# Support running with and without libtool. # Support running with and without libtool.
ifneq ($(LIBTOOL),) ifneq ($(LIBTOOL),)
@ -140,13 +187,10 @@ endif
# Use recursive makes in order to ignore errors during check # Use recursive makes in order to ignore errors during check
check-valgrind: check-valgrind:
ifeq ($(VALGRIND_ENABLED),yes) ifeq ($(VALGRIND_ENABLED),yes)
-$(foreach tool,$(valgrind_tools), \ $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k \
$(if $(VALGRIND_HAVE_TOOL_$(tool))$(VALGRIND_HAVE_TOOL_exp_$(tool)), \ $(foreach tool, $(valgrind_enabled_tools), check-valgrind-$(tool))
$(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-tool VALGRIND_TOOL=$(tool); \
) \
)
else else
@echo "Need to reconfigure with --enable-valgrind" @echo "Need to use GNU make and reconfigure with --enable-valgrind"
endif endif
# Valgrind running # Valgrind running
@ -160,16 +204,22 @@ VALGRIND_LOG_COMPILER = \
$(valgrind_lt) \ $(valgrind_lt) \
$(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS) $(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS)
check-valgrind-tool: define valgrind_tool_rule =
ifeq ($(VALGRIND_ENABLED),yes) check-valgrind-$(1):
$(MAKE) check-TESTS \ ifeq ($$(VALGRIND_ENABLED)-$$(ENABLE_VALGRIND_$(1)),yes-yes)
TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ $$(valgrind_v_use)$$(MAKE) check-TESTS \
LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ TESTS_ENVIRONMENT="$$(VALGRIND_TESTS_ENVIRONMENT)" \
LOG_FLAGS="$(valgrind_$(VALGRIND_TOOL)_flags)" \ LOG_COMPILER="$$(VALGRIND_LOG_COMPILER)" \
TEST_SUITE_LOG=test-suite-$(VALGRIND_TOOL).log LOG_FLAGS="$$(valgrind_$(1)_flags)" \
TEST_SUITE_LOG=test-suite-$(1).log
else ifeq ($$(VALGRIND_ENABLED),yes)
@echo "Need to reconfigure with --enable-valgrind-$(1)"
else else
@echo "Need to reconfigure with --enable-valgrind" @echo "Need to reconfigure with --enable-valgrind"
endif endif
endef
$(foreach tool,$(valgrind_tools),$(eval $(call valgrind_tool_rule,$(tool))))
A''M_DISTCHECK_CONFIGURE_FLAGS ?= A''M_DISTCHECK_CONFIGURE_FLAGS ?=
A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind
@ -177,14 +227,9 @@ A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind
MOSTLYCLEANFILES ?= MOSTLYCLEANFILES ?=
MOSTLYCLEANFILES += $(valgrind_log_files) MOSTLYCLEANFILES += $(valgrind_log_files)
.PHONY: check-valgrind check-valgrind-tool .PHONY: check-valgrind $(add-prefix check-valgrind-,$(valgrind_tools))
'] ']
AS_IF([test "$enable_valgrind" != "yes"],[
VALGRIND_CHECK_RULES='
check-valgrind:
@echo "Need to use GNU make and reconfigure with --enable-valgrind"'
])
AC_SUBST([VALGRIND_CHECK_RULES]) AC_SUBST([VALGRIND_CHECK_RULES])
m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])])
]) ])