Skip to content

Commit 1351570

Browse files
ttaylorrj6t
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 [j6t: cherry-picked from 728b9ac] Reported-by: Dario Gjorgjevski <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent 34a2498 commit 1351570

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ endif
107107

108108
ifeq ($(uname_S),Darwin)
109109
TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
110-
ifeq ($(shell echo "$(uname_R)" | awk -F. '{if ($$1 >= 9) print "y"}')_$(shell test -d $(TKFRAMEWORK) || echo n),y_n)
110+
ifeq ($(shell echo "$(uname_R)" | awk -F. '{if ($$1 >= 9) print "y"}')_$(shell test -d $(TKFRAMEWORK) || echo n),y_n)
111111
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish.app
112-
ifeq ($(shell test -d $(TKFRAMEWORK) || echo n),n)
112+
ifeq ($(shell test -d $(TKFRAMEWORK) || echo n),n)
113113
TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
114-
endif
115-
endif
114+
endif
115+
endif
116116
TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
117117
endif
118118

@@ -143,9 +143,9 @@ ifeq ($(exedir),$(gg_libdir))
143143
endif
144144
gg_libdir_sed_in := $(gg_libdir)
145145
ifeq ($(uname_S),Darwin)
146-
ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
146+
ifeq ($(shell test -d $(TKFRAMEWORK) && echo y),y)
147147
GITGUI_MACOSXAPP := YesPlease
148-
endif
148+
endif
149149
endif
150150
ifneq (,$(findstring MINGW,$(uname_S)))
151151
ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
@@ -220,9 +220,9 @@ ifdef NO_MSGFMT
220220
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
221221
else
222222
MSGFMT ?= msgfmt
223-
ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
223+
ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
224224
MSGFMT := $(TCL_PATH) po/po2msg.sh
225-
endif
225+
endif
226226
endif
227227

228228
msgsdir = $(gg_libdir)/msgs

0 commit comments

Comments
 (0)