Skip to content

Commit

Permalink
Fixing up Makefile for docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
wmat committed Jul 25, 2024
1 parent ea4068f commit 7953656
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
52 changes: 47 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
all: zjid-spec.pdf zjpm-spec.pdf
DOCKER_RUN := docker run --rm -v ${PWD}:/build -w /build \
riscvintl/riscv-docs-base-container-image:latest

zjid-spec.pdf: zjid/*.adoc
asciidoctor-pdf \
HEADER_SOURCE := zjpm/header.adoc
PDF_RESULT := zjpm-spec.pdf

ASCIIDOCTOR_PDF := asciidoctor-pdf
OPTIONS := --trace \
-a compress \
-a mathematical-format=svg \
-a pdf-fontsdir=docs-resources/fonts \
-a pdf-theme=docs-resources/themes/riscv-pdf.yml \
--failure-level=ERROR
REQUIRES := --require=asciidoctor-diagram

.PHONY: all build clean build-container build-no-container

all: build

#zjid-spec.pdf: zjid/*.adoc
# asciidoctor-pdf \
--attribute=mathematical-format=svg \
--attribute=pdf-fontsdir=docs-resources/fonts \
--attribute=pdf-theme=docs-resources/themes/riscv-pdf.yml \
--failure-level=ERROR \
--out-file=$@ \
zjid/header.adoc

zjpm-spec.pdf: zjpm/*.adoc
asciidoctor-pdf \
build:
@echo "Checking if Docker is available..."
@if command -v docker >/dev/null 2>&1 ; then \
echo "Docker is available, building inside Docker container..."; \
$(MAKE) build-container; \
else \
echo "Docker is not available, building without Docker..."; \
$(MAKE) build-no-container; \
fi

build-container:
@echo "Starting build inside Docker container..."
$(DOCKER_RUN) /bin/sh -c "$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) --out-file=$(PDF_RESULT) $(HEADER_SOURCE)"
@echo "Build completed successfully inside Docker container."

build-no-container:
@echo "Starting build..."
$(ASCIIDOCTOR_PDF) $(OPTIONS) $(REQUIRES) --out-file=$(PDF_RESULT) $(HEADER_SOURCE)
@echo "Build completed successfully."

clean:
@echo "Cleaning up generated files..."
rm -f $(PDF_RESULT)
@echo "Cleanup completed."

#zjpm-spec.pdf: zjpm/*.adoc
# asciidoctor-pdf \
--attribute=mathematical-format=svg \
--attribute=pdf-fontsdir=docs-resources/fonts \
--attribute=pdf-theme=docs-resources/themes/riscv-pdf.yml \
Expand Down
Binary file modified zjpm-spec.pdf
Binary file not shown.

0 comments on commit 7953656

Please sign in to comment.