-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
33 lines (26 loc) · 803 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
P_NAME = digital_invaders
OBJECTS = main scrolling_tile framerate graphic bullet spaceship enemy collision \
scrolling_text weapon powerup spaceship_enchantments game interface ai
# flags
CFLAGS = -Wall -Wextra -O2 `sdl-config --cflags`
LDFLAGS = `sdl-config --libs` -lm -lSDL_gfx -lSDL_image -lSDL_ttf
# build OBJECTS
.PHONY: all
all: $(P_NAME)/$(P_NAME)
# build main program
$(P_NAME)/$(P_NAME): $(OBJECTS:%=obj/%.o) $(P_NAME)
$(CC) $(OBJECTS:%=obj/%.o) $(LDFLAGS) -o $(P_NAME)/$(P_NAME)
# create main directory
$(P_NAME):
mkdir $(P_NAME)
# compile objects
obj/%.o: %.c
mkdir -p obj
$(CC) $(CFLAGS) -c $< -o $@
# additional stuff
.PHONY: run
run: $(P_NAME)/$(P_NAME)
cd $(P_NAME) && ./$(P_NAME)
clean:
- rm -rf $(P_NAME)/$(P_NAME) obj
- rmdir --ignore-fail-on-non-empty $(P_NAME)