threads / patch / 63341

patchmeson: allow customize perl installation path

Subject: [PATCH] meson: allow customize perl installation path

## tl;dr

4 messages between Apr 24, 2025 and May 8, 2025. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Đoàn Trần Công Danh· Apr 24, 2025, 15:16 UTC · lore

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>
---
 meson.build                        | 9 +++++++--
 meson_options.txt                  | 5 +++++
 perl/FromCPAN/Mail/meson.build     | 2 +-
 perl/FromCPAN/meson.build          | 2 +-
 perl/Git/LoadCPAN/Mail/meson.build | 2 +-
 perl/Git/LoadCPAN/meson.build      | 2 +-
 perl/Git/SVN/Memoize/meson.build   | 2 +-
 perl/Git/SVN/meson.build           | 2 +-
 perl/Git/meson.build               | 2 +-
 perl/meson.build                   | 2 +-
 10 files changed, 20 insertions(+), 10 deletions(-)
Show changes to 10 files +20 −10

meson.build, meson_options.txt, perl/FromCPAN/Mail/meson.build, perl/FromCPAN/meson.build, perl/Git/LoadCPAN/Mail/meson.build, perl/Git/LoadCPAN/meson.build, perl/Git/SVN/Memoize/meson.build, perl/Git/SVN/meson.build, perl/Git/meson.build, perl/meson.build

diff --git a/meson.build b/meson.build
index 223384b130b62..830deb9a069a6 100644
--- a/meson.build
+++ b/meson.build
@@ -1826,14 +1826,19 @@ if perl_features_enabled
     perl_header_template = 'perl/header_templates/runtime_prefix.template.pl'
   endif
 
+  perllibdir = get_option('perllibdir')
+  if perllibdir == ''
+    perllibdir = get_option('datadir') / 'perl5'
+  endif
+
   perl_header = configure_file(
     input: perl_header_template,
     output: 'GIT-PERL-HEADER',
     configuration: {
       'GITEXECDIR_REL': get_option('libexecdir') / 'git-core',
-      'PERLLIBDIR_REL': get_option('datadir') / 'perl5',
+      'PERLLIBDIR_REL': perllibdir,
       'LOCALEDIR_REL': get_option('datadir') / 'locale',
-      'INSTLIBDIR': get_option('datadir') / 'perl5',
+      'INSTLIBDIR': perllibdir,
       'PATHSEP': pathsep,
     },
   )
diff --git a/meson_options.txt b/meson_options.txt
index 78d172a74019a..43f3f2d234a8e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,8 @@
+# Configuration for Git installation
+
+option('perllibdir', type: 'string', value: '',
+  description: 'Directory to install perl lib to. Default to <datadir>/perl5')
+
 # Configuration for how Git behaves at runtime.
 option('default_pager', type: 'string', value: 'less',
   description: 'Fall-back pager.')
diff --git a/perl/FromCPAN/Mail/meson.build b/perl/FromCPAN/Mail/meson.build
index b4ff2fc0b24c9..467507c5e690e 100644
--- a/perl/FromCPAN/Mail/meson.build
+++ b/perl/FromCPAN/Mail/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'Address.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail',
+  install_dir: perllibdir / 'FromCPAN/Mail',
   depends: [git_version_file],
 )
diff --git a/perl/FromCPAN/meson.build b/perl/FromCPAN/meson.build
index 1f9ea6ce8e844..720c60283d89b 100644
--- a/perl/FromCPAN/meson.build
+++ b/perl/FromCPAN/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Error.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/FromCPAN',
+  install_dir: perllibdir / 'FromCPAN',
   depends: [git_version_file],
 )
 
diff --git a/perl/Git/LoadCPAN/Mail/meson.build b/perl/Git/LoadCPAN/Mail/meson.build
index 89cde56be8491..05a5770560d3d 100644
--- a/perl/Git/LoadCPAN/Mail/meson.build
+++ b/perl/Git/LoadCPAN/Mail/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'Address.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail',
+  install_dir: perllibdir / 'Git/LoadCPAN/Mail',
   depends: [git_version_file],
 )
