-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
49 lines (37 loc) · 1 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
# Set the compiler.
CC=g++-8
CFLAGS+=-MD -MP # Autogenerate dependencies.
CFLAGS+=-O3 -std=c++17
CFLAGS+=-Iinclude
ifeq ($(OS),Windows_NT)
CFLAGS+=-mwindows
endif
LIBS=-lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system -lstdc++fs
# Directories.
BINDIR=bin
OBJDIR=obj
SRCDIR=src
# Src files and object files.
SRCS:=$(wildcard $(SRCDIR)/*.cpp)
OBJS:=$(subst $(SRCDIR),$(OBJDIR),$(SRCS:%.cpp=%.o))
.PHONY: all
all: $(BINDIR)/main
main: $(BINDIR)/main
# Dependencies to force the creation of the $(BINDIR) directory
# @: suppress the echoing of the command
$(BINDIR):
@mkdir -p $@
$(OBJDIR):
@mkdir -p $@
$(OBJS): $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
# Create list of auto dependencies
AUTODEPS:=$(subst $(SRCDIR),$(OBJDIR),$(SRCS:%.cpp=%.d))
# https://www.gnu.org/software/make/manual/html_node/Include.html#Include
-include $(AUTODEPS)
$(BINDIR)/main: $(OBJS) | $(BINDIR)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
.PHONY: clean
clean:
rm -rf $(BINDIR)/*
rm -rf $(OBJDIR)/*