Skip to content

Commit f3f3d93

Browse files
avargitster
authored andcommitted
Makefile & configure: add a NO_FNMATCH flag
Windows and MinGW both lack fnmatch() in their C library and needed compat/fnmatch, but they had duplicate code for adding the compat function, and there was no Makefile flag or configure check for fnmatch. Change the Makefile it so that it's now possible to compile the compat function with a NO_FNMATCH=YesPlease flag, and add a configure probe for it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3235b70 commit f3f3d93

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ all::
6868
#
6969
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
7070
#
71+
# Define NO_FNMATCH if you don't have fnmatch in the C library.
72+
#
7173
# Define NO_LIBGEN_H if you don't have libgen.h.
7274
#
7375
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
@@ -1035,6 +1037,7 @@ ifeq ($(uname_S),Windows)
10351037
NO_UNSETENV = YesPlease
10361038
NO_STRCASESTR = YesPlease
10371039
NO_STRLCPY = YesPlease
1040+
NO_FNMATCH = YesPlease
10381041
NO_MEMMEM = YesPlease
10391042
# NEEDS_LIBICONV = YesPlease
10401043
NO_ICONV = YesPlease
@@ -1064,8 +1067,8 @@ ifeq ($(uname_S),Windows)
10641067
AR = compat/vcbuild/scripts/lib.pl
10651068
CFLAGS =
10661069
BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
1067-
COMPAT_OBJS = compat/msvc.o compat/fnmatch/fnmatch.o compat/winansi.o compat/win32/pthread.o
1068-
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/fnmatch -Icompat/regex -Icompat/fnmatch -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
1070+
COMPAT_OBJS = compat/msvc.o compat/winansi.o compat/win32/pthread.o
1071+
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
10691072
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
10701073
EXTLIBS = advapi32.lib shell32.lib wininet.lib ws2_32.lib
10711074
PTHREAD_LIBS =
@@ -1089,6 +1092,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
10891092
NO_UNSETENV = YesPlease
10901093
NO_STRCASESTR = YesPlease
10911094
NO_STRLCPY = YesPlease
1095+
NO_FNMATCH = YesPlease
10921096
NO_MEMMEM = YesPlease
10931097
NEEDS_LIBICONV = YesPlease
10941098
OLD_ICONV = YesPlease
@@ -1109,10 +1113,9 @@ ifneq (,$(findstring MINGW,$(uname_S)))
11091113
NO_REGEX = YesPlease
11101114
NO_PYTHON = YesPlease
11111115
BLK_SHA1 = YesPlease
1112-
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
1116+
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
11131117
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
1114-
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
1115-
compat/win32/pthread.o
1118+
COMPAT_OBJS += compat/mingw.o compat/winansi.o compat/win32/pthread.o
11161119
EXTLIBS += -lws2_32
11171120
PTHREAD_LIBS =
11181121
X = .exe
@@ -1319,6 +1322,11 @@ endif
13191322
ifdef NO_STRTOULL
13201323
COMPAT_CFLAGS += -DNO_STRTOULL
13211324
endif
1325+
ifdef NO_FNMATCH
1326+
COMPAT_CFLAGS += -Icompat/fnmatch
1327+
COMPAT_CFLAGS += -DNO_FNMATCH
1328+
COMPAT_OBJS += compat/fnmatch/fnmatch.o
1329+
endif
13221330
ifdef NO_SETENV
13231331
COMPAT_CFLAGS += -DNO_SETENV
13241332
COMPAT_OBJS += compat/setenv.o

config.mak.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ NO_IPV6=@NO_IPV6@
4646
NO_C99_FORMAT=@NO_C99_FORMAT@
4747
NO_HSTRERROR=@NO_HSTRERROR@
4848
NO_STRCASESTR=@NO_STRCASESTR@
49+
NO_FNMATCH=@NO_FNMATCH@
4950
NO_MEMMEM=@NO_MEMMEM@
5051
NO_STRLCPY=@NO_STRLCPY@
5152
NO_UINTMAX_T=@NO_UINTMAX_T@

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,12 @@ GIT_CHECK_FUNC(strcasestr,
783783
[NO_STRCASESTR=YesPlease])
784784
AC_SUBST(NO_STRCASESTR)
785785
#
786+
# Define NO_FNMATCH if you don't have fnmatch
787+
GIT_CHECK_FUNC(fnmatch,
788+
[NO_FNMATCH=],
789+
[NO_FNMATCH=YesPlease])
790+
AC_SUBST(NO_FNMATCH)
791+
#
786792
# Define NO_MEMMEM if you don't have memmem.
787793
GIT_CHECK_FUNC(memmem,
788794
[NO_MEMMEM=],

0 commit comments

Comments
 (0)