forked from alexdantas/sdl2-platformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
89 lines (66 loc) · 2.02 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# platformer Makefile
EXE = platformer
CFLAGS = -g `sdl2-config --cflags`
CXXFLAGS = -Wall -Wextra -g `sdl2-config --cflags` -std=c++0x
LDFLAGS = `sdl2-config --libs` \
-lSDL2_image -lSDL2_ttf -lSDL2_mixer -lSDL2_gfx -lm
INCLUDE = -I"/usr/include/SDL"
# No need to edit below here
# All C++ source files of the project
CXXFILES = $(shell find src -maxdepth 1 -type f -name '*.cpp')
CXXOBJECTS = $(CXXFILES:.cpp=.o)
SOURCES = $(CXXFILES)
OBJECTS = $(CXXOBJECTS)
ifdef V
MUTE =
VTAG = -v
else
MUTE = @
endif
###################################################################
# This is a Makefile progress indicator.
# I couldn't understand how it was done - simply copied here.
# BUILD is initially undefined
ifndef BUILD
# max equals 256 x's
sixteen := x x x x x x x x x x x x x x x x
MAX := $(foreach x,$(sixteen),$(sixteen))
# T estimates how many targets we are building by replacing BUILD with
# a special string
T := $(shell $(MAKE) -nrRf $(firstword $(MAKEFILE_LIST)) $(MAKECMDGOALS) \
BUILD="COUNTTHIS" | grep -c "COUNTTHIS")
# N is the number of pending targets in base 1, well in fact, base x
# :-)
N := $(wordlist 1,$T,$(MAX))
# auto-decrementing counter that returns the number of pending targets
# in base 10
counter = $(words $N)$(eval N := $(wordlist 2,$(words $N),$N))
# BUILD is now defined to show the progress, this also avoids
# redefining T in loop
BUILD = @echo $(counter) of $(T)
endif
###################################################################
all: $(EXE)
# Build successful!
$(EXE): $(OBJECTS)
# Linking...
$(MUTE)$(CXX) $(OBJECTS) -o $(EXE) $(LDFLAGS)
src/%.o: src/%.cpp
# Compiling $<...
$(MUTE)$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o $@
$(BUILD)
src/%.o: src/%.c
# Compiling $<...
$(MUTE)$(CC) $(CFLAGS) $(INCLUDE) $< -c -o $@
run: all
$(MUTE)./$(EXE)
clean:
# Cleaning...
-$(MUTE)rm -f $(EXE) $(OBJECTS)
# Generates full documentation for the project
dox:
$(MUTE)doxygen Doxyfile
# Documentation generated!
doxclean:
$(MUTE)rm -rf doc/html
# Documentation cleaned!