With a standard project layout of
$(src_topdir)/include
$(src_topdir)/src
$(src_topdir)/tests
I would like to run all the tests in $(src_topdir)/tests
when typing "make check" in $(src_topdir)/src
in addition to running any configured tests in $(src_topdir)/src
.
Automake provides an extension to add additional targets to the check
Makefile target, by adding (in Makefile.am) the target local-check
which I can define to
local-check:
cd ../tests && $(MAKE) $(AM_MAKEFLAGS) check
And while this permits me to make check
within the $(src_topdir)/src
directory with satisfaction, unfortunately it breaks the call to make check
from the $(src_topdir)
directory. This is because calling from $(src_topdir)
recursively enters both $(src_topdir)/src
and $(src_topdir)/tests
triggering the tests in $(src_topdir)/tests
twice.
Is there a way in which I would be able to alter my Makefile.am
in $(src_topdir)/src
such that local make check
calls trigger the desired additional testing while make check
calls from the rest of the tooling are unaffected?
There's no way to do this in Automake.
One workaround is to simply change the name of the target. That is, instead of typing make check
, type make mycheck
(or whatever you like). Then the mycheck
rule is very easy to write.
Another idea is to simply dispense with subdirectory Makefiles. It's generally better, these days, to have one single Makefile
for the entire tree. Then this problem goes away -- or, if you really want, with this you can write a tiny src/Makefile
that just has the single check
target.