diff --git a/perl/Git/LoadCPAN/meson.build b/perl/Git/LoadCPAN/meson.build
index 1ee915c650517..b975d4972631d 100644
--- a/perl/Git/LoadCPAN/meson.build
+++ b/perl/Git/LoadCPAN/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Error.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN',
+  install_dir: perllibdir / 'Git/LoadCPAN',
   depends: [git_version_file],
 )
 
diff --git a/perl/Git/SVN/Memoize/meson.build b/perl/Git/SVN/Memoize/meson.build
index 233ec670d7de9..4c589b30c387a 100644
--- a/perl/Git/SVN/Memoize/meson.build
+++ b/perl/Git/SVN/Memoize/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'YAML.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/SVN',
+  install_dir: perllibdir / 'Git/SVN',
   depends: [git_version_file],
 )
diff --git a/perl/Git/SVN/meson.build b/perl/Git/SVN/meson.build
index 44abaf42b7cea..8858985fe8660 100644
--- a/perl/Git/SVN/meson.build
+++ b/perl/Git/SVN/meson.build
@@ -13,7 +13,7 @@ foreach source : [
     output: source,
     command: generate_perl_command,
     install: true,
-    install_dir: get_option('datadir') / 'perl5/Git/SVN',
+    install_dir: perllibdir / 'Git/SVN',
     depends: [git_version_file],
   )
 endforeach
diff --git a/perl/Git/meson.build b/perl/Git/meson.build
index b21fa5591e7e7..a61b7b1f4abf2 100644
--- a/perl/Git/meson.build
+++ b/perl/Git/meson.build
@@ -10,7 +10,7 @@ foreach source : [
     output: source,
     command: generate_perl_command,
     install: true,
-    install_dir: get_option('datadir') / 'perl5/Git',
+    install_dir: perllibdir / 'Git',
     depends: [git_version_file],
   )
 endforeach
diff --git a/perl/meson.build b/perl/meson.build
index 2d4ab1c4a986f..3c66b007eaad9 100644
--- a/perl/meson.build
+++ b/perl/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Git.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5',
+  install_dir: perllibdir,
   depends: [git_version_file],
 )
 
-- 
2.49.0.395.g12beb8f557ceb
Patrick Steinhardt· Apr 25, 2025, 06:25 UTC · re: Đoàn Trần Công Danh · lore

Re: [PATCH] meson: allow customize perl installation path

On Thu, Apr 24, 2025 at 10:16:18PM +0700, Đoàn Trần Công Danh wrote:
Show 12 quoted lines
> diff --git a/meson.build b/meson.build
> index 223384b130b62..830deb9a069a6 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1826,14 +1826,19 @@ if perl_features_enabled
>      perl_header_template = 'perl/header_templates/runtime_prefix.template.pl'
>    endif
>  
> +  perllibdir = get_option('perllibdir')
> +  if perllibdir == ''
> +    perllibdir = get_option('datadir') / 'perl5'
> +  endif

Makes sense. We try to do the "right thing" by default, but let the users override the location.

Show 20 quoted lines
>    perl_header = configure_file(
>      input: perl_header_template,
>      output: 'GIT-PERL-HEADER',
>      configuration: {
>        'GITEXECDIR_REL': get_option('libexecdir') / 'git-core',
> -      'PERLLIBDIR_REL': get_option('datadir') / 'perl5',
> +      'PERLLIBDIR_REL': perllibdir,
>        'LOCALEDIR_REL': get_option('datadir') / 'locale',
> -      'INSTLIBDIR': get_option('datadir') / 'perl5',
> +      'INSTLIBDIR': perllibdir,
>        'PATHSEP': pathsep,
>      },
>    )
> diff --git a/meson_options.txt b/meson_options.txt
> index 78d172a74019a..43f3f2d234a8e 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,3 +1,8 @@
> +# Configuration for Git installation
> +

Pedantic nit: let's drop this empty newline, we don't have it for any of the other sections, either.

> +option('perllibdir', type: 'string', value: '',
> +  description: 'Directory to install perl lib to. Default to <datadir>/perl5')

