diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
index c7657cc47c..380bc23c82 100644
--- a/src/backend/catalog/genbki.pl
+++ b/src/backend/catalog/genbki.pl
@@ -439,25 +439,9 @@ foreach my $catname (@catnames)
 	open my $def, '>', $def_file . $tmpext
 	  or die "can't open $def_file$tmpext: $!";
 
-	# Opening boilerplate for pg_*_d.h
-	printf $def <<EOM, $catname, $catname, uc $catname, uc $catname;
-/*-------------------------------------------------------------------------
- *
- * %s_d.h
- *    Macro definitions for %s
- *
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * NOTES
- *  ******************************
- *  *** DO NOT EDIT THIS FILE! ***
- *  ******************************
- *
- *  It has been GENERATED by src/backend/catalog/genbki.pl
- *
- *-------------------------------------------------------------------------
- */
+	print_boilerplate($def, "${catname}_d.h",
+		"Macro definitions for $catname");
+	printf $def <<EOM, uc $catname, uc $catname;
 #ifndef %s_D_H
 #define %s_D_H
 
@@ -705,25 +689,9 @@ foreach my $c (@system_constraints)
 
 # Now generate schemapg.h
 
-# Opening boilerplate for schemapg.h
+print_boilerplate($schemapg, "schemapg.h",
+	"Schema_pg_xxx macros for use by relcache.c");
 print $schemapg <<EOM;
-/*-------------------------------------------------------------------------
- *
- * schemapg.h
- *    Schema_pg_xxx macros for use by relcache.c
- *
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * NOTES
- *  ******************************
- *  *** DO NOT EDIT THIS FILE! ***
- *  ******************************
- *
- *  It has been GENERATED by src/backend/catalog/genbki.pl
- *
- *-------------------------------------------------------------------------
- */
 #ifndef SCHEMAPG_H
 #define SCHEMAPG_H
 EOM
@@ -741,25 +709,9 @@ print $schemapg "\n#endif\t\t\t\t\t\t\t/* SCHEMAPG_H */\n";
 
 # Now generate system_fk_info.h
 
-# Opening boilerplate for system_fk_info.h
+print_boilerplate($fk_info, "system_fk_info.h",
+	"Data about the foreign-key relationships in the system catalogs");
 print $fk_info <<EOM;
-/*-------------------------------------------------------------------------
- *
- * system_fk_info.h
- *    Data about the foreign-key relationships in the system catalogs
- *
- * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * NOTES
- *  ******************************
- *  *** DO NOT EDIT THIS FILE! ***
- *  ******************************
- *
- *  It has been GENERATED by src/backend/catalog/genbki.pl
- *
- *-------------------------------------------------------------------------
- */
 #ifndef SYSTEM_FK_INFO_H
 #define SYSTEM_FK_INFO_H
 
@@ -1121,6 +1073,30 @@ sub assign_next_oid
 	return $result;
 }
 
+sub print_boilerplate
+{
+	my ($fh, $fname, $descr) = @_;
+	printf $fh <<EOM, $fname, $descr;
+/*-------------------------------------------------------------------------
+ *
+ * %s
+ *    %s
+ *
+ * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * NOTES
+ *  ******************************
+ *  *** DO NOT EDIT THIS FILE! ***
+ *  ******************************
+ *
+ *  It has been GENERATED by src/backend/catalog/genbki.pl
+ *
+ *-------------------------------------------------------------------------
+ */
+EOM
+}
+
 sub usage
 {
 	die <<EOM;