From Fedora Project Wiki
    • This page is a draft that is still in progress and will eventually be put in a different location in the wiki**

Sometimes it is necessary to patch an autotools-generated file in a spec file, such as the ever-present 'configure' script. If not done properly, this could trigger a new buildtime dependency on autoconf and automake. This is not always a good thing because upstream may be using a different version of autotools than what is in the Fedora build system. Differences between these two versions could introduce build failures if Fedora's autotools can no longer handle upstream's configure.in and other autotools-related files.

Here is how to avoid it.

These examples illustrate changes to configure and configure.in. Similar techniques are used when making changes to Makefile.am, aclocal.m4, and other autoxxx files.

Generate a patch

There are two ways to generate the necessary patches. The first method involves making changes to the autotools-generated files by hand. Changes to the autotools source files should also be made and sent to the developers for inclusion into the upstream sources.


The second method involves making changes only to autotools source files and running autoxxx to regenerate the generated files. This is somewhat easier because it doesn't require editting the very large configure scripts by hand, but will often result in much larger patches:



Add the patch to the spec file

Once the patch is generated, it is added to the spec file as any other patch. But there is a catch. When the patch is applied in the %prep section of the spec file, the timestamp on the autotools source files (such as configure.in) are updated. This will cause most Makefiles to detect that configure.in is newer than configure and re-run autoxxx during %prep. This will then necessitate adding BuildRequires: autoconf.

To work around this problem, it is necessary to modify timestamps so that the autotools-generated files are newer than the autotools source files. This is best done by preserving the autotools source file timestamps:

...
Patch0:  mypackage-1.0-autotools.patch

%prep
%setup -q

touch -r configure.in configure.in.stamp
%patch0
touch -r configure.in.stamp configure.in

...or by updating the autotools-generated file timestamps. But this requires that *all* of the autotools-generated files are touched, which can be cumbersome if there are many autotools-generated files in the package:

...
Patch0:  mypackage-1.0-autotools.patch

%prep
%setup -q

%patch0
touch configure Mailefile.in foo/Makefile.in bar/Makefile.in