Autotools¶
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.
Usage:
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 read the arguments for calling the configure and make scripts:
- configure_args: Arguments to call the - configurescript.
- make_args: Arguments to call the - makescript.
Reference¶
- class Autotools(conanfile, namespace=None)¶
- Parameters:
- 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(build_script_folder=None, args=None)¶
- Call the configure script. - Parameters:
- args – List of arguments to use for the - configurecall.
- build_script_folder – Subfolder where the configure script is located. If not specified conanfile.source_folder is used. 
 
 
 - make(target=None, args=None, makefile=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 the- makecall.
- makefile – (Optional, Defaulted to - None): Allow specifying a custom makefile to use instead of default “Makefile”
 
 
 - install(args=None, target=None, makefile=None)¶
- This is just an “alias” of - self.make(target="install")or- self.make(target="install-strip")- Parameters:
- args – (Optional, Defaulted to - None): List of arguments to use for the- makecall. By default an argument- DESTDIR=unix_path(self.package_folder)is added to the call if the passed value is- None. See more information about tools.microsoft.unix_path() function
- target – (Optional, Defaulted to - None): Choose which target to install.
- makefile – (Optional, Defaulted to - None): Allow specifying a custom makefile to use instead of default “Makefile”
 
 
 - autoreconf(build_script_folder=None, args=None)¶
- Call - autoreconf- Parameters:
- args – (Optional, Defaulted to - None): List of arguments to use for the- autoreconfcall.
- build_script_folder – Subfolder where the configure script is located. If not specified conanfile.source_folder is used. 
 
 
 
conf¶
The Autotools build helper is affected by these [conf] variables:
- tools.gnu:make_programallows to define which- makeexecutable is being used. This will default for- mingw32-makefor MinGW builds or to- makefor any other build.
- tools.build:install_strip(Since Conan 2.20.0) will define in the- Autotools.install()method the- make install-striptarget if set to- True, otherwise it will use the- make installtarget.