From 8f1e4410d69d9e5a9bda2bd905bd067a61b7d1a6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 11 May 2022 09:06:13 +0200
Subject: [PATCH v10 08/16] meson: prereq: Refactor dtrace postprocessing make
 rules

Move the dtrace postprocessing sed commands into a separate file so
that it can be shared by meson.  Also split the rule into two for
proper dependency declaration.
---
 src/backend/utils/Makefile               | 21 +++++++--------------
 src/backend/utils/postprocess_dtrace.sed | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 14 deletions(-)
 create mode 100644 src/backend/utils/postprocess_dtrace.sed

diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index 2011c5148d3..ccca0a0dd3c 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -54,22 +54,15 @@ fmgr-stamp: Gen_fmgrtab.pl $(catalogdir)/Catalog.pm $(top_srcdir)/src/include/ca
 errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl
 	$(PERL) $(srcdir)/generate-errcodes.pl --outfile $@ $<
 
-ifneq ($(enable_dtrace), yes)
-probes.h: Gen_dummy_probes.sed
-endif
-
-# We editorialize on dtrace's output to the extent of changing the macro
-# names (from POSTGRESQL_foo to TRACE_POSTGRESQL_foo) and changing any
-# "char *" arguments to "const char *".
-probes.h: probes.d
 ifeq ($(enable_dtrace), yes)
-	$(DTRACE) -C -h -s $< -o $@.tmp
-	sed -e 's/POSTGRESQL_/TRACE_POSTGRESQL_/g' \
-	    -e 's/( *char \*/(const char */g' \
-	    -e 's/, *char \*/, const char */g' $@.tmp >$@
-	rm $@.tmp
+probes.h: postprocess_dtrace.sed probes.h.tmp
+	sed -f $^ >$@
+
+probes.h.tmp: probes.d
+	$(DTRACE) -C -h -s $< -o $@
 else
-	sed -f $(srcdir)/Gen_dummy_probes.sed $< >$@
+probes.h: Gen_dummy_probes.sed probes.d
+	sed -f $^ >$@
 endif
 
 # These generated headers must be symlinked into builddir/src/include/,
diff --git a/src/backend/utils/postprocess_dtrace.sed b/src/backend/utils/postprocess_dtrace.sed
new file mode 100644
index 00000000000..a68c30c75e4
--- /dev/null
+++ b/src/backend/utils/postprocess_dtrace.sed
@@ -0,0 +1,15 @@
+#-------------------------------------------------------------------------
+# sed script to postprocess dtrace output
+#
+# Copyright (c) 2008-2022, PostgreSQL Global Development Group
+#
+# src/backend/utils/postprocess_dtrace.sed
+#-------------------------------------------------------------------------
+
+# We editorialize on dtrace's output to the extent of changing the macro
+# names (from POSTGRESQL_foo to TRACE_POSTGRESQL_foo) and changing any
+# "char *" arguments to "const char *".
+
+s/POSTGRESQL_/TRACE_POSTGRESQL_/g
+s/( *char \*/(const char */g
+s/, *char \*/, const char */g
-- 
2.37.0.3.g30cc8d0f14

