-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
61 lines (48 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.PHONY: app clean cleanall run test
CMD := g++
LIB := -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lboost_unit_test_framework
FLAGS := -std=c++17 -g
RM := rm -rf
SRC := src/
OBJ := obj/
BIN := ./
SRCS := $(shell find $(SRC) -type f -name "*.cpp")
OBJS := $(patsubst $(SRC)%.cpp,$(OBJ)%.o,$(SRCS))
APP := $(BIN)Chess
MKDIR = mkdir
TEST_SRC := tests/
TEST_SRCS := $(wildcard $(TEST_SRC)*.cpp)
TEST_OBJS := $(patsubst $(TEST_SRC)%.cpp,$(OBJ)%.o,$(TEST_SRCS))
TEST_APP := $(BIN)Test
TEST_OBJS += $(filter-out $(OBJ)Application/main.o, $(OBJS))
app: OBJS := $(filter-out $(OBJ)main_test.o, $(OBJS)) # Exclude main_test.o for app
app: $(APP)
$(APP): $(OBJS) | $(BIN)
$(CMD) -o $@ $^ $(LIB) $(FLAGS)
@echo "Finished app compilation"
$(OBJ)%.o: $(SRC)%.cpp | $(OBJ)
$(MKDIR) -p $(@D)
$(CMD) -o $@ -c $< $(FLAGS)
@echo "Finished building object file for $<"
$(BIN) $(OBJ):
$(MKDIR) $@
clean:
$(RM) $(OBJ)*.o
$(RM) $(OBJ)*/*.o
@echo "Removed object files"
cleanall: clean
$(RM) $(APP)
@echo "Removed compiled file"
run: app
@echo "Starting program"
$(APP)
test: $(TEST_APP)
@echo "Running tests"
$(TEST_APP)
$(TEST_APP): $(TEST_OBJS)
$(CMD) -o $@ $^ $(LIB) $(FLAGS)
@echo "Finished test compilation"
$(OBJ)%.o: $(TEST_SRC)%.cpp | $(OBJ)
$(MKDIR) -p $(@D)
$(CMD) -o $@ -c $< $(FLAGS)
@echo "Finished building object file for $<"