Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for 11678 (AutotoolsToolchain) #2660

Merged
merged 1 commit into from Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 33 additions & 5 deletions reference/conanfile/tools/gnu/autotoolstoolchain.rst
Expand Up @@ -123,10 +123,10 @@ values:

* **make_args** (Defaulted to ``[]``): Additional arguments to be passed to he make script.
* **autoreconf_args** (Defaulted to ``["--force", "--install"]``): 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.
* **extra_defines** (Defaulted to ``[]``): Additional defines.
* **extra_cxxflags** (Defaulted to ``[]``): Additional cxxflags.
* **extra_cflags** (Defaulted to ``[]``): Additional cflags.
* **extra_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``.
Expand All @@ -140,6 +140,34 @@ values:
* **msvc_runtime_flag**: Flag from ``settings.compiler.runtime_type`` when compiler is ``msvc`` or
``settings.compiler.runtime`` when using the deprecated ``Visual Studio``.

The following attributes are ready-only and will contain the calculated values for the current configuration and customized
attributes. Some recipes might need to read them to generate custom build files (not strictly Autotools) with the configuration:

* **defines**
* **cxxflags**
* **cflags**
* **ldflags**


.. code:: python

from conan import ConanFile
from conan.tools.gnu import AutotoolsToolchain

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

def generate(self):
tc = AutotoolsToolchain(self)
# Customize the flags
tc.extra_cxxflags = ["MyFlag"]

# Read the computed flags and use them (write custom files etc)
tc.defines
tc.cxxflags
tc.cflags
tc.ldflags


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

Expand Down Expand Up @@ -194,4 +222,4 @@ The ``environment()`` method returns an :ref:`Environment<conan_tools_env_enviro
at = AutotoolsToolchain(self)
env = at.environment()
env.define("FOO", "BAR")
at.generate(env)
at.generate(env)