-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (42 loc) · 1.09 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
# C++ compiler flags.
CXXFLAGS = -Wall -O3 -fPIC
# Libraries.
LDLIBS = -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer
# Source directory.
SRC_DIR = src
# Source files.
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
# Object directory.
OBJ_DIR = build
# Object files.
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))
# Implicit rule to compile.
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $^ -o $@
# Phony targets.
.PHONY: all rm headers
# Default target.
all: build $(OBJ_DIR)/libDPGE.so $(OBJ_DIR)/libDPGE.a headers
# Build dir.
build:
mkdir build
# Shared library.
$(OBJ_DIR)/libDPGE.so: $(OBJ_FILES)
$(CXX) -shared $(OBJ_FILES) -o $@ $(LDLIBS)
# Static library.
$(OBJ_DIR)/libDPGE.a: $(OBJ_FILES)
ar rcs $@ $(OBJ_FILES)
# Make headers directory
headers:
mkdir -p include/DPGE
cp $(SRC_DIR)/*.hpp include/DPGE/
# Copy the headers in a directory.
$(OBJ_DIR)/DPGE: $(wildcard $(SRC_DIR/*.hpp))
mkdir -p build/DPGE
cp $(SRC_DIR)/*.hpp $(OBJ_DIR)/DPGE
# Documentation.
doc: Doxyfile
doxygen $^
# Remove all the object files.
rm:
rm -rf build/*.o build/DPGE.so build/headers