xref: /freebsd/contrib/pkgconf/README.md (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1*a3cefe7fSPierre Pronchery# pkgconf [![test](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml/badge.svg)](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml)
2*a3cefe7fSPierre Pronchery
3*a3cefe7fSPierre Pronchery`pkgconf` is a program which helps to configure compiler and linker flags for
4*a3cefe7fSPierre Proncherydevelopment libraries.  It is a superset of the functionality provided by
5*a3cefe7fSPierre Proncherypkg-config from freedesktop.org, but does not provide bug-compatibility with
6*a3cefe7fSPierre Proncherythe original pkg-config.
7*a3cefe7fSPierre Pronchery
8*a3cefe7fSPierre Pronchery`libpkgconf` is a library which provides access to most of `pkgconf`'s functionality,
9*a3cefe7fSPierre Proncheryto allow other tooling such as compilers and IDEs to discover and use libraries
10*a3cefe7fSPierre Proncheryconfigured by pkgconf.
11*a3cefe7fSPierre Pronchery
12*a3cefe7fSPierre Pronchery## release tarballs
13*a3cefe7fSPierre Pronchery
14*a3cefe7fSPierre ProncheryRelease tarballs are available on [distfiles.ariadne.space][distfiles].
15*a3cefe7fSPierre Pronchery
16*a3cefe7fSPierre Pronchery   [distfiles]: https://distfiles.ariadne.space/pkgconf/
17*a3cefe7fSPierre Pronchery
18*a3cefe7fSPierre Pronchery## build system setup
19*a3cefe7fSPierre Pronchery
20*a3cefe7fSPierre ProncheryIf you would like to use the git sources directly, or a snapshot of the
21*a3cefe7fSPierre Proncherysources from GitHub, you will need to regenerate the autotools build
22*a3cefe7fSPierre Proncherysystem artifacts yourself, or use Meson instead.  For example, on Alpine:
23*a3cefe7fSPierre Pronchery
24*a3cefe7fSPierre Pronchery    $ apk add autoconf automake libtool build-base
25*a3cefe7fSPierre Pronchery    $ sh ./autogen.sh
26*a3cefe7fSPierre Pronchery
27*a3cefe7fSPierre Pronchery## pkgconf-lite
28*a3cefe7fSPierre Pronchery
29*a3cefe7fSPierre ProncheryIf you only need the original pkg-config functionality, there is also pkgconf-lite,
30*a3cefe7fSPierre Proncherywhich builds the `pkgconf` frontend and relevant portions of `libpkgconf` functionality
31*a3cefe7fSPierre Proncheryinto a single binary:
32*a3cefe7fSPierre Pronchery
33*a3cefe7fSPierre Pronchery    $ make -f Makefile.lite
34*a3cefe7fSPierre Pronchery
35*a3cefe7fSPierre Pronchery## why `pkgconf` over original `pkg-config`?
36*a3cefe7fSPierre Pronchery
37*a3cefe7fSPierre Proncherypkgconf builds a flattened directed dependency graph, which allows for more insight
38*a3cefe7fSPierre Proncheryinto relationships between dependencies, allowing for some link-time dependency
39*a3cefe7fSPierre Proncheryoptimization, which allows for the user to more conservatively link their binaries,
40*a3cefe7fSPierre Proncherywhich may be helpful in some environments, such as when prelink(1) is being used.
41*a3cefe7fSPierre Pronchery
42*a3cefe7fSPierre ProncheryThe solver is also optimized to handle large dependency graphs with hundreds of
43*a3cefe7fSPierre Proncherythousands of edges, which can be seen in any project using the Abseil frameworks
44*a3cefe7fSPierre Proncheryfor example.
45*a3cefe7fSPierre Pronchery
46*a3cefe7fSPierre ProncheryIn addition, pkgconf has full support for virtual packages, while the original
47*a3cefe7fSPierre Proncherypkg-config does not, as well as fully supporting `Conflicts` at dependency
48*a3cefe7fSPierre Proncheryresolution time, which is more efficient than checking for `Conflicts` while
49*a3cefe7fSPierre Proncherywalking the dependency graph.
50*a3cefe7fSPierre Pronchery
51*a3cefe7fSPierre Pronchery## linker flags optimization
52*a3cefe7fSPierre Pronchery
53*a3cefe7fSPierre Proncherypkgconf, when used effectively, can make optimizations to avoid overlinking binaries.
54*a3cefe7fSPierre Pronchery
55*a3cefe7fSPierre ProncheryThis functionality depends on the pkg-config module properly declaring its dependency
56*a3cefe7fSPierre Proncherytree instead of using `Libs` and `Cflags` fields to directly link against other modules
57*a3cefe7fSPierre Proncherywhich have pkg-config metadata files installed.
58*a3cefe7fSPierre Pronchery
59*a3cefe7fSPierre ProncheryThe practice of using `Libs` and `Cflags` to describe unrelated dependencies is
60*a3cefe7fSPierre Proncherynot recommended in [Dan Nicholson's pkg-config tutorial][fd-tut] for this reason.
61*a3cefe7fSPierre Pronchery
62*a3cefe7fSPierre Pronchery   [fd-tut]: http://people.freedesktop.org/~dbn/pkg-config-guide.html
63*a3cefe7fSPierre Pronchery
64*a3cefe7fSPierre Pronchery## bug compatibility with original pkg-config
65*a3cefe7fSPierre Pronchery
66*a3cefe7fSPierre ProncheryIn general, we do not provide bug-level compatibility with pkg-config.
67*a3cefe7fSPierre Pronchery
68*a3cefe7fSPierre ProncheryWhat that means is, if you feel that there is a legitimate regression versus pkg-config,
69*a3cefe7fSPierre Proncherydo let us know, but also make sure that the .pc files are valid and follow the rules of
70*a3cefe7fSPierre Proncherythe [pkg-config tutorial][fd-tut], as most likely fixing them to follow the specified
71*a3cefe7fSPierre Proncheryrules will solve the problem.
72*a3cefe7fSPierre Pronchery
73*a3cefe7fSPierre Pronchery## debug output
74*a3cefe7fSPierre Pronchery
75*a3cefe7fSPierre ProncheryPlease use only the stable interfaces to query pkg-config.  Do not screen-scrape the
76*a3cefe7fSPierre Proncheryoutput from `--debug`: this is sent to `stderr` for a reason, it is not intended to be
77*a3cefe7fSPierre Proncheryscraped.  The `--debug` output is **not** a stable interface, and should **never** be
78*a3cefe7fSPierre Proncherydepended on as a source of information.  If you need a stable interface to query pkg-config
79*a3cefe7fSPierre Proncherywhich is not covered, please get in touch.
80*a3cefe7fSPierre Pronchery
81*a3cefe7fSPierre Pronchery## compiling `pkgconf` and `libpkgconf` on UNIX
82*a3cefe7fSPierre Pronchery
83*a3cefe7fSPierre Proncherypkgconf is basically compiled the same way any other autotools-based project is
84*a3cefe7fSPierre Proncherycompiled:
85*a3cefe7fSPierre Pronchery
86*a3cefe7fSPierre Pronchery    $ ./configure
87*a3cefe7fSPierre Pronchery    $ make
88*a3cefe7fSPierre Pronchery    $ sudo make install
89*a3cefe7fSPierre Pronchery
90*a3cefe7fSPierre ProncheryIf you are installing pkgconf into a custom prefix, such as `/opt/pkgconf`, you will
91*a3cefe7fSPierre Proncherylikely want to define the default system includedir and libdir for your toolchain.
92*a3cefe7fSPierre ProncheryTo do this, use the `--with-system-includedir` and `--with-system-libdir` configure
93*a3cefe7fSPierre Proncheryflags like so:
94*a3cefe7fSPierre Pronchery
95*a3cefe7fSPierre Pronchery    $ ./configure \
96*a3cefe7fSPierre Pronchery         --prefix=/opt/pkgconf \
97*a3cefe7fSPierre Pronchery         --with-system-libdir=/lib:/usr/lib \
98*a3cefe7fSPierre Pronchery         --with-system-includedir=/usr/include
99*a3cefe7fSPierre Pronchery    $ make
100*a3cefe7fSPierre Pronchery    $ sudo make install
101*a3cefe7fSPierre Pronchery
102*a3cefe7fSPierre Pronchery## compiling `pkgconf` and `libpkgconf` with Meson (usually for Windows)
103*a3cefe7fSPierre Pronchery
104*a3cefe7fSPierre Proncherypkgconf is compiled using [Meson](https://mesonbuild.com) on Windows. In theory, you could also use
105*a3cefe7fSPierre ProncheryMeson to build on UNIX, but this is not recommended at this time as pkgconf is typically built
106*a3cefe7fSPierre Proncherymuch earlier than Meson.
107*a3cefe7fSPierre Pronchery
108*a3cefe7fSPierre Pronchery    $ meson setup build -Dtests=disabled
109*a3cefe7fSPierre Pronchery    $ meson compile -C build
110*a3cefe7fSPierre Pronchery    $ meson install -C build
111*a3cefe7fSPierre Pronchery
112*a3cefe7fSPierre ProncheryThere are a few defines such as `SYSTEM_LIBDIR`, `PKGCONFIGDIR` and `SYSTEM_INCLUDEDIR`.
113*a3cefe7fSPierre ProncheryHowever, on Windows, the default `PKGCONFIGDIR` value is usually overridden at runtime based
114*a3cefe7fSPierre Proncheryon path relocation.
115*a3cefe7fSPierre Pronchery
116*a3cefe7fSPierre Pronchery## pkg-config symlink
117*a3cefe7fSPierre Pronchery
118*a3cefe7fSPierre ProncheryIf you want pkgconf to be used when you invoke `pkg-config`, you should install a
119*a3cefe7fSPierre Proncherysymlink for this.  We do not do this for you, as we believe it is better for vendors
120*a3cefe7fSPierre Proncheryto make this determination themselves.
121*a3cefe7fSPierre Pronchery
122*a3cefe7fSPierre Pronchery    $ ln -sf pkgconf /usr/bin/pkg-config
123*a3cefe7fSPierre Pronchery
124*a3cefe7fSPierre Pronchery## contacts
125*a3cefe7fSPierre Pronchery
126*a3cefe7fSPierre ProncheryYou can report bugs at <https://github.com/pkgconf/pkgconf/issues>.
127*a3cefe7fSPierre Pronchery
128*a3cefe7fSPierre ProncheryThere is a mailing list at <https://lists.sr.ht/~kaniini/pkgconf>.
129*a3cefe7fSPierre Pronchery
130*a3cefe7fSPierre ProncheryYou can contact us via IRC at `#pkgconf` at `irc.oftc.net`.
131