make/common/ProcessMarkdown.gmk
author coffeys
Mon, 22 Oct 2018 10:47:28 +0100
changeset 52208 5bf98ad48412
parent 45227 97be1bcd7b25
child 52714 2e52aa822c57
child 56891 78ed9c424877
permissions -rw-r--r--
8212752: Typo in SSL log message related to inactive/disabled signature scheme Reviewed-by: coffeys Contributed-by: jai.forums2013@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44983
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     1
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     2
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     3
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     4
# This code is free software; you can redistribute it and/or modify it
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     5
# under the terms of the GNU General Public License version 2 only, as
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     6
# published by the Free Software Foundation.  Oracle designates this
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     7
# particular file as subject to the "Classpath" exception as provided
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     8
# by Oracle in the LICENSE file that accompanied this code.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
     9
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    14
# accompanied this code).
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    15
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    19
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    22
# questions.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    23
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    24
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    25
ifeq (,$(_MAKEBASE_GMK))
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    26
  $(error You must include MakeBase.gmk prior to including ProcessMarkdown.gmk)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    27
endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    28
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    29
# Helper function for SetupProcessMarkdown
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    30
# $1: The $1 from SetupProcessMarkdown
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    31
# $2: The name of the current source file, relative to $1_SRC
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    32
define ProcessMarkdown
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    33
  $1_$2_OUTPUT_FILE := $$($1_DEST)/$$(basename $2).html
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    34
  $1_$2_TARGET_DIR := $$(dir $$($1_$2_OUTPUT_FILE))
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    35
  ifneq ($$($1_CSS), )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    36
    ifneq ($$(findstring http:/, $$($1_CSS)), )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    37
      $1_$2_CSS_OPTION := --css '$$($1_CSS)'
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    38
    else
45227
97be1bcd7b25 8180472: Pandoc should generate html5 from markdown
ihse
parents: 44983
diff changeset
    39
      $1_$2_CSS := $$(strip $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR)))
44983
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    40
      $1_$2_CSS_OPTION := --css '$$($1_$2_CSS)'
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    41
    endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    42
  endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    43
  $1_$2_OPTIONS = $$(shell $$(GREP) _pandoc-options_: $$($1_SRC)/$2 | $$(CUT) -d : -f 2-)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    44
  $1_$2_MARKER := $$(subst /,_,$1_$2)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    45
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    46
  $1_$2_VARDEPS := $$($1_OPTIONS) $$($1_CSS)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    47
  $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    48
      $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    49
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    50
$$($1_$2_OUTPUT_FILE): $$($1_SRC)/$2 $$($1_$2_VARDEPS_FILE)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    51
	$$(call LogInfo, Converting $2 to html)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    52
	$$(call MakeDir, $$($1_$2_TARGET_DIR) $$(SUPPORT_OUTPUTDIR)/markdown)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    53
	$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
45227
97be1bcd7b25 8180472: Pandoc should generate html5 from markdown
ihse
parents: 44983
diff changeset
    54
	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html5 --standalone \
44983
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    55
	    $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$<' -o '$$@')
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    56
        ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    57
	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    58
	if [ "x$$$$TOO_LONG_LINES" != x ]; then \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    59
	  $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    60
	  $$(ECHO) "The following lines are longer than 80 characters:" ; \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    61
	  $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    62
	fi
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    63
        endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    64
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    65
  $1 += $$($1_$2_OUTPUT_FILE)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    66
endef
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    67
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    68
################################################################################
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    69
# Setup make rules for converting a markdown file to html.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    70
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    71
# Parameter 1 is the name of the rule. This name is used as variable prefix,
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    72
# and the targets generated are listed in a variable by that name.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    73
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    74
# Remaining parameters are named arguments. These include:
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    75
#   SRC     : Source root dir (defaults to dir of first file)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    76
#   DEST    : Dest root dir
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    77
#   FILES   : List of files to copy with absolute paths, or path relative to SRC.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    78
#             Must be in SRC.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    79
#   OPTIONS : Additional options to pandoc
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    80
#
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    81
SetupProcessMarkdown = $(NamedParamsMacroTemplate)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    82
define SetupProcessMarkdownBody
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    83
  ifeq ($$($1_FILES), )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    84
    $$(error FILES is missing in SetupProcessMarkdown $1)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    85
  endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    86
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    87
  ifeq ($$($1_DEST), )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    88
    $$(error DEST is missing in SetupProcessMarkdown $1)
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    89
  endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    90
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    91
  # Default SRC to the dir of the first file.
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    92
  ifeq ($$($1_SRC), )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    93
    $1_SRC := $$(dir $$(firstword $$($1_FILES)))
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    94
  endif
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    95
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    96
  # Remove any trailing slash from SRC and DEST
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    97
  $1_SRC := $$(patsubst %/,%,$$($1_SRC))
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    98
  $1_DEST := $$(patsubst %/,%,$$($1_DEST))
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
    99
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
   100
  $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
   101
    $$(eval $$(call ProcessMarkdown,$1,$$f)) \
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
   102
  )
4e216c0475ee 8179453: Add a proper SetupProcessMarkdown
ihse
parents:
diff changeset
   103
endef