• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

AUTHORSH A D03-May-20221.5 KiB4241

README.mdH A D03-May-20226 KiB142100

README.md

1# pkgconf [![test](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml/badge.svg)](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml)
2
3`pkgconf` is a program which helps to configure compiler and linker flags for
4development libraries.  It is similar to pkg-config from freedesktop.org.
5
6`libpkgconf` is a library which provides access to most of `pkgconf`'s functionality, to allow
7other tooling such as compilers and IDEs to discover and use libraries configured by
8pkgconf.
9
10## using `pkgconf` with autotools
11
12Implementations of pkg-config, such as pkgconf, are typically used with the
13PKG_CHECK_MODULES autoconf macro.  As far as we know, pkgconf is
14compatible with all known variations of this macro. pkgconf detects at
15runtime whether or not it was started as 'pkg-config', and if so, attempts
16to set program options such that its behaviour is similar.
17
18In terms of the autoconf macro, it is possible to specify the PKG_CONFIG
19environment variable, so that you can test pkgconf without overwriting your
20pkg-config binary.  Some other build systems may also respect the PKG_CONFIG
21environment variable.
22
23To set the environment variable on the bourne shell and clones (i.e. bash), you
24can run:
25
26    $ export PKG_CONFIG=/usr/bin/pkgconf
27
28## comparison of `pkgconf` and `pkg-config` dependency resolvers
29
30pkgconf builds an acyclic directed dependency graph.  This allows for the user
31to more conservatively link their binaries -- which may be helpful in some
32environments, such as when prelink(1) is being used.  As a result of building
33a directed dependency graph designed for the specific problem domain provided
34by the user, more accurate dependencies can be determined.
35
36Current release versions of pkg-config, on the other hand, build a database of all
37known pkg-config files on the system before attempting to resolve dependencies, which
38is a considerably slower and less efficient design.  Efforts have been made recently
39to improve this behaviour.
40
41As of the 1.1 series, pkgconf also fully implements support for `Provides` rules,
42while pkg-config does not.  pkg-config only provides the `--print-provides` functionality
43as a stub.  There are other intentional implementation differences in pkgconf's dependency
44resolver verses pkg-config's dependency resolver in terms of completeness and correctness,
45such as, for example, how `Conflicts` rules are processed.
46
47## linker flags optimization
48
49As previously mentioned, pkgconf makes optimizations to the linker flags in both the
50case of static and shared linking in order to avoid overlinking binaries and also
51simplifies the `CFLAGS` and `LIBS` output of the pkgconf tool for improved readability.
52
53This functionality depends on the pkg-config module properly declaring it's dependency
54tree instead of using `Libs` and `Cflags` fields to directly link against other modules
55which have pkg-config metadata files installed.
56
57Doing so is discouraged by the [freedesktop tutorial][fd-tut] anyway.
58
59   [fd-tut]: http://people.freedesktop.org/~dbn/pkg-config-guide.html
60
61## compatibility with pkg-config
62
63I really hate that I have to have this section, I like being a nice person, but we
64unfortunately have to say this because otherwise we get passive-aggressive people who
65try to argue with us about what pkg-config compatibility means.
66
67We do not provide bug-level compatibility with pkg-config.
68
69What that means is, if you feel that there is a legitimate regression versus pkg-config,
70do let us know, but also make sure that the .pc files are valid and follow the rules of
71the [pkg-config tutorial][fd-tut], as most likely fixing them to follow the specified
72rules will solve the problem.
73
74Additionally, **we do not consider pkgconf doing what you tell it to do, when pkg-config
75fails to do so, to be a bug**.
76
77If, for example, you use environment variables such as `PKG_CONFIG_SYSTEM_[INCLUDE|LIBRARY]_PATH`
78and then find yourself surprised that `pkgconf` is stripping `-I` and `-L` flags relating
79to those paths, it's not a `pkgconf` problem -- `pkgconf` is doing exactly what you told
80it to do.
81
82We will reject bugs like this, and if you choose to violate our [Code of Conduct](CODE_OF_CONDUCT.md)
83by demanding we fix your non-bug, we will fix the problem by banning you from the repo instead.
84
85## compiling `pkgconf` and `libpkgconf` on UNIX
86
87pkgconf is basically compiled the same way any other autotools-based project is
88compiled:
89
90    $ ./configure
91    $ make
92    $ sudo make install
93
94If you are installing pkgconf into a custom prefix, such as `/opt/pkgconf`, you will
95likely want to define the default system includedir and libdir for your toolchain.
96To do this, use the `--with-system-includedir` and `--with-system-libdir` configure
97flags like so:
98
99    $ ./configure \
100         --prefix=/opt/pkgconf \
101         --with-system-libdir=/lib:/usr/lib \
102         --with-system-includedir=/usr/include
103    $ make
104    $ sudo make install
105
106## compiling `pkgconf` and `libpkgconf` with CMake (usually for Windows)
107
108pkgconf is compiled using CMake on Windows.  In theory, you could also use CMake to build
109on UNIX, but this is not recommended at this time as it pkgconf is typically built much earlier
110than CMake.
111
112    $ mkdir build
113    $ cd build
114    $ cmake ..
115    $ make
116    $ sudo make install
117
118There are a few defines such as SYSTEM_LIBDIR, PKGCONFIGDIR and SYSTEM_INCLUDEDIR.
119However, on Windows, the default PKGCONFIGDIR value is usually overridden at runtime based
120on path relocation.
121
122## pkg-config symlink
123
124If you want pkgconf to be used when you invoke `pkg-config`, you should install a
125symlink for this.  We do not do this for you, as we believe it is better for vendors
126to make this determination themselves.
127
128    $ ln -sf pkgconf /usr/bin/pkg-config
129
130## release tarballs
131
132Release tarballs are available at <https://distfiles.dereferenced.org/pkgconf/>.
133Please only use the tarballs from distfiles.dereferenced.org.
134
135## contacts
136
137You can report bugs at <https://github.com/pkgconf/pkgconf/issues>.
138
139There is a mailing list at <https://lists.sr.ht/~kaniini/pkgconf>.
140
141You can contact us via IRC at `#pkgconf` at `irc.oftc.net`.
142