-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
50 lines (36 loc) · 1.01 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
CC := g++
CFLAGS := -c -std=c++11 -O3 --static
LD := g++
LDFLAGS := -Wall -std=c++11 -I/usr/local/lib/
LIBS := -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
SRCDIR := src
INCLDIR := include
OBJDIR := obj
BINDIR := bin
SRCFILES := ${shell find ${SRCDIR} | grep .cpp}
OBJECTS := ${patsubst ${SRCDIR}/%.cpp,${OBJDIR}/%.o,${SRCFILES}}
TARGET := bacteria_simulation
.PHONY: all
all : build
${OBJDIR}/%.o : ${SRCDIR}/%.cpp
@printf "\tBuilding %-30s" $@
@mkdir -p ${dir $@}
@${CC} ${CFLAGS} $< -MM -I./${INCLDIR} -MT $@ > ${patsubst %.o,%.d,$@}
@${CC} -I./${INCLDIR} ${CFLAGS} -c $< -o $@
@printf "done\n"
-include ${patsubst %.o,%.d,${OBJECTS}}
${BINDIR}/${TARGET} : ${OBJECTS}
@echo "\tBuilding executable at $@"
@mkdir -p ${dir $@}
@${LD} $^ ${LDFLAGS} -o $@ ${LIBS}
.PHONY: build run clean
build: ${BINDIR}/${TARGET}
run: build
@echo "\tRunning application..."
@${BINDIR}/${TARGET}
rerun: clean run
rebuild: clean build
clean:
@echo "\tRemoving objects and binary files"
@rm -rf obj
@rm -rf bin