-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 1.46 KB
/
Copy pathMakefile
File metadata and controls
67 lines (51 loc) · 1.46 KB
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
62
63
64
65
66
67
# Set default target as link
.DEFAULT_GOAL := link
# Directories
MAIN_SRCDIR = ./src
SECONDARY_SRCDIR = $(MAIN_SRCDIR)/classes
TERCIARY_SRCDIR = $(MAIN_SRCDIR)/misc
LIBDIR = ./lib
OBJDIR = ./build
INCDIR = ./include
THIRD_PARTY_INCDIR = ./thirdParty
# Compiler
CC = g++
# Output
EXEC = minesweeper
# Change .cpp to .o
SRC = $(wildcard $(TERCIARY_SRCDIR)/*.cpp $(SECONDARY_SRCDIR)/*.cpp $(MAIN_SRCDIR)/*.cpp)
OBJ = $(addprefix $(OBJDIR)/,$(notdir $(SRC:.cpp=.o)))
# Flags
CFLAGS = -I $(THIRD_PARTY_INCDIR) -I $(INCDIR) -Wall -Wextra -pedantic -std=c++11
DBGFLAGS = -g -fno-inline
LFLAGS = -lrayliblinux -lpthread -ldl
# Ignore these files
.PHONY : compile link run clean valgrind
# Compile source to outputs .o
compile: $(OBJ)
ifeq ($(DEBUG),YES)
CFLAGS := $(CFLAGS) $(DBGFLAGS)
endif
ifeq ($(OS),Windows_NT)
LFLAGS := -lraylibwin -lopengl32 -lgdi32 -lwinmm -mwindows
endif
$(OBJDIR)/%.o: $(TERCIARY_SRCDIR)/%.cpp
$(CC) -c $(CFLAGS) $< -o $@
$(OBJDIR)/%.o: $(SECONDARY_SRCDIR)/%.cpp
$(CC) -c $(CFLAGS) $< -o $@
$(OBJDIR)/%.o: $(MAIN_SRCDIR)/%.cpp
$(CC) -c $(CFLAGS) $< -o $@
# Link everything together
link: compile
$(CC) -o $(EXEC) $(OBJDIR)/*.o -L $(LIBDIR) $(LFLAGS)
# Run the program
run:
./$(EXEC)
# Delete the program and build files
clean:
rm -f $(EXEC)
rm -f $(EXEC).*
rm -f $(OBJDIR)/*.o
# Run valgrind to search for memory leaks
valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./$(EXEC)