-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
46 lines (31 loc) · 931 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
43
44
45
46
# game code directory name
GAMEDIR := src
# binary output directory name
OUTPUTDIR := bin
# name for the output(binary) of the game code
GAMENAME := game
# if you want debug information about memory e.g. memory leaks use -fsanitize=address
# add C flags, like: CFLAGS := -Wall -Werror -Wconversion -Wextra
CFLAGS := -Wall -O2 -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
# add load flags, others like -pthread
LDLIB := -lm
# CC := gcc -std=c17
CC := gcc -std=c11
RM := rm -f
MK := mkdir -p
EXT := c
GAMESOURCES := $(shell find $(GAMEDIR) -type f -name *.$(EXT))
GAMEOBJS := $(subst .$(EXT),.o,$(GAMESOURCES))
all: mkdirs buildGAME clean runGAME
build: mkdirs buildGAME clean
run: runGAME
buildGAME: $(GAMEOBJS)
$(CC) -o $(OUTPUTDIR)/$(GAMENAME) $(GAMEOBJS) $(LDLIB) $(CFLAGS)
%.o : %.$(EXT)
$(CC) -c $< -o $@ $(CFLAGS)
mkdirs:
$(MK) $(OUTPUTDIR)
clean:
$(RM) $(GAMEOBJS)
runGAME:
./$(OUTPUTDIR)/$(GAMENAME)