All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: nvdimm@lists.linux.dev
Cc: Vaibhav Jain <vaibhav@linux.ibm.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Shivaprasad G Bhat <sbhat@linux.ibm.com>
Subject: [ndctl PATCH] ndctl/build: Fix 'iniparser' includes due to variances in distros
Date: Wed, 16 Mar 2022 11:00:30 +0530	[thread overview]
Message-ID: <20220316053030.2954642-1-vaibhav@linux.ibm.com> (raw)

The location of 'iniparser' header-files varies from distro to distro. For
example on Centos/Fedora/RHEL they are located at /usr/include/iniparser with
soft-links to the individual header files located at /usr/include. On
Ubuntu/Debian no such soft-links are present at /usr/include. In case of Arch
the files are located at /usr/include itself. This results in build breaks on
distros where iniparser headers aren't located in /usr/include.

Fixing this issue presents a challenge as iniparser's Makefile [1] hasn't
standardized on a specific location for these headers hence distros are free to
pickup a location.

The patch tries to address this problem by updating meson.build to check the
default include-directory (/usr/include/) for iniparser header files
{iniparser.h,dictionary.h} and if not found there then look into
'/usr/include/iniparser'.

Also a new meson build option 'iniparserdir' is introduced that user can used to
point to the directory where the header files are located.

Once the header-files/library are located successfully the 'iniparser' dependency
is updated to have 'include_directories' point to the correct include directory.

Testing
------------
Tested on Fedora-35 under these scenarios:

* iniparser header files not available : Meson Config Faile
* iniparser header files only located at /usr/include/iniparser : Build Succeeded
* iniparser header files only located at /usr/include  : Build Succeeded
* iniparser header files located at /usr/include/iniparser with soft-links
  to headers present at /usr/include  : Build Succeeded
* iniparser header files located at a custom location : Build Succeeded
* iniparser header files located at a custom location which doesn't exists :
  Meson Config Failed
* iniparser headers custom location missing 'dictionary.h' : Meson Config Failed

[1] https://github.com/ndevilla/iniparser/blob/master/Makefile

Fixes: addc5fd8511("Fix iniparser.h include")
Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 meson.build       | 22 ++++++++++++++++++++--
 meson_options.txt |  2 ++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 42e11aa25cba..252741528c75 100644
--- a/meson.build
+++ b/meson.build
@@ -158,9 +158,27 @@ endif
 
 cc = meson.get_compiler('c')
 
-# keyutils and iniparser lack pkgconfig
+# keyutils lacks pkgconfig
 keyutils = cc.find_library('keyutils', required : get_option('keyutils'))
-iniparser = cc.find_library('iniparser', required : true)
+
+# iniparser lacks pkgconfig and its header files are either at '/usr/include' or '/usr/include/iniparser'
+# Use the path provided by user via meson configure -Diniparserdir=<somepath>
+# if thats not provided then try searching for 'iniparser.h' in default system include path
+# and if that not found then as a last resort try looking at '/usr/include/iniparser'
+iniparser_headers = ['iniparser.h', 'dictionary.h']
+
+message('Looking for iniparser include headers', iniparser_headers)
+
+iniparserdir = include_directories(includedir / get_option('iniparserdir'), is_system:true)
+iniparser = cc.find_library('iniparser', required : (get_option('iniparserdir') != '') ,
+	  has_headers :iniparser_headers ,header_include_directories : iniparserdir)
+
+if not iniparser.found()
+   iniparserdir = include_directories(includedir / 'iniparser', is_system:true)
+   iniparser = cc.find_library('iniparser', required : true, has_headers : iniparser_headers,
+	     header_include_directories : iniparserdir)
+endif
+iniparser = declare_dependency(include_directories: iniparserdir, dependencies:iniparser)
 
 conf = configuration_data()
 check_headers = [
diff --git a/meson_options.txt b/meson_options.txt
index aa4a6dc8e12a..f7491969f5e0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,3 +23,5 @@ option('pkgconfiglibdir', type : 'string', value : '',
        description : 'directory for standard pkg-config files')
 option('bashcompletiondir', type : 'string',
        description : '''${datadir}/bash-completion/completions''')
+option('iniparserdir', type : 'string',
+       description : 'Path containing the iniparser header files')

base-commit: dd58d43458943d20ff063850670bf54a5242c9c5
prerequisite-patch-id: 85adfc17cde2ef48dc02711966881bd4f3f3f7c3
-- 
2.35.1


                 reply	other threads:[~2022-03-16  5:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220316053030.2954642-1-vaibhav@linux.ibm.com \
    --to=vaibhav@linux.ibm.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=sbhat@linux.ibm.com \
    --cc=vishal.l.verma@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.