Thankfully, you can now use automake without recursion if you set the "subdir-objects" option:
AM_INIT_AUTOMAKE([subdir-objects])
and reference your source with their relative path in the (only) Makefile.am in $(top_srcdir)
bin_PROGRAMS = foo
foo_SOURCES = src/main.c \
src/foo.c src/foo.h \
src/quux/bar.c src/quux/bar.h \
src/quux/baz.c src/quux/baz.h
You can use relative paths like in most places automake accepts file names. The only time I've run into trouble using non-recursive automake (1.13.4) is adding flex+bison source. This requires BUILT_SOURCES, which is confusing, and automake is
very picky and non-obvious about the names of the generated source files. I think it may not have been updated to support relative paths yet? It required some heavy workarounds:
AM_YFLAGS = -d
# this was VERY important
# (must be abs_top_srcdir, not top_srcdir)
foo_LFLAGS = --header-file=$(abs_top_srcdir)/src/xyzzy_lexer.h
foo_SOURCES += src/xyzzy_lexer.l src/xyzzy_parser.y
EXTRA_DIST += src/xyzzy_lexer.h
# note the inconsistency here
BUILT_SOURCES += src/foo-xyzzy_lexer.c \
src/xyzzy_parser.h
# ...and this doesn't match BUILT_SOURCES
MAINTAINERCLEANFILES += src/foo-xyzzy_lexer.c \
src/xyzzy_lexer.h \
src/xyzzy_parser.h
Even with this annoyance, I would still highly recommend using this style instead of the traditional (recursive) automake. Autotools Mythbuster has more information on this other modern-autotools features:
https://autotools.io/automake/nonrecursive.html