From 2cb9b6fdc38a5df00ade737f90a9daf685ab89c3 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Thu, 13 Jul 2023 12:20:29 -0500 Subject: Init commit --- makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 makefile (limited to 'makefile') diff --git a/makefile b/makefile new file mode 100644 index 0000000..1dd3151 --- /dev/null +++ b/makefile @@ -0,0 +1,68 @@ +EMCPP = /usr/lib/emscripten/emcc +CPP = /opt/emscripten-llvm/bin/clang++ +CXXFLAGS = -std=c++20 +CXXFLAGS += -Wall -Wextra -Wno-unused-function +CXXFLAGS += -Isrc +EMSCRIPT_FLAGS = $(CXXFLAGS) -lembind --bind +TEST_FLAGS = $(CXXFLAGS) -Itest/include -DTEST + +SRC_VIEW = src/view +SRC_CONTROLLERS = src/controllers +SRC_MODELS = src/models + +OBJS := models/timer.o +OBJS += models/counter.o +OBJS += utils/utils.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)) + +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) + +$(DIST_BUILD_DIR)/%.js: $(SRC_CONTROLLERS)/%.cpp $(DIST_OBJS) $(DIST_BUILD_DIR) + $(EMCPP) $(EMSCRIPT_FLAGS) -o $@ $(filter %.cpp %.o, $^) + +$(DIST_BUILD_DIR)/%.o: src/%.cpp + mkdir -p $(basename $@) + $(EMCPP) $(CXXFLAGS) -c -o $@ $< + +$(VIEW_DIRECTORIES): + mkdir -p $@ + +$(VIEW_FILES): + cp $(patsubst $(DIST_DIR)/%,$(SRC_VIEW)/%,$@) $@ + +$(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: + python serve.py + +clean: + rm -rf $(DIST_DIR) $(TEST_BUILD_DIR) -- cgit v1.2.3