summaryrefslogtreecommitdiff
path: root/main.c
Commit message (Collapse)AuthorAgeFilesLines
* Call setlocale in main functionTing-Wei Lan2019-06-231-0/+6
| | | | | | If setlocale isn't called, GNU gettext will try to convert translated text to ASCII because the default locale is C. It isn't always possible and it causes question marks to be shown on FreeBSD.
* Optimization to load only needed .pc filesMarco Diego Aurélio Mesquita2016-12-221-1/+1
| | | | | | | | | | | | Currently pkg-config scans all .pc files from the search path during initialization. That makes some of the code simpler and works fine when there are not many .pc files on the system. When there are a lot of .pc files, then this represents a lot of wasted effort. Rework the package gathering so that it happens as needed. To support the --list-all mode, the scanning at initialization can still be done. https://bugs.freedesktop.org/show_bug.cgi?id=98215
* Sort --print-variables outputDan Nicholson2015-02-211-7/+10
| | | | | | | Makes the output consistent regardless of how glib puts together the variables hash table. https://bugs.freedesktop.org/show_bug.cgi?id=66939
* Add --validate option to check .pc syntax without dependenciesDan Nicholson2014-09-271-2/+9
| | | | | | | | | Provide developers a way to check their .pc files prior to release. This works the same as --exists except that package dependencies are not processed. That allows the .pc file to be checked in complete isolation of others. Freedesktop #7000 (https://bugs.freedesktop.org/show_bug.cgi?id=7000)
* Allow errors in .pc files for --list-allDan Nicholson2013-05-171-0/+4
| | | | | | | | | | | 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)
* Silence errors by default with --list-allDan Nicholson2013-05-171-15/+16
| | | | | | | When listing all packages, the purpose is to get a quick look at what's installed and not to scrutinize the validity of each .pc file. To see errors from the parser during --list-all, the user can just add --print-errors.
* Make the --define-prefix feature available on all platformsDan Nicholson2013-05-171-1/+1
| | | | | | | | 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)
* Allow more control of redefined prefix behaviorDan Nicholson2013-05-171-3/+7
| | | | | | | | | | | 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.
* Flush stderr when not immediately exitingDan Nicholson2013-04-091-0/+2
| | | | | | | 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.
* Fix handling of --print/silence-errors for all output optionsDan Nicholson2012-12-111-20/+16
| | | | | | | | | | 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)
* Enforce that only the first --atleast/exact/max-version option honoredDan Nicholson2012-12-111-1/+6
| | | | | | 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.
* Imply --exists when --atleast/exact/max-version passedDan Nicholson2012-12-111-3/+25
| | | | | | | | 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)
* Explicitly set --exists as the default optionDan Nicholson2012-12-111-0/+7
| | | | | | | | 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.
* Enforce exclusive output optionsDan Nicholson2012-12-111-0/+31
| | | | | | | | | | | | | | | | | | | | 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)
* Use flags for --cflags/--libs optionsDan Nicholson2012-12-111-47/+19
| | | | | | 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.
* Handle output mode options in callbackDan Nicholson2012-12-111-31/+77
| | | | | This will provide one function to handle all the various options the user could supply sanely.
* Convert ints used as bools to gbooleansDan Nicholson2012-12-111-22/+22
| | | | | This matches the GOption documentation that G_OPTION_ARG_NONE should use a gboolean.
* Split out package processing to separate function to cleanup mainDan Nicholson2012-12-111-99/+89
| | | | | | 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.
* Cleanup local variable declarationsDan Nicholson2012-12-111-100/+101
| | | | | | 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.
* Convert to doubly-linked GListDan Nicholson2012-12-031-25/+25
| | | | | | | | 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.
* Allow all combinations of --cflags and --libs variantsDan Nicholson2012-11-031-46/+19
| | | | | | | | | Use a bitmask to keep track of what Libs/Cflags to output. This makes it simple to handle any combination of --cflags and --libs option variants. A lot of excess code is removed in the process as all the flags options can now be carried around in a single variable. Freedesktop #54388 (https://bugs.freedesktop.org/show_bug.cgi?id=54388)
* Move --print-variables handling after --exists for consistencyDan Nicholson2012-10-301-16/+15
| | | | | | | | | The --print-variables output is inconsistent with other printing options when --exists is supplied or not. Move the handling after --exists like --print-requires and others requiring a valid package list so that --exists is given it takes priority and exits early. Freedesktop #54384 (https://bugs.freedesktop.org/show_bug.cgi?id=54384)
* Don't crash on --print-variables when there are no variablesDan Nicholson2012-10-131-3/+4
| | | | | | | | Apparently g_hash_table_foreach doesn't check for NULL input, so make sure we don't call it to print the variables if the variable list is empty. Freedesktop #54721
* Enable Requires and Requires.private for --existsDan Nicholson2012-07-111-2/+3
| | | | | | | | | | 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
* Always use g_free when allocating memory from glibDan Nicholson2012-05-291-3/+3
|
* Don't use deprecated glib function to construct path on win32LRN2012-05-211-1/+42
| | | | | | | | | | | | | | 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
* Kill unused result variableDan Nicholson2012-05-181-1/+0
| | | | Gets rid of a compiler warning.
* Convert to GOption for command line option parsingDan Nicholson2012-05-141-114/+102
| | | | | | | | | | | | | | | | | | Use glib's GOption instead of popt for command line option handling. The APIs and output are very similar. A couple minor differences are: * The callback for handling --define-variable is associated only with that option where popt was just leaving the argument and then it was handled in a generic callback. * Remaining arguments after option parsing are in argc/argv while they are collected through poptGetArg with popt. * GOption does not provide the short --usage summary. This also works around bugs in the command line option handling with the ancient internal popt.
* Unify handling of operator and command line option version checkingDan Nicholson2012-05-101-28/+20
| | | | | | | | | | The code for --exact/atleast/max-version was taking a different path than the handling of operators like =/>=/<=. Make the long option versions override the operators and take place during the standard package checking stage. This also means that --print-errors is respected. Fixes Freedesktop #8653
* Revert "Print out \r\n on windows, not just \n"Dieter Verfaillie2012-05-051-4/+0
| | | | | | | This reverts commit 25e8ca84acd7fc604fbc59213587887d5119d51a. This was working around a bug with mingw/msys shell which seems to be fixed now. Freedesktop #17053
* Drop dead codeTollef Fog Heen2011-05-151-5/+0
|
* Add --print-provides and --print-requires(-private) optionsJohannes Schmid2010-05-101-1/+79
| | | | | These are useful for applications that need to query the pkg-config database, e.g. managers or IDEs.
* Move popt to subdirectory and make a convenience library of itDan Nicholson2010-05-091-1/+1
| | | | | This keeps a cleaner separation of the pkg-config sources and the imported popt sources.
* Add listing of variablesJorn Amundsen2010-05-091-1/+30
| | | | Fixes Freedesktop #133
* Print out \r\n on windows, not just \nTollef Fog Heen2009-12-061-0/+4
| | | | This should hopefully fix bug #17053
* Fix up help for --silence-errorsTollef Fog Heen2009-12-061-2/+4
| | | | Bug #8616
* Reduce the width of argumentsTollef Fog Heen2009-12-061-2/+2
| | | | This makes the --help output flow easier and look better.
* 2009-06-12 Tor Lillqvist <tml@iki.fi>Tollef Fog Heen2009-06-301-11/+0
| | | | | | | | | | | | | | * 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-03-30 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2009-03-301-0/+6
| | | | | | * pkg.[ch], main.c, check/check-missing: Don't recurse Requires at all unless we need to. Add check. Again, thanks to Loïc Minier for most of the idea and the implementation.
* 2009-03-30 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2009-03-301-0/+7
| | | | | | | | * 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
* 2008-04-28 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2008-04-281-1/+1
| | | | | * main.c (main): Make sure log is initialized to prevent segfaults.
* 2008-03-23 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2008-03-231-1/+28
| | | | | * main.c (main): Add logging support from NetBSD. Thanks to Julio M. Merino Vidal for forwarding the patch from ages ago.
* 2008-02-19 Tor Lillqvist <tml@novell.com>Tollef Fog Heen2008-03-231-54/+7
| | | | | | | | | | | | | | | | | | | | * 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 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2008-03-231-20/+20
| | | | | | | | | * main.c (main): Fix small portability problem by defining all the variables in main that are used in the static initialiser as static variables. This makes the IRIX/mipseb compiler happier. Thanks to Roland Illig of NetBSD for the patch. This doesn't apply to some of the Win32 variables, but I don't believe that is a problem with the existing compilers there.
* 2008-01-16 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2008-01-161-0/+11
| | | | | | * pkg.h, pkg.c (string_list_to_string), pkg-config.1, main.c (main): Add sysroot support and document same. Triggered by setting PKG_CONFIG_SYSROOT_DIR in the environment.
* 2006-08-16 Tollef Fog Heen <tfheen@err.no>Tollef Fog Heen2006-08-161-6/+5
| | | | | * main.c (main): Always add the elements from PKG_CONFIG_PATH. Freedesktop #4795.
* Try to print out all the errors and not just the first.Tollef Fog Heen2005-10-161-2/+11
| | | | | | | 2005-10-16 Tollef Fog Heen <tfheen@err.no> * main.c (main): Try to print out all the errors and not just the first.
* Add --short-errorsTollef Fog Heen2005-10-161-1/+7
| | | | | | | | | | | | | | 2005-10-16 Tollef Fog Heen <tfheen@err.no> * pkg.c (get_package_quiet): Add get_package_quiet which is just the same as get_package except it sets warn to false. * pkg.h: Add prototype for get_package_quiet. * main.c (main): Add --short-errors flag to suppress most of the output when a module is not found.
* 2005-05-21 Tollef Fog Heen <tfheen@err.no>Arch Librarian2005-07-141-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-04-22 Tollef Fog Heen <tfheen@err.no>Arch Librarian2005-07-141-5/+12
| | | | | | | | | Author: tfheen Date: 2005-04-22 00:19:24 GMT 2005-04-22 Tollef Fog Heen <tfheen@err.no> * main.c (main): Re-add PKG_CONFIG_LIBDIR support which was removed by mistake.