Subject: Re: bug#13104: Extending automake rules w.r.t dependencies

From: "Theophile Ranquet" <[email-masked]>
Date: Fri, 7 Dec 2012 10:46:01 +0100 (CET)

> Hello,

Hi,

> The usual workaround to add prerequisites to an automake-generated
> rule is to use a one-off make variable for the target name.  For
> example,
>
>   doc_bison_dvi = doc/bison.dvi
>   $(doc_bison_dvi): $(FIGS_DOT:.dot=.eps)
>
> and so on.  Automake does a simple string comparison of the target name
> to decide whether or the generated rule is overridden, so using a
> variable will hide the "real" target name from this check.  Note that
> this is only appropriate for rules with no commands.

We did something similar, with a little tweak because using three
variables seemed a bit of an overkill:

commit 476af12837af129d36b302e30789c549c85fdadb
Author: Theophile Ranquet <[email-masked]>
Date:   Tue Dec 4 16:09:24 2012 +0100

    doc: fix build dependencies

    * doc/local.mk: Avoid overwriting Automake's rules.

diff --git a/doc/local.mk b/doc/local.mk
index aaea996..cef4448 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -20,7 +20,14 @@ doc_bison_TEXINFOS =                            \
   doc/fdl.texi                                  \
   doc/gpl-3.0.texi

-TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d
+# Cannot express dependencies directly on file names because of Automake.
+# Obfuscate with a variable.
+doc_bison = doc/bison
+$(doc_bison).dvi: $(FIGS_DOT:.dot=.eps)
+$(doc_bison).pdf: $(FIGS_DOT:.dot=.pdf)
+$(doc_bison).html: $(FIGS_DOT:.dot=.html)
+
+TEXI2DVI = texi2dvi --build-dir=doc/bison.t2d -I doc
 CLEANDIRS = doc/bison.t2d
 clean-local:
 	rm -rf $(CLEANDIRS)
@@ -123,10 +130,6 @@ EXTRA_DIST +=								\
   $(FIGS_DOT:.dot=.eps) $(FIGS_DOT:.dot=.pdf) $(FIGS_DOT:.dot=.png)
 SUFFIXES += .dot .eps .pdf .png

-doc/bison.dvi:  $(FIGS_DOT:.dot=.eps)
-doc/bison.html: $(FIGS_DOT:.dot=.png)
-doc/bison.pdf:  $(FIGS_DOT:.dot=.pdf)
-
 .dot.eps:
 	$(AM_V_GEN) $(MKDIR_P) `echo "./$@" | sed -e 's,/[^/]*$$,,'`
 	$(AM_V_at) $(DOT) -Gmargin=0 -Teps $< >$@.tmp

> Hope that helps,

It did, thanks!