English 中文(简体)
GNU Autotools: How do you include source files in the make dist tarball that are above the root source directory?
原标题:

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.

最佳回答

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.

问题回答

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.





相关问题
C++ GNU linker errors

I m trying to compile my program on Windows via Cygwin with the compilation command: g++ ping.cpp -I./include -L./lib -lchartdir50 I m using an API called ChartDirector which draws charts for me. I ...

How to avoid misformatting of binary values with GNU indent?

When GNU indent (at least version 2.2.6 and 2.2.10) is used on the following code... void main () { int i = 0b01010101; } it will be reformatted into this ... void main () { int i = 0 b01010101;...

热门标签