Commit graph

431 commits

Author SHA1 Message Date
Dan Nicholson
e7238e823f check: Define all useful build directories in config.sh
Define all the autoconf build directories besides srcdir, which is
required to run the test scripts and set by "make check", and builddir,
which is always assumed to be ".".
2013-05-17 05:13:15 -07:00
Dan Nicholson
925119ce51 Document all pkg-config derived metadata variables
The derived variables pcfiledir, pc_top_builddir and pc_sysrootdir were
lacking in documentation. Rework the "QUERYING PKG-CONFIG'S DEFAULTS"
section to describe these and pc_path.

The example of using "pkg-config --modversion pkg-config" was removed
since it's superfluous to "pkg-config --version".

Freedesktop #62018 (https://bugs.freedesktop.org/show_bug.cgi?id=62018)
2013-05-17 05:13:15 -07:00
Dan Nicholson
43c1e0e4af Make the --define-prefix feature available on all platforms
Allowing pkg-config to override the prefix variable in .pc files is a
useful feature for making packages relocatable. There's nothing Windows
specific about it.

Freedesktop #63602 (https://bugs.freedesktop.org/show_bug.cgi?id=63602)
2013-05-17 05:13:15 -07:00
Dan Nicholson
755639aac0 Remove compat definition of G_IS_DIR_SEPARATOR
This has been available on glib since 2.5.4, and pkg-config requires at
least 2.16.
2013-05-17 05:13:15 -07:00
Dan Nicholson
f655cf91a0 Store the original prefix value in the package
Avoids making implicit assumptions about parse ordering needed to store
the original prefix as a static file local variable.
2013-05-17 05:13:14 -07:00
Dan Nicholson
a65d5cff5f Allow Windows prefix redefinition in any pkgconfig directory
The prefix redefinition feature on Windows to make packages relocatable
was being confined only to locations where the .pc file was in a
directory ending in lib/pkgconfig or share/pkgconfig. This is too
restrictive as it's quite common for the libdir to have a different name
such as lib64. This keeps the convention that the feature will only be
enabled when the .pc file is in a pkgconfig directory, and it continues
to define the prefix to the grandparent of the pkgconfig directory.

The path handling is switched over to standard glib functions
g_path_get_basename and g_path_get_dirname to avoid handrolled handling
of Windows paths.
2013-05-17 05:13:14 -07:00
Dan Nicholson
409ee76ce1 Allow more control of redefined prefix behavior
Currently the native Win32 builds default to redefining the prefix
variable in .pc files based on their installation paths. This behavior
is not always desired when pkg-config is being used in a traditional
fixed path environment (e.g., /mingw like /usr).

