Makefile reworked.

This commit is contained in:
Philippe PITTOLI 2024-06-22 00:50:15 +02:00
parent 516ccf1e58
commit 835415caac
2 changed files with 33 additions and 80 deletions

View File

@ -8,101 +8,71 @@ else
LOGIN_OPT = -l $(LOGIN) LOGIN_OPT = -l $(LOGIN)
endif endif
# No idea why, but I need that to run applications. Ignore that.
#LD_P ?= LD_PRELOAD=/usr/local/lib/libipc.so.0
OPTS ?= --progress OPTS ?= --progress
Q ?= @ Q ?= @
SHOULD_UPDATE = ./bin/should-update SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)
#################### ####################
### REQUEST EXAMPLES ### REQUEST EXAMPLES
#################### ####################
DOMAIN ?= example.com DOMAIN ?= example.com
build-write-zone-file: tools/write-zone-file.cr bin/write-zone-file: tools/write-zone-file.cr
$(Q)-([ ! -f bin/write-zone-file ] || [ tools/write-zone-file.cr -nt bin/write-zone-file ]) && shards build write-zone-file $(OPTS) $(Q)-shards build write-zone-file $(OPTS)
build-write-zone-file: bin/write-zone-file
zone-file: build-write-zone-file zone-file: build-write-zone-file
$(Q)./bin/write-zone-file $(DOMAIN) $(Q)./bin/write-zone-file $(DOMAIN)
build-write-template-zone-file: tools/write-template-zone-file.cr bin/write-template-zone-file: tools/write-template-zone-file.cr
$(Q)-([ ! -f bin/write-template-zone-file ] || [ tools/write-template-zone-file.cr -nt bin/write-template-zone-file ]) && shards build write-template-zone-file $(OPTS) $(Q)-shards build write-template-zone-file $(OPTS)
build-write-template-zone-file: bin/write-template-zone-file
zone-basic-template-file: build-write-template-zone-file zone-basic-template-file: build-write-template-zone-file
$(Q)./bin/write-template-zone-file $(DOMAIN) $(Q)./bin/write-template-zone-file $(DOMAIN)
VERBOSITY ?= 4 VERBOSITY ?= 4
run-client-verbosity: run-client-verbosity:; $(Q)./bin/dnsmanager-client admin maintenance verbosity $(VERBOSITY) $(LOGIN_OPT)
$(Q)$(LD_P) ./bin/dnsmanager-client admin maintenance verbosity $(VERBOSITY) $(LOGIN_OPT) run-client-domain-add:; $(Q)./bin/dnsmanager-client user domain add $(DOMAIN) $(LOGIN_OPT)
run-client-domain-del:; $(Q)./bin/dnsmanager-client user domain del $(DOMAIN) $(LOGIN_OPT)
run-client-domain-add: run-client-domain-list:; $(Q)./bin/dnsmanager-client user domain list $(LOGIN_OPT)
$(Q)$(LD_P) ./bin/dnsmanager-client user domain add $(DOMAIN) $(LOGIN_OPT) run-client-zone-add:; $(Q)./bin/dnsmanager-client user zone add $(DOMAIN).json $(LOGIN_OPT)
run-client-zone-get:; $(Q)./bin/dnsmanager-client user zone get $(DOMAIN) $(LOGIN_OPT)
run-client-domain-del:
$(Q)$(LD_P) ./bin/dnsmanager-client user domain del $(DOMAIN) $(LOGIN_OPT)
run-client-domain-list:
$(Q)$(LD_P) ./bin/dnsmanager-client user domain list $(LOGIN_OPT)
run-client-zone-add:
$(Q)$(LD_P) ./bin/dnsmanager-client user zone add $(DOMAIN).json $(LOGIN_OPT)
run-client-zone-get:
$(Q)$(LD_P) ./bin/dnsmanager-client user zone get $(DOMAIN) $(LOGIN_OPT)
RRID ?= 1 RRID ?= 1
NAME ?= NAME ?=
TTL ?= 3600 TTL ?= 3600
TARGET ?= TARGET ?=
run-client-rr-add-a: run-client-rr-add-a:; $(Q)./bin/dnsmanager-client user rr add A $(DOMAIN) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT)
$(Q)$(LD_P) ./bin/dnsmanager-client user rr add A $(DOMAIN) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT) run-client-rr-update-a:; $(Q)./bin/dnsmanager-client user rr update A $(DOMAIN) $(RRID) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT)
run-client-rr-del:; $(Q)./bin/dnsmanager-client user rr del $(DOMAIN) $(RRID) $(LOGIN_OPT)
run-client-rr-update-a: run-client-genzones:; $(Q)./bin/dnsmanager-client admin genall $(LOGIN_OPT)
$(Q)$(LD_P) ./bin/dnsmanager-client user rr update A $(DOMAIN) $(RRID) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT)
run-client-rr-del:
$(Q)$(LD_P) ./bin/dnsmanager-client user rr del $(DOMAIN) $(RRID) $(LOGIN_OPT)
run-admin-generate-all-zonefiles:
$(Q)$(LD_P) ./bin/dnsmanager-client admin genall $(LOGIN_OPT)
################## ##################
### SETUP COMMANDS ### SETUP COMMANDS
################## ##################
DBDIR=/tmp/DATA-dnsmanagerd DBDIR=/tmp/DATA-dnsmanagerd
run-dnsmanagerd: bin/dnsmanagerd: $(SOURCE_FILES); $(Q)shards build dnsmanagerd $(OPTS)
$(Q)$(LD_P) ./bin/dnsmanagerd -v $(VERBOSITY) -r $(DBDIR) build-server: bin/dnsmanagerd
run-dnsmanagerd:; $(Q)./bin/dnsmanagerd -v $(VERBOSITY) -r $(DBDIR)
bin/dnsmanager-client: $(SOURCE_FILES); $(Q)shards build dnsmanager-client $(OPTS)
build-client: bin/dnsmanager-client
PORT ?= 8082 PORT ?= 8082
ADDR ?= ADDR ?=
run-token-handler: bin/token-handler: tools/token-handler.cr; $(Q)shards build token-handler $(OPTS)
$(Q)$(LD_P) ./bin/token-handler $(PORT) $(ADDR) build-token-handler: bin/token-handler
run-token-handler: bin/token-handler; $(Q)./bin/token-handler $(PORT) $(ADDR)
build-server:
$(Q)-$(SHOULD_UPDATE) bin/dnsmanagerd && shards build dnsmanagerd $(OPTS)
build-client:
$(Q)-$(SHOULD_UPDATE) bin/dnsmanager-client && shards build dnsmanager-client $(OPTS)
build-token-handler:
$(Q)shards build token-handler $(OPTS)
build: build-server build-client build-token-handler build: build-server build-client build-token-handler
print-messages: print-messages:; cat src/requests/*.cr | ./bin/get-messages.awk
cat src/requests/*.cr | ./bin/get-messages.awk print-message-numbers:; make -s print-messages | grep -E "^[0-9]" | sort -n
print-message-numbers: print-messages-no-comments:; make -s print-messages | grep -vE '^[[:blank:]]+#'
make -s print-messages | grep -E "^[0-9]" | sort -n print-response-messages:; cat src/responses/*.cr | ./bin/get-messages.awk
print-messages-without-comments: print-response-message-numbers:; make -s print-response-messages | grep -E "^[0-9]" | sort -n
make -s print-messages | grep -vE '^[[:blank:]]+#' print-response-messages-no-comments:; make -s print-response-messages | grep -vE '^[[:blank:]]+#'
print-response-messages:
cat src/responses/*.cr | ./bin/get-messages.awk
print-response-message-numbers:
make -s print-response-messages | grep -E "^[0-9]" | sort -n
print-response-messages-without-comments:
make -s print-response-messages | grep -vE '^[[:blank:]]+#'
# format: nb-domains <TAB> login <TAB> domain1 <TAB> domain2 <TAB> domain3 # format: nb-domains <TAB> login <TAB> domain1 <TAB> domain2 <TAB> domain3
MIGRATION_FILE_TARGET = /tmp/dnsmanagerd-migration MIGRATION_FILE_TARGET = /tmp/dnsmanagerd-migration
@ -115,7 +85,7 @@ migration: migration-file run-migration-client
doc: doc:
crystal docs src/main.cr src/client.cr lib/authd/src/client.cr crystal docs src/main.cr src/client.cr lib/authd/src/client.cr
HTTPD_ACCESS_LOGS ?= /tmp/access-dodb-docs.log HTTPD_ACCESS_LOGS ?= /tmp/access-dnsmanager-docs.log
HTTPD_ADDR ?= 127.0.0.1 HTTPD_ADDR ?= 127.0.0.1
HTTPD_PORT ?= 9001 HTTPD_PORT ?= 9001
DIR ?= docs DIR ?= docs

View File

@ -1,17 +0,0 @@
#!/bin/sh
# Should we run the build?
if [ $# -lt 1 ]; then
exec >& 2
echo "Usage: $0 <exe>"
exit 1
fi
exe=$1
# If the binary hasn't already be compiled.
[ -f "${exe}" ] || exit 0
v=`find src/ -type f -newer "${exe}" | wc -l`
test "${v}" != "0"