-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (30 loc) · 991 Bytes
/
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
#CC=x86_64-w64-mingw32-g++
CC=g++
WX_CONFIG := wx-config
WX_CXXFLAGS := $(shell $(WX_CONFIG) --cxxflags)
WX_LIBS := $(shell $(WX_CONFIG) --libs)
CCFLAGS = -c -g -MMD -std=c++17
LDFLAGS = -g -lGL -lGLU
OBJDIR = build
SRCDIR = src
TESTSRCDIR = test
SRC = $(shell find $(SRCDIR) -name "*.cpp")
OBJ = $(SRC:$(SRCDIR)%.cpp=$(OBJDIR)%.o)
DEPENDENCIES = $(SRC:$(SRCDIR)%.cpp=$(OBJDIR)%.d)
APP = main
TEST = test
$(APP): $(OBJ)
@echo "== LINKING EXECUTABLE $(OBJDIR)/$(APP)"
@$(CC) -o $(OBJDIR)/$(APP) $^ $(LDFLAGS) $(WX_LIBS) $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@echo "== COMPILING SOURCE $< INTO $@"
@mkdir -p $(@D)
@$(CC) $(CCFLAGS) -o $@ $< $(WX_CXXFLAGS)
-include $(DEPENDENCIES)
test: $(TESTSRCDIR)/main.cpp $(OBJ)
@echo "== COMPILING MAIN TEST"
@$(CC) $(CCFLAGS) -o $(OBJDIR)/$(TEST).o $(TESTSRCDIR)/main.cpp
@echo "== LINKING MAIN TEST"
@$(CC) $(LDFLAGS) -o $(OBJDIR)/$(TEST) $(filter-out $(OBJDIR)/$(APP).o, $(OBJ)) $(OBJDIR)/$(TEST).o
clean:
@rm -rf $(OBJDIR)