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