Merge branch 'rj/build-tweaks-part2'

Updates to meson-based build procedure.

* rj/build-tweaks-part2:
  configure.ac: upgrade to a compilation check for sysinfo
  meson.build: correct setting of GIT_EXEC_PATH
  meson: correct path to system config/attribute files
  meson: correct install location of YAML.pm
  meson.build: quote the GITWEBDIR build configuration
maint
Junio C Hamano 2025-05-27 13:59:09 -07:00
commit 6b6c366e79
4 changed files with 52 additions and 13 deletions

View File

@ -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 <stdint.h>
#include <sys/sysinfo.h>
]], [[
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])

#

View File

@ -743,7 +743,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'))
@ -761,8 +761,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"',
@ -773,6 +771,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 + '"'
@ -1584,10 +1596,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'
@ -1624,7 +1645,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 + '"'


View File

@ -7,10 +7,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,

View File

@ -3,6 +3,6 @@ test_dependencies += custom_target(
output: 'YAML.pm',
command: generate_perl_command,
install: true,
install_dir: perllibdir / 'Git/SVN',
install_dir: perllibdir / 'Git/SVN/Memoize',
depends: [git_version_file],
)