-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (41 loc) · 1.59 KB
/
Makefile
File metadata and controls
51 lines (41 loc) · 1.59 KB
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 & build settings
########################################################################
TARGET := Muffet_Game
OUT := bin/$(TARGET)
BUILDDIR := bin/build
SFMLPATH ?=
# ----- toolchain & flags ----------------------------------------------
CXX := g++
CPPFLAGS ?= -I./include
CXXFLAGS ?= -MMD -MP -Wall -pedantic -O2 -std=c++17
LDFLAGS ?= -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
ifneq ($(SFMLPATH),)
CPPFLAGS += -I$(SFMLPATH)/include
LDFLAGS := -L$(SFMLPATH)/lib $(LDFLAGS)
endif
# ----- file lists ------------------------------------------------------
SRC := $(wildcard src/*.cpp)
OBJ := $(patsubst src/%.cpp,$(BUILDDIR)/%.o,$(SRC))
DEP := $(OBJ:.o=.d)
########################################################################
# Build rules
########################################################################
all: $(OUT)
# ----- link ------------------------------------------------------------
$(OUT): $(OBJ) | bin
$(CXX) $(OBJ) $(LDFLAGS) -o "$@"
# ----- compile ---------------------------------------------------------
$(BUILDDIR)/%.o: src/%.cpp | $(BUILDDIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c "$<" -o "$@"
# ----- on-demand directories -------------------------------------------
bin $(BUILDDIR):
mkdir -p $@
########################################################################
# House-keeping
########################################################################
clean:
rm -rf bin
.PHONY: all clean
# ----- include auto-generated header dependency files (ignore if missing)
-include $(DEP)