From f783b3fe740eeb021f8386df2de2ab9fa32eed1b Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 19 May 2025 17:25:19 +0100 Subject: [PATCH 1/5] meson.build: quote the GITWEBDIR build configuration The build configuration options with (non-empty) values, for example filesystem paths potentially containing spaces, have been set using the '.set_quoted()' method. However, the GITWEBDIR value has been set using the '.set()' method instead. In order to correctly quote the GITWEBDIR value, replace the '.set()' method with '.set_quoted()'. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 270ce933d0..48f31157a0 100644 --- a/meson.build +++ b/meson.build @@ -739,7 +739,7 @@ build_options_config.set('GIT_TEST_OPTS', '') build_options_config.set('GIT_TEST_PERL_FATAL_WARNINGS', '') build_options_config.set_quoted('GIT_TEST_UTF8_LOCALE', get_option('test_utf8_locale')) build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir'))) -build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb')) +build_options_config.set_quoted('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb')) if get_option('sane_tool_path').length() != 0 sane_tool_path = (host_machine.system() == 'windows' ? ';' : ':').join(get_option('sane_tool_path')) From bdb38432f383ad397447bcfd80d1659f3c978644 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 19 May 2025 17:25:20 +0100 Subject: [PATCH 2/5] meson: correct install location of YAML.pm When executing an 'meson install' the YAML.pm file is incorrectly placed in the /share/perl5/Git/SVN directory. The YAML.pm file should be placed in a 'Memoize' subdirectory instead. In order to correct the location, update the 'install_dir' of the relevant target in the 'perl/Git/SVN/Memoize/meson.build' file. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- perl/Git/SVN/Memoize/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl/Git/SVN/Memoize/meson.build b/perl/Git/SVN/Memoize/meson.build index 233ec670d7..8c2e80d2d2 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: get_option('datadir') / 'perl5/Git/SVN/Memoize', depends: [git_version_file], ) From 46a626c3891ad39f8534c5e649c38affa1f4e7e1 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 19 May 2025 17:25:21 +0100 Subject: [PATCH 3/5] meson: correct path to system config/attribute files The path to the system-wide config and attributes files are not being set correctly in the meson build. Unless explicitly overridden on the command line during setup, the 'gitconfig' and 'gitattributes' options are defaulting to absolute paths in the '/etc' system directory. This is only appropriate if the is set specifically to '/usr'. The directory in which these files are placed is generally referred to as the 'system configuration directory' or 'sysconfdir' for short. When the prefix is '/usr' then the sysconfdir is usually set to '/etc', but any other value for prefix results in the relative directory value 'etc' instead. (eg if prefix is '/usr/local', then the 'etc' relative value results in a system configuration directory of '/usr/local/etc'). When setting the 'sysconfdir' builtin option value, the meson system uses exactly this algorithm, so we can use get_option('sysconfdir') directly when setting the (non-overridden) build variables. In order to allow for overriding from the command line, remove the default values specified for the 'gitconfig' and 'gitattributes' options in the 'meson_options.txt' file. This allows the user to specify any pathname for those options, while being able to test for the unset (empty) value. An absolute pathname will be used unchanged and a relative pathname will be appended to '/'. These values are then used to set the 'ETC_GITCONFIG' and 'ETC_GITATTRIBUTES' build variables which are, in turn, passed to the compiler as '-D' arguments. When the 'gitconfig' or 'gitattributes' options are not used, then use the built-in 'sysconfdir' and set the ETC_GITCONFIG build variable to the string "/gitconfig". Similarly, set ETC_ATTRIBUTES to "/gitattributes". Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- meson.build | 16 ++++++++++++++-- meson_options.txt | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 48f31157a0..8e8f228a37 100644 --- a/meson.build +++ b/meson.build @@ -757,8 +757,6 @@ endif libgit_c_args = [ '-DBINDIR="' + get_option('bindir') + '"', '-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"', - '-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"', - '-DETC_GITCONFIG="' + get_option('gitconfig') + '"', '-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"', '-DGIT_HOST_CPU="' + host_machine.cpu_family() + '"', '-DGIT_HTML_PATH="' + get_option('datadir') / 'doc/git-doc"', @@ -769,6 +767,20 @@ libgit_c_args = [ '-DSHELL_PATH="' + fs.as_posix(target_shell.full_path()) + '"', ] +system_attributes = get_option('gitattributes') +if system_attributes != '' + libgit_c_args += '-DETC_GITATTRIBUTES="' + system_attributes + '"' +else + libgit_c_args += '-DETC_GITATTRIBUTES="' + get_option('sysconfdir') / 'gitattributes"' +endif + +system_config = get_option('gitconfig') +if system_config != '' + libgit_c_args += '-DETC_GITCONFIG="' + system_config + '"' +else + libgit_c_args += '-DETC_GITCONFIG="' + get_option('sysconfdir') / 'gitconfig"' +endif + editor_opt = get_option('default_editor') if editor_opt != '' and editor_opt != 'vi' libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"' diff --git a/meson_options.txt b/meson_options.txt index 8547c0eb47..5afbf8ec00 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,10 +3,10 @@ option('default_pager', type: 'string', value: 'less', description: 'Fall-back pager.') option('default_editor', type: 'string', value: 'vi', description: 'Fall-back editor.') -option('gitconfig', type: 'string', value: '/etc/gitconfig', - description: 'Path to the global git configuration file.') -option('gitattributes', type: 'string', value: '/etc/gitattributes', - description: 'Path to the global git attributes file.') +option('gitconfig', type: 'string', + description: 'Path to the global git configuration file. (default: etc/gitconfig)') +option('gitattributes', type: 'string', + description: 'Path to the global git attributes file. (default: etc/gitattributes)') option('pager_environment', type: 'string', value: 'LESS=FRX LV=-c', description: 'Environment used when spawning the pager') option('perl_cpan_fallback', type: 'boolean', value: true, From 837f637cf51ee066e98ceefea76cc6e9c3277469 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 19 May 2025 17:25:22 +0100 Subject: [PATCH 4/5] meson.build: correct setting of GIT_EXEC_PATH For the non-'runtime prefix' case, the meson build sets the GIT_EXEC_PATH build variable to an absolute path equivalent to /libexec/git-core. In comparison, the default make build sets it to a relative path equivalent to 'libexec/git-core'. Indeed, the make build requires the use of some means outside of the Makefile (eg. config.mak[.*] or the command-line) to set GIT_EXEC_PATH to anything other than 'libexec/git-core'. For example, the make invocation: $ make gitexecdir=/some/other/bin all install will build git with GIT_EXEC_PATH set to '/some/other/bin' and install the 'library' executables to that location. However, without setting the 'gitexecdir' make variable, irrespective of the 'runtime prefix' setting, the GIT_EXEC_PATH is always set to 'libexec/git-core'. The meson built-in 'libexecdir' option can be used to provide a similar configurability. The default value for the option is 'libexec'. Attempting to set the option to '' on the command-line, will reset it to the '.' string, presumably to ensure a relative path value. This commit allows the meson build, similar to the above, to configure the project like: $ meson setup --buildtype=debugoptimized -Dprefix=$HOME -Dpcre2=disabled \ -Dlibexecdir=/some/other/bin build so that the GIT_EXEC_PATH is set to '/some/other/bin'. Absent the -Dlibexecdir argument, the GIT_EXEC_PATH is set to 'libexec/git-core'. In order to correct the value of GIT_EXEC_PATH, default the value to the static string value 'libexec/git-core', and only override if the value of the 'libexecdir' option has a value different to 'libexec' or '.'. Also, like the Makefile, add a check for an absolute path when the runtime prefix option is true (and if so, error out). Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- meson.build | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 8e8f228a37..bd14bc15a1 100644 --- a/meson.build +++ b/meson.build @@ -1592,10 +1592,19 @@ else error('Unsupported CSPRNG backend: ' + csprng_backend) endif +git_exec_path = 'libexec/git-core' +libexec = get_option('libexecdir') +if libexec != 'libexec' and libexec != '.' + git_exec_path = libexec +endif + if get_option('runtime_prefix') libgit_c_args += '-DRUNTIME_PREFIX' build_options_config.set('RUNTIME_PREFIX', 'true') - git_exec_path = get_option('libexecdir') / 'git-core' + + if git_exec_path.startswith('/') + error('runtime_prefix requires a relative libexecdir not:', libexec) + endif if compiler.has_header('mach-o/dyld.h') libgit_c_args += '-DHAVE_NS_GET_EXECUTABLE_PATH' @@ -1632,7 +1641,6 @@ if get_option('runtime_prefix') endif else build_options_config.set('RUNTIME_PREFIX', 'false') - git_exec_path = get_option('prefix') / get_option('libexecdir') / 'git-core' endif libgit_c_args += '-DGIT_EXEC_PATH="' + git_exec_path + '"' From 187ce0222f73dd5e8e8c0f5d0b764b4820cc9143 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Mon, 19 May 2025 17:25:23 +0100 Subject: [PATCH 5/5] configure.ac: upgrade to a compilation check for sysinfo Commit f5e3c6c57d ("meson: do a full usage-based compile check for sysinfo", 2025-04-25) updated the 'sysinfo()' check, as part of the meson build, due to the failure of the check on Solaris. Prior to that commit, the meson build only checked the availability of the '' header file. On Solaris, both the header and the 'sysinfo()' function exist, but are completely unrelated to the same function on Linux (and cygwin). Commit 50dec7c566 ("config.mak.uname: add sysinfo() configuration for cygwin", 2025-04-17) added a similar 'sysinfo()' check to the autoconf build. This check looked for the 'sysinfo()' function itself, rather than just the header, but it will fail (incorrectly set HAVE_SYSINFO) for the same reason. In order to correctly identify the 'sysinfo()' function we require as part of 'git-gc' (used in the 'total_ram() function), we also upgrade to a compilation check, in a similar way to the meson commit. Note that since commit c9a51775a3 ("builtin/gc.c: correct RAM calculation when using sysinfo", 2025-04-17) both the 'totalram' and 'mem_unit' fields of the 'struct sysinfo' are used, so the new check includes both of those fields in the compile check. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- configure.ac | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index d7e0503f1e..f6caab919a 100644 --- a/configure.ac +++ b/configure.ac @@ -1069,9 +1069,28 @@ GIT_CONF_SUBST([CHARSET_LIB]) # # Define HAVE_SYSINFO=YesPlease if sysinfo is available. -GIT_CHECK_FUNC(sysinfo, - [HAVE_SYSINFO=YesPlease], - [HAVE_SYSINFO=]) +# +AC_DEFUN([HAVE_SYSINFO_SRC], [ +AC_LANG_PROGRAM([[ +#include +#include +]], [[ +struct sysinfo si; +uint64_t t = 0; +if (!sysinfo(&si)) { + t = si.totalram; + if (si.mem_unit > 1) + t *= (uint64_t)si.mem_unit; +} +return t; +]])]) + +AC_MSG_CHECKING([for sysinfo]) +AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC], + [AC_MSG_RESULT([yes]) + HAVE_SYSINFO=YesPlease], + [AC_MSG_RESULT([no]) + HAVE_SYSINFO=]) GIT_CONF_SUBST([HAVE_SYSINFO]) #