diff --git a/Makefile b/Makefile index 71259f4..7b1708d 100644 --- a/Makefile +++ b/Makefile @@ -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)