generate graphviz png

This commit is contained in:
Malin Freeborn 2025-03-26 02:09:03 +01:00
parent cd9bdb80c1
commit f398f52e55
Signed by: andonome
GPG Key ID: 52295D2377F4D70F

View File

@ -1,5 +1,8 @@
.PHONY: help
ignore_file = .git/info/exclude
.PHONY: help
help: ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
@ -20,23 +23,45 @@ queries = queries authqueries
query_formats = $(patsubst %, .dbs/%.txt, $(queries))
.dbs/:
dotquery_formats = $(patsubst %, .dbs/%.dot, $(queries))
.dbs/: | $(ignore_file)
mkdir $@
ignored += .dbs/
$(query_formats): .dbs/%.txt: | .dbs/
echo "[ {{name}} ] -- $(basename $(@F)) --> [ {{$(basename $(@F))}} ]" > $@
$(dotquery_formats): .dbs/%.dot: | .dbs/
echo '{{name}} -> {{$(basename $(@F))}} [ label="$(basename $(@F))" ];' > $@
.PHONY: map
map: .dbs/network.txt ## Show a network map
$(graph_cmd) < $<
.dbs/network.txt: network.rec $(query_formats)
$(RM) .dbs/network.txt
$(RM) $@
$(foreach relation, $(queries), \
recsel $< -t lxc -e "$(relation) != ''" -p name,$(relation) | recfmt -f .dbs/$(relation).txt >> $@ ;\
)
.dbs/network.dot: network.rec $(dotquery_formats)
echo 'digraph network {' > $@
$(foreach relation, $(queries), \
recsel $< -t lxc -e "$(relation) != ''" -p name,$(relation) | recfmt -f .dbs/$(relation).dot >> $@ ;\
)
echo '}' >> $@
network.png: .dbs/network.dot $(ignore_file) $(ignore_file)
dot < $< -T png > $@
ignored += network.png
##########
$(ignore_file): $(MAKEFILE_LIST)
echo $(ignored) | tr ' ' '\n' > $@
clean:
$(RM) -r .dbs
$(RM) -r $(ignored)