dmzconf/Makefile

43 lines
1.1 KiB
Makefile

.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 | \
column -s ':' -t
.PHONY: check
check: ## Check you have all dependencies
@command -v graph-easy >/dev/null || { echo "Install perl-graph-easy" && exit 1 ;}
@command -v recsel >/dev/null || { echo "Install recutils" && exit 1 ;}
@command -v lowdown >/dev/null || { echo "Install lowdown" && exit 1 ;}
@echo "All dependencies installed"
########## Network Map ##########
graph_cmd = graph-easy --boxart
queries = queries authqueries
query_formats = $(patsubst %, .dbs/%.txt, $(queries))
.dbs/:
mkdir $@
$(query_formats): .dbs/%.txt: | .dbs/
echo "[ {{name}} ] -- $(basename $(@F)) --> [ {{$(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
$(foreach relation, $(queries), \
recsel $< -t lxc -e "$(relation) != ''" -p name,$(relation) | recfmt -f .dbs/$(relation).txt >> $@ ;\
)
##########
clean:
$(RM) -r .dbs