Commit graph

59 commits

Author SHA1 Message Date
Dan Nicholson
2dd2b19944 parse: Don't emit unknown keyword warning for Libs.private
Requires.private and Libs.private are skipped unless --static is in use.
However, the parser was checking for Libs.private and this option in a
single conditional unlike Requires.private. This was making the check
fall through to the else and emit an "Unknown keyword" debug message
when --static was not used. This was harmless but not true.

https://bugs.freedesktop.org/show_bug.cgi?id=99770
2017-04-07 09:17:28 -05:00
Dan Nicholson
d5d8074893 Respect sysroot for -isystem and -idirafter
Treat -isystem and -idirafter as -I Cflags since they control the
compiler search path. Adjust the sysroot handling so that the arguments
to these options have the sysroot prefixed. However, leave them out of the
system Cflags handling since these directives are explicitly trying to
adjust the compiler's system header search behavior.

The special-flags test case output needs adjustment since all the flags
are now considered -I flags and come out in the order specified in the
pc file.

https://bugs.freedesktop.org/show_bug.cgi?id=97337
2017-03-20 07:13:23 -05:00
Dan Nicholson
bbbdab4c60 Don't override empty prefix setting
If the original prefix setting is empty, skip prepending the redefined
prefix to other variables. This works the same as if the pc file doesn't
have a prefix variable at all.

https://bugs.freedesktop.org/show_bug.cgi?id=97453-empty
2016-08-30 09:41:54 -07:00
Dan Nicholson
1c564a3583 Only unquote --variable when it appears quoted
The change to unquote values in the --variable output broke users that
had shell special characters in the variable. Instead, only unquote if
the value starts with " or '. A larger fix to do a full unquote, split
and escaping like --cflags/--libs is possible, but that might break the
old semantics even further.

Add a new function, parse_package_variable(), to handle that logic.

https://bugs.freedesktop.org/show_bug.cgi?id=93284
2016-02-26 08:56:52 -08:00
Dan Nicholson
8d19fad1a0 Also match -Wl,-framework for OSX framework
Freedesktop #1278 (https://bugs.freedesktop.org/show_bug.cgi?id=1278)
2016-01-29 14:44:34 -08:00
Alexander Larsson
9ef2d3475d Pass key into parse_package_key so it can be set early
We will need this to properly pick up environment-overridden
per-package vairables.

https://bugs.freedesktop.org/show_bug.cgi?id=90917
2016-01-29 14:25:21 -08:00
Dan Nicholson
9294307b21 Handle pcfiledir variable like normal variable
Rather than responding to the pcfiledir variable specially, store it
in the hash table with all the other package specific variables. This
does result in pcfiledir showing up in the --print-variables output.
2014-12-09 05:24:43 -08:00
Dan Nicholson
abdbaba3e0 Ensure -isystem Cflags not compressed like -I
Treat -isystem specially like -idirafter so that multiple arguments
retain the preceding -isystem.

Freedesktop #72584 (https://bugs.freedesktop.org/show_bug.cgi?id=72584)
2013-12-14 10:47:56 -08:00
Dan Nicholson
715cc306b0 Allow errors in .pc files for --list-all
Normally, the parser will exit immediately when it encounters errors in
.pc files. This is good most of the time, but for --list-all, the
purpose is to just get a quick list of packages and not to validate .pc
files. This is especially the case for pkg-config wrappers such as the
Ruby or Bash completion modules that scrape the output from --list-all
and don't expect to encounter errors there.

Freedesktop #26615 (https://bugs.freedesktop.org/show_bug.cgi?id=26615)
2013-05-17 05:53:13 -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
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
1694230365 Merge branch 'flag-order-fixes' 2013-01-22 05:11:59 -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
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
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
e8086bc54f Convert to doubly-linked GList
Using a doubly-linked list allows it to be easily traversed in both
directions and makes removing nodes in place much simpler. This adds an
extra pointer to each node and associated manipulation during any list
processing, but this trade seems acceptable over the repeated hacks to
work with singly-linked lists.
2012-12-03 07:02:27 -08:00
Dan Nicholson
3f1f6e79b7 Delay converting Requires entries to Packages until after parsing
When the parser encounters Requires or Requires.private, it immediately
tries to sees if we have a parsed package for that entry. If not it
tries to locate the needed file and parse it out. If there's a circular
dependency, this will eventually error opening too many files.

