CXXFLAGS := -std=c++17 -O2 -Wall
LDFLAGS  := $(shell pkgconf --libs grpc++ protobuf) -lssl -lcrypto

.PHONY: clean

all: gen/hash_service_pb2.py hash_service

# use absolute import
gen/hash_service_pb2.py:
	protoc -Igen=. --python_out=. --grpc_python_out=. --plugin=protoc-gen-grpc_python=/usr/bin/grpc_python_plugin hash_service.proto

gen/hash_service.pb.h: gen/hash_service_pb2.py
	protoc --cpp_out=gen --grpc_cpp_out=gen --plugin=protoc-gen-grpc_cpp=/usr/bin/grpc_cpp_plugin hash_service.proto

gen/hash_service.pb.cc:      gen/hash_service.pb.h
gen/hash_service.pb.o:       gen/hash_service.pb.cc
gen/hash_service.grpc.pb.cc: gen/hash_service.pb.h
gen/hash_service.grpc.pb.o:  gen/hash_service.grpc.pb.cc

hash_service.o: gen/hash_service.pb.h

hash_service: gen/hash_service.pb.o gen/hash_service.grpc.pb.o hash_service.o
	$(CXX) $(LDFLAGS) $^ -o $@

clean:
	rm -rf hash_service hash_service.o gen
