-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (31 loc) · 870 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
# Simple Makefile
# Vars
CC= gcc
CPPFLAGS= -MMD `pkg-config --cflags sdl`
CFLAGS= -Wall -Wextra -std=c99 -g
LDFLAGS=
LDLIBS= `pkg-config --libs sdl` -export-dynamic -lSDL_ttf -lSDL_image -lm
BIN = main
SRCDIR= src
OBJDIR= bin
SRC= $(wildcard $(SRCDIR)/*.c)
OBJ= $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
DEP= ${OBJ:.o=.d}
# Default rule: just ask for bin main
all: $(OBJDIR)/$(BIN)
# main depends on object files, that's all we need
$(OBJDIR)/$(BIN): $(OBJ)
mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) $^ -o $@ $(LDLIBS)
-include $(DEP)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@ $(LDLIBS)
# cleaning rule
clean:
${RM} ${OBJ} ${DEP} $(OBJDIR)/$(BIN)
run:
./$(OBJDIR)/$(BIN) $(filter-out $@,$(MAKECMDGOALS))
%:
@:
# END of Makefile