Instead, just store the requires entries so the parsing completes and
the package is added to the database. After parsing, the entries can be
resolved into Packages and any circular requires entries will find the
first package in the database.

This is a partial fix for Freedesktop #7331.
2012-10-13 08:14:35 -07:00
John Stumpo
f57fafe1d1 Escape spaces in autodetected ${prefix} values on Windows
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.
2012-08-21 05:49:07 -07:00
Dan Nicholson
02d99c6ab1 Use glib to parse argv strings instead of popt
Glib's g_shell_parse_argv offers basically a 1:1 replacement for
poptParseArgvString except that you have to free all the elements of
the array explicitly.
2012-05-14 14:19:10 -07:00
Tollef Fog Heen
7c45ef3c84 Drop dead code 2011-05-15 11:05:42 +02:00
Tollef Fog Heen
1b1bd80f5f Allow $() through unescaped.
$(foo) is used for make escapes, so allow them through.

Freedesktop #33920
2011-04-13 22:02:51 +02:00
Hauke Fath
5764fbe873 Fix C99-ism
Old NetBSD versions don't have a C99 compiler, so get rid a C99ism for
their benefit.
2011-04-13 20:29:22 +02:00
Tollef Fog Heen
03bd4a5528 Drop support for legacy -config scripts
We used to call gnome-config, gtk-config, glib-config and so on, which
was useful in the beginning of pkg-config.  This hasn't served any
practical purpose in recent years, so drop the support.
2010-09-01 20:48:57 +02:00
Dan Nicholson
6a27c57057 Handle empty valued fields with newer external popt
The bundled popt handled the case of Cflags or Libs with no value, but
newer popt linked through --with-installed-popt chokes parsing it into
a vector. This is arguably a popt bug in poptParseArgvString, but I
guess they expect you not to ask it to split an empty string.
2010-05-27 22:23:19 +02:00
Tollef Fog Heen
2ce485c65d Allow : and = unescaped in output too 2010-05-27 21:48:52 +02:00
Tollef Fog Heen
69a7eaa676 Make it possible to escape paths containing special shell characters
Allow paths and other components to contain shell metacharacters, but
escape them on output.  White space has to be escaped in the input
files using quotes or backslashes

Freedesktop.org #3571
2010-05-23 23:11:40 +02:00
Dan Nicholson
aa4634eb31 Move popt to subdirectory and make a convenience library of it
This keeps a cleaner separation of the pkg-config sources and the
imported popt sources.
2010-05-09 10:22:02 +02:00
Tollef Fog Heen
c5a3105f41 Handle -idirafter specially
Don't split -idirafter from its argument.

Fixes Freedesktop #23480
2010-05-09 09:43:10 +02:00
Tollef Fog Heen
39663612a6 2009-06-12 Tor Lillqvist <tml@iki.fi>
* parse.c: On Win32, if the value of a a variable other than the
	"prefix" one starts with the non-overridden value of "prefix",
	then replace that prefix, too, with the run-time one.

	To avoid shadowing warnings, rename a 'p' variable to 'q'.

	* pkg-config.1: Corresponding update.

	* main.c
	* pkg.h: Move the Win32 redefinition of PKG_CONFIG_PC_PATH from
	main.c to pkg.h as it now is needed in pkg.c, too.
2009-06-30 03:47:01 +02:00
Tollef Fog Heen
02d5ae3fb6 2009-03-30 Tollef Fog Heen <tfheen@err.no>
* pkg.[ch], parse.[ch], main.c, check/Makefile.am,
	check/check-missing, check/missing-requires-private.pc:
	Skip Requires.private unless we need to look at them for cflags.
	Add test case.  Thanks to Loïc Minier for most of the idea and the
	implementation.  Debian #475031
2009-03-30 20:40:53 +02:00
Tollef Fog Heen
6d2f77a219 2008-04-28 Tollef Fog Heen <tfheen@err.no>
* parse.c Add my name to the copyright header, mainly to prevent
	emacs from being stupid and updating RH's copyright year.
2008-04-28 21:25:51 +02:00
Tollef Fog Heen
d5d6a8f8a7 2008-04-28 Tollef Fog Heen <tfheen@err.no>
* parse.c (_do_parse_libs): Special-case "-lib:" in the Libs
	field; it's not an -l.  Yes, this breaks if your library is called
	libib:$something, in which case you lose.  Gnome #142952
