GNU Autotools: How do you include the source files in the 'make dist' tar file, which is located above the root source directory?

I have a Subversion project that uses Gnu Autotools (ie automake, autoconf and libtool) to control the source code inside a subfolder (called "subpackage"). Subpackage refers to source files that are above the root source directory of subpackages and are common to other subpackages. Unfortunately, when you run 'make dist' to create a distribution tarball, the shared source files are not included in the distribution.

Is there a way to use autoconf / automake to move these shared source files to a subdirectory of a subpackage before distributing the source and for the makefile to configure itself correctly to point to the moved source files? Obviously, it would be possible for the makefile to move these source files before compilation, but this causes problems for working in the Subversion repository because these moved files are controlled by revision and it is easy to accidentally change the moved file instead of the original.

+4
source share
2 answers

Instead of moving files around (which always seems suspicious to me), why not use symbolic links? You can have a link to the subpackage only local files and a Makefile rule that says: "If there are no local files here, create a symbolic link to the parent file." During make dist symlink will automatically be converted to a simple file.

+2
source

You may have an empty directory in a subpackage, called, say, "shared", with a make file that copies external files. You can then use the dist-hook target to move the files directly to the version of the “shared” directory, which will be encrypted in tarball. This way, you don’t have to worry about them laying down and being edited. You also overwrite Makefile.am, Makefile.in, and Makefile in a “generic” way when copying.

Example in subpackage / common / Makefile.am (untested):

 dist-hook: cp -p $(top_srcdir)/../common/Makefile* $(top_srcdir)/../common/*.[ch] $(distdir) 

I am not sure that 100% this will work. This can break the rest of your package, depending on where everything else expects to find these source files; it will probably break if you unpack the archive and try to escape from there. You should know that this trick is disapproving. But I hope I have given you enough ideas to play with them.

+3
source

All Articles