-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (37 loc) · 1.09 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
DIR := src
# binary output directory name
OUTPUTDIR := bin
NAME := Myncraft
# add C flags, like: CFLAGS := -Wall -Werror -Wconversion -Wextra
CFLAGS :=
# add load flags, others like -pthread
LDLIB := -lm -lSDL2 -lSDL2_ttf -lGL -lGLEW -pthread
CC := g++ -std=c++17
RM := rm -f
MK := mkdir -p
EXT := cpp
SRC := $(shell find $(DIR) -type f -name *.$(EXT))
OBJS := $(subst .$(EXT),.o,$(SRC))
all: mkdirs buildClient run
debug: mkdirs buildClientDebug
game: mkdirs buildClient clean runClient
run: runClient
buildClient: $(OBJS)
@echo "Linking $(NAME)..."
$(CC) -o $(OUTPUTDIR)/$(NAME) $(OBJS) $(LDLIB) $(CFLAGS)
#buildClientDebug: $(OBJS)
# @echo "Linking (DEBUG) $(NAME)..."
# $(CC) -o $(OUTPUTDIR)/$(NAME) $(OBJS) $(LDLIB) $(CFLAGS) -fsanitize=address
buildClientDebug: $(OBJS)
@echo "Linking (DEBUG) $(NAME)..."
$(CC) -o $(OUTPUTDIR)/$(NAME) $(OBJS) $(LDLIB) $(CFLAGS) -O0
%.o : %.$(EXT)
$(CC) -c $< -o $@ $(CFLAGS) -MD -MP
mkdirs:
$(MK) $(OUTPUTDIR)
clean:
@echo "Cleaning..."
$(RM) $(OBJS)
runClient:
@echo "Starting to run $(NAME)... "; ./$(OUTPUTDIR)/$(NAME)
-include $(OBJS:.o=.d)