2008-04-28 21:19:02 +02:00
Tollef Fog Heen
dce0339076 2008-02-19 Tor Lillqvist <tml@novell.com>
* main.c: Remove the possibility to have a default PKG_CONFIG_PATH
	in the Registry. It is much more flexible to just use environment
	variables. In general the Registry is not used in the ports of
	GTK+ or GNOME libraries and software to Windows.

	* parse.c (parse_line): On Windows, handle also .pc files found in
	a share/pkgconfig folder when automatically redefining a prefix
	variable for the package.

	* pkg-config.1: Corresponding changes.

2008-02-18  Tor Lillqvist  <tml@novell.com>

	* main.c: Fix some bitrot: On Windows, don't use the compile-time
	PKG_CONFIG_PC_PATH, but deduce a default one at run-time based on
	the location of the executable. This was originally what
	pkg-config did on Windows, but it had bit-rotted.
2008-03-23 20:00:00 +01:00
Tollef Fog Heen
a5c1a0d417 2007-05-30 Tor Lillqvist <tml@novell.com>
* parse.c: Fix problem on Win32 where the automagic prefix
	replacement logic didn't work. I don't know what change had 
	broken it.
	(pathnamecmp): New Win32-only function. Compares two file
	paths case insensitively and treating backslashes as equal to
	slashes.
	(parse_line): Use it instead of g_ascii_strcasecmp().
2007-05-30 13:24:42 +02:00
Tollef Fog Heen
b81987653f 2007-02-21 Tollef Fog Heen <tfheen@err.no>
* parse.c (parse_package_file and others): Move the reversal of
	the _libs lists to the end to avoid double-reversing either.
	Thanks to J. Scott Berg for both the bug and the fix.  Freedesktop
	#9132
2007-02-21 22:21:14 +01:00
Tollef Fog Heen
6d32cb3e6d 2006-08-16 Tollef Fog Heen <tfheen@err.no>
* parse.c (trim_and_sub): Since %{...} has not been used for a
	long time, there is no point in being able to escape %.  However,
	make the code able to escape $ by doubling the $ to $$.  
	Debian #378570
2006-08-16 20:47:14 +02:00
Arch Librarian
29afc67918 2005-06-27 Tollef Fog Heen <tfheen@err.no>
Author: tfheen
Date: 2005-06-27 19:53:05 GMT
2005-06-27  Tollef Fog Heen  <tfheen@err.no>

    All those Requires.private changes are thanks to James
    Henstridge.  Thanks!

    * check/private-dep.pc, check/public-dep.pc,
      check/requires-test.pc: New files, data for the
    check-requires-private test.

    * check/check-requires-private: New test to check for
    Requires.private support.

    * check/Makefile.am (EXTRA_DIST, TESTS): Add Requires.private
    test.

    * pkg.h (struct _Package): Add requires_private

    * pkg.c (get_requires_private, fill_list_single_package)
    (fill_list, verify_package, verify_package, get_merged)
    (get_merged_from_back, get_multi_merged)
    (get_multi_merged_from_back, package_get_l_libs)
    (packages_get_l_libs, package_get_L_libs, packages_get_L_libs)
    (package_get_other_libs, packages_get_other_libs)
    (package_get_I_cflags, packages_get_I_cflags)
    (package_get_other_cflags, packages_get_other_cflags): Handle
    private requires and cascading changes.

    * parse.c (parse_requires_private, parse_conflicts)
    (parse_package_file): Handle Requires.private
