make/CompileToolsJdk.gmk
changeset 52714 2e52aa822c57
parent 52175 c2672a0f233a
child 52940 26e2cfebcfba
child 57049 d13c49f43710
--- a/make/CompileToolsJdk.gmk	Tue Nov 27 15:56:10 2018 +0100
+++ b/make/CompileToolsJdk.gmk	Wed Nov 28 10:00:41 2018 +0100
@@ -29,6 +29,7 @@
 include MakeBase.gmk
 include JavaCompilation.gmk
 include SetupJavaCompilers.gmk
+include TextFileProcessing.gmk
 
 ################################################################################
 
@@ -87,4 +88,30 @@
 
 ################################################################################
 
+# To be able to call the javascript filter when generating man pages using
+# pandoc, we need to create this executable wrapper script.
+ifneq ($(PANDOC), )
+  # PANDOC_FILTER is duplicated for export in ToolsJdk.gmk.
+  PANDOC_FILTER := $(BUILDTOOLS_OUTPUTDIR)/manpages/pandoc-manpage-filter
+  PANDOC_FILTER_SETUP := $(BUILDTOOLS_OUTPUTDIR)/manpages/_pandoc_filter_setup.marker
+
+  # Create a usable instance of the wrapper script that calls the pandoc filter
+  # (which is written in javascript).
+  $(eval $(call SetupTextFileProcessing, CREATE_PANDOC_FILTER, \
+      SOURCE_FILES := $(TOPDIR)/make/scripts/pandoc-manpage-filter.sh.template, \
+      OUTPUT_FILE := $(PANDOC_FILTER), \
+      REPLACEMENTS := \
+          @@BOOT_JDK@@ => $(BOOT_JDK) ; \
+          @@TOPDIR@@ => $(TOPDIR) ; \
+          @@JJS_FLAGS@@ => $(addprefix -J, $(JAVA_FLAGS_SMALL)), \
+  ))
+
+  # Created script must be made executable
+  $(PANDOC_FILTER_SETUP): $(CREATE_PANDOC_FILTER)
+	$(CHMOD) a+rx $(PANDOC_FILTER)
+	$(TOUCH) $@
+
+  TARGETS += $(PANDOC_FILTER_SETUP)
+endif
+
 all: $(TARGETS)