Skip to content

Commit 4de066b

Browse files
avargitster
authored andcommitted
Makefile & configure: add a NO_FNMATCH_CASEFOLD flag
On some platforms (like Solaris) there is a fnmatch, but it doesn't support the GNU FNM_CASEFOLD extension that's used by the jj/icase-directory series' fnmatch_icase wrapper. Change the Makefile so that it's now possible to set NO_FNMATCH_CASEFOLD=YesPlease on those systems, and add a configure probe for it. Unlike the NO_REGEX check we don't add AC_INCLUDES_DEFAULT to our headers. This is because on a GNU system the definition of FNM_CASEFOLD in fnmatch.h is guarded by: #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE One of the headers AC_INCLUDES_DEFAULT includes ends up defining one of those, so if we'd use it we'd always get NO_FNMATCH_CASEFOLD=YesPlease on GNU systems, even though they have FNM_CASEFOLD. When checking the flags we use: ifdef NO_FNMATCH ... else ifdef NO_FNMATCH_CASEFOLD ... endif endif The "else" so that we don't link against compat/fnmatch/fnmatch.o twice if both NO_FNMATCH and NO_FNMATCH_CASEFOLD are defined. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent f3f3d93 commit 4de066b

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ all::
7070
#
7171
# Define NO_FNMATCH if you don't have fnmatch in the C library.
7272
#
73+
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
74+
# FNM_CASEFOLD GNU extension.
75+
#
7376
# Define NO_LIBGEN_H if you don't have libgen.h.
7477
#
7578
# Define NEEDS_LIBGEN if your libgen needs -lgen when linking
@@ -834,6 +837,7 @@ ifeq ($(uname_S),SunOS)
834837
NO_MKDTEMP = YesPlease
835838
NO_MKSTEMPS = YesPlease
836839
NO_REGEX = YesPlease
840+
NO_FNMATCH_CASEFOLD = YesPlease
837841
ifeq ($(uname_R),5.6)
838842
SOCKLEN_T = int
839843
NO_HSTRERROR = YesPlease
@@ -1326,6 +1330,12 @@ ifdef NO_FNMATCH
13261330
COMPAT_CFLAGS += -Icompat/fnmatch
13271331
COMPAT_CFLAGS += -DNO_FNMATCH
13281332
COMPAT_OBJS += compat/fnmatch/fnmatch.o
1333+
else
1334+
ifdef NO_FNMATCH_CASEFOLD
1335+
COMPAT_CFLAGS += -Icompat/fnmatch
1336+
COMPAT_CFLAGS += -DNO_FNMATCH_CASEFOLD
1337+
COMPAT_OBJS += compat/fnmatch/fnmatch.o
1338+
endif
13291339
endif
13301340
ifdef NO_SETENV
13311341
COMPAT_CFLAGS += -DNO_SETENV

config.mak.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ NO_C99_FORMAT=@NO_C99_FORMAT@
4747
NO_HSTRERROR=@NO_HSTRERROR@
4848
NO_STRCASESTR=@NO_STRCASESTR@
4949
NO_FNMATCH=@NO_FNMATCH@
50+
NO_FNMATCH_CASEFOLD=@NO_FNMATCH_CASEFOLD@
5051
NO_MEMMEM=@NO_MEMMEM@
5152
NO_STRLCPY=@NO_STRLCPY@
5253
NO_UINTMAX_T=@NO_UINTMAX_T@

configure.ac

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,28 @@ GIT_CHECK_FUNC(fnmatch,
789789
[NO_FNMATCH=YesPlease])
790790
AC_SUBST(NO_FNMATCH)
791791
#
792+
# Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
793+
# FNM_CASEFOLD GNU extension.
794+
AC_CACHE_CHECK([whether the fnmatch function supports the FNMATCH_CASEFOLD GNU extension],
795+
[ac_cv_c_excellent_fnmatch], [
796+
AC_EGREP_CPP(yippeeyeswehaveit,
797+
AC_LANG_PROGRAM([
798+
#include <fnmatch.h>
799+
],
800+
[#ifdef FNM_CASEFOLD
801+
yippeeyeswehaveit
802+
#endif
803+
]),
804+
[ac_cv_c_excellent_fnmatch=yes],
805+
[ac_cv_c_excellent_fnmatch=no])
806+
])
807+
if test $ac_cv_c_excellent_fnmatch = yes; then
808+
NO_FNMATCH_CASEFOLD=
809+
else
810+
NO_FNMATCH_CASEFOLD=YesPlease
811+
fi
812+
AC_SUBST(NO_FNMATCH_CASEFOLD)
813+
#
792814
# Define NO_MEMMEM if you don't have memmem.
793815
GIT_CHECK_FUNC(memmem,
794816
[NO_MEMMEM=],

0 commit comments

Comments
 (0)