-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (38 loc) · 1.13 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
#SRC specifies which files to compile as part of the project
SRC_DIR = src
BUILD_DIR = build
SRC = $(wildcard $(SRC_DIR)/*.cpp)
HDR = $(wildcard $(SRC_DIR)/*.h)
#CC specifies which compiler we're using
CC = g++
#Compiler Flags
# -w suppresses all warnings
CC_FLAGS = -w -std=c++11
#Linker Flags
LD_FLAGS = -lSDL2 -lSDL2_image -lSDL2_ttf -lopenal -lalut
INCLUDES = -Iinclude
#TARGET specifies the name of our exectuable
TARGET_NAME = breakout
TARGET = $(TARGET_NAME)
OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRC))
.PHONY: clean distclean run
#This is the target that compiles our executable
all: dir $(TARGET)
dir:
@mkdir -p $(BUILD_DIR)
$(TARGET): $(OBJS)
@echo Linking $@
@$(CC) -ggdb $^ -o $@ $(LD_FLAGS)
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp $(BUILD_DIR)/%.d
@echo Compiling $< to $@
@$(CC) -ggdb $(CC_FLAGS) $(INCLUDES) -c $< -o $@ -MT $@ -MMD -MP -MF $(@:.o=.d)
clean:
@echo Cleaning
@rm -f $(BUILD_DIR)/*.o $(BUILD_DIR)/*.d $(TARGET)
distclean:
@echo Removing Directory $(BUILD_DIR)
@$(RM) -rf $(BUILD_DIR)
$(BUILD_DIR)/%.d: ;
.PRECIOUS: $(BUILD_DIR)/%.d
-include $(OBJS:.o=.d)