# Build the C++ token example. uECC is C, compiled with the C compiler and
# linked in. Only P-256 is enabled to keep code size down.

UECC_DIR := ../uECC
UECC_DEFS := -DuECC_SUPPORTS_secp160r1=0 -DuECC_SUPPORTS_secp192r1=0 \
             -DuECC_SUPPORTS_secp224r1=0 -DuECC_SUPPORTS_secp256k1=0
CXXFLAGS := -O2 -std=c++17 -Wall -Wextra -I. -I$(UECC_DIR) $(UECC_DEFS)
CFLAGS   := -O2 -I$(UECC_DIR) $(UECC_DEFS)

token_example: token_example.o device_token.o uECC.o
	$(CXX) $^ -o $@

token_example.o: token_example.cpp device_token.hpp
	$(CXX) $(CXXFLAGS) -c token_example.cpp -o $@

device_token.o: device_token.cpp device_token.hpp
	$(CXX) $(CXXFLAGS) -c device_token.cpp -o $@

uECC.o: $(UECC_DIR)/uECC.c
	$(CC) $(CFLAGS) -c $< -o $@

run: token_example
	./token_example

clean:
	rm -f token_example token_example.o device_token.o uECC.o

.PHONY: run clean
