Skip to content

Commit 028c432

Browse files
committed
Merge branch 'rj/build-tweaks'
Various build tweaks, including CSPRNG selection on some platforms. * rj/build-tweaks: config.mak.uname: set CSPRNG_METHOD to getrandom on Linux config.mak.uname: add arc4random to the cygwin build config.mak.uname: add sysinfo() configuration for cygwin builtin/gc.c: correct RAM calculation when using sysinfo config.mak.uname: add clock_gettime() to the cygwin build config.mak.uname: add HAVE_GETDELIM to the cygwin section config.mak.uname: only set NO_REGEX on cygwin for v1.7 config.mak.uname: add a note about NO_STRLCPY for Linux Makefile: remove NEEDS_LIBRT build variable meson.build: set default help format to html on windows meson.build: only set build variables for non-default values Makefile: only set some BASIC_CFLAGS when RUNTIME_PREFIX is set meson.build: remove -DCURL_DISABLE_TYPECHECK
2 parents 2bc5414 + cdda67d commit 028c432

File tree

8 files changed

+94
-34
lines changed

8 files changed

+94
-34
lines changed

Documentation/meson.build

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ if docs_backend == 'asciidoc'
250250
'--attribute=build_dir=' + meson.current_build_dir(),
251251
]
252252

253+
pager_opt = get_option('default_pager')
254+
if pager_opt != '' and pager_opt != 'less'
255+
asciidoc_common_options += '-agit-default-pager=' + pager_opt
256+
endif
257+
258+
editor_opt = get_option('default_editor')
259+
if editor_opt != '' and editor_opt != 'vi'
260+
asciidoc_common_options += '-agit-default-editor=' + editor_opt
261+
endif
262+
253263
documentation_deps = [
254264
asciidoc_conf,
255265
]
@@ -287,6 +297,16 @@ elif docs_backend == 'asciidoctor'
287297
'--require', 'asciidoctor-extensions',
288298
]
289299

300+
pager_opt = get_option('default_pager')
301+
if pager_opt != '' and pager_opt != 'less'
302+
asciidoc_common_options += '-agit-default-pager=' + pager_opt
303+
endif
304+
305+
editor_opt = get_option('default_editor')
306+
if editor_opt != '' and editor_opt != 'vi'
307+
asciidoc_common_options += '-agit-default-editor=' + editor_opt
308+
endif
309+
290310
documentation_deps = [
291311
asciidoctor_extensions,
292312
]

Makefile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,6 @@ include shared.mak
340340
#
341341
# Define HAVE_SYNC_FILE_RANGE if your platform has sync_file_range.
342342
#
343-
# Define NEEDS_LIBRT if your platform requires linking with librt (glibc version
344-
# before 2.17) for clock_gettime and CLOCK_MONOTONIC.
345-
#
346343
# Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.
347344
#
348345
# Define HAVE_GETDELIM if your system has the getdelim() function.
@@ -2174,18 +2171,14 @@ ifdef HAVE_SYNC_FILE_RANGE
21742171
BASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE
21752172
endif
21762173

2177-
ifdef NEEDS_LIBRT
2178-
EXTLIBS += -lrt
2174+
ifdef HAVE_SYSINFO
2175+
BASIC_CFLAGS += -DHAVE_SYSINFO
21792176
endif
21802177

21812178
ifdef HAVE_BSD_SYSCTL
21822179
BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
21832180
endif
21842181

2185-
ifdef HAVE_BSD_KERN_PROC_SYSCTL
2186-
BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
2187-
endif
2188-
21892182
ifdef HAVE_GETDELIM
21902183
BASIC_CFLAGS += -DHAVE_GETDELIM
21912184
endif
@@ -2216,25 +2209,33 @@ ifneq ($(findstring openssl,$(CSPRNG_METHOD)),)
22162209
EXTLIBS += -lcrypto -lssl
22172210
endif
22182211

2219-
ifneq ($(PROCFS_EXECUTABLE_PATH),)
2220-
procfs_executable_path_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
2221-
BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
2222-
endif
2223-
22242212
ifndef HAVE_PLATFORM_PROCINFO
22252213
COMPAT_OBJS += compat/stub/procinfo.o
22262214
endif
22272215

