From: Lukel495 Date: Wed, 22 Nov 2023 14:39:10 +0000 (+0100) Subject: Revert "gitignoreing" X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=160e9893e651a95b5e3f35008e1299f65c49e1a8;p=TDDC76_proj.git Revert "gitignoreing" This reverts commit 4da6eb8e4af74a4c4e9dea7493edd0d3c8e71aa4. --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bd5e408 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +CC := g++ +CCFLAGS := -std=c++17 -Wall -Wextra -pedantic -Weffc++ -Wold-style-cast -I src +LDFLAGS := -L${SFML_ROOT}/lib -I${SFML_ROOT}/include -lsfml-window -lsfml-graphics -lsfml-system + +OBJDIR := build +EXEDIR := build/exe +EXE := $(EXEDIR)/game.out +TEST := $(EXEDIR)/test.out + +SRC := $(shell find src -type f -name '[^_]*.cc') +SRC_H := $(shell find src -type f -name '[^_]*.h') +OBJECTS := $(addprefix $(OBJDIR)/, $(SRC:src/%.cc=%.o) ) + +vpath %.cc src + +.PHONY: all clean + +all: dir game-target test-target + +dir: + mkdir -p $(OBJDIR) + mkdir -p $(EXEDIR) + +game: dir + @$(MAKE) --no-print-directory game-target + +testing: dir + @$(MAKE) --no-print-directory test-target + +game-target: $(OBJDIR)/_main.o $(OBJECTS) + $(CC) $(LDFLAGS) $^ -o $(EXE) $(LDFLAGS) + +test-target: $(OBJDIR)/_test.o $(OBJECTS) + $(CC) $(LDFLAGS) $^ -o $(TEST) $(LDFLAGS) + +$(OBJDIR)/%.o: %.cc $(SRC_H) + $(CC) $(CCFLAGS) -c -o $@ $< + +run: + ./$(EXE) + +test: + ./$(TEST) + +clean: + rm -rf $(OBJDIR)/* \ No newline at end of file