-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (38 loc) · 1.16 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
# Project name
EXEC=prpg
# Compiler
IDIR=include SFML/include
IDIRFLAG=$(foreach idir, $(IDIR), -I$(idir))
CXXFLAGS=-std=c++11 -W -Wall -Wextra -pedantic -Wno-sign-compare -Wno-unused-parameter $(IDIRFLAG)
# Linker
LFLAGS=$(IDIRFLAG) -LSFML/lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
# Directories
SRCDIR=src
OBJDIR=obj
BINDIR=bin
# Files
SOURCES=$(foreach sdir, $(SRCDIR), $(wildcard $(sdir)/*.cpp))
OBJECTS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(notdir $(SOURCES)))
vpath %.cpp $(SRCDIR)
# Reminder, 'cause it is easy to forget makefile's fucked-up syntax...
# $@ is what triggered the rule, ie the target before :
# $^ is the whole dependencies list, ie everything after :
# $< is the first item in the dependencies list
# Rules
#gcc: clean
gcc: CXX=g++
gcc: LINKER=g++ -o
gcc: CXXFLAGS += -DNDEBUG -Ofast
gcc: $(BINDIR)/$(EXEC)
#gcc-debug: clean
gcc-debug: CXX=g++
gcc-debug: LINKER=g++ -o
gcc-debug: CXXFLAGS += -ggdb -O0
gcc-debug: $(BINDIR)/$(EXEC)
$(BINDIR)/$(EXEC): $(OBJECTS)
$(LINKER) $@ $^ $(LFLAGS)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
.PHONY: gcc gcc-debug clang clang-debug clean
clean:
rm -fr $(OBJECTS) $(BINDIR)/$(EXEC)