s/perl lib/the Perl library/ s/Default/Defaults/

The remainder of this patch looks good to me, thanks!
Patrick
Đoàn Trần Công Danh· May 8, 2025, 08:24 UTC · re: Đoàn Trần Công Danh · lore

[PATCH v2] 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>
---
 meson.build                        | 9 +++++++--
 meson_options.txt                  | 4 ++++
 perl/FromCPAN/Mail/meson.build     | 2 +-
 perl/FromCPAN/meson.build          | 2 +-
 perl/Git/LoadCPAN/Mail/meson.build | 2 +-
 perl/Git/LoadCPAN/meson.build      | 2 +-
 perl/Git/SVN/Memoize/meson.build   | 2 +-
 perl/Git/SVN/meson.build           | 2 +-
 perl/Git/meson.build               | 2 +-
 perl/meson.build                   | 2 +-
 10 files changed, 19 insertions(+), 10 deletions(-)
Show changes to 10 files +19 −10

meson.build, meson_options.txt, perl/FromCPAN/Mail/meson.build, perl/FromCPAN/meson.build, perl/Git/LoadCPAN/Mail/meson.build, perl/Git/LoadCPAN/meson.build, perl/Git/SVN/Memoize/meson.build, perl/Git/SVN/meson.build, perl/Git/meson.build, perl/meson.build

diff --git a/meson.build b/meson.build
index efe2871c9dba1..5155aa726b20e 100644
--- a/meson.build
+++ b/meson.build
@@ -1825,14 +1825,19 @@ if perl_features_enabled
     perl_header_template = 'perl/header_templates/runtime_prefix.template.pl'
   endif
 
+  perllibdir = get_option('perllibdir')
+  if perllibdir == ''
+    perllibdir = get_option('datadir') / 'perl5'
+  endif
+
   perl_header = configure_file(
     input: perl_header_template,
     output: 'GIT-PERL-HEADER',
     configuration: {
       'GITEXECDIR_REL': get_option('libexecdir') / 'git-core',
-      'PERLLIBDIR_REL': get_option('datadir') / 'perl5',
+      'PERLLIBDIR_REL': perllibdir,
       'LOCALEDIR_REL': get_option('datadir') / 'locale',
-      'INSTLIBDIR': get_option('datadir') / 'perl5',
+      'INSTLIBDIR': perllibdir,
       'PATHSEP': pathsep,
     },
   )
diff --git a/meson_options.txt b/meson_options.txt
index 78d172a74019a..cc19918a7ccfa 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,7 @@
+# Configuration for Git installation
+option('perllibdir', type: 'string', value: '',
+  description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
+
 # Configuration for how Git behaves at runtime.
 option('default_pager', type: 'string', value: 'less',
   description: 'Fall-back pager.')
diff --git a/perl/FromCPAN/Mail/meson.build b/perl/FromCPAN/Mail/meson.build
index b4ff2fc0b24c9..467507c5e690e 100644
--- a/perl/FromCPAN/Mail/meson.build
+++ b/perl/FromCPAN/Mail/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'Address.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/FromCPAN/Mail',
+  install_dir: perllibdir / 'FromCPAN/Mail',
   depends: [git_version_file],
 )
diff --git a/perl/FromCPAN/meson.build b/perl/FromCPAN/meson.build
index 1f9ea6ce8e844..720c60283d89b 100644
--- a/perl/FromCPAN/meson.build
+++ b/perl/FromCPAN/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Error.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/FromCPAN',
+  install_dir: perllibdir / 'FromCPAN',
   depends: [git_version_file],
 )
 
diff --git a/perl/Git/LoadCPAN/Mail/meson.build b/perl/Git/LoadCPAN/Mail/meson.build
index 89cde56be8491..05a5770560d3d 100644
--- a/perl/Git/LoadCPAN/Mail/meson.build
+++ b/perl/Git/LoadCPAN/Mail/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'Address.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN/Mail',
+  install_dir: perllibdir / 'Git/LoadCPAN/Mail',
   depends: [git_version_file],
 )
