I am working on a library project which mixes C, C++, and Rust code. For historical reasons I use autotools to drive building.
Essentially, my Makefile.am
looks like this:
libfoo_la_LIBADD += rustfoo/target/release/librustfoo.a
rustfoo/target/release/librustfoo.a:
cd rustfoo/; \
cargo rustc --release -- --crate-type staticlib
dist-hook:
mkdir -p $(distdir)/rustfoo
cp -a $(srcdir)/rustfoo/* $(distdir)/rustfoo
rm -rf $(distdir)/rustfoo/target
Notice, that it is not practical to enumerate all Rust source files in some ....librustfoo_a_SOURCES
variable or similar. (Mainly because, I bundle some dependencies in rustfoo/dependencies/
.)
All works fine for non-VPATH builds, but fails as expected for VPATH build. Autotools does not know about the rust sources and cannot copy/link them into the $(builddir)
. Sure, I could cd into the source tree as
rustfoo/target/release/librustfoo.a:
cd $(srcdir)/rustfoo/; ...
but that would defeat the purpose of VPATH builds.
Is there any best practices how to approach this?