SHELL := /usr/bin/env bash

# dot, neato, twopi, circo, fdp, sfdp, patchwork, osage
DOT ?= dot

FONT ?= "Latin Modern Roman"

DOTs = $(wildcard *.dot) pipeline-simple.dot
SVGs = $(patsubst %.dot,%.svg,$(DOTs))

svg: $(SVGs)

# remove edge label
pipeline-simple.dot: pipeline.dot
	printf "%s\n\n" "// This is auto-generated from \`$<\`. Do not edit this file directly." > $@
	sed -E -e 's/->(.*)label="[^"]+",? ?/->\1/' -e 's/ \[\]//' -e 's/rankdir=LR/rankdir=TB/' $< >> $@

%.svg: %.dot
	$(DOT) -T svg $< -o $*.svg -Nfontname=$(FONT) -Efontname=$(FONT) -Gfontname=$(FONT)

clean:
	rm -f $(SVGs)

print-%:
	$(info $* = $($*))
