meson: allow customize perl installation path

Some distros, notably Fedora, want to install non-core Perl libraries into specific directory, namely /usr/share/perl5/vendor_perl. The Makefile build system allows this by overriding perllibdir variable, let's make meson works on par with our Makefile. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Đoàn Trần Công Danh committed May 8, 2025 at 15:24 UTC 5463c1d4f6d03e63ee79bd822de667090f015356
10 files changed +19 -10
meson.build
+7 -2
@@ -1871,14 +1871,19 @@ if perl_features_enabled
1871 perl_header_template = 'perl/header_templates/runtime_prefix.template.pl'
1872 endif
1873
1874 + perllibdir = get_option('perllibdir')
1875 + if perllibdir == ''
1876 + perllibdir = get_option('datadir') / 'perl5'
1877 + endif
1878 +
1879 perl_header = configure_file(
1880 input: perl_header_template,
1881 output: 'GIT-PERL-HEADER',
1882 configuration: {
1883 'GITEXECDIR_REL': get_option('libexecdir') / 'git-core',
1879 - 'PERLLIBDIR_REL': get_option('datadir') / 'perl5',
1884 + 'PERLLIBDIR_REL': perllibdir,
1885 'LOCALEDIR_REL': get_option('datadir') / 'locale',
1881 - 'INSTLIBDIR': get_option('datadir') / 'perl5',
1886 + 'INSTLIBDIR': perllibdir,
1887 'PATHSEP': pathsep,
1888 },
1889 )
meson_options.txt
+4
@@ -1,3 +1,7 @@
1 +# Configuration for Git installation
2 +option('perllibdir', type: 'string', value: '',
3 + description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
4 +
5 # Configuration for how Git behaves at runtime.
6 option('default_pager', type: 'string', value: 'less',
7 description: 'Fall-back pager.')
perl/FromCPAN/Mail/meson.build
+1 -1
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
3 output: 'Address.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail',
6 + install_dir: perllibdir / 'FromCPAN/Mail',
7 depends: [git_version_file],
8 )
perl/FromCPAN/meson.build
+1 -1
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
3 output: 'Error.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5/FromCPAN',
6 + install_dir: perllibdir / 'FromCPAN',
7 depends: [git_version_file],
8 )
9
perl/Git/LoadCPAN/Mail/meson.build
+1 -1
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
3 output: 'Address.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail',
6 + install_dir: perllibdir / 'Git/LoadCPAN/Mail',
7 depends: [git_version_file],
8 )
perl/Git/LoadCPAN/meson.build
+1 -1
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
3 output: 'Error.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN',
6 + install_dir: perllibdir / 'Git/LoadCPAN',
7 depends: [git_version_file],
8 )
9
perl/Git/SVN/Memoize/meson.build
+1 -1
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
3 output: 'YAML.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5/Git/SVN',
6 + install_dir: perllibdir / 'Git/SVN',
7 depends: [git_version_file],
8 )
perl/Git/SVN/meson.build
+1 -1
@@ -13,7 +13,7 @@ foreach source : [
13 output: source,
14 command: generate_perl_command,
15 install: true,
16 - install_dir: get_option('datadir') / 'perl5/Git/SVN',
16 + install_dir: perllibdir / 'Git/SVN',
17 depends: [git_version_file],
18 )
19 endforeach
perl/Git/meson.build
+1 -1
@@ -10,7 +10,7 @@ foreach source : [
10 output: source,
11 command: generate_perl_command,
12 install: true,
13 - install_dir: get_option('datadir') / 'perl5/Git',
13 + install_dir: perllibdir / 'Git',
14 depends: [git_version_file],
15 )
16 endforeach
perl/meson.build
+1 -1
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
3 output: 'Git.pm',
4 command: generate_perl_command,
5 install: true,
6 - install_dir: get_option('datadir') / 'perl5',
6 + install_dir: perllibdir,
7 depends: [git_version_file],
8 )
9