Autotools
Important
Some of the features used in this section are still under development, while they are recommended and usable and we will try not to break them in future releases, some breaking changes might still happen if necessary to prepare for the Conan 2.0 release.
Available since: 1.35.0
The Autotools build helper is a wrapper around the command line invocation of autotools. It will abstract the
calls like ./configure or make into Python method calls.
The Autotools helper can be used like:
from conan import ConanFile
from conan.tools.gnu import Autotools
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
def build(self):
autotools = Autotools(self)
autotools.configure()
autotools.make()
It will read the conanbuild.conf file generated by the AutotoolsToolchain
to know what arguments to use when calling the configure and make scripts:
configure_args: Arguments to call the
configurescript.make_args: Arguments to call the
makescript.
Methods
constructor
def __init__(self, conanfile, namespace=None):
conanfile: the current recipe object. Always use
self.namespace: this argument avoids collisions when you have multiple toolchain calls in the same recipe. By setting this argument, the conanbuild.conf file used to pass information to the toolchain will be named as: <namespace>_conanbuild.conf. The default value is
Nonemeaning that the name of the generated file is conanbuild.conf. This namespace must be also set with the same value in the constructor of the AutotoolsToolchain so that it reads the information from the proper file.
configure(self, build_script_folder=None, args=None):
def configure(self, build_script_folder=None, args=None):
Call the configure script.
- build_script_folder (Optional, Defaulted to
None): Subfolder where the configure script is located. If
None,conanfile.source_folderwill be used.
- build_script_folder (Optional, Defaulted to
- args (Optional, Defaulted to
None): List of arguments to use for the configurecall.
- args (Optional, Defaulted to
autoreconf(self, args=None):
def autoreconf(self, args=None)
Call the autoreconf program.
- Parameters:
- args (Optional, Defaulted to
None): List of arguments to use for the autoreconfcall.
- args (Optional, Defaulted to
make(self, target=None, args=None):
def make(self, target=None)
Call the make program.
- Parameters:
target (Optional, Defaulted to
None): Choose which target to build. This allows building of e.g., docs, shared libraries or install for some AutoTools projects.args (Optional, Defaulted to
None): List of arguments to use for themakecall.
install(self, args=None, target=”install”):
def install(self, args=None, target="install")
This is just an “alias” of self.make(target="install")
- Parameters:
args (Optional, Defaulted to
None): List of arguments to use for themake installcall. By default an argumentDESTDIR=unix_path(self, self.package_folder)is added to the call if the passed value isNone. See more information about tools.microsoft.unix_path() function.target (Optional, Defaulted to
install): Target name to use when calling tomake <target>.