From ca592cb6e6a9aeee619d3fd7311030ab34844c2f Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Sun, 27 Aug 2023 20:11:39 -0500 Subject: Add wg2nd-web source --- makefile | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 makefile (limited to 'makefile') diff --git a/makefile b/makefile new file mode 100644 index 0000000..babe492 --- /dev/null +++ b/makefile @@ -0,0 +1,84 @@ +EMCC = emcc +EMCPP = em++ + +CFLAGS += -Wall -Wextra -Wno-unused-function -g +CFLAGS += -Isrc + +EMSCRIPT_FLAGS := $(CFLAGS) -lembind +EMSCRIPT_FLAGS += -static --bind +EMSCRIPT_FLAGS += -fwasm-exceptions + +CXXFLAGS = $(CFLAGS) -std=c++20 -fwasm-exceptions + +TEST_FLAGS = $(CXXFLAGS) -Itest/include -DTEST + + +SRC_VIEW = src/view +SRC_CONTROLLERS = src/controllers +SRC_MODELS = src/models + +OBJS := src/models/wg2nd.o + +C_OBJS := src/models/crypto/halfsiphash.o +C_OBJS += src/models/crypto/curve25519.o +C_OBJS += src/models/crypto/encoding.o +C_OBJS += src/models/crypto/pubkey.o + +TEST_DIR=test +TEST_BUILD_DIR=$(TEST_DIR)/build +TESTS=timer_test +TEST_TARGETS := $(patsubst %, $(TEST_BUILD_DIR)/%, $(TESTS)) + +DIST_DIR = dist +DIST_BUILD_DIR = $(DIST_DIR)/build + +# DIST_OBJS := $(patsubst %, $(DIST_BUILD_DIR)/%, $(OBJS)) +# DIST_C_OBJS := $(patsubst %, $(DIST_BUILD_DIR)/%, $(C_OBJS)) + +CONTROLLERS := $(wildcard $(SRC_CONTROLLERS)/*.cpp) +CONTROLLER_HARNESSES := $(patsubst $(SRC_CONTROLLERS)/%.cpp, $(DIST_BUILD_DIR)/%.js, $(CONTROLLERS)) + +VIEW_DIRECTORIES=$(patsubst $(SRC_VIEW)/%, $(DIST_DIR)/%, $(shell find $(SRC_VIEW) -type d)) +VIEW_FILES=$(patsubst $(SRC_VIEW)/%, $(DIST_DIR)/%, $(shell find $(SRC_VIEW) -type f)) + +.PHONY: all clean run test + +all: $(DIST_DIR) $(VIEW_DIRECTORIES) $(VIEW_FILES) $(CONTROLLER_HARNESSES) + +test: $(TEST_TARGETS) + +$(OBJS): %.o: %.cpp + $(EMCPP) $(CXXFLAGS) -c -o $@ $< + +$(C_OBJS): %.o: %.c + $(EMCC) $(CFLAGS) -c -o $@ $< + +$(DIST_BUILD_DIR)/%.js: src/controllers/browser.cpp $(OBJS) $(C_OBJS) $(DIST_BUILD_DIR) + $(EMCPP) -o $@ $(EMSCRIPT_FLAGS) $(filter %.cpp %.o %.a, $^) + +$(VIEW_DIRECTORIES): + mkdir -p $@ + +$(DIST_DIR)/%: $(SRC_VIEW)/% + cp $^ $@ + +$(DIST_DIR): + mkdir -p $(DIST_DIR) + +$(DIST_BUILD_DIR): $(DIST_DIR) + mkdir -p $(DIST_BUILD_DIR) + +$(TEST_BUILD_DIR): + mkdir -p $(TEST_BUILD_DIR) + +$(TEST_BUILD_DIR)/%: $(TEST_BUILD_DIR) $(TEST_DIR)/%.cpp $(SRC_MODELS)/*.cpp + $(CPP) $(TEST_FLAGS) -o $@ $(filter %.cpp, $^) + +run: # requires flask + python serve.py + +watch: # requires nodemon + nodemon -w "./src" --exec "make" -e "js,html,css,cpp,hpp" + +clean: + rm -rf $(DIST_DIR) $(OBJS) $(C_OBJS) $(TEST_BUILD_DIR) -- cgit v1.2.3