Skip to content

Commit

Permalink
Add documentation for MakeDeps (#3348)
Browse files Browse the repository at this point in the history
* Add integration page for Makefile

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add MakeDeps reference

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add makedeps entry in gnu index

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add experimental warning to MakeDeps

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Grammar fix

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>

* Grammar fix

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>

* Grammar fix

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>

* Update reference/tools/gnu/makedeps.rst

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent 6a38171 commit 8b09cca
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Integrations
Conan provides seamless integration with several platforms, build systems, and IDEs. Conan
brings off-the-shelf support for some of the most important operating systems, including
Windows, Linux, macOS, Android, and iOS. Some of the most important build systems
supported by Conan include CMake, MSBuild, Meson and Autotools. In addition to build
supported by Conan include CMake, MSBuild, Meson, Autotools and Make. In addition to build
systems, Conan also provides integration with popular IDEs, such as Visual Studio and
Xcode.

Expand All @@ -17,6 +17,7 @@ Xcode.
integrations/cmake
integrations/visual_studio
integrations/autotools
integrations/makefile
integrations/xcode
integrations/meson
integrations/android
Expand All @@ -28,4 +29,3 @@ Xcode.
recommended to use them right now because they're not updated for the 2.0 version yet.
However, we intend to resume working on these plugins and enhance their functionality
once Conan 2.0 is released.

22 changes: 22 additions & 0 deletions integrations/makefile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. _integrations_makefile:

|gnu_make_logo| Makefile
========================

Conan provides different tools to help manage your projects using Make. They can be
imported from ``conan.tools.gnu``. Besides the most popular variant, GNU Make, Conan also
supports other variants like BSD Make. The most relevant tools are:

- `MakeDeps`: the dependencies generator for Make, which generates a Makefile containing
definitions that the Make build tool can understand.

Currently, there is no ``MakeToolchain`` generator, it should be added in the future.

For the full list of tools under ``conan.tools.gnu`` please check the :ref:`reference
<conan_tools_gnu>` section.

.. seealso::

- Reference for :ref:`MakeDeps<conan_tools_gnu_makedeps>`.

.. |gnu_make_logo| image:: ../images/integrations/conan-autotools-logo.png
1 change: 1 addition & 0 deletions reference/tools/gnu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ conan.tools.gnu
gnu/autotoolsdeps
gnu/autotoolstoolchain
gnu/autotools
gnu/makedeps
gnu/pkgconfigdeps
gnu/pkgconfig
93 changes: 93 additions & 0 deletions reference/tools/gnu/makedeps.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.. _conan_tools_gnu_makedeps:

MakeDeps
========

.. include:: ../../../common/experimental_warning.inc

.. _MakeDeps:

``MakeDeps`` is the dependencies generator for make. It generates a Makefile file named ``conandeps.mk``
containing a valid make file syntax with all dependencies listed, including their components.

This generator can be used by name in conanfiles:

.. code-block:: python
:caption: conanfile.py
class Pkg(ConanFile):
generators = "MakeDeps"
.. code-block:: text
:caption: conanfile.txt
[generators]
MakeDeps
And it can also be fully instantiated in the conanfile ``generate()`` method:

.. code:: python
from conan import ConanFile
from conan.tools.gnu import MakeDeps
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"
requires = "zlib/1.2.13"
def generate(self):
pc = MakeDeps(self)
pc.generate()
Generated files
---------------

`make` format file named ``conandeps.mk``, containing a valid makefile file syntax.
The ``prefix`` variable is automatically adjusted to the ``package_folder``:

.. code-block:: makefile
CONAN_DEPS = zlib
# zlib/1.2.13
CONAN_NAME_ZLIB = zlib
CONAN_VERSION_ZLIB = 1.2.13
CONAN_REFERENCE_ZLIB = zlib/1.2.13
CONAN_ROOT_ZLIB = /home/conan/.conan2/p/b/zlib273508b343e8c/p
CONAN_INCLUDE_DIRS_ZLIB = $(CONAN_INCLUDE_DIR_FLAG)$(CONAN_ROOT_ZLIB)/include
CONAN_LIB_DIRS_ZLIB = $(CONAN_LIB_DIR_FLAG)$(CONAN_ROOT_ZLIB)/lib
CONAN_BIN_DIRS_ZLIB = $(CONAN_BIN_DIR_FLAG)$(CONAN_ROOT_ZLIB)/bin
CONAN_LIBS_ZLIB = $(CONAN_LIB_FLAG)z
CONAN_INCLUDE_DIRS = $(CONAN_INCLUDE_DIRS_ZLIB)
CONAN_LIB_DIRS = $(CONAN_LIB_DIRS_ZLIB)
CONAN_BIN_DIRS = $(CONAN_BIN_DIRS_ZLIB)
CONAN_LIBS = $(CONAN_LIBS_ZLIB)
Customization
-------------

Flags
+++++

By default, the ``conandeps.mk`` will contain all dependencies listed, including their ``cpp_info`` information, but will not pass any flags to the compiler.

Thus, the consumer should pass the following flags to the compiler:

- **CONAN_LIB_FLAG**: Add a prefix to all libs variables, e.g. ``-l``
- **CONAN_DEFINE_FLAG**: Add a prefix to all defines variables, e.g. ``-D``
- **CONAN_SYSTEM_LIB_FLAG**: Add a prefix to all system_libs variables, e.g. ``-l``
- **CONAN_INCLUDE_DIR_FLAG**: Add a prefix to all include dirs variables, e.g. ``-I``
- **CONAN_LIB_DIR_FLAG**: Add a prefix to all lib dirs variables, e.g. ``-L``
- **CONAN_BIN_DIR_FLAG**: Add a prefix to all bin dirs variables, e.g. ``-L``

Those flags should be appended as prefixes to flags variables. For example, if the ``CONAN_LIB_FLAG`` is set to ``-l``, the ``CONAN_LIBS`` variable will be set to ``-lz``.

Reference
---------

.. currentmodule:: conan.tools.gnu

.. autoclass:: MakeDeps
:members:

0 comments on commit 8b09cca

Please sign in to comment.