RFC: pkgconfigdir: where?

tlaronde at kergis.com tlaronde at kergis.com
Mon Mar 4 09:49:13 UTC 2024


As written in a previous mail, I'm trying to adjust meson to provide
the same rope as AC.

For xorg-sgml-doctools, there was a small discrepancy if the user was
not selecting the defaults. This is easy to fix (diff attached), but I
now wonder about pkgconfig .pc files directory.

In generated aclocal.m4, pkgconfigdir is said to be, by default,
${libdir}/pkgconfig, and supposed to be settable with
--with-pkgconfigdir (it is not settable in fact: the option is not
recognized).

We put .pc files in ${datadir}/pkgconfig. By default, datadir ==
datarootdir, but this can be changed (with AC) so that X11 stuff is
put in a dedicated subdir, while pkgconfig files are reachable in a
more general dir.

In fact, on my OS (NetBSD), pkgconfig files are placed in
${libdir}/pkgconfig and not ${datarootdir}/pkgconfig.

So is there some rule about this for X11 stuff?
-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C
-------------- next part --------------
diff --git a/meson.build b/meson.build
index 5b38853..e2fabc5 100644
--- a/meson.build
+++ b/meson.build
@@ -1,25 +1,43 @@
 project('xorg-sgml-doctools',
         version: '1.12',
-        meson_version: '>= 0.49.0',
+        meson_version: '>= 0.58.0',
         license: 'MIT'
 )
 
-datarootdir = get_option('prefix') / get_option('datadir')
+# datarootdir will be used as is in pcconfig, and ${prefix} (default)
+# replaced only after (since, as is, it is correct in pkgconfig.
+# Others are not settable in AC, so neither here.
+#
+datarootdir = get_option('datarootdir')
 sgmlrootdir = datarootdir / 'sgml'
-sgmlx11dir = sgmlrootdir / 'X11'
-sgmldbsdir = sgmlx11dir / 'dbs'
 
+# datadir is a meson built-in and is used as subdir for the
+# pkgconfig file. 'datarootdir', settable, if for other data.
+#
 pc_conf = configuration_data({
     'prefix': get_option('prefix'),
-    'datarootdir': '${prefix}/share',
-    'sgmlrootdir': '${datarootdir}/sgml',
+    'datarootdir': datarootdir,
+    'sgmlrootdir': sgmlrootdir,
     'PACKAGE_VERSION': meson.project_version()
 })
+# pkgconfigdir can be set via AC with --with-pkgconfigdir.
+#
+pkgconfigdir = get_option('pkgconfigdir')
+pkgconfigdir = pkgconfigdir.replace('${libdir}', get_option('libdir'))
+
 configure_file(input: 'xorg-sgml-doctools.pc.in',
                output: 'xorg-sgml-doctools.pc',
-               install_dir: get_option('datadir') / 'pkgconfig',
+               install_dir: pkgconfigdir,
                configuration: pc_conf)
 
+# Replace '${prefix}' if existing in datarootdir, and reset other
+# paths.
+#
+datarootdir = datarootdir.replace('${prefix}', get_option('prefix'))
+sgmlrootdir = datarootdir / 'sgml'
+sgmlx11dir = sgmlrootdir / 'X11'
+sgmldbsdir = sgmlx11dir / 'dbs'
+
 sgmlx11_files = [
   'defs.ent',
   'xorg.css',
-------------- next part --------------
option('datarootdir', type: 'string', value: '${prefix}/share',
    description: 'read-only arch.-independent data root')
option('pkgconfigdir', type: 'string', value: '${libdir}/pkgconfig',
    description: 'pkg-config installation directory for .pc files')


More information about the xorg-devel mailing list