CRFLAGS ?= --progress
SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)

bin/write-zone-file: tools/write-zone-file.cr
	$(Q)-shards build write-zone-file $(CRFLAGS)
build-write-zone-file: bin/write-zone-file

bin/write-template-zone-file: tools/write-template-zone-file.cr
	$(Q)-shards build write-template-zone-file $(CRFLAGS)
build-write-template-zone-file: bin/write-template-zone-file

bin/powerdns-sync: tools/powerdns-sync.cr
	$(Q)-shards build powerdns-sync $(CRFLAGS)
build-powerdns-sync: bin/powerdns-sync

bin/dnsmanagerd: $(SOURCE_FILES)
	$(Q)shards build dnsmanagerd $(CRFLAGS)
build-server: bin/dnsmanagerd

bin/dnsmanager-client: $(SOURCE_FILES)
	$(Q)shards build dnsmanager-client $(CRFLAGS)
build-client: bin/dnsmanager-client

bin/token-handler: tools/token-handler.cr
	$(Q)shards build token-handler $(CRFLAGS)
build-token-handler: bin/token-handler

# The documentation includes the `authd` API.
doc:
	crystal docs src/main.cr src/client.cr lib/authd/src/client.cr

build: build-server build-client build-token-handler build-powerdns-sync

release:
	make build-server CRFLAGS="--release --progress --no-debug"