How configure script decides to regenerate itself
Asked Answered
H

1

5

When I run ./configure sometimes it decides that it's too old and re-runs autoconf through missing script to regenerate itself. Sometimes it leads to weird breakages since autoconf on the target machine is older then autoconf that was used to originally generate configure.

I was wondering how it figures out that it's too old? Is there a standard way for configure to do that? or it depends on the library. Pointers to documentation would be appreciated.

Hay answered 5/11, 2010 at 3:18 Comment(0)
C
10

configure does not decide this: make does. If the configure script is older than configure.ac or any of the files it includes (starting with aclocal.m4), then make runs autoconf to rebuild configure.

Similar rules exist to rebuild aclocal.m4 using aclocal, and the various Makefile.in using automake.

These rebuild rules should never be triggered after you unpack a tarball on a target machine, because the timestamp of all these files in the tarball should be correct (configure newer than configure.ac, etc.). So if this happens, either something is bogus in your tarball (like you did not use make dist or preferably make distcheck to generate it), or the user compiling the source code did something wrong (like copying the entire directory without preserving the timestamps), or there is something bogus in the target system (e.g. make usually fail to work properly on a NFS-mounted directory if the clock of the NFS-server is not synchronized with that of the client).

Another frequent source of unwelcome rebuilt is observed by people who keep the generated files in version-control system. See https://www.gnu.org/software/automake/manual/html_node/CVS.html for a discussion about this if that is your case.

Confidential answered 7/11, 2010 at 12:48 Comment(3)
I would preemptively add that AM_MAINTAINER_MODE is not a solution. It just adds another point where breakage can occur. Don't keep generated files in source control and use make distcheck to build tarballs and you should be fine.Experimentalism
The culprit ended up being git, since it does not preserve timestamps configure.ac was checked out to be newer then configure. Need to look into the issue why we keep generated files under source control.Hay
@KiRPiCH: Note also that with modern automake, you can usually go from configure.ac + Makefile.am to having everything ready to ./configure by running autoreconf -i. No need to worry about running aclocal, autoconf, autoheader, automake, libtoolize and whatever else in the correct order. If that isn't enough, then make a script called bootstrap.sh (autogen.sh is another common name, but there's an obscure tool called autogen) that runs the autotools in the correct order.Experimentalism

© 2022 - 2024 — McMap. All rights reserved.