-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
58 lines (45 loc) · 1.12 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
NAME?=game.x86_64
CXX?=g++
__CXXFLAGS= -Og -g -std=c++11 \
-Wall -Wpedantic -Wextra \
-pthread \
-lSDL2 -lSDL2_image -lSDL2_ttf
LDXX?=g++
IDIR=include
SDIR=src
BDIR=bin
ODIR=obj
DDIR=dep
_CXXFLAGS = ${__CXXFLAGS} -I${IDIR} ${CXXFLAGS}
SRC = $(shell find ${SDIR} -type f -name '*.cpp' -o -name ".backup" -prune -type f)
OBJ = $(patsubst ${SDIR}/%.cpp,${ODIR}/%.o,${SRC})
DEP = $(patsubst ${SDIR}/%.cpp,${DDIR}/%.dep,${SRC})
ifndef VERBOSE
.SILENT:
endif
build: depend ${SRC} ${BDIR}/${NAME}
${DEP}: ${DDIR}/%.dep: ${SDIR}/%.cpp
mkdir -p ${DDIR}
echo "Calculating dependencies for $^"
mkdir -p $$(dirname $@)
${CXX} ${_CXXFLAGS} $^ -MM -MP -MT $(patsubst ${SDIR}/%.cpp,${ODIR}/%.o,$^) > $@
depend: ${DEP}
include ${DEP}
${OBJ}: ${ODIR}/%.o: ${SDIR}/%.cpp
mkdir -p ${ODIR}
echo "Compiling $@"
mkdir -p $$(dirname $@)
${CXX} -c -o $@ $< ${_CXXFLAGS}
${BDIR}/${NAME}: ${OBJ}
mkdir -p ${BDIR}
echo "Linking ${NAME}"
${LDXX} -o $@ ${OBJ} ${_CXXFLAGS}
clean:
echo "Cleaning build files"
rm -r ${ODIR} ${DDIR}
run: build
echo "Running ${NAME}"
${BDIR}/${NAME}
ctags: ${SRC}
echo "Generating ctags"
ctags -R ${IDIR} ${SDIR}