Commit graph

40 commits

Author SHA1 Message Date
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
Arch Librarian
d192f98006 2002-02-01 Havoc Pennington <hp@redhat.com>
Author: hp
Date: 2002-02-01 22:24:24 GMT
2002-02-01  Havoc Pennington  <hp@redhat.com>

        Throughout: cast chars to guchar before passing to isspace, etc.,
	noted by Morten Welinder

	* pkg.c (verify_package): actually strip system -I/-L out of the
	cflags/libs, unless you set an environment variable asking to
	leave them in.
2005-07-14 13:04:51 +00:00
Arch Librarian
4722cb5782 2001-10-28 Havoc Pennington <hp@pobox.com>
Author: hp
Date: 2001-10-28 23:59:20 GMT
2001-10-28  Havoc Pennington  <hp@pobox.com>

	* pkg.c: track position of package in the path search order,
	and sort packages accordingly before assembling flags lists,
	reported by Jacob Berkman

	* parse.c (get_compat_package): set path position to maxint,
	always at end of path
2005-07-14 13:04:45 +00:00
Arch Librarian
b890f705eb 2001-10-27 Tor Lillqvist <tml@iki.fi>
Author: tml
Date: 2001-10-27 17:55:11 GMT
2001-10-27  Tor Lillqvist  <tml@iki.fi>

	New Win32 feature to make pkg-config useful for users of MSVC:
	with the flag --msvc-syntax, munge -L and -l flags appropriately
	for the MSVC command-line compiler. (-I flags are the same.)

	* README.win32: Update.

	* main.c (main): Add --msvc-syntax flag.

	* pkg-config.1: Document it.

	* pkg.h: Declare msvc_syntax.

	* parse.c (parse_libs): Obey msvc_syntax.
2005-07-14 13:04:41 +00:00
Arch Librarian
d86ec30f0a 2001-10-25 Tor Lillqvist <tml@iki.fi>
Author: tml
Date: 2001-10-24 21:22:33 GMT
2001-10-25  Tor Lillqvist  <tml@iki.fi>

	Improve Windows behaviour: Make it even easier to install
	developer packages in random locations, without having to modify
	the .pc files. Don't set "prefix" globally, instead override it
	for each .pc file parsed, if the path where the .pc file is seems
	to be the standard .../lib/pkgconfig.

	* main.c (main): Add search directories also from two Registry
	keys, in addition to the PKG_CONFIG_PATH environment
	variable. Don't define prefix globally.

	* parse.c (parse_line): Instead, if a .pc file is in
	/foo/bar/lib/pkgconfig, define prefix as /foo/bar for that package
	only.

	* pkg.c: Case-fold file names on Windows, in case they have been
	uppercasified by some tool.

	* pkg-config.1: Document Windows behaviour.
2005-07-14 13:04:37 +00:00
Arch Librarian
1aaee14cab 2001-09-30 Tor Lillqvist <tml@iki.fi>
Author: tml
Date: 2001-09-29 21:05:25 GMT
2001-09-30  Tor Lillqvist  <tml@iki.fi>

	Changes for "pure" Win32 (without Cygwin or similar)
	support. The most important differences compared to pkg-config
	on Unix are:

	We don't use hardcoded PKGLIBDIR paths but deduce the
	installation prefix at runtime.

	Use the normal GLib DLL, not a private copy. Yes, this does
	introduce a circular dependency, but that can be worked around.

	* README.win32: New file.

	* configure.in: Check for Win32. If so, define USE_INSTALLED_GLIB,
	and don't configure in the included glib-1.2.8. Set GLIB_CFLAGS
	and GLIB_LIBS assuming that GLib is installed in the same location
	pkgconfig will be. Check for dirent.h, unistd.h and sys/wait.h
	headers.

	* Makefile.am: If USE_INSTALLED_GLIB, use the GLIB_* values set
	above, and don't make in the glib-1.2.8 subdir.

	* autogen.sh: Use perl -p -i.bak, works better on Win32 (and Cygwin).

	* *.c: Conditionalize inclusions of unistd.h and sys/wait.h.

	* findme.c: Define X_OK on Win32 if necessary.

	* parse.c
	* popthelp.c: Minor Win32 portability ifdefs.

	* parse.c: No need to include <windows.h>.

	* pkg.c: Don't hardcode PKGLIBDIR, but use
	g_win32_get_package_installation_directory() to deduce it.
	(scan_dir): Make a temp copy of dirname with potential superfluous
	trailing slash removed. The Win32 opendir implementation doesn't
	always like those.

	* pkg.h: If USE_INSTALLED_GLIB, include <glib.h> instead of
	partial-glib.h.

	* popt.c (execCommand): Don't compile on Win32.

	* poptconfig.c (configLine): Don't bother with the "exec" stuff on
	Win32, too complex to port, at least for now.
	(poptReadDefaultConfig) Don't bother compiling on Win32, this
	function isn't even called.
2005-07-14 13:04:29 +00:00
Arch Librarian
41f8b289db no getc_unlocked
Author: hp
Date: 2001-07-10 23:16:26 GMT
no getc_unlocked
2005-07-14 13:04:21 +00:00
Arch Librarian
e7323695df 2001-07-11 Havoc Pennington <hp@pobox.com>
Author: hp
Date: 2001-07-10 22:51:39 GMT
2001-07-11  Havoc Pennington  <hp@pobox.com>

	* parse.c (parse_cflags): fix failure to put space between cflags,
	reported by Chema
	(parse_line): allow spelling Cflags as CFlags, pointed out by Tim
	(get_compat_package): support legacy script gnome-vfs-config for
	package name "libgnomevfs"
2005-07-14 13:04:19 +00:00
Arch Librarian
282c3b775f 2001-06-05 Havoc Pennington <hp@redhat.com>
Author: hp
Date: 2001-06-05 17:45:02 GMT
2001-06-05  Havoc Pennington  <hp@redhat.com>

	* parse.c: never use flockfile, getc_unlocked
2005-07-14 13:04:08 +00:00
Arch Librarian
2ac96cbcc7 import
Author: hp
Date: 2001-06-05 16:39:09 GMT
import
2005-07-14 13:04:01 +00:00