Skip to content

Commit 728b9ac

Browse files
ttaylorrgitster
authored andcommitted
Makefile(s): avoid recipe prefix in conditional statements
In GNU Make commit 07fcee35 ([SV 64815] Recipe lines cannot contain conditional statements, 2023-05-22) and following, conditional statements may no longer be preceded by a tab character (which Make refers to as the recipe prefix). There are a handful of spots in our various Makefile(s) which will break in a future release of Make containing 07fcee35. For instance, trying to compile the pre-image of this patch with the tip of make.git results in the following: $ make -v | head -1 && make GNU Make 4.4.90 config.mak.uname:842: *** missing 'endif'. Stop. The kernel addressed this issue in 82175d1f9430 (kbuild: Replace tabs with spaces when followed by conditionals, 2024-01-28). Address the issues in Git's tree by applying the same strategy. When a conditional word (ifeq, ifneq, ifdef, etc.) is preceded by one or more tab characters, replace each tab character with 8 space characters with the following: find . -type f -not -path './.git/*' -name Makefile -or -name '*.mak' | xargs perl -i -pe ' s/(\t+)(ifn?eq|ifn?def|else|endif)/" " x (length($1) * 8) . $2/ge unless /\\$/ ' The "unless /\\$/" removes any false-positives (like "\telse \" appearing within a shell script as part of a recipe). After doing so, Git compiles on newer versions of Make: $ make -v | head -1 && make GNU Make 4.4.90 GIT_VERSION = 2.44.0.414.gfac1dc44ca9 [...] $ echo $? 0 Reported-by: Dario Gjorgjevski <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c2a3fd commit 728b9ac

File tree

4 files changed

+135
-135
lines changed

4 files changed

+135
-135
lines changed

Makefile

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,23 +1552,23 @@ ifneq (,$(SOCKLEN_T))
15521552
endif
15531553

15541554
ifeq ($(uname_S),Darwin)
1555-
ifndef NO_FINK
1556-
ifeq ($(shell test -d /sw/lib && echo y),y)
1555+
ifndef NO_FINK
1556+
ifeq ($(shell test -d /sw/lib && echo y),y)
15571557
BASIC_CFLAGS += -I/sw/include
15581558
BASIC_LDFLAGS += -L/sw/lib
1559-
endif
1560-
endif
1561-
ifndef NO_DARWIN_PORTS
1562-
ifeq ($(shell test -d /opt/local/lib && echo y),y)
1559+
endif
1560+
endif
1561+
ifndef NO_DARWIN_PORTS
1562+
ifeq ($(shell test -d /opt/local/lib && echo y),y)
15631563
BASIC_CFLAGS += -I/opt/local/include
15641564
BASIC_LDFLAGS += -L/opt/local/lib
1565-
endif
1566-
endif
1567-
ifndef NO_APPLE_COMMON_CRYPTO
1565+
endif
1566+
endif
1567+
ifndef NO_APPLE_COMMON_CRYPTO
15681568
NO_OPENSSL = YesPlease
15691569
APPLE_COMMON_CRYPTO = YesPlease
15701570
COMPAT_CFLAGS += -DAPPLE_COMMON_CRYPTO
1571-
endif
1571+
endif
15721572
PTHREAD_LIBS =
15731573
endif
15741574

@@ -1607,53 +1607,53 @@ ifdef NO_CURL
16071607
REMOTE_CURL_NAMES =
16081608
EXCLUDED_PROGRAMS += git-http-fetch git-http-push
16091609
else
1610-
ifdef CURLDIR
1610+
ifdef CURLDIR
16111611
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
16121612
CURL_CFLAGS = -I$(CURLDIR)/include
16131613
CURL_LIBCURL = $(call libpath_template,$(CURLDIR)/$(lib))
1614-
else
1614+
else
16151615
CURL_CFLAGS =
16161616
CURL_LIBCURL =
1617-
endif
1617+
endif
16181618

1619-
ifndef CURL_LDFLAGS
1619+
ifndef CURL_LDFLAGS
16201620
CURL_LDFLAGS = $(eval CURL_LDFLAGS := $$(shell $$(CURL_CONFIG) --libs))$(CURL_LDFLAGS)
1621-
endif
1621+
endif
16221622
CURL_LIBCURL += $(CURL_LDFLAGS)
16231623

1624-
ifndef CURL_CFLAGS
1624+
ifndef CURL_CFLAGS
16251625
CURL_CFLAGS = $(eval CURL_CFLAGS := $$(shell $$(CURL_CONFIG) --cflags))$(CURL_CFLAGS)
1626-
endif
1626+
endif
16271627
BASIC_CFLAGS += $(CURL_CFLAGS)
16281628

16291629
REMOTE_CURL_PRIMARY = git-remote-http$X
16301630
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
16311631
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
16321632
PROGRAM_OBJS += http-fetch.o
16331633
PROGRAMS += $(REMOTE_CURL_NAMES)
1634-
ifndef NO_EXPAT
1634+
ifndef NO_EXPAT
16351635
PROGRAM_OBJS += http-push.o
1636-
endif
1636+
endif
16371637
curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
1638-
ifeq "$(curl_check)" "072200"
1638+
ifeq "$(curl_check)" "072200"
16391639
USE_CURL_FOR_IMAP_SEND = YesPlease
1640-
endif
1641-
ifdef USE_CURL_FOR_IMAP_SEND
1640+
endif
1641+
ifdef USE_CURL_FOR_IMAP_SEND
16421642
BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND
16431643
IMAP_SEND_BUILDDEPS = http.o
16441644
IMAP_SEND_LDFLAGS += $(CURL_LIBCURL)
1645-
endif
1646-
ifndef NO_EXPAT
1647-
ifdef EXPATDIR
1645+
endif
1646+
ifndef NO_EXPAT
1647+
ifdef EXPATDIR
16481648
BASIC_CFLAGS += -I$(EXPATDIR)/include
16491649
EXPAT_LIBEXPAT = $(call libpath_template,$(EXPATDIR)/$(lib)) -lexpat
1650-
else
1650+
else
16511651
EXPAT_LIBEXPAT = -lexpat
1652-
endif
1653-
ifdef EXPAT_NEEDS_XMLPARSE_H
1652+
endif
1653+
ifdef EXPAT_NEEDS_XMLPARSE_H
16541654
BASIC_CFLAGS += -DEXPAT_NEEDS_XMLPARSE_H
1655-
endif
1656-
endif
1655+
endif
1656+
endif
16571657
endif
16581658
IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
16591659

@@ -1665,15 +1665,15 @@ EXTLIBS += -lz
16651665

16661666
ifndef NO_OPENSSL
16671667
OPENSSL_LIBSSL = -lssl
1668-
ifdef OPENSSLDIR
1668+
ifdef OPENSSLDIR
16691669
BASIC_CFLAGS += -I$(OPENSSLDIR)/include
16701670
OPENSSL_LINK = $(call libpath_template,$(OPENSSLDIR)/$(lib))
1671-
else
1671+
else
16721672
OPENSSL_LINK =
1673-
endif
1674-
ifdef NEEDS_CRYPTO_WITH_SSL
1673+
endif
1674+
ifdef NEEDS_CRYPTO_WITH_SSL
16751675
OPENSSL_LIBSSL += -lcrypto
1676-
endif
1676+
endif
16771677
else
16781678
BASIC_CFLAGS += -DNO_OPENSSL
16791679
OPENSSL_LIBSSL =
@@ -1691,18 +1691,18 @@ ifdef APPLE_COMMON_CRYPTO
16911691
endif
16921692
endif
16931693
ifndef NO_ICONV
1694-
ifdef NEEDS_LIBICONV
1695-
ifdef ICONVDIR
1694+
ifdef NEEDS_LIBICONV
1695+
ifdef ICONVDIR
16961696
BASIC_CFLAGS += -I$(ICONVDIR)/include
16971697
ICONV_LINK = $(call libpath_template,$(ICONVDIR)/$(lib))
1698-
else
1698+
else
16991699
ICONV_LINK =
1700-
endif
1701-
ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
1700+
endif
1701+
ifdef NEEDS_LIBINTL_BEFORE_LIBICONV
17021702
ICONV_LINK += -lintl
1703-
endif
1703+
endif
17041704
EXTLIBS += $(ICONV_LINK) -liconv
1705-
endif
1705+
endif
17061706
endif
17071707
ifdef ICONV_OMITS_BOM
17081708
BASIC_CFLAGS += -DICONV_OMITS_BOM
@@ -1823,10 +1823,10 @@ ifdef NO_MMAP
18231823
COMPAT_CFLAGS += -DNO_MMAP
18241824
COMPAT_OBJS += compat/mmap.o
18251825
else
1826-
ifdef USE_WIN32_MMAP
1826+
ifdef USE_WIN32_MMAP
18271827
COMPAT_CFLAGS += -DUSE_WIN32_MMAP
18281828
COMPAT_OBJS += compat/win32mmap.o
1829-
endif
1829+
endif
18301830
endif
18311831
ifdef MMAP_PREVENTS_DELETE
18321832
BASIC_CFLAGS += -DMMAP_PREVENTS_DELETE
@@ -1951,11 +1951,11 @@ else
19511951
BASIC_CFLAGS += -DSHA1_DC
19521952
LIB_OBJS += sha1dc_git.o
19531953
ifdef DC_SHA1_EXTERNAL
1954-
ifdef DC_SHA1_SUBMODULE
1955-
ifneq ($(DC_SHA1_SUBMODULE),auto)
1954+
ifdef DC_SHA1_SUBMODULE
1955+
ifneq ($(DC_SHA1_SUBMODULE),auto)
19561956
$(error Only set DC_SHA1_EXTERNAL or DC_SHA1_SUBMODULE, not both)
1957-
endif
1958-
endif
1957+
endif
1958+
endif
19591959
BASIC_CFLAGS += -DDC_SHA1_EXTERNAL
19601960
EXTLIBS += -lsha1detectcoll
19611961
else

0 commit comments

Comments
 (0)