[MacPorts] #55577: getting rid of unforeseen -I${prefix}/include option adding and its potential side-effects
MacPorts
noreply at macports.org
Sat Dec 23 12:18:07 UTC 2017
#55577: getting rid of unforeseen -I${prefix}/include option adding and its
potential side-effects
-------------------------+-------------------------
Reporter: RJVB | Owner:
Type: enhancement | Status: new
Priority: Normal | Milestone:
Component: ports | Version:
Keywords: | Port: pcre, glib2
-------------------------+-------------------------
I ran into header file conflicts the other day building code that depends
indirectly on glib-2. This was on Linux using my MacPorts-for-Linux
adaptation but the same thing could easily happen on Mac too because the
same rules and guidelines apply for header search path priorities.
The culprit was an unhappy -I/opt/local/include compiler option which
caused a build to find headers from $prefix that were incompatible with
the ones included and needed by the project.
I traced that option first to glib-2.0.pc which is patched by port:glib2
to add the include path, and then to port:pcre which installs its headers
into ${prefix}/include and thus actually needs it.
The proper fix here is:
1. Install the pcre (and pcre2) headers in a subdirectory with the
official mechanism, i.e. add this to `configure.args` in `port file pcre`:
{{{
--includedir=${prefix}/include/${subport} \
}}}
This change will be reflected in the pcre/pcre2 pkg-config files.
2. update port:glib2 . This should be automatic but I didn't want to
second-guess the reason NOT to use pkgconfig in `port configure glib2`
which means a few changes are required. No hacks though, if anything the
modified version is less of a hack than the original. `PCRE_CFLAGS` and
`PCRE_LIBS` are now set by querying pkg-config instead of with hardcoded
values (idem for the ZLIB variables, as a bonus). Assuming the change to
glib-2.0.pc is still required, this can actually be done in such a way
that the build system inserts the proper option(s) by adding
`@PCRE_CFLAGS@` instead of the hardcoded `-I` option.
After applying the changes above I get the pkg-config output below, which
is far more specific
{{{
> pkg-config --cflags glib-2.0
-I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include
-I/opt/local/include/pcre
}}}
--
Ticket URL: <https://trac.macports.org/ticket/55577>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list