Search code examples
linuxbuildcompilationautoconf

How can I copy an autoconf build to another directory for further testing?


If I build a package with autoconf, how can I copy everything in the source/build* directory to another location for further testing etc.?

To elaborate further, I would like to do a simple backup of some of my work by building + testing everything in one directory before copying the directory, applying some transformations to the code (that don't require recompiling), and rerunning the tests. The problem I am running into is autoconf seems to want me to run autoreconf in the newly copied directory requiring me to rebuild things. This is what I would like to avoid, if possible.

For example, when I try to run tests with the newly copied m4 (without even applying any transformations), I get the following:

m4-1.4.18/build-aux/missing: line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>

EDIT:

As @Bodo pointed out, I should say that the copying method I use is cp -r.


* I build things in the source directory without a separate build directory.


Solution

  • By copying the data with cp -r you create new files with the modification time set to the time of copying. Depending on the order in which the files are copied this will result in make (or your build tool) to re-build the target.

    You can use something like

    cd sourcedir
    tar cvf ../sorcedit.tar .
    cd ../targetdir
    tar xvf ../sourcedir.tar
    

    to copy the files while keeping their original time stamps.

    Or you could use something like Git (or any other distributed version control system) to save every step of your work. Then you can run the tests directly in the source/build directory and afterwards throw away all files (except the Git repository, of course) and use Git to re-create the source files.