These tools are still experimental (so subject to breaking changes) but with very stable syntax. We encourage the usage of it to be prepared for Conan 2.0.

The AutotoolsToolchain is the toolchain generator for Autotools. It will generate shell scripts containing environment variable definitions that the autotools build system can understand.


This class will require very soon to define both the “host” and “build” profiles. It is very recommended to start defining both profiles immediately to avoid future breaking. Furthermore, some features, like trying to cross-compile might not work at all if the “build” profile is not provided.

The AutotoolsToolchain generator can be used by name in conanfiles:
class Pkg(ConanFile):
    generators = "AutotoolsToolchain"

And it can also be fully instantiated in the conanfile generate() method:

from conans import ConanFile
from import AutotoolsToolchain

class App(ConanFile):
    settings = "os", "arch", "compiler", "build_type"

    def generate(self):
        tc = AutotoolsToolchain(self)

The AutotoolsToolchain will generate after a conan install command the or conanautotoolstoolchain.bat files:

$ conan install # default is Release
$ source
# or in Windows
$ conanautotoolstoolchain.bat

This generator will append information to the CPPFLAGS, LDFLAGS, CXXFLAGS, CFLAGS environment variables that translate the settings and options to the corresponding build flags like -stdlib=libstdc++, -std=gnu14, architecture flags, etc. It will also append the folder where the Conan generators are located to the PKG_CONFIG_PATH environment variable.

This generator will also generate a file called conanbuild.conf containing two keys:

  • configure_args: Arguments to call the configure script.
  • make_args: Arguments to call the make script.

The Autotools build helper will use that conanbuild.conf file to seamlessly call the configure and make script using these precalculated arguments.

It supports the following methods and attributes:


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 build helper will be named as: <namespace>_conanbuild.conf. The default value is None meaning 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 Autotools build helper so that it reads the information from the proper file.


You can change some attributes before calling the generate() method if you want to change some of the precalculated values:

from conans import ConanFile
from import AutotoolsToolchain

class App(ConanFile):
    settings = "os", "arch", "compiler", "build_type"

    def generate(self):
        tc = AutotoolsToolchain(self)
  • configure_args (Defaulted to []): Additional arguments to be passed to the configure script.

  • make_args (Defaulted to []): Additional arguments to be passed to he make script.

  • defines (Defaulted to []): Additional defines.

  • cxxflags (Defaulted to []): Additional cxxflags.

  • cflags (Defaulted to []): Additional cflags.

  • ldflags (Defaulted to []): Additional ldflags.

  • ndebug: “NDEBUG” if the settings.build_type != Debug.

  • gcc_cxx11_abi: “_GLIBCXX_USE_CXX11_ABI” if gcc/libstdc++.

  • libcxx: Flag calculated from settings.compiler.libcxx.

  • fpic: True/False from options.fpic if defined.

  • cppstd: Flag from settings.compiler.cppstd

  • arch_flag: Flag from settings.arch

  • build_type_flags: Flags from settings.build_type

  • apple_arch_flag: Only when cross-building with Apple systems. Flags from settings.arch.

  • apple_isysroot_flag: Only when cross-building with Apple systems. Path to the root sdk.

  • msvc_runtime_flag: Flag from settings.compiler.runtime_type when compiler is msvc or settings.compiler.runtime when using the deprecated Visual Studio.

  • default_configure_install_args (Defaulted to True): If True it will pass automatically the following flags to the configure script:

    • --prefix: With the self.package_folder value.
    • --bindir=${prefix}/bin
    • --sbindir=${prefix}/bin
    • --libdir=${prefix}/lib
    • --includedir=${prefix}/include
    • --oldincludedir=${prefix}/include
    • --datarootdir=${prefix}/res

If you want to change the default values, adjust the cpp.package object at the layout() method:

def layout(self):
    # For bindir and sbindir takes the first value:
    self.cpp.package.bindirs = ["mybin"]
    # For libdir takes the first value:
    self.cpp.package.libdirs = ["mylib"]
    # For includedir and oldincludedir takes the first value:
    self.cpp.package.includedirs = ["myinclude"]
    # For datarootdir takes the first value:
    self.cpp.package.resdirs = ["myres"]


It is not valid to change the self.cpp_info at the package_info() method.


AutotoolsToolchain is affected by these [conf] variables:

  • list of extra C++ flags that will be used by CXXFLAGS.
  • list of extra of pure C flags that will be used by CFLAGS.
  • list of extra linker flags that will be used by LDFLAGS.
  • list of extra linker flags that will be used by by LDFLAGS.
  • list of preprocessor definitions that will be used by CPPFLAGS.

Customizing the environment

If your Makefile or configure scripts need some other environment variable rather than CPPFLAGS, LDFLAGS, CXXFLAGS or CFLAGS, you can customize it before calling the generate() method. Call the environment() method to calculate the mentioned variables and then add the variables that you need. The environment() method returns an Environment object:

from conans import ConanFile
from import AutotoolsToolchain

class App(ConanFile):
    settings = "os", "arch", "compiler", "build_type"

    def generate(self):
        at = AutotoolsToolchain(self)
        env = at.environment()
        env.define("FOO", "BAR")