From: Nick Bowler Date: Tue, 8 Jan 2013 23:54:41 +0000 (-0500) Subject: Add some backwards-compatibility helpers for silent-rules. X-Git-Url: http://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/aec623761eb5cb6ad797259594664fa8aa3d3424 Add some backwards-compatibility helpers for silent-rules. The silent-rules support in Automake has changed over the ages. Most glaringly, the output alignment changed between 1.11 and 1.12. Add a new macro, DX_AUTOMAKE_COMPAT, which is intended to capture the compatibility hacks needed to support multiple versions of Automake. Currently, this means that it will define a variable to help print silent-rule output that maintains alignment, and it will AC_SUBST compatible versions, if necessary, of variables substituted in later versions of Automake's silent-rule support. Update glconfig.mk to make use of the new feature. --- diff --git a/m4/am-compat.m4 b/m4/am-compat.m4 new file mode 100644 index 0000000..46b2edf --- /dev/null +++ b/m4/am-compat.m4 @@ -0,0 +1,64 @@ +dnl Copyright © 2012 Nick Bowler +dnl +dnl Definitions to help maintain compatibility with older versions of Automake. +dnl +dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. +dnl This is free software: you are free to do what the fuck you want to. +dnl There is NO WARRANTY, to the extent permitted by law. + +dnl DX_AUTOMAKE_COMPAT +dnl +dnl Provides definitions to help maintain compatibility with older versions of +dnl Automake. Currently, this means: +dnl +dnl - AM_V and AM_DEFAULT_V (new in Automake 1.12) are defined and AC_SUBSTed +dnl if Automake did not already, in a manner compatible with silent-rules +dnl support from previous versions. +dnl +dnl - A make variable DX_ALIGN_V is defined which contain printf alignment +dnl flags for silent-rules output, since the alignment changed between +dnl Automake 1.11 and 1.12. It is intended to be used like this: +dnl +dnl MYGEN_V = $(MYGEN_V@AM_V@) +dnl MYGEN_V_ = $(MYGEN_V_@AM_DEFAULT_V) +dnl MYGEN_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'MYGEN ' $@ +dnl +dnl The spacing after MYGEN should be defined so that the silent-rules +dnl alignment is correct for the latest version of Automake if DX_ALIGN_V +dnl is empty (that way, this definition provides only backwards +dnl compatibility). However, it is irrelevant when DX_ALIGN_V is defined +dnl by this macro, as the spacing will always be correct. This feature +dnl maintains alignment by truncating the argument, so it will only work +dnl properly if your string can actually be aligned in all versions of +dnl Automake being targeted (this means you are limited to 6 characters +dnl in Automake 1.11). + +AC_DEFUN_ONCE([DX_AUTOMAKE_COMPAT], [dnl +AC_REQUIRE([DX_INIT]) + +AC_CONFIG_COMMANDS_PRE([dnl + AS_VAR_SET_IF([AM_V], [], [AC_SUBST([AM_V], ['$(V)'])]) + AS_VAR_SET_IF([AM_DEFAULT_V], [], + [AC_SUBST([AM_DEFAULT_V], ['$(AM_DEFAULT_VERBOSITY)'])])]) + +# This will only work if there is a Makefile.in generated at the top srcdir. +AC_CACHE_CHECK([for alignment of silent-rules output], [dx_cv_align_v], [dnl +cat >conftest.sed <<'EOF' +/^am__v_GEN_0 *=/{ + s/@<:@^"@:>@*" \(GEN *\).*/\1/ + s/ /x/g + p +} +EOF +if sed -nf conftest.sed Makefile.in >conftest.out 2>/dev/null; then + read dx_genline