diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-17 15:56:11 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-08-17 15:56:11 -0500 |
commit | 34779155d5b69b51aa301e7c111f95ea9c840589 (patch) | |
tree | 7289232dc3c4cd187e065792191dd707f08d6e79 /makefile | |
download | wg2nd-34779155d5b69b51aa301e7c111f95ea9c840589.tar.xz wg2nd-34779155d5b69b51aa301e7c111f95ea9c840589.zip |
init commit
Diffstat (limited to 'makefile')
-rw-r--r-- | makefile | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/makefile b/makefile new file mode 100644 index 0000000..c08daf5 --- /dev/null +++ b/makefile @@ -0,0 +1,73 @@ +# Compiler +CXX = g++ + +# Compiler flags +CXXFLAGS = -Wall -Wextra -Werror +CXXFLAGS += -Isrc -std=c++20 -Wno-unused-function + +# Release flags +RELEASE_FLAGS = -O3 -lrt + +# Debug flags +DEBUGFLAGS = -ggdb -O0 + +# Linking flags +LDFLAGS = -largon2 + +# Object files +OBJECTS := wg2sd.o +OBJECTS += main.o + +# Source directory +SRC_DIR = src +TEST_DIR = test + +TEST_FILES := $(wildcard $(TEST_DIR)/*.cpp) +TEST_TARGETS := $(patsubst $(TEST_DIR)/%.cpp, $(TEST_DIR)/%, $(TEST_FILES)) + +SRC_FILES := $(patsubst %.o,$(SRC_DIR)/%.cpp,$(OBJECTS)) + +# Object directory +OBJ_DIR = obj +DEBUG_OBJ_DIR = obj/debug + +# Target executable +TARGET = wg2sd + +# Build rules +all: CXXFLAGS += $(RELEASE_FLAGS) +all: targets + +targets: $(TARGET) + +tests: $(TEST_TARGETS) + +debug: CXXFLAGS += $(DEBUGFLAGS) +debug: OBJ_DIR = $(DEBUG_OBJ_DIR) +debug: tests targets + +$(TARGET): $(addprefix $(OBJ_DIR)/, $(OBJECTS)) + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) + $(CXX) $(CXXFLAGS) -c $< -o $@ + +$(TEST_DIR)/%: $(TEST_DIR)/%.cpp $(addprefix $(OBJ_DIR)/, wg2sd.o) | $(OBJ_DIR) + $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ + +$(OBJ_DIR) $(DEBUG_OBJ_DIR): + mkdir -p $@ + +# Clean rule +clean: + rm -rf $(OBJ_DIR) $(DEBUG_OBJ_DIR) $(TARGET) $(TEST_TARGETS) + +# Help rule +help: + @echo "Available targets:" + @echo " all (default) : Build the project" + @echo " release : Build the project with release flags" + @echo " tests : Build the tests" + @echo " debug : Build the project and tests with debug flags" + @echo " clean : Remove all build artifacts" + @echo " help : Display this help message" |