diff --git a/Makefile b/Makefile index 12f6b2d..fd2a8b0 100644 --- a/Makefile +++ b/Makefile @@ -12,16 +12,26 @@ # This Makefile is designed to automate the process of building and packaging # the Doc Template for RISC-V Extensions. +DOCS := \ + riscv-server-soc.adoc \ + riscv-server-soc-ts.adoc + DATE ?= $(shell date +%Y-%m-%d) VERSION ?= v0.0.0 REVMARK ?= Draft -DOCKER_RUN := docker run --rm -v ${PWD}:/build -w /build \ -riscvintl/riscv-docs-base-container-image:latest +ifneq ($(SKIP_DOCKER),true) + DOCKER_CMD := docker run --rm -v ${PWD}:/build -w /build \ + riscvintl/riscv-docs-base-container-image:latest \ + /bin/sh -c + DOCKER_QUOTE := " +endif SRC_DIR := src BUILD_DIR := build -HEADER_SOURCE := $(SRC_DIR)/riscv-server-soc.adoc -TS_HEADER_SOURCE := $(SRC_DIR)/riscv-server-soc-ts.adoc + +DOCS_PDF := $(DOCS:%.adoc=%.pdf) +DOCS_HTML := $(DOCS:%.adoc=%.html) + XTRA_ADOC_OPTS := ASCIIDOCTOR_PDF := asciidoctor-pdf ASCIIDOCTOR_HTML := asciidoctor @@ -40,10 +50,20 @@ REQUIRES := --require=asciidoctor-bibtex \ --require=asciidoctor-diagram \ --require=asciidoctor-mathematical -.PHONY: all build clean build-container build-no-container +.PHONY: all build clean build-container build-no-container build-docs all: build +build-docs: $(DOCS_PDF) $(DOCS_HTML) + +vpath %.adoc $(SRC_DIR) + +%.pdf: %.adoc + $(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE) + +%.html: %.adoc + $(DOCKER_CMD) $(DOCKER_QUOTE) $(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $< $(DOCKER_QUOTE) + build: @echo "Checking if Docker is available..." @if command -v docker >/dev/null 2>&1 ; then \ @@ -56,18 +76,12 @@ build: build-container: @echo "Starting build inside Docker container..." - $(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $(HEADER_SOURCE)" - $(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $(HEADER_SOURCE)" - $(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $(TS_HEADER_SOURCE)" - $(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $(TS_HEADER_SOURCE)" + $(MAKE) build-docs @echo "Build completed successfully inside Docker container." build-no-container: @echo "Starting build..." - $(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $(HEADER_SOURCE) - $(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $(HEADER_SOURCE) - $(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) $(TS_HEADER_SOURCE) - $(ASCIIDOCTOR_HTML) $(OPTIONS) $(REQUIRES) $(TS_HEADER_SOURCE) + $(MAKE) SKIP_DOCKER=true build-docs @echo "Build completed successfully." clean: