blob: ae5bb733334c081340bf70cf5c648a7199b9bfb1 [file] [log] [blame]
#
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
default: all
include $(SPEC)
include MakeBase.gmk
################################################################################
# This makefile updates the generated build html documentation.
#
################################################################################
ifeq ($(PANDOC), )
$(info No pandoc executable was detected by configure)
$(error Cannot continue)
endif
################################################################################
# Setup make rules for converting a markdown file to html.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These include:
# SOURCE_FILE The markdown source file
# TARGET_DIR The directory where to store the generated html file
#
define SetupMarkdownToHtml
$(foreach i,2 3, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
$(call LogSetupMacroEntry,SetupMarkdownToHtml($1),$2,$3)
$(if $(4),$(error Internal makefile error: Too many arguments to SetupMarkdownToHtml, please update UpdateBuildDocs.gmk))
ifeq ($$($1_SOURCE_FILE), )
$$(error SOURCE_FILE is missing in SetupMarkdownToHtml $1)
endif
ifeq ($$($1_TARGET_DIR), )
$$(error TARGET_DIR is missing in SetupMarkdownToHtml $1)
endif
$1_BASENAME := $$(notdir $$(basename $$($1_SOURCE_FILE)))
$1_OUTPUT_FILE := $$($1_TARGET_DIR)/$$($1_BASENAME).html
$$($1_OUTPUT_FILE): $$($1_SOURCE_FILE)
$$(ECHO) $$(LOG_INFO) Converting $$(notdir $1) to html
$$(MKDIR) -p $$($1_TARGET_DIR)
$$(PANDOC) -f markdown -t html --standalone '$$<' -o '$$@'
TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` ; \
if [ "x$${TOO_LONG_LINES}" != x ]; then \
$$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
$$(ECHO) "The following lines are longer than 80 characters:" ; \
$$(GREP) -E -e '^.{80}.+$$$$' $$< ; \
fi
$1 := $$($1_OUTPUT_FILE)
TARGETS += $$($1)
endef
################################################################################
BUILD_DOCS_DIR := $(TOPDIR)/doc
BUILD_DOCS_MD_FILE := building.md
$(eval $(call SetupMarkdownToHtml,building, \
SOURCE_FILE := $(BUILD_DOCS_DIR)/$(BUILD_DOCS_MD_FILE), \
TARGET_DIR := $(BUILD_DOCS_DIR) \
))
################################################################################
all: $(TARGETS)
.PHONY: all default