Skip to content

Instantly share code, notes, and snippets.

Last active February 22, 2022 23:51
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Makefile for processing Mermaid files in the current directory
# Makefile for Mermaid files in this directory
# `make all` - build all targets
# `make png` - build PNGs for all source files
# `make svg` - build SVGs for all source files
# `make pdf` - build PDFs for all source files
# `make clean` - delete all targets
# `make listsources` - print list of all files to be processed
# `make listtargets` - print list of all output files
# `brew install mermaid-cli` to get the `mmdc` utility.
%.png : %.mmd
$(MMDC) --input $< --output $@ $(MMDCFLAGS)
%.svg : %.mmd
$(MMDC) --input $< --output $@ $(MMDCFLAGS)
%.pdf : %.mmd
$(MMDC) --input $< --output $@ $(MMDCFLAGS) --pdfFit
# Process all *.mmd files in this directory, producing .png and .svg output.
MMD_SRC_FILES=$(wildcard *.mmd)
MMD_OUT_FILES=$(MMD_SRC_FILES:.mmd=.png) $(MMD_SRC_FILES:.mmd=.svg) $(MMD_SRC_FILES:.mmd=.pdf)
.PHONY: all
png: $(MMD_SRC_FILES:.mmd=.png)
.PHONY: png
svg: $(MMD_SRC_FILES:.mmd=.svg)
.PHONY: svg
pdf: $(MMD_SRC_FILES:.mmd=.pdf)
.PHONY: pdf
@ echo $(MMD_SRC_FILES)
.PHONY: listsources
@ echo $(MMD_OUT_FILES)
.PHONY: listtargets
.PHONY: clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment