automake 1.14 onwards has started emitting lots of warnings about this
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the
automake: automake option hasn't been enabled. For now, the corresponding
automake: object file(s) will be placed in the top-level directory.
automake: this behaviour will change in future Automake versions: they will
automake: unconditionally cause object files to be placed in the same
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout
automake: project, to avoid future incompatibilities.
So enable this in AM_INIT_AUTOMAKE.
This doesn't seem to break older automake versions.