UpdateBuildDocs.gmk revision 2554:6fafcd0896fc
1#
2# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# This code is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 2 only, as
7# published by the Free Software Foundation.  Oracle designates this
8# particular file as subject to the "Classpath" exception as provided
9# by Oracle in the LICENSE file that accompanied this code.
10#
11# This code is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14# version 2 for more details (a copy is included in the LICENSE file that
15# accompanied this code).
16#
17# You should have received a copy of the GNU General Public License version
18# 2 along with this work; if not, write to the Free Software Foundation,
19# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22# or visit www.oracle.com if you need additional information or have any
23# questions.
24#
25
26default: all
27
28include $(SPEC)
29include MakeBase.gmk
30
31################################################################################
32# This makefile updates the generated build html documentation.
33#
34################################################################################
35
36ifeq ($(PANDOC), )
37  $(info No pandoc executable was detected by configure)
38  $(error Cannot continue)
39endif
40
41################################################################################
42# Setup make rules for converting a markdown file to html.
43#
44# Parameter 1 is the name of the rule. This name is used as variable prefix,
45# and the targets generated are listed in a variable by that name.
46#
47# Remaining parameters are named arguments. These include:
48#   SOURCE_FILE  The markdown source file
49#   TARGET_DIR   The directory where to store the generated html file
50#   OPTIONS      Additional options to pandoc
51#
52SetupMarkdownToHtml = $(NamedParamsMacroTemplate)
53define SetupMarkdownToHtmlBody
54  ifeq ($$($1_SOURCE_FILE), )
55    $$(error SOURCE_FILE is missing in SetupMarkdownToHtml $1)
56  endif
57
58  ifeq ($$($1_TARGET_DIR), )
59    $$(error TARGET_DIR is missing in SetupMarkdownToHtml $1)
60  endif
61
62  $1_BASENAME := $$(notdir $$(basename $$($1_SOURCE_FILE)))
63  $1_OUTPUT_FILE := $$($1_TARGET_DIR)/$$($1_BASENAME).html
64
65$$($1_OUTPUT_FILE): $$($1_SOURCE_FILE)
66	$$(call LogInfo, Converting $$(notdir $1) to html)
67	$$(call MakeDir, $$($1_TARGET_DIR) $$(MAKESUPPORT_OUTPUTDIR)/markdown)
68	$$(call ExecuteWithLog, $$(MAKESUPPORT_OUTPUTDIR)/markdown/$1, \
69	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html --standalone \
70	    --css 'http://openjdk.java.net/page.css' '$$<' -o '$$@')
71	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
72	if [ "x$$$$TOO_LONG_LINES" != x ]; then \
73	  $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
74	  $$(ECHO) "The following lines are longer than 80 characters:" ; \
75	  $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
76	fi
77
78  $1 := $$($1_OUTPUT_FILE)
79
80  TARGETS += $$($1)
81endef
82
83################################################################################
84
85DOCS_DIR := $(TOPDIR)/common/doc
86
87$(eval $(call SetupMarkdownToHtml, building, \
88  SOURCE_FILE := $(DOCS_DIR)/building.md, \
89  TARGET_DIR := $(DOCS_DIR), \
90))
91
92$(eval $(call SetupMarkdownToHtml, testing, \
93  SOURCE_FILE := $(DOCS_DIR)/testing.md, \
94  TARGET_DIR := $(DOCS_DIR), \
95  OPTIONS := --toc, \
96))
97
98################################################################################
99
100$(eval $(call IncludeCustomExtension, , UpdateBuildDocs.gmk))
101
102################################################################################
103
104all: $(TARGETS)
105
106.PHONY: all default
107