2228-
ifdef HAVE_NS_GET_EXECUTABLE_PATH
2229-
BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
2230-
endif
2216+
ifdef RUNTIME_PREFIX
22312217

2232-
ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
2233-
BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH
2234-
endif
2218+
ifdef HAVE_BSD_KERN_PROC_SYSCTL
2219+
BASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL
2220+
endif
2221+
2222+
ifneq ($(PROCFS_EXECUTABLE_PATH),)
2223+
pep_SQ = $(subst ','\'',$(PROCFS_EXECUTABLE_PATH))
2224+
BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(pep_SQ)"'
2225+
endif
2226+
2227+
ifdef HAVE_NS_GET_EXECUTABLE_PATH
2228+
BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
2229+
endif
2230+
2231+
ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
2232+
BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH
2233+
endif
2234+
2235+
ifdef HAVE_WPGMPTR
2236+
BASIC_CFLAGS += -DHAVE_WPGMPTR
2237+
endif
22352238

2236-
ifdef HAVE_WPGMPTR
2237-
BASIC_CFLAGS += -DHAVE_WPGMPTR
22382239
endif
22392240

22402241
ifdef FILENO_IS_A_MACRO

builtin/gc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,13 @@ static uint64_t total_ram(void)
424424
#if defined(HAVE_SYSINFO)
425425
struct sysinfo si;
426426

427-
if (!sysinfo(&si))
428-
return si.totalram;
427+
if (!sysinfo(&si)) {
428+
uint64_t total = si.totalram;
429+
430+
if (si.mem_unit > 1)
431+
total *= (uint64_t)si.mem_unit;
432+
return total;
433+
}
429434
#elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM))
430435
int64_t physical_memory;
431436
int mib[2];

