.PHONY: all check run test clean help

CC ?= cc
PKG_CONFIG ?= pkg-config
CFLAGS ?= -std=c11 -O2 -Wall -Wextra -pedantic
PKG_CFLAGS := $(shell $(PKG_CONFIG) --cflags zlib openssl 2>/dev/null)
PKG_LIBS := $(shell $(PKG_CONFIG) --libs zlib openssl 2>/dev/null)
LDLIBS ?= $(if $(PKG_LIBS),$(PKG_LIBS),-lz -lcrypto)

all: aip56

aip56: aip56.c
	$(CC) $(CFLAGS) $(PKG_CFLAGS) $< -o $@ $(LDLIBS)

check: aip56
	./aip56 --check

run: aip56
	./aip56

test: check

clean:
	rm -f aip56 *.o

help:
	@printf '%s\n' \
		'make check  Build and validate the canonical wordlist' \
		'make run    Build and generate one AIP-56 phrase' \
		'make test   Run the validation smoke test' \
		'make clean  Remove the binary and object files' \
		'make help   Show these targets'