2005-07-14 13:07:31 +00:00
Arch Librarian
20d118d57a 2005-05-21 Tollef Fog Heen <tfheen@err.no>
Author: tfheen
Date: 2005-05-21 09:14:47 GMT
2005-05-21  Tollef Fog Heen  <tfheen@err.no>

    * check/check-libs-private: New test to check for support for
    private libraries.

    * check/simple.pc (prefix): Add Libs.private header.

    * check/Makefile.am (TESTS): Add check-libs-private test

    * pkg.h: Adjust function prototypes.

    * pkg.c: Add global ignore_private_libs variable.
    (scan_dir): Use the correct free function.  Stop leaking file
    descriptors.
    (package_get_l_libs, packages_get_l_libs, package_get_L_libs,
    packages_get_L_libs): Stop the recursive silliness and go back to
    old behaviour.
    (packages_get_all_libs): Adjust parameters to packages_get_*_libs
    (enable_private_libs, disable_private_libs): Trivial helper
    functions.

    * pkg-config.1: Update documentation wrt search path (Debian
    #308942), update docs for Libs.private and add the problematic
    handling of mixing = and non-= arguments to the bugs section.

    * parse.h: Adjust parameters for parse_package_file to get private
    libs or not.

    * parse.c (trim_and_sub): Fix memory leak.
    (_do_parse_libs): New function including what's common between
    parse_libs and parse_private_libs.
    (parse_libs_private): New function.  Handle private libraries.
    (parse_line): Add . to the list of valid characters in headers (so
    Libs.private works correctly.
    (parse_line): Fix memory leaks.
    (parse_line): Handle Libs.private.
    (parse_package_file): Fix memory leak.

    * main.c (main): Fix memory leak.

    * NEWS: Document changes to inter-library handling.

    * main.c (main): Handle inter-library dependencies old-style, but
    do private libraries too.  Adjust parameters to
    packages_get_*_libs.

    * configure.in: Change comment wrt inter-library handling to talk
    about private libraries instead.
2005-07-14 13:07:18 +00:00
Arch Librarian
650d0a6ab6 2005-04-02 Tollef Fog Heen <tfheen@err.no>
Author: tfheen
Date: 2005-04-02 09:06:39 GMT
 2005-04-02  Tollef Fog Heen  <tfheen@err.no>

       * parse.c (parse_libs): Handle -framework as a single argument.
       (Freedesktop #1278)
2005-07-14 13:06:47 +00:00
Arch Librarian
03723d4caa 2005-03-18 Tollef Fog Heen <tfheen@debian.org>
Author: tfheen
Date: 2005-03-22 08:54:08 GMT
2005-03-18  Tollef Fog Heen  <tfheen@debian.org>

       * pkg.c (print_package_list): Ignore requires when just listing
       the available packages.
       (internal_get_package): Pass ignore_requires on.

       * parse.h: update prototype for parse_package_file.

       * parse.c (parse_line): Ignore Requires when told so.
       (parse_package_file): Pass ingore_requires on to parse_line.

       (Freedesktop #191, Debian #232719)
2005-07-14 13:06:19 +00:00
Arch Librarian
77d6ced01e 2005-02-21 Tollef Fog Heen <tfheen@err.no>
Author: tfheen
Date: 2005-02-21 08:09:28 GMT
2005-02-21  Tollef Fog Heen  <tfheen@err.no>

	* parse.c (parse_package_file): Stop leaking file descriptors.
	(Freedesktop #1006)
2005-07-14 13:06:15 +00:00
Arch Librarian
7d74866d21 2003-04-30 James Henstridge <james@daa.com.au>
Author: jamesh
Date: 2003-05-01 01:14:30 GMT
2003-04-30  James Henstridge  <james@daa.com.au>

        * pkg.c (verify_package): fix up error messages.

        * parse.c (parse_line): don't error out on unknown keywords, as
        they may represent future extensions to the file format.
2005-07-14 13:05:55 +00:00
Arch Librarian
7207c289d8 2003-02-15 Havoc Pennington <hp@pobox.com>
Author: hp
Date: 2003-02-15 15:04:07 GMT
2003-02-15  Havoc Pennington  <hp@pobox.com>

	Fixes suggested by Werner Trobin

	* main.c (verbose_error): honor --errors-to-stdout and flush
	the same stream we write to

	* parse.c (parse_url): support an "url" field so if someone
	has a .pc file they can figure out where to go for newer
	versions and such
2005-07-14 13:05:41 +00:00
Arch Librarian
e27a94dda9 2002-09-26 Tor Lillqvist <tml@iki.fi>
Author: tml
Date: 2002-09-26 17:25:41 GMT
2002-09-26  Tor Lillqvist  <tml@iki.fi>

	* parse.c (get_compat_package): Return NULL right away on
	Windows. There has never been any of these legacy *-config scripts
	distributed for Windows as far as I know.
2005-07-14 13:05:27 +00:00
Arch Librarian
fcb804effe 2002-09-06 Havoc Pennington <hp@redhat.com>
Author: hp
Date: 2002-09-06 20:00:08 GMT
2002-09-06  Havoc Pennington  <hp@redhat.com>

	* parse.c, pkg.c: handle other_libs other_cflags same
	as -l/-L/-I flags, so we pull in from dependent packages.
	Closes #85244, #90706, #89851
2005-07-14 13:05:17 +00:00
Arch Librarian
e3b14fd5e8 add copyright notices to files
Author: hp
Date: 2002-09-06 19:32:18 GMT
add copyright notices to files
2005-07-14 13:05:14 +00:00