1From b0f2b20b23780dd2e67a01c15462070dd86c4ac1 Mon Sep 17 00:00:00 2001
2From: Jan Tojnar <jtojnar@gmail.com>
3Date: Sun, 3 Mar 2019 11:50:27 +0100
4Subject: [PATCH] build: Add datadir option for /usr/share
5
6Hardcoded /usr/share does not work for platforms that do not have global /usr like Nix.
7Let’s introduce a new DATADIR option, that allows overriding the directory and use it for metainfodir.
8
9While at it, let’s also use it for SHAREDIR and MANDIR for consistency,
10following the GNU directory convention:
11https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
12---
13 SConstruct | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/SConstruct b/SConstruct
17index 05755e4b..3fbdc1d8 100644
18--- a/SConstruct
19+++ b/SConstruct
20@@ -49,9 +49,10 @@
21 PathVariable( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathVariable.PathAccept ),
22 PathVariable( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathVariable.PathAccept ),
23 PathVariable( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathVariable.PathAccept ),
24- PathVariable( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathVariable.PathAccept ),
25+ PathVariable( "DATADIR", "Overwrite the directory where platform-independent files are installed to.", "$PREFIX/share", PathVariable.PathAccept ),
26+ PathVariable( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$DATADIR/libffado", PathVariable.PathAccept ),
27 PathVariable( "LIBDATADIR", "Location for architecture-dependent data.", "$LIBDIR/libffado", PathVariable.PathAccept ),
28- PathVariable( "MANDIR", "Overwrite the directory where manpages are installed", "$PREFIX/man", PathVariable.PathAccept ),
29+ PathVariable( "MANDIR", "Overwrite the directory where manpages are installed", "$DATADIR/man", PathVariable.PathAccept ),
30 PathVariable( "PYPKGDIR", "The directory where the python modules get installed.",
31 distutils.sysconfig.get_python_lib( prefix="$PREFIX" ), PathVariable.PathAccept ),
32 PathVariable( "UDEVDIR", "Overwrite the directory where udev rules are installed to.", "/lib/udev/rules.d/", PathVariable.PathAccept ),
33@@ -523,6 +524,7 @@
34 env['BINDIR'] = Template( env['BINDIR'] ).safe_substitute( env )
35 env['LIBDIR'] = Template( env['LIBDIR'] ).safe_substitute( env )
36 env['INCLUDEDIR'] = Template( env['INCLUDEDIR'] ).safe_substitute( env )
37+env['DATADIR'] = Template( env['DATADIR'] ).safe_substitute( env )
38 env['SHAREDIR'] = Template( env['SHAREDIR'] ).safe_substitute( env )
39 env['LIBDATADIR'] = Template( env['LIBDATADIR'] ).safe_substitute( env )
40 env['UDEVDIR'] = Template( env['UDEVDIR'] ).safe_substitute( env )
41@@ -531,18 +533,21 @@
42 env['bindir'] = Template( env.destdir + env['BINDIR'] ).safe_substitute( env )
43 env['libdir'] = Template( env.destdir + env['LIBDIR'] ).safe_substitute( env )
44 env['includedir'] = Template( env.destdir + env['INCLUDEDIR'] ).safe_substitute( env )
45+env['datadir'] = Template( env.destdir + env['DATADIR'] ).safe_substitute( env )
46 env['sharedir'] = Template( env.destdir + env['SHAREDIR'] ).safe_substitute( env )
47 env['libdatadir'] = Template( env.destdir + env['LIBDATADIR'] ).safe_substitute( env )
48 env['mandir'] = Template( env.destdir + env['MANDIR'] ).safe_substitute( env )
49 env['pypkgdir'] = Template( env.destdir + env['PYPKGDIR'] ).safe_substitute( env )
50 env['udevdir'] = Template( env.destdir + env['UDEVDIR'] ).safe_substitute( env )
51 env['PYPKGDIR'] = Template( env['PYPKGDIR'] ).safe_substitute( env )
52-env['metainfodir'] = Template( env.destdir + "/usr/share/metainfo" ).safe_substitute( env )
53-
54+env['metainfodir'] = Template( env.destdir + env['DATADIR'] + "/metainfo" ).safe_substitute( env )
55+
56+env.Command( target=env['datadir'], source="", action=Mkdir( env['datadir'] ) )
57 env.Command( target=env['sharedir'], source="", action=Mkdir( env['sharedir'] ) )
58
59 env.Alias( "install", env['libdir'] )
60 env.Alias( "install", env['includedir'] )
61+env.Alias( "install", env['datadir'] )
62 env.Alias( "install", env['sharedir'] )
63 env.Alias( "install", env['libdatadir'] )
64 env.Alias( "install", env['bindir'] )