On 2021-May-11, Andrew Dunstan wrote:

> Yeah, but this will create the perl file in the vpath directory where it
> won't ever be used anyway. You really want this back in the source
> directory where you can check it in etc.

Hmm ... no, it doesn't.  As far as I can see it works as intended.  The
path to the prolog file is broken, yes, but that's it.  However, maybe
I'm doing something wrong but if you define the rule like that, then it
no longer works in normal (non-vpath) mode.  This works:


-- 
Álvaro Herrera                            39°49'30"S 73°17'W
diff --git a/src/backend/utils/Gen_dummy_probes.pl.prolog b/src/backend/utils/Gen_dummy_probes.pl.prolog
new file mode 100644
index 0000000000..1c8993377d
--- /dev/null
+++ b/src/backend/utils/Gen_dummy_probes.pl.prolog
@@ -0,0 +1,19 @@
+#! /usr/bin/perl -w
+#-------------------------------------------------------------------------
+#
+# Gen_dummy_probes.pl
+#    Perl script that generates probes.h file when dtrace is not available
+#
+# Portions Copyright (c) 2008-2021, PostgreSQL Global Development Group
+#
+#
+# IDENTIFICATION
+#    src/backend/utils/Gen_dummy_probes.pl
+#
+# This program was generated by running perl's s2p over Gen_dummy_probes.sed
+#
+#-------------------------------------------------------------------------
+
+# turn off perlcritic for autogenerated code
+## no critic
+
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index bcf9dd41ad..16c2217f2a 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -92,12 +92,16 @@ $(top_builddir)/src/include/utils/probes.h: probes.h
 # Nothing depends on it, so it will never be called unless explicitly requested
 # The last two lines of the recipe format the script according to  our
 # standard and put back some blank lines for improved readability.
+ifeq ($(vpath_build),yes)
+$(top_srcdir)/src/backend/utils/Gen_dummy_probes.pl: Gen_dummy_probes.sed
+else
 Gen_dummy_probes.pl: Gen_dummy_probes.sed
-	perl -ni -e ' print; exit if /^\$$0/;' $@
-	s2p -f $<  | sed -e 1,4d -e '/# #/d' -e '$$d' >> $@
-	perltidy --profile=../../tools/pgindent/perltidyrc $@
-	perl -pi -e '!$$lb && ( /^\t+#/  || /^# prototypes/ ) && print qq{\n};'\
-		-e '$$lb = m/^\n/; ' $@
+endif
+	(cat $(top_srcdir)/$(subdir)/Gen_dummy_probes.pl.prolog; \
+		s2p -f $< | sed -e 1,3d -e '/# #/ d' -e '$$ d') | \
+	perltidy --profile=$(top_srcdir)/src/tools/pgindent/perltidyrc | \
+	perl -p -e '!$$lb && ( /^\t+#/ || /^# prototypes/ ) && print qq{\n};' \
+		-e '$$lb = m/^\n/; ' > $@
 
 .PHONY: install-data
 install-data: errcodes.txt installdirs

Reply via email to