Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pkg-config in configure.ac for iniparser #622

Open
ionenwks opened this issue Feb 21, 2025 · 4 comments
Open

Support pkg-config in configure.ac for iniparser #622

ionenwks opened this issue Feb 21, 2025 · 4 comments

Comments

@ionenwks
Copy link

Currently configure.ac hardcodes some paths like -I/usr/include/iniparser as a best effort, but this doesn't account for any non-typical installation or other needs like when cross-compiling. This is fine as a fallback for old versions of iniparser, but since iniparser-4.2 a iniparser.pc is shipped and it'd be nice if it was tried first.

@karlstav
Copy link
Owner

I have iniparser 4.2.1 on my ubuntu 24.10 but I can't seem to have the package file

both

  PKG_CHECK_MODULES(INIPARSER, libiniparser, have_iniparser=yes, have_iniparser=no)

and

  PKG_CHECK_MODULES(INIPARSER, iniparser, have_iniparser=yes, have_iniparser=no)

fails to find any iniparser

i don't think the package file was added properly before quit recently:

ndevilla/iniparser@141d773

4.2.2?

Anyway, the reason for the hard coded path was because debian have the header file in iniparser/iniparser.h and other distros did not:

https://bugzilla.redhat.com/show_bug.cgi?id=1635706

this may be resolved all over now and I can remove the include path and just do #include <iniparser/iniparser.h>

the correct way to do it would of course be to leave the include as it is and use the package config file.

looks like the package config file adds the iniparser sub dir to the include paths:

https://github.com/ndevilla/iniparser/blob/4bef811283e0ec1658c60e09950bd5a1ddc92e4b/CMakeLists.txt#L167

@ionenwks
Copy link
Author

ionenwks commented Feb 22, 2025

Ah I see, I hadn't checked as far back as 4.2.1 given we never had that version in Gentoo and kind of assumed, sorry.

Currently have 4.2.6, in case interested the file has:

$ cat /usr/lib64/pkgconfig/iniparser.pc 
prefix=/usr
exec_prefix=/usr
includedir=${prefix}/include/iniparser
libdir=${exec_prefix}/lib64

Name: iniparser
Description: Simple C library offering ini file parsing services
Version: 4.2.6
Libs: -L${libdir} -liniparser
Cflags: -I${includedir}

For us, during cross-compilation, pkg-config --cflags would give e.g. -I/usr/aarch64-unknown-linux-gnu/usr/include/iniparser. aarch64/usr/include is already in the default search path so #include <iniparser/iniparser.h> would technically work while with current #include <iniparser.h> combined with -I/usr/include/iniparser then it may either fail to find it or find the host's header which may even be a different version of iniparser.

Using pkg-config may handle odd cases like /opt/iniparser though, not that (we) need that.

@ionenwks
Copy link
Author

ionenwks commented Feb 22, 2025

Using pkg-config may handle odd cases like /opt/iniparser though, not that (we) need that.

Well... historically we also had a odd include path at /usr/include/iniparser4 back when we installed iinparser3 and 4 at same time, but we got rid of the logic recently given we have nothing that needs 3 anymore.

In that kind of situation (when possible, it wasn't with iniparser) we often rely on pkg-config to tell a package which version to use.

Just to say that it's nice to leave it up to pkg-config when possible rather than assume anything.

@karlstav
Copy link
Owner

I can make it use the pkg-config if it exists and fall back to using the manual include path if it can't find any pkg-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants