@@ -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 = [
@@ -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')
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(-) base-commit: dd58d43458943d20ff063850670bf54a5242c9c5 prerequisite-patch-id: 85adfc17cde2ef48dc02711966881bd4f3f3f7c3