The function recursive_fill_list() is designed to descend lists of
packages, so it only makes sense to use with Requires and
Requires.private. Ensure it to make later code additions simpler.
If pkg-config is used in a multiarch or cross-compiling scenario it's
likely pkg-config needs to behave differently for each of them. It's
possible to handle this through environment variables with one
pkg-config, but another option is to have one pkg-config per platform,
each with the host alias prefixed to the program.
PKG_PROG_PKG_CONFIG supports this type of installation, and this is also
how autoconf/libtool handle other build tools like compilers and
linkers.
The host-prefixed tool is installed as a hardlink where supported and a
copy otherwise. This is how gcc handles it's host-prefixed versions.
This feature can be turned off by passing --disable-host-tool to
configure.
Freedesktop #130
From what I can tell, these single package variants have never been used
going back to pkg-config-0.4.0. pkg-config always uses the multipackage
versions that loop over the list of supplied packages.
Make sure that the --*-only-* variants of --cflags and --libs do the
right thing. This should probably be extended to cover a chain of
packages to get the ordering right, but this is good for now.
Test the usage of -uninstalled packages with two .pc files: inst.pc and
inst-uninstalled.pc. pkg-config should prefer the -uninstalled version
unless PKG_CONFIG_DISABLE_UNINSTALLED is set. It should also use the
default value of pc_top_builddir unless PKG_CONFIG_TOP_BUILD_DIR is set.
Add a test for pkg-config's path handling. The first test covers
PKG_CONFIG_PATH, and the second covers the built-in path. For this one
we need to unset the PKG_CONFIG_LIBDIR that normally is set during the
tests. Since we can't rely on the contents of the default path, we just
check to see that the built-in path matches what was specified in
configure. To do this, we need to add a bunch of variables to config.sh
so the variable resolves. These variables don't need to be exported,
though.
Add tests for checking the output of various options that print
information. For --list-all, a subdirectory with only two packages has
been added so that its output doesn't change when more test packages are
added to the check directory.
The run_test shell function was running pkg-config with arguments stored
in an environment variable. This has problems when trying to pass shell
special characters with the proper escaping. Instead, pass the arguments
to the test where they can maintain correct formatting through use of
the special variable "$@".
Use gcov to find how much code coverage our current testing gets. This
can be enabled by passing --with-gcov to configure and running "make
gcov". This is limited to gcc. Here's a run from the current code (for
some reason, gcov insists on profiling gstring.h).
/usr/bin/gcov pkg.h pkg.c parse.h parse.c main.c
File 'pkg.c'
Lines executed:73.16% of 611
pkg.c:creating 'pkg.c.gcov'
File '/usr/include/glib-2.0/glib/gstring.h'
Lines executed:100.00% of 6
/usr/include/glib-2.0/glib/gstring.h:creating 'gstring.h.gcov'
File 'parse.c'
Lines executed:79.67% of 492
parse.c:creating 'parse.c.gcov'
File 'main.c'
Lines executed:57.34% of 293
main.c:creating 'main.c.gcov'
When the VARIABLE-PREFIX tag is used more than once in PKG_CHECK_MODULES
it can result in later runs reporting success without actually running
pkg-config. This is because PKG_CHECK_MODULES looks for FOO_CFLAGS and
FOO_LIBS from the environment as a way to allow users to override the
test. PKG_CHECK_MODULES also sets these variables, though, and
subsequent calls will simply use these values.
Although there are legitimate ways to use the same VARIABLE-PREFIX
(e.g., they're all under conditionals meaning only one will be used),
document that repeated usage is not recommended.
Freedesktop #3550
Making --enable-static --disable-shared the default fixes most cases,
but build environments often pass --enable-shared --disable-static for
all autotooled projects. Force static building by setting the
appropriate variables as if they've come from the command line
parameters.
Without this, if the new ${prefix} path contains spaces, they are not
properly quoted in pkg-config's output. Besides the problems this causes
with things using the output, this also causes nonsensical results when
pkg-config splits such options to combine equal options.
By specifying the pkg-config to use for testing from make, we can easily
control its path and add the .exe extension for Windows. It also allows
easy testing of another pkg-config from make:
make check TESTS_PKG_CONFIG=/usr/bin/pkg-config
Although the trick of finding a POSIX shell in the system PATH works
fine most of the time, it has some drawbacks.
* The commands must be copied into every test script.
* The scripts are always forced to re-execute themselves.
* There's no guarantee the sh found in `getconf PATH` is a POSIX shell
and there's no way to override it.
Move the handling of this shell to configure where we can detect it
once. This gives preference to bash and ksh since they're typically
POSIX compatible. It also uses the current PATH with the getconf PATH at
the end which should allow things to work on platforms where getconf
might not be available like mingw/msys.
By specifying the shell in TESTS_ENVIRONMENT, automake will run each
script with this shell and we can drop the re-exec dance.
When glib is built static, the threads and clock code are not
initialized since DllMain is never run. Instead, initialize them from
the glib constructor.
https://bugzilla.gnome.org/show_bug.cgi?id=678387
pkg-config doesn't use message translation, so there's no need to build
it into the bundled glib. Furthermore, when not using glibc, this drags
in extra dependencies on gettext, libintl and iconv. Remove their usage
in two steps:
1. Don't include libintl.h directly from code. glibintl.h
conditionalizes the include of libintl.h based on the ENABLE_NLS define
and creates fallback macros when it's unwanted.
2. Remove the usage of the gettext macros in glib's configure.ac. This
ensures that the unwanted dependencies aren't searched for. Two defines
are kept around to keep the code happy.
When reapplying the glib patches we often end up with .orig files when
the hunks have moved. Any backup suffix is possible, but this is the
default from patch(1).
Since we're going to use glib as a convenience library, we need to make
sure it builds as if --enable-static was passed. This only matters on
Windows where a couple extra macros are defined and the DLL machinery is
disabled.
GLib out of the box does not support being built for multiple arches.
This means pkg-config using the internal glib can't be built as a
universal binary on OS X. Document this and available workarounds.
Freedesktop #52032
Prior to pkg-config 0.24, --exists honored Requires and
Requires.private. This was regressed in commits 02d5ae3f and 669bfe2e,
which split the handling of Requires and Requires.private out more
correctly for other options. This adds exists to the group of options
that enable the Requires functionality.
Freedesktop #43149
Currently the check-missing passes the packages on the command line with
no options prior to running through --cflags/--libs, etc. Make this more
explicitly pass --exists since this is a much more common operation
performed from PKG_CHECK_MODULES.
The expected result of 0 when Requires or Requires.private is missing is
a regression from pre-0.24 pkg-config.
Until the needed surgery is done to remove gettext support from the
internal glib (since pkg-config doesn't need it), make sure that libintl
is linked in when necessary.
If only PKG_CONFIG_PATH is set when running the tests, we'll still pick
up packages from the system default path. By overriding that with
PKG_CONFIG_LIBDIR and unsetting PKG_CONFIG_PATH, the path is forced to
the check directory.
Replace deprecated macros and use the new libtool syntax. The required
versions of the tools have been bumped up to match the versions of the
bundled glib. This was effectively the requirement, anyway. The new
required autotools versions are:
autoconf-2.62 (released 2008-04-08)
automake-1.11 (released 2009-05-17)
libtool-2.2 (released 2008-03-01)
Also use silent rules to quiet the build a bit.
Freedesktop #34382
acconfig.h was being used to undefine some macros, but these aren't
actually used anywhere in the pkg-config code. I suspect this was a
holdover from when glib-1 was used internally. glib does define some
similar macros, but that code is all self-contained there and not
anything we need to worry about in pkg-config.
g_win32_get_package_installation_subdirectory() has been deprecated
since GLib 2.18 and in recent (2.31) GLib versions disabled entirely by
default. This patch replaces usage of that function by
g_win32_get_package_installation_directory_of_module() and
g_build_filename(). Use the new functions and rework the code a bit so
it leaks less memory.
g_win32_get_package_installation_directory_of_module() is supported
since GLib 2.16. The minimal GLib version is bumped accordingly.
Freedesktop #45742