xref: /freebsd/contrib/pkgconf/man/pkg.m4.7 (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1.\" Copyright (c) 2017 pkgconf authors (see AUTHORS).
2.\"
3.\" Permission to use, copy, modify, and/or distribute this software for any
4.\" purpose with or without fee is hereby granted, provided that the above
5.\" copyright notice and this permission notice appear in all copies.
6.\"
7.\" This software is provided 'as is' and without any warranty, express or
8.\" implied.  In no event shall the authors be liable for any damages arising
9.\" from the use of this software.
10.Dd December 5, 2017
11.Dt PKG.M4 7
12.Os
13.Sh NAME
14.Nm pkg.m4
15.Nd autoconf macros for using pkgconf
16.Sh SYNOPSIS
17.Nm PKG_PREREQ
18.Nm PKG_PROG_PKG_CONFIG
19.Nm PKG_CHECK_MODULES
20.Nm PKG_CHECK_MODULES_STATIC
21.Nm PKG_INSTALLDIR
22.Nm PKG_NOARCH_INSTALLDIR
23.Nm PKG_CHECK_VAR
24.Nm PKG_WITH_MODULES
25.Nm PKG_HAVE_WITH_MODULES
26.Nm PKG_HAVE_DEFINE_WITH_MODULES
27.Sh DESCRIPTION
28.Nm
29is a collection of autoconf macros which help to configure compiler and linker
30flags for development libraries.
31This allows build systems to detect other dependencies and use them with the
32system toolchain.
33.Sh "AUTOCONF MACROS"
34.Ss "PKG_PREREQ(MIN-VERSION)"
35Checks that the version of the
36.Nm
37autoconf macros in use is at least MIN-VERSION.
38This can be used to ensure a particular
39.Nm
40macro will be available.
41.Ss "PKG_PROG_PKG_CONFIG([MIN-VERSION])"
42Checks for an implementation of
43.Nm pkg-config
44which is at least MIN-VERSION or newer.
45.Ss "PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])"
46.Ss "PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])"
47Checks whether a given module set exists, and if so, defines
48.Nm CFLAGS
49and
50.Nm LIBS
51variables prefixed by
52.Nm VARIABLE-PREFIX
53with the output from
54.Fl -cflags
55and
56.Fl -libs
57respectively.
58.Pp
59The optional
60.Nm ACTION-IF-FOUND
61and
62.Nm ACTION-IF-NOT-FOUND
63arguments are shell fragments that should be executed if the module set is
64found or not found.
65.Pp
66If
67.Nm $PKG_CONFIG
68is not defined, the
69.Nm PKG_PROG_PKG_CONFIG
70macro will be executed to locate a
71.Nm pkg-config
72implementation.
73.Pp
74The
75.Nm PKG_CHECK_MODULES_STATIC
76macro provides the same behaviour as
77.Nm PKG_CHECK_MODULES
78with static linking enabled via the
79.Fl -static
80flag.
81.Ss "PKG_INSTALLDIR(DIRECTORY)"
82Defines the variable $pkgconfigdir as the location where a package
83should install pkg-config .pc files.
84.Pp
85By default the directory is $libdir/pkgconfig, but the default can
86be changed by passing the
87.Nm DIRECTORY
88parameter.
89.Pp
90This value can be overridden with the
91.Fl -with-pkgconfigdir
92configure parameter.
93.Ss "PKG_NOARCH_INSTALLDIR(DIRECTORY)"
94Defines the variable $noarch_pkgconfigdir as the location where a package
95should install pkg-config .pc files.
96.Pp
97By default the directory is $datadir/pkgconfig, but the default can
98be changed by passing the
99.Nm DIRECTORY
100parameter.
101.Pp
102This value can be overridden with the
103.Fl -with-noarch-pkgconfigdir
104configure parameter.
105.Ss "PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])"
106Retrieves the value of the
107.Nm pkg-config
108variable
109.Nm CONFIG-VARIABLE
110from
111.Nm MODULE
112and stores it in the
113.Nm VARIABLE
114variable.
115.Pp
116Note that repeated usage of
117.Nm VARIABLE
118is not recommended as the check will be skipped if the variable is
119already set.
120.Ss "PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], [DESCRIPTION], [DEFAULT])"
121Prepares a "--with-" configure option using the lowercase
122.Nm VARIABLE-PREFIX
123name, merging the behaviour of
124.Nm AC_ARG_WITH
125and
126.Nm PKG_CHECK_MODULES
127in a single macro.
128.Ss "PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, [DESCRIPTION], [DEFAULT])"
129Convenience macro to trigger
130.Nm AM_CONDITIONAL
131after a
132.Nm PKG_WITH_MODULES check.\&
133.Nm VARIABLE-PREFIX
134is exported as a make variable.
135.Ss "PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, [DESCRIPTION], [DEFAULT])"
136Convenience macro to trigger
137.Nm AM_CONDITIONAL
138and
139.Nm AC_DEFINE
140after a
141.Nm PKG_WITH_MODULES check.\&
142.Nm VARIABLE-PREFIX
143is exported as a make variable.
144