GNU Autotools: How do you include source files in the 'make dist' tarball that are above the root source directory?

StackOverflow https://stackoverflow.com/questions/1836209

Question

I've got a Subversion project that uses Gnu Autotools (i.e., automake, autoconf, and libtool) to manage source code within a subfolder (called 'subpackage'). The subpackage references source files that are above the subpackage's root source directory, and are common to other subpackages. Unfortunately, when running 'make dist' to create the distribution tarball, the common source files do not get included in the distribution.

Is there a way to use autoconf/automake to move these common source files into a subdirectory of the subpackage before distributing the source, and to have the makefile adjust itself to correctly point to the relocated source files? Clearly, it would be possible to have the makefile move these source files over before compiling, but for working within the Subversion repository, this causes problems because these moved files are revision controlled, and its easy to accidentally edit the moved file instead of the original.

Was it helpful?

Solution

Instead of moving files around (which always sounds fishy to me), Why not use symbolic links? You could have your subpackage reference only local files, and a Makefile rule that says "if the local files is not here, create a symbolic link to the parent's file". During make dist, the symbolic link will be converted into a plain file automatically.

OTHER TIPS

You could have an empty directory in subpackage, called, say, "common", with a makefile that copies the external files in. Then you could use the dist-hook target to move the files directly into the version of the "common" directory that will get zipped up into the tarball. That way you don't have to worry about them lying around and being edited. You would also overwrite the Makefile.am, Makefile.in and Makefile in "common" as you copied.

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

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

I'm not 100% sure this will work though. It might break the rest of your package, depending on where everything else expects to find those source files; it probably will break making dist if you unpack the tarball and try to make dist from there. You should know that this sort of trickery is frowned upon. But I hope I've given you enough ideas to play around with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top