public inbox for docs@lists.yoctoproject.org
 help / color / mirror / Atom feed
From: michael.opdenacker@bootlin.com
To: docs@lists.yoctoproject.org
Cc: Michael Opdenacker <michael.opdenacker@bootlin.com>,
	Talel BELHAJSALEM <bhstalel@gmail.com>
Subject: [mickledore][PATCH 05/13] ref-manual: Fix PACKAGECONFIG term and add an example
Date: Tue, 24 Oct 2023 15:23:10 +0200	[thread overview]
Message-ID: <20231024132318.90209-6-michael.opdenacker@bootlin.com> (raw)
In-Reply-To: <20231024132318.90209-1-michael.opdenacker@bootlin.com>

From: Michael Opdenacker <michael.opdenacker@bootlin.com>

From: BELHADJ SALEM Talel <bhstalel@gmail.com>

PACKAGECONFIG's first and second flag value will be added to PACKAGECONFIG_CONFARGS
and then it will be added to the appropriate variable (EXTRA_OECMAKE, or ...)
So we need to only mention PACKAGECONFIG_CONFARGS and it will lead to other variables.

I added a custom example that can help understanding very well PACKAGECONFIG.

Signed-off-by: Talel BELHAJSALEM <bhstalel@gmail.com>
Reviewed-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
---
 documentation/ref-manual/variables.rst | 42 ++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/documentation/ref-manual/variables.rst b/documentation/ref-manual/variables.rst
index 445274f62f..8d557495d4 100644
--- a/documentation/ref-manual/variables.rst
+++ b/documentation/ref-manual/variables.rst
@@ -5925,13 +5925,11 @@ system and gives an overview of their function and contents.
       omit any argument you like but must retain the separating commas. The
       order is important and specifies the following:
 
-      #. Extra arguments that should be added to the configure script
-         argument list (:term:`EXTRA_OECONF` or
-         :term:`PACKAGECONFIG_CONFARGS`) if
-         the feature is enabled.
+      #. Extra arguments that should be added to :term:`PACKAGECONFIG_CONFARGS`
+         if the feature is enabled.
 
-      #. Extra arguments that should be added to :term:`EXTRA_OECONF` or
-         :term:`PACKAGECONFIG_CONFARGS` if the feature is disabled.
+      #. Extra arguments that should be added to :term:`PACKAGECONFIG_CONFARGS`
+         if the feature is disabled.
 
       #. Additional build dependencies (:term:`DEPENDS`)
          that should be added if the feature is enabled.
@@ -5989,6 +5987,38 @@ system and gives an overview of their function and contents.
 
             PACKAGECONFIG:append:pn-recipename = " f4"
 
+      Consider the following example of a :ref:`ref-classes-cmake` recipe with a systemd service
+      in which :term:`PACKAGECONFIG` is used to transform the systemd service
+      into a feature that can be easily enabled or disabled via :term:`PACKAGECONFIG`::
+
+         example.c
+         example.service
+         CMakeLists.txt
+
+      The ``CMakeLists.txt`` file contains::
+
+         if(WITH_SYSTEMD)
+            install(FILES ${PROJECT_SOURCE_DIR}/example.service DESTINATION /etc/systemd/systemd)
+         endif(WITH_SYSTEMD)
+
+      In order to enable the installation of ``example.service`` we need to
+      ensure that ``-DWITH_SYSTEMD=ON`` is passed to the ``cmake`` command
+      execution.  Recipes that have ``CMakeLists.txt`` generally inherit the
+      :ref:`ref-classes-cmake` class, that runs ``cmake`` with
+      :term:`EXTRA_OECMAKE`, which :term:`PACKAGECONFIG_CONFARGS` will be
+      appended to.  Now, knowing that :term:`PACKAGECONFIG_CONFARGS` is
+      automatically filled with either the first or second element of
+      :term:`PACKAGECONFIG` flag value, the recipe would be like::
+
+         inherit cmake
+         PACKAGECONFIG = "systemd"
+         PACKAGECONFIG[systemd] = "-DWITH_SYSTEMD=ON,-DWITH_SYSTEMD=OFF"
+
+      A side note to this recipe is to check if ``systemd`` is in fact the used :term:`INIT_MANAGER`
+      or not::
+
+         PACKAGECONFIG = "${@'systemd' if d.getVar('INIT_MANAGER') == 'systemd' else ''}"
+
    :term:`PACKAGECONFIG_CONFARGS`
       A space-separated list of configuration options generated from the
       :term:`PACKAGECONFIG` setting.
-- 
2.34.1



  parent reply	other threads:[~2023-10-24 13:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 13:23 [mickledore][PATCH 00/13] mickledore documentation backports michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 01/13] ref-manual: Warn about COMPATIBLE_MACHINE skipping native recipes michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 02/13] bsp-guide: bsp: skip Intel machines no longer supported in Poky michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 03/13] sdk-manual: appendix-obtain: improve and update descriptions michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 04/13] dev-manual: new-recipe.rst: add missing parenthesis to "Patching Code" section michael.opdenacker
2023-10-24 13:23 ` michael.opdenacker [this message]
2023-10-24 13:23 ` [mickledore][PATCH 06/13] profile-manual: aesthetic cleanups michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 07/13] ref-manual: variables: provide no-match example for COMPATIBLE_MACHINE michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 08/13] dev-manual: layers: Add notes about layer.conf michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 09/13] brief-yoctoprojectqs: use new CDN mirror for sstate michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 10/13] dev-manual: start.rst: remove obsolete reference michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 11/13] ref-manual: variables: add RECIPE_SYSROOT and RECIPE_SYSROOT_NATIVE michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 12/13] ref-manual: variables: add TOOLCHAIN_OPTIONS variable michael.opdenacker
2023-10-24 13:23 ` [mickledore][PATCH 13/13] ref-manual: variables: add example for SYSROOT_DIRS variable michael.opdenacker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231024132318.90209-6-michael.opdenacker@bootlin.com \
    --to=michael.opdenacker@bootlin.com \
    --cc=bhstalel@gmail.com \
    --cc=docs@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox