From 1308ffe5afade6e3962a2001e044d21cb50c8a7f Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Mon, 29 Dec 2025 09:26:34 +0800
Subject: [PATCH v1] Introduce ENDLIST to terminate multiline makefile lists

Introduce a common ENDLIST variable and append it to these multiline lists,
so that items can be added or removed without worrying about whether they are
last in the list. This is purely a build-system cleanup and does not change
the resulting list contents.

Define ENDLIST once in Makefile.global.in and apply it consistently across
the affected makefiles.

Author: Chao Li <lic@highgo.com>
---
 contrib/pageinspect/Makefile   | 3 ++-
 src/Makefile.global.in         | 3 +++
 src/backend/Makefile           | 6 ++++--
 src/backend/access/Makefile    | 3 ++-
 src/backend/optimizer/Makefile | 3 ++-
 src/backend/storage/Makefile   | 3 ++-
 src/bin/scripts/Makefile       | 3 ++-
 src/include/Makefile           | 3 ++-
 src/interfaces/ecpg/Makefile   | 3 ++-
 src/pl/tcl/Makefile            | 3 ++-
 src/test/Makefile              | 3 ++-
 src/test/examples/Makefile     | 3 ++-
 12 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/contrib/pageinspect/Makefile b/contrib/pageinspect/Makefile
index eae989569d0..de1994a42a3 100644
--- a/contrib/pageinspect/Makefile
+++ b/contrib/pageinspect/Makefile
@@ -10,7 +10,8 @@ OBJS = \
 	gistfuncs.o \
 	hashfuncs.o \
 	heapfuncs.o \
-	rawpage.o
+	rawpage.o \
+	$(ENDLIST)
 
 EXTENSION = pageinspect
 DATA =  pageinspect--1.12--1.13.sql \
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 371cd7eba2c..641019f71c1 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -76,6 +76,9 @@ VPATH = $(srcdir)
 endif
 endif # not PGXS
 
+# Used to terminated a multi-line list
+ENDLIST=
+
 
 ##########################################################################
 #
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 43e1e604891..dc59d8d61d6 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -43,7 +43,8 @@ SUBDIRS = \
 	tsearch \
 	utils \
 	$(top_builddir)/src/timezone \
-	jit
+	jit \
+	$(ENDLIST)
 
 include $(srcdir)/common.mk
 
@@ -63,7 +64,8 @@ OBJS = \
 	$(LOCALOBJS) \
 	$(SUBDIROBJS) \
 	$(top_builddir)/src/common/libpgcommon_srv.a \
-	$(top_builddir)/src/port/libpgport_srv.a
+	$(top_builddir)/src/port/libpgport_srv.a \
+	$(ENDLIST)
 
 # We put libpgport and libpgcommon into OBJS, so remove it from LIBS.
 LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS))
diff --git a/src/backend/access/Makefile b/src/backend/access/Makefile
index e88d72ea039..dc4d89b9863 100644
--- a/src/backend/access/Makefile
+++ b/src/backend/access/Makefile
@@ -22,6 +22,7 @@ SUBDIRS	    = \
 	sequence \
 	table \
 	tablesample \
-	transam
+	transam \
+	$(ENDLIST)
 
 include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/optimizer/Makefile b/src/backend/optimizer/Makefile
index 0e7e76a7150..68986591dac 100644
--- a/src/backend/optimizer/Makefile
+++ b/src/backend/optimizer/Makefile
@@ -13,6 +13,7 @@ SUBDIRS = \
 	path \
 	plan \
 	prep \
-	util
+	util \
+	$(ENDLIST)
 
 include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/storage/Makefile b/src/backend/storage/Makefile
index 2afb42ca96e..45f4c717ddc 100644
--- a/src/backend/storage/Makefile
+++ b/src/backend/storage/Makefile
@@ -18,6 +18,7 @@ SUBDIRS = \
 	lmgr \
 	page \
 	smgr \
-	sync
+	sync \
+	$(ENDLIST)
 
 include $(top_srcdir)/src/backend/common.mk
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index 0adac081f2e..797eb580a19 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -24,7 +24,8 @@ PROGRAMS = \
 	dropuser \
 	pg_isready \
 	reindexdb \
-	vacuumdb
+	vacuumdb \
+	$(ENDLIST)
 
 override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
diff --git a/src/include/Makefile b/src/include/Makefile
index 4ef060e9050..58ee522a278 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -56,7 +56,8 @@ SUBDIRS = \
 	port/win32/arpa \
 	port/win32/netinet \
 	port/win32/sys \
-	portability
+	portability \
+	$(ENDLIST)
 
 # Install all headers
 install: all installdirs
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index 1977981aa95..c2be6458bfc 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -7,7 +7,8 @@ SUBDIRS = \
 	ecpglib \
 	include \
 	pgtypeslib \
-	preproc
+	preproc \
+	$(ENDLIST)
 
 # Suppress parallel build of subdirectories to avoid a bug in GNU make 3.82, cf
 # https://savannah.gnu.org/bugs/?30653
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 7dc7cf3497a..8c3ae14ab7d 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -40,7 +40,8 @@ REGRESS = \
 	pltcl_subxact \
 	pltcl_transaction \
 	pltcl_trigger \
-	pltcl_unicode
+	pltcl_unicode \
+	$(ENDLIST)
 
 # Tcl on win32 ships with import libraries only for Microsoft Visual C++,
 # which are not compatible with mingw gcc. Therefore we need to build a
diff --git a/src/test/Makefile b/src/test/Makefile
index 3eb0a06abb4..104a6d91312 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -20,7 +20,8 @@ SUBDIRS = \
 	postmaster \
 	recovery \
 	regress \
-	subscription
+	subscription \
+	$(ENDLIST)
 
 ifeq ($(with_icu),yes)
 SUBDIRS += icu
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index 3a4e36465ba..175fae06f11 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -20,7 +20,8 @@ PROGS = \
 	testlibpq3 \
 	testlibpq4 \
 	testlo \
-	testlo64
+	testlo64 \
+	$(ENDLIST)
 
 all: $(PROGS)
 
-- 
2.39.5 (Apple Git-154)

