-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (35 loc) · 713 Bytes
/
Makefile
File metadata and controls
49 lines (35 loc) · 713 Bytes
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
CC=clang
CFLAGS=-Wall -std=c11 -pedantic `pkg-config --cflags sdl2`
LDFLAGS=
LIBS=`pkg-config --libs sdl2` -lm
SRC=$(wildcard *.c)
HEAD=$(wildcard *.h)
ifeq ($(MAKECMDGOALS),debug)
PROFILE=debug
endif
ifeq ($(MAKECMDGOALS),)
PROFILE=debug
endif
ifeq ($(MAKECMDGOALS),release)
PROFILE=release
endif
ifeq ($(PROFILE),debug)
CFLAGS+=-DDEBUG -g
endif
ifeq ($(PROFILE),release)
CFLAGS+=-O3
endif
OBJ:=$(SRC:%.c=$(PROFILE)/%.o)
release: asteroids
debug: asteroids
asteroids: $(OBJ) FORCE
@echo Linking $@
@$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o asteroids
FORCE:
$(PROFILE)/%.o: %.c $(HEAD)
@echo $<
@mkdir -p $(PROFILE)
@$(CC) $(CFLAGS) $< -c -o $@
.phony: clean
clean:
rm -rf debug/ release/ asteroids