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

Autotools improved #2135

Merged
merged 2 commits into from Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions reference/conanfile/tools/cmake.rst
Expand Up @@ -10,6 +10,7 @@ conan.tools.cmake

.. toctree::
:maxdepth: 2

cmake/cmakedeps
cmake/cmaketoolchain
cmake/cmake
1 change: 0 additions & 1 deletion reference/conanfile/tools/gnu.rst
Expand Up @@ -9,5 +9,4 @@ conan.tools.gnu

gnu/autotoolsdeps
gnu/autotoolstoolchain
gnu/autotoolsgen
gnu/autotools
46 changes: 43 additions & 3 deletions reference/conanfile/tools/gnu/autotools.rst
@@ -1,3 +1,5 @@
.. _conan_tools_gnu_build_helper:

Autotools
=========

Expand All @@ -24,7 +26,45 @@ The ``Autotools`` helper can be used like:
autotools.configure()
autotools.make()

It will read the ``conanbuild.json`` file generated by the :ref:`AutotoolsToolchain<conan_tools_gnu_autotools_toolchain>`
to know read the arguments for calling the configure and make scripts:

- **configure_args**: Arguments to call the ``configure`` script.
- **make_args**: Arguments to call the ``make`` script.


Methods
-------

configure()
+++++++++++

.. code-block:: python

def configure(self)

Call the configure script.


make()
++++++

.. code-block:: python

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.


install()
+++++++++

.. code-block:: python

def install(self)

The current support is limited:
- It does not support cross-building or --target, --host, --build definitions
- It does not handle install functionality
This is just an "alias" of ``self.make(target="install")``
6 changes: 6 additions & 0 deletions reference/conanfile/tools/gnu/autotoolsdeps.rst
Expand Up @@ -50,3 +50,9 @@ This generator will define aggregated variables ``CPPFLAGS``, ``LIBS``, ``LDFLAG
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 ``build_requires`` one is not managed by this generator yet.


Attributes
++++++++++

At this moment, it is pending to expose attributes to let the user modify the behavior before calling ``generate()``
58 changes: 0 additions & 58 deletions reference/conanfile/tools/gnu/autotoolsgen.rst

This file was deleted.

58 changes: 57 additions & 1 deletion reference/conanfile/tools/gnu/autotoolstoolchain.rst
@@ -1,3 +1,5 @@
.. _conan_tools_gnu_autotools_toolchain:

AutotoolsToolchain
==================

Expand All @@ -9,7 +11,7 @@ AutotoolsToolchain
The ``AutotoolsToolchain`` is the toolchain generator for Autotools. It will generate shell scripts containing
environment variable definitions that the autotools build system can understand.

The ``AutotooAutotoolsToolchainlsDeps`` generator can be used by name in conanfiles:
The ``AutotooAutotoolsToolchain`` generator can be used by name in conanfiles:
czoido marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: python
:caption: conanfile.py
Expand Down Expand Up @@ -48,3 +50,57 @@ The ``AutotoolsToolchain`` will generate after a ``conan install`` command the *

This generator will define aggregated variables ``CPPFLAGS``, ``LDFLAGS``, ``CXXFLAGS``, ``CFLAGS`` that
accumulate all dependencies information, including transitive dependencies, with flags like ``-stdlib=libstdc++``, ``-std=gnu14``, architecture flags, etc.

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

- **configure_args**: Arguments to call the ``configure`` script.
- **make_args**: Arguments to call the ``make`` script.

The :ref:`Autotools build helper<conan_tools_gnu_build_helper>` will use that ``conanbuild.json`` file to seamlessly call
the configure and make script using these precalculated arguments.

Attributes
++++++++++

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

.. code:: python

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

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

def generate(self):
tc = AutotoolsToolchain(self)
tc.configure_args.append("--my_argument")
tc.generate()


* **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.
* **default_configure_install_args** (Defaulted to ``False``): 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}/includev``
* ``--datarootdir=${prefix}/share``

* **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.