[squid-dev] [RFC] The situation with helpers/

Amos Jeffries squid3 at treenet.co.nz
Wed Jan 13 21:13:30 UTC 2016


On 14/01/2016 2:12 a.m., Kinkie wrote:
> 
> About build dependencies from src/ : while refactoring some helpers I
> came across a recipe which seems reasonably clean and maintainable,
> and I submit it for consideration until a more structured approach
> (such as lifting helpers/ into src/) can be chosen:
> 
> In each helper's Makefile.am, the following clauses must be added:
> 
> IMPORTED_FILES = <list of files including paths relative to src/ to be
> imported into the helper's directory from src>
> nodist_<target>_SOURCES = $(IMPORTED_FILES)
> <target>_DEPENDENCIES = $(IMPORTED_FILES)
> CLEANFILES += $(IMPORTED_FILES)

Okay on the above. "Nooooo..." on the below bit.

> 
> $(IMPORTED_FILES): $(top_srcdir)/src/$@
>         test -d $(dir $@)|| mkdir -p $(dir $@)
>         cp $(top_srcdir)/src/$@ $@
> 

... doing it like that will make dozens of .am snippets of code that
have to be maintained in-sync forever.

Like I said on IRC this part needs to be in a src/ImportedFiles.am that
gets included wherever its needed. Not copy-pasted everywhere.
See how we use doc/manuals/Substitute.am if you want an example.

All that the various Makefile.am should contain is the X=Y variable
definitions followed by a "include src/ImportedFiles.am" statement.


And for the love of all thats holy, avoid *_DEPENDENCIES variables.

When DEPENDENCIES is *absent*, automake will take the SOURCES list and
add dependency for each file listed, plus (compiler version dependent) a
sub-dependency recursively for each file #include'd by those. It will
also take the LDADD list and for all local tree objects will add a
dependency. It is smart enough to filter out flags and system libraries
nowdays (AFAICT that was the reason DEPENDENCIES was used to begin with
back in Y2K).

When DEPENDENCIES is present only objects explicitly listed in that
variable are dependencies. *all* of the existing ones are broken and
breaking Squid builds.



> <target> must be replaced with the executable's name. The need for
> this replacement unfortunately means that this recipe must be copied
> to each helper, and can't be factored out.

The important part to factor away duplication of is:

> $(IMPORTED_FILES): $(top_srcdir)/src/$@
>         test -d $(dir $@)|| mkdir -p $(dir $@)
>         cp $(top_srcdir)/src/$@ $@
>

which does not contain the "target" bit.

Amos



More information about the squid-dev mailing list