AutotoolsDeps

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

It can be used by name in conanfiles:

conanfile.py

  1. class Pkg(ConanFile):
  2. generators = "AutotoolsDeps"

conanfile.txt

  1. [generators]
  2. AutotoolsDeps

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

  1. from conan import ConanFile
  2. from conan.tools.gnu import AutotoolsDeps
  3. class App(ConanFile):
  4. settings = "os", "arch", "compiler", "build_type"
  5. def generate(self):
  6. tc = AutotoolsDeps(self)
  7. tc.generate()

Generated files

It will generate the file conanautotoolsdeps.sh or conanautotoolsdeps.bat:

  1. $ conan install conanfile.py # default is Release
  2. $ source conanautotoolsdeps.sh
  3. # or in Windows
  4. $ conanautotoolsdeps.bat

These launchers will define aggregated variables CPPFLAGS, LIBS, LDFLAGS, CXXFLAGS, CFLAGS that accumulate all dependencies information, including transitive dependencies, with flags like -I<path>, -L<path>, etc.

At this moment, only the requires information is generated, the tool_requires one is not managed by this generator yet.

Customization

To modify the computed values, you can access the .environment property that returns an Environment class.

  1. from conan import ConanFile
  2. from conan.tools.gnu import AutotoolsDeps
  3. class App(ConanFile):
  4. settings = "os", "arch", "compiler", "build_type"
  5. def generate(self):
  6. tc = AutotoolsDeps(self)
  7. tc.environment.remove("CPPFLAGS", "undesired_value")
  8. tc.environment.append("CPPFLAGS", "var")
  9. tc.environment.define("OTHER", "cat")
  10. tc.environment.unset("LDFLAGS")
  11. tc.generate()

Reference

class AutotoolsDeps(conanfile)

  • property environment

    • Returns:

      An Environment object containing the computed variables. If you need to modify some of the computed values you can access to the environment object.