diff --git a/perl/Git/LoadCPAN/meson.build b/perl/Git/LoadCPAN/meson.build
index 1ee915c650517..b975d4972631d 100644
--- a/perl/Git/LoadCPAN/meson.build
+++ b/perl/Git/LoadCPAN/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Error.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/LoadCPAN',
+  install_dir: perllibdir / 'Git/LoadCPAN',
   depends: [git_version_file],
 )
 
diff --git a/perl/Git/SVN/Memoize/meson.build b/perl/Git/SVN/Memoize/meson.build
index 233ec670d7de9..4c589b30c387a 100644
--- a/perl/Git/SVN/Memoize/meson.build
+++ b/perl/Git/SVN/Memoize/meson.build
@@ -3,6 +3,6 @@ test_dependencies += custom_target(
   output: 'YAML.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5/Git/SVN',
+  install_dir: perllibdir / 'Git/SVN',
   depends: [git_version_file],
 )
diff --git a/perl/Git/SVN/meson.build b/perl/Git/SVN/meson.build
index 44abaf42b7cea..8858985fe8660 100644
--- a/perl/Git/SVN/meson.build
+++ b/perl/Git/SVN/meson.build
@@ -13,7 +13,7 @@ foreach source : [
     output: source,
     command: generate_perl_command,
     install: true,
-    install_dir: get_option('datadir') / 'perl5/Git/SVN',
+    install_dir: perllibdir / 'Git/SVN',
     depends: [git_version_file],
   )
 endforeach
diff --git a/perl/Git/meson.build b/perl/Git/meson.build
index b21fa5591e7e7..a61b7b1f4abf2 100644
--- a/perl/Git/meson.build
+++ b/perl/Git/meson.build
@@ -10,7 +10,7 @@ foreach source : [
     output: source,
     command: generate_perl_command,
     install: true,
-    install_dir: get_option('datadir') / 'perl5/Git',
+    install_dir: perllibdir / 'Git',
     depends: [git_version_file],
   )
 endforeach
diff --git a/perl/meson.build b/perl/meson.build
index 2d4ab1c4a986f..3c66b007eaad9 100644
--- a/perl/meson.build
+++ b/perl/meson.build
@@ -3,7 +3,7 @@ test_dependencies += custom_target(
   output: 'Git.pm',
   command: generate_perl_command,
   install: true,
-  install_dir: get_option('datadir') / 'perl5',
+  install_dir: perllibdir,
   depends: [git_version_file],
 )
 

Range-diff against v1:
1:  14e38695adbd6 ! 1:  a9d431944b6d9 meson: allow customize perl installation path
    @@ meson.build: if perl_features_enabled
      ## meson_options.txt ##
     @@
     +# Configuration for Git installation
    -+
     +option('perllibdir', type: 'string', value: '',
    -+  description: 'Directory to install perl lib to. Default to <datadir>/perl5')
    ++  description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
     +
      # Configuration for how Git behaves at runtime.
      option('default_pager', type: 'string', value: 'less',
Junio C Hamano· May 8, 2025, 14:34 UTC · re: Đoàn Trần Công Danh · lore

Re: [PATCH v2] meson: allow customize perl installation path

Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
Show 8 quoted lines
> 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>
> ---

Will queue. The incremental since the previous iteration looks exactly as Patrick suggested, which looks good to me, too.

Thanks.
Show 13 quoted lines
> Range-diff against v1:
> 1:  14e38695adbd6 ! 1:  a9d431944b6d9 meson: allow customize perl installation path
>     @@ meson.build: if perl_features_enabled
>       ## meson_options.txt ##
>      @@
>      +# Configuration for Git installation
>     -+
>      +option('perllibdir', type: 'string', value: '',
>     -+  description: 'Directory to install perl lib to. Default to <datadir>/perl5')
>     ++  description: 'Directory to install perl lib to. Defaults to <datadir>/perl5')
>      +
>       # Configuration for how Git behaves at runtime.
>       option('default_pager', type: 'string', value: 'less',

← back to recent threads