]> git.draconx.ca Git - dxcommon.git/commitdiff
Add some backwards-compatibility helpers for silent-rules.
authorNick Bowler <nbowler@draconx.ca>
Tue, 8 Jan 2013 23:54:41 +0000 (18:54 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 8 Jan 2013 23:54:41 +0000 (18:54 -0500)
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.

m4/am-compat.m4 [new file with mode: 0644]
snippet/glconfig.mk

diff --git a/m4/am-compat.m4 b/m4/am-compat.m4
new file mode 100644 (file)
index 0000000..46b2edf
--- /dev/null
@@ -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 <conftest.out
+       dx_cv_align_v=`expr "$dx_genline" : '.*'`
+       test $dx_cv_align_v -eq 0 && dx_cv_align_v=unknown
+fi
+: "${dx_cv_align_v:=unknown}"
+rm -f conftest*
+])
+
+AS_IF([test x"$dx_cv_align_v" != x"unknown"],
+       [AC_SUBST([DX_ALIGN_V], [-$dx_cv_align_v.$dx_cv_align_v])])
+])
index dd999af22c4ad6e624511c3084063cabfb226219..4bf112ec478808d170a6f94983ed029f21ec7b80 100644 (file)
@@ -16,9 +16,9 @@
 GLCONFIG = @GLSRC@/glconfig.h
 GLCAT    = cat /dev/null
 
-GLSYM_V   = $(GLSYM_V_$(V))
-GLSYM_V_  = $(GLSYM_V_$(AM_DEFAULT_VERBOSITY))
-GLSYM_V_0 = @echo "  GLSYM " $<;
+GLSYM_V   = $(GLSYM_V_@AM_V@)
+GLSYM_V_  = $(GLSYM_V_@AM_DEFAULT_V@)
+GLSYM_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GLSYM   ' $<;
 
 gnulib_symfiles = $(gnulib_lt_objects:.lo=.glsym)
 gnulib_headers += $(GLCONFIG)