-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
44 lines (33 loc) · 1.07 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
CXX = clang++
# Name of the executable
EXEC = pong-game.out
# Build directories
BUILD = build
OBJ_DIR = obj
SRCDIR = src
SUBDIRS := $(shell find ${SRCDIR} -type d)
CXXFLAGS := -Wall -Wextra -O3 -std=c++14 $(addprefix -I, ${SUBDIRS})
CXXFLAGS_D := -Wall -Wextra -O1 -fsanitize=address -g -std=c++14 $(addprefix -I, ${SUBDIRS})
LIBS := -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
SOURCES = $(shell find ${SRCDIR} -name "*.cpp")
OBJECTS = $(patsubst %.cpp,%.o,$(SOURCES))
OBJECTS := $(notdir $(OBJECTS))
OBJECTS := $(addprefix $(BUILD)/$(OBJ_DIR)/, $(OBJECTS))
all: release
release:
$(CXX) $(CXXFLAGS) -c $(SOURCES)
@mv -f *.o $(BUILD)/$(OBJ_DIR)
$(CXX) $(CXXFLAGS) -o $(EXEC) $(OBJECTS) $(LIBS)
@mv -f $(EXEC) $(BUILD)
debug:
$(CXX) $(CXXFLAGS_D) -c $(SOURCES)
@mv -f *.o $(BUILD)/$(OBJ_DIR)
$(CXX) $(CXXFLAGS_D) -o $(EXEC) $(OBJECTS) $(LIBS)
@mv -f $(EXEC) $(BUILD)
vars:
@echo "sources: ${SOURCES}"
@echo "objects: ${OBJECTS}"
@echo "flags: ${CXXFLAGS}"
clean:
rm -f $(wildcard $(RELEASE_BUILD)/$(OBJ_DIR)/*.o)
rm -f $(wildcard $(DEBUG_BUILD)/$(OBJ_DIR)/*.o)