On Tue, 2022-03-15 at 22:16 +0530, Vaibhav Jain wrote:
> "Aneesh Kumar K.V" <[email protected]> writes:
> 
> > Vaibhav Jain <[email protected]> writes:
> > 
> > > Second hunk of this diff seems to be a revert of [1]  which might
> > > break the ndctl build on Arch Linux.
> > > 
> > > AFAIS for Centos/Fedora/RHEL etc the iniparser.h file is present in the
> > > default include path('/usr/include') as a softlink to
> > > '/usr/include/iniparser/iniparser.h' . Ubuntu/Debian seems to an
> > > exception where path '/usr/include/iniparser.h' is not present.
> > 

Sigh, yeah, that's an unfortunate situation.

> > 
> 
> Agree, above patch can fix this issue. Though I really wanted to avoid
> trickling changes to the parse-configs.c since the real problem is with
> non consistent location for iniparser.h header across distros.
> 
> I gave it some thought and came up with this patch to meson.build that can
> pick up appropriate '/usr/include' or '/usr/include/iniparser' directory
> as include path to the compiler.
> 
> Also since there seems to be no standard location for this header file
> I have included a meson build option named 'iniparser-includedir' that
> can point to the dir where 'iniparser.h' can be found.

This approach sounds fine, do you want to send it as a proper patch.

> 
> diff --git a/meson.build b/meson.build
> index 42e11aa25cba..8c347e64ca2d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -158,9 +158,27 @@ endif
>  
>  cc = meson.get_compiler('c')
>  
> -# keyutils and iniparser lack pkgconfig
> +# keyutils lack pkgconfig

s/lack/lacks/

>  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'
> +# First use the path provided by user via meson configure 
> -Diniparser-includedir=<somepath>
> +# if thats not provided than try searching for 'iniparser.h' in default 
> system include path
> +# and if that not found than as a last resort try looking at 
> '/usr/include/iniparser'
> +
> +if get_option('iniparser-includedir') == ''
> +  iniparser = cc.find_library('iniparser', required : false, has_headers : 
> 'iniparser.h')
> +  # if not available at the default path try '/usr/include/iniparser'
> +  if not iniparser.found()
> +    iniparser = cc.find_library('iniparser', required : true, has_headers : 
> 'iniparser/iniparser.h')
> +    iniparser = 
> declare_dependency(include_directories:'/usr/include/iniparser', 
> dependencies:iniparser)
> +  endif
> +else
> +  iniparser_incdir = include_directories(get_option('iniparser-includedir'))
> +  iniparser = cc.find_library('iniparser', required : true, has_headers : 
> 'iniparser.h',
> +                                            
> header_include_directories:iniparser_incdir)
> +  iniparser = declare_dependency(include_directories:iniparser_incdir, 
> dependencies:iniparser)
> +endif
>  
>  conf = configuration_data()
>  check_headers = [
> diff --git a/meson_options.txt b/meson_options.txt
> index aa4a6dc8e12a..d08151691553 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('iniparser-includedir', type : 'string',
> +       description : '''Path containing the iniparser header files''')
> 
> 

Reply via email to