Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
> On 13.07.22 20:19, Tom Lane wrote:
>> Hmm. We could list built files explicitly, perhaps, and still be
>> a good step ahead on the maintenance burden. Does xgettext get
>> upset if the same input file is mentioned twice, ie would we have
>> to filter sql_help.c out of the wildcard result?
> It seems it would be ok with that.
Actually, we can get rid of those easily enough anyway with $(sort).
Here's a draft that might solve these problems. The idea is to use
$(wildcard) for files in the srcdir, and manually enumerate only
built files.
regards, tom lane
diff --git a/src/bin/initdb/nls.mk b/src/bin/initdb/nls.mk
index 19c9136849..54d6d034b5 100644
--- a/src/bin/initdb/nls.mk
+++ b/src/bin/initdb/nls.mk
@@ -1,5 +1,7 @@
# src/bin/initdb/nls.mk
CATALOG_NAME = initdb
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) findtimezone.c initdb.c ../../common/exec.c
../../common/fe_memutils.c../../common/file_utils.c ../../common/pgfnames.c ../../common/restricted_token.c
../../common/rmtree.c../../common/username.c ../../common/wait_error.c ../../port/dirmod.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../common/exec.c ../../common/fe_memutils.c ../../common/file_utils.c ../../common/pgfnames.c
../../common/restricted_token.c../../common/rmtree.c ../../common/username.c ../../common/wait_error.c
../../port/dirmod.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) simple_prompt
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_amcheck/nls.mk b/src/bin/pg_amcheck/nls.mk
index 5e6171952c..1f70ed4c70 100644
--- a/src/bin/pg_amcheck/nls.mk
+++ b/src/bin/pg_amcheck/nls.mk
@@ -1,7 +1,7 @@
# src/bin/pg_amcheck/nls.mk
CATALOG_NAME = pg_amcheck
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- pg_amcheck.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../fe_utils/cancel.c \
../../fe_utils/connect_utils.c \
../../fe_utils/option_utils.c \
diff --git a/src/bin/pg_archivecleanup/nls.mk b/src/bin/pg_archivecleanup/nls.mk
index 801cf1c51e..8b4b64de8f 100644
--- a/src/bin/pg_archivecleanup/nls.mk
+++ b/src/bin/pg_archivecleanup/nls.mk
@@ -1,5 +1,6 @@
# src/bin/pg_archivecleanup/nls.mk
CATALOG_NAME = pg_archivecleanup
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) pg_archivecleanup.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_basebackup/nls.mk b/src/bin/pg_basebackup/nls.mk
index 8d28e249de..04af63ac3c 100644
--- a/src/bin/pg_basebackup/nls.mk
+++ b/src/bin/pg_basebackup/nls.mk
@@ -1,18 +1,7 @@
# src/bin/pg_basebackup/nls.mk
CATALOG_NAME = pg_basebackup
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- bbstreamer_file.c \
- bbstreamer_gzip.c \
- bbstreamer_inject.c \
- bbstreamer_lz4.c \
- bbstreamer_tar.c \
- bbstreamer_zstd.c \
- pg_basebackup.c \
- pg_receivewal.c \
- pg_recvlogical.c \
- receivelog.c \
- streamutil.c \
- walmethods.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../common/compression.c \
../../common/fe_memutils.c \
../../common/file_utils.c \
diff --git a/src/bin/pg_checksums/nls.mk b/src/bin/pg_checksums/nls.mk
index f7cd2a5ee9..0b08f46f4d 100644
--- a/src/bin/pg_checksums/nls.mk
+++ b/src/bin/pg_checksums/nls.mk
@@ -1,7 +1,7 @@
# src/bin/pg_checksums/nls.mk
CATALOG_NAME = pg_checksums
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- pg_checksums.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../fe_utils/option_utils.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_config/nls.mk b/src/bin/pg_config/nls.mk
index d86c28c404..8642be47e4 100644
--- a/src/bin/pg_config/nls.mk
+++ b/src/bin/pg_config/nls.mk
@@ -1,3 +1,4 @@
# src/bin/pg_config/nls.mk
CATALOG_NAME = pg_config
-GETTEXT_FILES = pg_config.c ../../common/config_info.c ../../common/exec.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../common/config_info.c ../../common/exec.c
diff --git a/src/bin/pg_controldata/nls.mk b/src/bin/pg_controldata/nls.mk
index ab34205b96..805085a56b 100644
--- a/src/bin/pg_controldata/nls.mk
+++ b/src/bin/pg_controldata/nls.mk
@@ -1,5 +1,6 @@
# src/bin/pg_controldata/nls.mk
CATALOG_NAME = pg_controldata
-GETTEXT_FILES = pg_controldata.c ../../common/controldata_utils.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../common/controldata_utils.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_ctl/nls.mk b/src/bin/pg_ctl/nls.mk
index 84e7fb4e56..6f1395d1cb 100644
--- a/src/bin/pg_ctl/nls.mk
+++ b/src/bin/pg_ctl/nls.mk
@@ -1,3 +1,4 @@
# src/bin/pg_ctl/nls.mk
CATALOG_NAME = pg_ctl
-GETTEXT_FILES = pg_ctl.c ../../common/exec.c ../../common/fe_memutils.c ../../common/wait_error.c ../../port/path.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../common/exec.c ../../common/fe_memutils.c ../../common/wait_error.c ../../port/path.c
diff --git a/src/bin/pg_dump/nls.mk b/src/bin/pg_dump/nls.mk
index 3054f93fad..e64090347d 100644
--- a/src/bin/pg_dump/nls.mk
+++ b/src/bin/pg_dump/nls.mk
@@ -1,12 +1,7 @@
# src/bin/pg_dump/nls.mk
CATALOG_NAME = pg_dump
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- pg_backup_archiver.c pg_backup_db.c pg_backup_custom.c \
- pg_backup_null.c pg_backup_tar.c \
- pg_backup_directory.c dumputils.c compress_io.c \
- pg_dump.c common.c pg_dump_sort.c \
- pg_restore.c pg_dumpall.c \
- parallel.c parallel.h pg_backup_utils.c pg_backup_utils.h \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../common/exec.c ../../common/fe_memutils.c \
../../common/wait_error.c \
../../fe_utils/option_utils.c
diff --git a/src/bin/pg_resetwal/nls.mk b/src/bin/pg_resetwal/nls.mk
index bc25482f2c..9ced597fcb 100644
--- a/src/bin/pg_resetwal/nls.mk
+++ b/src/bin/pg_resetwal/nls.mk
@@ -1,5 +1,7 @@
# src/bin/pg_resetwal/nls.mk
CATALOG_NAME = pg_resetwal
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) pg_resetwal.c ../../common/restricted_token.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../common/restricted_token.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_rewind/nls.mk b/src/bin/pg_rewind/nls.mk
index 0618cb8c2c..af3a644dd4 100644
--- a/src/bin/pg_rewind/nls.mk
+++ b/src/bin/pg_rewind/nls.mk
@@ -1,6 +1,10 @@
# src/bin/pg_rewind/nls.mk
CATALOG_NAME = pg_rewind
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) datapagemap.c file_ops.c filemap.c libpq_source.c local_source.c
parsexlog.cpg_rewind.c timeline.c xlogreader.c ../../common/fe_memutils.c ../../common/restricted_token.c
../../fe_utils/archive.c../../fe_utils/recovery_gen.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
+ xlogreader.c \
+ ../../common/fe_memutils.c ../../common/restricted_token.c \
+ ../../fe_utils/archive.c ../../fe_utils/recovery_gen.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) report_invalid_record:2
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \
report_invalid_record:2:c-format
diff --git a/src/bin/pg_test_fsync/nls.mk b/src/bin/pg_test_fsync/nls.mk
index a50782036c..ca5fdc05e1 100644
--- a/src/bin/pg_test_fsync/nls.mk
+++ b/src/bin/pg_test_fsync/nls.mk
@@ -1,5 +1,6 @@
# src/bin/pg_test_fsync/nls.mk
CATALOG_NAME = pg_test_fsync
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) pg_test_fsync.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) die
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/pg_test_timing/nls.mk b/src/bin/pg_test_timing/nls.mk
index 331931c591..8cb472fbdf 100644
--- a/src/bin/pg_test_timing/nls.mk
+++ b/src/bin/pg_test_timing/nls.mk
@@ -1,3 +1,3 @@
# src/bin/pg_test_timing/nls.mk
CATALOG_NAME = pg_test_timing
-GETTEXT_FILES = pg_test_timing.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c))
diff --git a/src/bin/pg_upgrade/nls.mk b/src/bin/pg_upgrade/nls.mk
index 4721fa6b5a..a370717ba8 100644
--- a/src/bin/pg_upgrade/nls.mk
+++ b/src/bin/pg_upgrade/nls.mk
@@ -1,8 +1,6 @@
# src/bin/pg_upgrade/nls.mk
CATALOG_NAME = pg_upgrade
-GETTEXT_FILES = check.c controldata.c dump.c exec.c file.c function.c \
- info.c option.c parallel.c pg_upgrade.c relfilenumber.c \
- server.c tablespace.c util.c version.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = pg_fatal pg_log:2 prep_status prep_status_progress report_status:2
GETTEXT_FLAGS = \
pg_fatal:1:c-format \
diff --git a/src/bin/pg_verifybackup/nls.mk b/src/bin/pg_verifybackup/nls.mk
index eba73a2c05..4a9d898259 100644
--- a/src/bin/pg_verifybackup/nls.mk
+++ b/src/bin/pg_verifybackup/nls.mk
@@ -1,8 +1,7 @@
# src/bin/pg_verifybackup/nls.mk
CATALOG_NAME = pg_verifybackup
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- parse_manifest.c \
- pg_verifybackup.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../common/fe_memutils.c \
../../common/jsonapi.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
diff --git a/src/bin/pg_waldump/nls.mk b/src/bin/pg_waldump/nls.mk
index a9eeb6712b..895df4900e 100644
--- a/src/bin/pg_waldump/nls.mk
+++ b/src/bin/pg_waldump/nls.mk
@@ -1,5 +1,6 @@
# src/bin/pg_waldump/nls.mk
CATALOG_NAME = pg_waldump
-GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) pg_waldump.c
+GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
+ $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/bin/psql/nls.mk b/src/bin/psql/nls.mk
index dad5816b9c..8774838d89 100644
--- a/src/bin/psql/nls.mk
+++ b/src/bin/psql/nls.mk
@@ -1,10 +1,8 @@
# src/bin/psql/nls.mk
CATALOG_NAME = psql
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- command.c common.c copy.c crosstabview.c help.c input.c large_obj.c \
- mainloop.c psqlscanslash.c startup.c \
- describe.c sql_help.h sql_help.c \
- tab-complete.c variables.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
+ psqlscanslash.c sql_help.c \
../../fe_utils/cancel.c ../../fe_utils/print.c ../../fe_utils/psqlscan.c \
../../common/exec.c ../../common/fe_memutils.c ../../common/username.c \
../../common/wait_error.c ../../port/thread.c
diff --git a/src/bin/scripts/nls.mk b/src/bin/scripts/nls.mk
index f4638a06f0..f788d00623 100644
--- a/src/bin/scripts/nls.mk
+++ b/src/bin/scripts/nls.mk
@@ -1,11 +1,7 @@
# src/bin/scripts/nls.mk
CATALOG_NAME = pgscripts
GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
- createdb.c createuser.c \
- dropdb.c dropuser.c \
- clusterdb.c vacuumdb.c reindexdb.c \
- pg_isready.c \
- common.c \
+ $(notdir $(wildcard $(srcdir)/*.c)) \
../../fe_utils/parallel_slot.c \
../../fe_utils/cancel.c ../../fe_utils/print.c \
../../fe_utils/connect_utils.c \
diff --git a/src/interfaces/ecpg/ecpglib/nls.mk b/src/interfaces/ecpg/ecpglib/nls.mk
index 77eecc98f3..24d7adb588 100644
--- a/src/interfaces/ecpg/ecpglib/nls.mk
+++ b/src/interfaces/ecpg/ecpglib/nls.mk
@@ -1,5 +1,5 @@
# src/interfaces/ecpg/ecpglib/nls.mk
CATALOG_NAME = ecpglib
-GETTEXT_FILES = connect.c descriptor.c error.c execute.c misc.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = ecpg_gettext
GETTEXT_FLAGS = ecpg_gettext:1:pass-c-format
diff --git a/src/interfaces/ecpg/preproc/nls.mk b/src/interfaces/ecpg/preproc/nls.mk
index 55ea19a44e..05164c9bbc 100644
--- a/src/interfaces/ecpg/preproc/nls.mk
+++ b/src/interfaces/ecpg/preproc/nls.mk
@@ -1,5 +1,6 @@
# src/interfaces/ecpg/preproc/nls.mk
CATALOG_NAME = ecpg
-GETTEXT_FILES = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ pgc.c preproc.c typename.c
GETTEXT_TRIGGERS = mmerror:3 mmfatal:2
GETTEXT_FLAGS = mmerror:3:c-format mmfatal:2:c-format
diff --git a/src/interfaces/libpq/nls.mk b/src/interfaces/libpq/nls.mk
index 9256b426c1..bf3eb9899d 100644
--- a/src/interfaces/libpq/nls.mk
+++ b/src/interfaces/libpq/nls.mk
@@ -1,5 +1,6 @@
# src/interfaces/libpq/nls.mk
CATALOG_NAME = libpq
-GETTEXT_FILES = fe-auth.c fe-auth-scram.c fe-connect.c fe-exec.c fe-gssapi-common.c fe-lobj.c fe-misc.c
fe-protocol3.cfe-secure.c fe-secure-common.c fe-secure-gssapi.c fe-secure-openssl.c win32.c ../../port/thread.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ ../../port/thread.c
GETTEXT_TRIGGERS = libpq_gettext pqInternalNotice:2
GETTEXT_FLAGS = libpq_gettext:1:pass-c-format pqInternalNotice:2:c-format
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..24f232892a 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -103,9 +103,11 @@ endif
else # GETTEXT_FILES
po/$(CATALOG_NAME).pot: $(GETTEXT_FILES) $(MAKEFILE_LIST)
# Change to srcdir explicitly, don't rely on $^. That way we get
-# consistent #: file references in the po files.
+# consistent #: file references in the po files. Also, sort to eliminate
+# duplicate references that we might get from use of $(wildcard) alongside
+# explicit references to built files.
ifdef XGETTEXT
- $(XGETTEXT) -D $(srcdir) -D . -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS))
$(GETTEXT_FILES)
+ $(XGETTEXT) -D $(srcdir) -D . -n $(addprefix -k, $(GETTEXT_TRIGGERS)) $(addprefix --flag=, $(GETTEXT_FLAGS))
$(sort$(GETTEXT_FILES))
else
@echo "You don't have 'xgettext'."; exit 1
endif
diff --git a/src/pl/plperl/nls.mk b/src/pl/plperl/nls.mk
index 8c41bfac7a..aedc381d9f 100644
--- a/src/pl/plperl/nls.mk
+++ b/src/pl/plperl/nls.mk
@@ -1,5 +1,6 @@
# src/pl/plperl/nls.mk
CATALOG_NAME = plperl
-GETTEXT_FILES = plperl.c SPI.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ SPI.c Util.c
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/pl/plpgsql/src/nls.mk b/src/pl/plpgsql/src/nls.mk
index 2bd620a8dd..dada8b8855 100644
--- a/src/pl/plpgsql/src/nls.mk
+++ b/src/pl/plpgsql/src/nls.mk
@@ -1,5 +1,6 @@
# src/pl/plpgsql/src/nls.mk
CATALOG_NAME = plpgsql
-GETTEXT_FILES = pl_comp.c pl_exec.c pl_gram.c pl_funcs.c pl_handler.c pl_scanner.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c)) \
+ pl_gram.c
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) yyerror plpgsql_yyerror
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)
diff --git a/src/pl/plpython/nls.mk b/src/pl/plpython/nls.mk
index 4c68a0e571..cfb5abf71e 100644
--- a/src/pl/plpython/nls.mk
+++ b/src/pl/plpython/nls.mk
@@ -1,7 +1,6 @@
# src/pl/plpython/nls.mk
CATALOG_NAME = plpython
-GETTEXT_FILES = plpy_cursorobject.c plpy_elog.c plpy_exec.c plpy_main.c plpy_planobject.c plpy_plpymodule.c \
- plpy_procedure.c plpy_resultobject.c plpy_spi.c plpy_subxactobject.c plpy_typeio.c plpy_util.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS) PLy_elog:2 PLy_exception_set:2 PLy_exception_set_plural:2,3
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \
PLy_elog:2:c-format \
diff --git a/src/pl/tcl/nls.mk b/src/pl/tcl/nls.mk
index 8366998df1..047e029cdd 100644
--- a/src/pl/tcl/nls.mk
+++ b/src/pl/tcl/nls.mk
@@ -1,5 +1,5 @@
# src/pl/tcl/nls.mk
CATALOG_NAME = pltcl
-GETTEXT_FILES = pltcl.c
+GETTEXT_FILES = $(notdir $(wildcard $(srcdir)/*.c))
GETTEXT_TRIGGERS = $(BACKEND_COMMON_GETTEXT_TRIGGERS)
GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS)