make/CompileToolsJdk.gmk
branchihse-manpages-branch
changeset 57045 9c7f4a3c4139
parent 52175 c2672a0f233a
child 57048 b2ed864c52b5
--- a/make/CompileToolsJdk.gmk	Mon Nov 26 14:18:32 2018 +0100
+++ b/make/CompileToolsJdk.gmk	Mon Nov 26 18:50:55 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)