1OS := $(shell uname) 2 3SOURCE_DIR = ../src 4BUILD_DIR = $(CURDIR)/build 5LIB_DIR = $(BUILD_DIR)/debug 6INCLUDE_DIR = ../include 7 8INCS = -I$(INCLUDE_DIR) 9CFLAGS = -I. -Wall -Werror -pedantic -fsanitize=address -g 10 11ifeq ($(OS), Darwin) 12CFLAGS += -framework Security 13endif 14 15LIBCRYPTO_DIR = $(dir $(shell find ${BUILD_DIR} -name libcrypto.a)) 16LIBSSL_DIR = $(dir $(shell find ${BUILD_DIR} -name libssl.a)) 17 18LDFLAGS = -L$(LIBCRYPTO_DIR) -L$(LIBSSL_DIR) -L$(LIB_DIR) 19 20LIBS = $(LIB_DIR)/libquiche.a -lev -ldl -pthread 21 22all: client server http3-client http3-server 23 24client: client.c $(INCLUDE_DIR)/quiche.h $(LIB_DIR)/libquiche.a 25 $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(INCS) $(LIBS) 26 27server: server.c $(INCLUDE_DIR)/quiche.h $(LIB_DIR)/libquiche.a 28 $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(INCS) $(LIBS) 29 30http3-client: http3-client.c $(INCLUDE_DIR)/quiche.h $(LIB_DIR)/libquiche.a 31 $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(INCS) $(LIBS) 32 33http3-server: http3-server.c $(INCLUDE_DIR)/quiche.h $(LIB_DIR)/libquiche.a 34 $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(INCS) $(LIBS) 35 36$(LIB_DIR)/libquiche.a: $(shell find $(SOURCE_DIR) -type f -name '*.rs') 37 cd .. && cargo build --target-dir $(BUILD_DIR) 38 39clean: 40 @$(RM) -rf client server http3-client http3-server build/ 41