Skip to content

Commit e78bca2

Browse files
committed
Merge branch 'rj/freebsd-sysinfo-build-fix'
Build fix for FreeBSD. * rj/freebsd-sysinfo-build-fix: build: fix FreeBSD build when sysinfo compat library installed
2 parents 8c5f7db + 0c83bbc commit e78bca2

File tree

2 files changed

+41
-30
lines changed

2 files changed

+41
-30
lines changed

configure.ac

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,32 +1067,6 @@ AC_CHECK_LIB([iconv], [locale_charset],
10671067
[CHARSET_LIB=-lcharset])])
10681068
GIT_CONF_SUBST([CHARSET_LIB])
10691069

1070-
#
1071-
# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
1072-
#
1073-
AC_DEFUN([HAVE_SYSINFO_SRC], [
1074-
AC_LANG_PROGRAM([[
1075-
#include <stdint.h>
1076-
#include <sys/sysinfo.h>
1077-
]], [[
1078-
struct sysinfo si;
1079-
uint64_t t = 0;
1080-
if (!sysinfo(&si)) {
1081-
t = si.totalram;
1082-
if (si.mem_unit > 1)
1083-
t *= (uint64_t)si.mem_unit;
1084-
}
1085-
return t;
1086-
]])])
1087-
1088-
AC_MSG_CHECKING([for sysinfo])
1089-
AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
1090-
[AC_MSG_RESULT([yes])
1091-
HAVE_SYSINFO=YesPlease],
1092-
[AC_MSG_RESULT([no])
1093-
HAVE_SYSINFO=])
1094-
GIT_CONF_SUBST([HAVE_SYSINFO])
1095-
10961070
#
10971071
# Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
10981072
GIT_CHECK_FUNC(clock_gettime,
@@ -1213,6 +1187,41 @@ AC_COMPILE_IFELSE([BSD_SYSCTL_SRC],
12131187
HAVE_BSD_SYSCTL=])
12141188
GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
12151189

1190+
#
1191+
# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
1192+
#
1193+
1194+
HAVE_SYSINFO=
1195+
# on a *BSD system, sysctl() takes precedence over the
1196+
# sysinfo() compatibility library (if installed).
1197+
1198+
if test -z "$HAVE_BSD_SYSCTL"; then
1199+
1200+
AC_DEFUN([HAVE_SYSINFO_SRC], [
1201+
AC_LANG_PROGRAM([[
1202+
#include <stdint.h>
1203+
#include <sys/sysinfo.h>
1204+
]], [[
1205+
struct sysinfo si;
1206+
uint64_t t = 0;
1207+
if (!sysinfo(&si)) {
1208+
t = si.totalram;
1209+
if (si.mem_unit > 1)
1210+
t *= (uint64_t)si.mem_unit;
1211+
}
1212+
return t;
1213+
]])])
1214+
1215+
AC_MSG_CHECKING([for sysinfo])
1216+
AC_COMPILE_IFELSE([HAVE_SYSINFO_SRC],
1217+
[AC_MSG_RESULT([yes])
1218+
HAVE_SYSINFO=YesPlease],
1219+
[AC_MSG_RESULT([no])
1220+
HAVE_SYSINFO=])
1221+
GIT_CONF_SUBST([HAVE_SYSINFO])
1222+
1223+
fi
1224+
12161225
## Other checks.
12171226
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
12181227
# Enable it on Windows. By default, symrefs are still used.

meson.build

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,10 +1331,6 @@ if host_machine.system() != 'windows'
13311331
endif
13321332
endif
13331333

1334-
if compiler.has_member('struct sysinfo', 'totalram', prefix: '#include <sys/sysinfo.h>')
1335-
libgit_c_args += '-DHAVE_SYSINFO'
1336-
endif
1337-
13381334
if compiler.has_member('struct stat', 'st_mtimespec.tv_nsec', prefix: '#include <sys/stat.h>')
13391335
libgit_c_args += '-DUSE_ST_TIMESPEC'
13401336
elif not compiler.has_member('struct stat', 'st_mtim.tv_nsec', prefix: '#include <sys/stat.h>')
@@ -1438,6 +1434,12 @@ if compiler.has_header('sys/sysctl.h')
14381434
endif
14391435
endif
14401436

1437+
if not has_bsd_sysctl
1438+
if compiler.has_member('struct sysinfo', 'totalram', prefix: '#include <sys/sysinfo.h>')
1439+
libgit_c_args += '-DHAVE_SYSINFO'
1440+
endif
1441+
endif
1442+
14411443
if not meson.is_cross_build() and compiler.run('''
14421444
#include <stdio.h>
14431445

0 commit comments

Comments
 (0)