Allow the default to be set via configure switch
--enable/disable-define-prefix, and allow it to be set both ways at
runtime through the --[dont-]define-prefix pkg-config option.
2013-05-17 05:13:14 -07:00
Dan Nicholson
636e804ded Fix default path in PKG_CONFIG_LIBDIR description
It's been a long time that $datadir/pkgconfig was in the default path.
2013-04-20 10:18:18 -07:00
Dan Nicholson
d04105f2e2 check: Make check-tilde executable like all other test scripts 2013-04-20 08:38:02 -07:00
Dan Nicholson
cf21a002be Document search path construction on Windows 2013-04-18 05:43:23 -07:00
Dan Nicholson
ec844f503c Fix regression in -L mangling for MSVC
Commit 9bf6277b reworked how Libs arguments are parsed but unfortunately
added an extra library suffix component into -L arguments. This only
affects MSVC syntax where the suffix is .libs. All other platforms use a
blank suffix in linker commands.
2013-04-18 05:42:59 -07:00
Dan Nicholson
7328e6fc9e Run cmd through Wine when available
If we have Wine, it will provide cmd so we can build the pkg-config path
for the test.
2013-04-09 05:45:40 -07:00
Dan Nicholson
4a0ab4be0b Check for Wine when cross-compiling to Windows
If Wine is available when cross-compiling to Windows, it can be used to
run the test suite from the build machine.
2013-04-09 05:45:40 -07:00
Dan Nicholson
80c2777b22 Substitute TESTS_PKG_CONFIG from configure
This just paves the way to calculate more useful defaults in a shell.
2013-04-09 05:45:40 -07:00
Dan Nicholson
85dce61788 Adjust PKG_CONFIG_PATH for tests correctly on Windows
For native Windows, the PKG_CONFIG_PATH separator is ; rather than :.
2013-04-09 05:45:07 -07:00
Dan Nicholson
bfe139da8c Mangle expected sysroot output to match MSYS shell
MSYS mangles UNIX paths on execution such that it prepends its root in
Windows format. This affects PKG_CONFIG_SYSROOT_DIR and thus the
check-sysroot test. Detect MSYS from the OSTYPE environment variable and
adjust the expected test results to match. This likely means that
sysroot support doesn't actually work on MSYS, but there probably aren't
any toolchains that support sysroot there, anyway.
2013-04-09 05:43:24 -07:00
Dan Nicholson
5f9116931d Flush stderr when not immediately exiting
When printing warnings on stderr that don't immediately exit pkg-config,
flush it so that the messages appear in order with stdout. This is
mostly to keep the test suite passing on Windows where output may appear
differently than on Linux.
2013-04-09 05:41:38 -07:00
Dan Nicholson
f6212f6b97 Adjust expected path for native Windows test
When check-path is run on native Windows (MINGW), that path reported
by `pkg-config --variable=pc_path pkg-config` is adjusted to the
directory pkg-config is run from. Adjust the expected result based on
getting the current directory from cmd in Windows format.
2013-04-09 05:41:38 -07:00
Dan Nicholson
df1ac943d4 Check $host rather than $build when deciding native Win32
The host triplet describes the machine the program will run on while the
build triplet describes the machine the program is being built on. The
determination of native Win32 should be based on where pkg-config is
going to be running. This makes pkg-config cross-compiled for windows
work as if it was built on windows.
2013-04-09 05:41:38 -07:00
Dan Nicholson
4ccdb947dd Remove duplicate LIBRARIES in manual
Freedesktop #62374 (https://bugs.freedesktop.org/show_bug.cgi?id=62374)
2013-04-06 11:29:57 -07:00
Dan Nicholson
74ceac54ef Update NEWS and bump version for release 2013-01-24 05:42:44 -08:00
Dan Nicholson
3da597804f Fix srcdir != builddir error in check-debug
Another fix for the fragile check-debug test where a message about
adding to the pkg-config path expected '.' to be the srcdir.
2013-01-23 11:11:21 -08:00
Dan Nicholson
8b7489a36f Remove $host-pkg-config when uninstalling
Fixes an error from distcheck about files left in the destdir after
uninstalling.
2013-01-23 11:09:56 -08:00
Dan Nicholson
1694230365 Merge branch 'flag-order-fixes' 2013-01-22 05:11:59 -08:00
Dan Nicholson
7867cbd79c Use the standard pkg-config macros to check for glib
By using our PKG_CHECK_MODULES from our in-tree pkg.m4, the check for
glib will be done the same way pkg-config is used everywhere else. This
includes the usage of AC_PATH_TOOL in PKG_PROG_PKG_CONFIG, which will
check for $host-pkg-config when --host is set during configure.

Freedesktop #59435 (https://bugs.freedesktop.org/show_bug.cgi?id=59435)
2013-01-17 05:39:00 -08:00
Dan Nicholson
ae2fef2c05 Greatly simplify circular Requires checking
Instead of keeping of list of packages in the current Requires chain and
searching it repeatedly, just mark each package as part of the chain or
not. This nearly cuts in half the time on a particularly rough torture
test I have.
2013-01-16 16:42:48 -08:00
Mike Frysinger
4dac402b18 Extend default system library path for libdirs other than lib64
When the basename of the libdir is lib64, we currently add the paths
/usr/lib64:/lib64 to the generic system library path of /usr/lib:/lib.
Extend this coverage to other valid ABIs that use libdirs such as lib32
or libx32.
2012-12-19 07:30:49 -08:00
Dan Nicholson
72e1346d04 Add root /lib* directories to the default -L paths
Avoids outputting -L/lib, which the linker will search in implicitly
like -L/usr/lib.