config.mak.uname

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ ifeq ($(uname_S),OSF1)
4848
endif
4949
ifeq ($(uname_S),Linux)
5050
HAVE_ALLOCA_H = YesPlease
51+
# override in config.mak if you have glibc >= 2.38
5152
NO_STRLCPY = YesPlease
53+
CSPRNG_METHOD = getrandom
5254
HAVE_PATHS_H = YesPlease
5355
LIBC_CONTAINS_LIBINTL = YesPlease
5456
HAVE_DEV_TTY = YesPlease
5557
HAVE_CLOCK_GETTIME = YesPlease
5658
HAVE_CLOCK_MONOTONIC = YesPlease
57-
# -lrt is needed for clock_gettime on glibc <= 2.16
58-
NEEDS_LIBRT = YesPlease
5959
HAVE_SYNC_FILE_RANGE = YesPlease
6060
HAVE_GETDELIM = YesPlease
6161
FREAD_READS_DIRECTORIES = UnfortunatelyYes
62-
BASIC_CFLAGS += -DHAVE_SYSINFO
62+
HAVE_SYSINFO = YesPlease
6363
PROCFS_EXECUTABLE_PATH = /proc/self/exe
6464
HAVE_PLATFORM_PROCINFO = YesPlease
6565
COMPAT_OBJS += compat/linux/procinfo.o
@@ -246,9 +246,16 @@ ifeq ($(uname_O),Cygwin)
246246
# Try commenting this out if you suspect MMAP is more efficient
247247
NO_MMAP = YesPlease
248248
else
249-
NO_REGEX = UnfortunatelyYes
249+
ifeq ($(shell expr "$(uname_R)" : '1\.7\.'),4)
250+
NO_REGEX = UnfortunatelyYes
251+
endif
250252
endif
251253
HAVE_DEV_TTY = YesPlease
254+
HAVE_GETDELIM = YesPlease
255+
HAVE_CLOCK_GETTIME = YesPlease
256+
HAVE_CLOCK_MONOTONIC = YesPlease
257+
HAVE_SYSINFO = YesPlease
258+
CSPRNG_METHOD = arc4random
252259
HAVE_ALLOCA_H = YesPlease
253260
NEEDS_LIBICONV = YesPlease
254261
NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,14 @@ AC_CHECK_LIB([iconv], [locale_charset],
10661066
[AC_CHECK_LIB([charset], [locale_charset],
10671067
[CHARSET_LIB=-lcharset])])
10681068
GIT_CONF_SUBST([CHARSET_LIB])
1069+
1070+
#
1071+
# Define HAVE_SYSINFO=YesPlease if sysinfo is available.
1072+
GIT_CHECK_FUNC(sysinfo,
1073+
[HAVE_SYSINFO=YesPlease],
1074+
[HAVE_SYSINFO=])
1075+
GIT_CONF_SUBST([HAVE_SYSINFO])
1076+
10691077
#
10701078
# Define HAVE_CLOCK_GETTIME=YesPlease if clock_gettime is available.
10711079
GIT_CHECK_FUNC(clock_gettime,

meson.build

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,7 @@ endif
727727
# These variables are used for building libgit.a.
728728
libgit_c_args = [
729729
'-DBINDIR="' + get_option('bindir') + '"',
730-
'-DDEFAULT_EDITOR="' + get_option('default_editor') + '"',
731730
'-DDEFAULT_GIT_TEMPLATE_DIR="' + get_option('datadir') / 'git-core/templates' + '"',
732-
'-DDEFAULT_HELP_FORMAT="' + get_option('default_help_format') + '"',
733-
'-DDEFAULT_PAGER="' + get_option('default_pager') + '"',
734731
'-DETC_GITATTRIBUTES="' + get_option('gitattributes') + '"',
735732
'-DETC_GITCONFIG="' + get_option('gitconfig') + '"',
736733
'-DFALLBACK_RUNTIME_PREFIX="' + get_option('prefix') + '"',
@@ -742,6 +739,29 @@ libgit_c_args = [
742739
'-DPAGER_ENV="' + get_option('pager_environment') + '"',
743740
'-DSHELL_PATH="' + fs.as_posix(target_shell.full_path()) + '"',
744741
]
742+
743+
editor_opt = get_option('default_editor')
744+
if editor_opt != '' and editor_opt != 'vi'
745+
libgit_c_args += '-DDEFAULT_EDITOR="' + editor_opt + '"'
746+
endif
747+
748+
pager_opt = get_option('default_pager')
749+
if pager_opt != '' and pager_opt != 'less'
750+
libgit_c_args += '-DDEFAULT_PAGER="' + pager_opt + '"'
751+
endif
752+
753+
help_format_opt = get_option('default_help_format')
754+
if help_format_opt == 'platform'
755+
if host_machine.system() == 'windows'
756+
help_format_opt = 'html'
757+
else
758+
help_format_opt = 'man'
759+
endif
760+
endif
761+
if help_format_opt != 'man'
762+
libgit_c_args += '-DDEFAULT_HELP_FORMAT="' + help_format_opt + '"'
763+
endif
764+
745765
libgit_include_directories = [ '.' ]
746766
libgit_dependencies = [ ]
747767

@@ -1012,7 +1032,6 @@ if curl.found()
10121032
# Most executables don't have to link against libcurl, but we still need its
10131033
# include directories so that we can resolve LIBCURL_VERSION in "help.c".
10141034
libgit_dependencies += curl.partial_dependency(includes: true)
1015-
libgit_c_args += '-DCURL_DISABLE_TYPECHECK'
10161035
build_options_config.set('NO_CURL', '')
10171036
else
10181037
libgit_c_args += '-DNO_CURL'

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ option('highlight_bin', type: 'string', value: 'highlight')
9595
# Documentation.
9696
option('docs', type: 'array', choices: ['man', 'html'], value: [],
9797
description: 'Which documenattion formats to build and install.')
98-
option('default_help_format', type: 'combo', choices: ['man', 'html'], value: 'man',
98+
option('default_help_format', type: 'combo', choices: ['man', 'html', 'platform'], value: 'platform',
9999
description: 'Default format used when executing git-help(1).')
100100
option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto'], value: 'auto',
101101
description: 'Which backend to use to generate documentation.')

t/t7815-grep-binary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test_expect_success 'git grep ile a' '
6363
git grep ile a
6464
'
6565

66-
test_expect_failure 'git grep .fi a' '
66+
test_expect_failure !CYGWIN 'git grep .fi a' '
6767
git grep .fi a
6868
'
6969

0 commit comments

Comments
 (0)