Freedesktop #58363 (https://bugs.freedesktop.org/show_bug.cgi?id=58363)
2012-12-19 07:20:05 -08:00
David Michael
5b463c927b Include PKG_CHECK_VAR macro for reading variables in .pc files
Freedesktop #48098 (https://bugs.freedesktop.org/show_bug.cgi?id=48098)
2012-12-14 14:13:41 -08:00
Dan Nicholson
86c45f0422 Fix handling of --print/silence-errors for all output options
The intention was that errors would be printed for all output options
besides --exists and --atleast/exact/max-version, which are intended to
operate silently. Since want_exists is always set for these latter
options, we can simply use that as the condition and catch all other
output options automatically.

Freedesktop #54390 (https://bugs.freedesktop.org/show_bug.cgi?id=54390)
2012-12-11 12:00:26 -08:00
Dan Nicholson
9cd35c624f Enforce that only the first --atleast/exact/max-version option honored
This provides the user with output matching the behavior of the code.
When multiple --atleast/exact/max-version options are supplied, only the
first will be honored.
2012-12-11 11:59:40 -08:00
Dan Nicholson
548ba5b223 Imply --exists when --atleast/exact/max-version passed
The --atleast/exact/max-version help description implied that it would
return as --exists does. However, this would only occur if no other
output options were set.

Freedesktop #54389 (https://bugs.freedesktop.org/show_bug.cgi?id=54389)
2012-12-11 11:59:40 -08:00
Dan Nicholson
ec11c93ef8 Explicitly set --exists as the default option
This happened basically by accident before when "pkg-config foo" was run
because the code wouldn't find any options set and just fall through to
the end after processing the package arguments. However, it would act
differently in that Requires.private was only enabled with an explicit
--exists.
2012-12-11 11:59:40 -08:00
Dan Nicholson
d1b7dd42d1 Enforce exclusive output options
Currently, any output option (e.g., --version or --libs) will be set as
valid and what's output is at the mercy of the order of the output
handling code in main(). However, most combinations of output would make
no sense to be used together. For example, mixing --modversion and
--print-provides provides no way to differentiate between the output
from the options. Further, mixing --variable and --cflags currently
causes an error because there's no space separating the option outputs.

Instead, keep track of when an output option has been set and ignore
subsequent output options. There are currently two exceptions:

1. Any combination of --cflags* and --libs* are allowed.

2. Both --print-requires and --print-requires-private can be used
   together as the user may just not care which is private.

Freedesktop #54391 (https://bugs.freedesktop.org/show_bug.cgi?id=54391)
2012-12-11 11:59:40 -08:00
Dan Nicholson
469a3d6366 Use flags for --cflags/--libs options
With the output options gathered in a callback, we can be more clever
with the --cflags/--libs options and set the flags mask straight off
without using the intermediate booleans.
2012-12-11 11:59:40 -08:00
Dan Nicholson
d65b2e58d0 Handle output mode options in callback
This will provide one function to handle all the various options the
user could supply sanely.
2012-12-11 11:59:40 -08:00
Dan Nicholson
1b47b03c2a Convert ints used as bools to gbooleans
This matches the GOption documentation that G_OPTION_ARG_NONE should use
a gboolean.
2012-12-11 11:59:40 -08:00
Dan Nicholson
30e7f31318 Split out package processing to separate function to cleanup main
The code handling processing of the packages from the command line was
in an awkward block in main. Split it out to a separate function to keep
main mostly about output.
2012-12-11 11:59:40 -08:00
Dan Nicholson
a15bb1e72e Cleanup local variable declarations
Having the option entries within main and requiring the option variables
to be static is just wrong. Just declare them at file scope like every
other program does.
2012-12-11 11:59:40 -08:00
Dan Nicholson
cd2520a004 Fix hardcoded version if check-debug 2012-12-11 11:58:57 -08:00
Dan Nicholson
454dd17b30 Update README.win32 to reflect current pkg-config behavior
Freedesktop #54427 (https://bugs.freedesktop.org/show_bug.cgi?id=54427)
2012-12-08 19:57:17 -08:00
Dan Nicholson
30245b2a89 Document PKG*INSTALLDIR autoconf macros in manpage
Freedesktop #54463 (https://bugs.freedesktop.org/show_bug.cgi?id=54463)
2012-12-08 12:37:12 -08:00
Michał Sawicz
69beecddb5 Allow ~ through unescaped
freedesktop #57078 (https://bugs.freedesktop.org/show_bug.cgi?id=57078)
2012-12-08 12:11:55 -08:00
Dan Nicholson
9adfd9ebfc Only strip duplicate arguments when they appear consecutively
pkg-config strips all duplicate arguments from the flag output string.
This is done for 2 reasons:

1. When a package shows up twice in the final package list after
resolving all Requires, stripping was used to ensure it's flags only
showed up once at the correct location.

2. An optimization so that the output string is not excessively long.

Since commit c6ec7869, 1. is no longer necessary as the final package
list only contains each package once. 2. causes problems when applied
too aggressively since some arguments have different semantics depending
on the prior or subsequent arguments.

To keep a bit of optimization, the stripping is reduced to only removing
consecutive duplicate arguments. This should ensure that the semantics
are kept intact while removing obviously unnecessary arguments.

The drawback is that some arguments will now appear multiple times in
the output when they previously would have only appeared once. Here we
have to rely on the tools using these arguments to handle the duplicates
appropriately since there is no way for pkg-config to encode all the
semantics of those arguments. Another thing that can help this situation
is if pkg-config is used for all packages in the Requires chain so that
the Libs/Cflags of each package only pertain to itself and don't encode
the compiling/linking rules of a 3rd party package.

Freedesktop #16101 (https://bugs.freedesktop.org/show_bug.cgi?id=16101)
2012-12-04 13:04:57 -08:00
Dan Nicholson
5b6ec1b6e9 Output -l and other Libs flags in the order they appear
Often other Libs flags have semantics that are based on their context
with -l arguments. For example, the GNU linker options
-Bdynamic/-Bstatic pertain only to the objects or link options that
follow them. So, a valid link command containing these options would get
mangled by pkg-config since it separates -l flags from others..

-Bdynamic -la -Bstatic -lb -> -Bdynamic -Bstatic -la -lb

Instead, output -l and other Libs flags in a single pass so they mantain
their ordering.

Freedesktop #19950 (https://bugs.freedesktop.org/show_bug.cgi?id=19950)
2012-12-04 13:04:57 -08:00
Dan Nicholson
9bf6277b9c Keep Libs and Cflags together to maintain ordering
Instead of splitting to -l/-L/other and -I/other, keep the args together
and mark each argument with its type. Then we can maintain order all the
way through.
2012-12-04 13:04:57 -08:00
Dan Nicholson
05f319d3e5 Output -L Libs flags before other Libs flags
Outputting other Libs flags such as -Wl,foo just prior to the -l Libs
flags gives a better chance the --libs output will be correct. This
should be no change in the usage of the output since pkg-config
currently groups all flag types together.
2012-12-04 13:04:57 -08:00
Dan Nicholson
28c6468405 Pass around flags types instead of function pointers
This makes the code uglier in the short term, but prepares for using
merged lists of Cflags and Libs in one go.
2012-12-04 13:04:57 -08:00
Dan Nicholson
75a95f6f8b Limit merging of packages and flags to path or dependency order
Unify the get_multi_merged functions since there are only two valid ways
to do the merging of packages and flags.

1. Packages are sorted by their position in the pkg-config path and then
   duplicate flags are stripped from the beginning of the list. This
   pertains to -I and -L flags.

2. Packages are sorted by dependency with most required last and then
   duplicate flags are stripped from the end of the list. This ensures
   that flags that come from packages required by multiple others come
   later in the output. This applies to all non-L/I flags.
2012-12-04 13:04:57 -08:00
Dan Nicholson
8f354125d1 Unify string list stripping functions and operate on list in place
There were two string list stripping functions, when the only difference
was to operate from the beginning or end of the list. Also, the function
was copying the list and operating on that unnecessarily.
2012-12-04 13:04:57 -08:00