-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (53 loc) · 1.88 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
59
60
61
62
63
64
65
CXX ?= g++
PREFIX ?= /usr
VARS ?=
DEBUG ?= 1
LOG_FRAME ?= 0
# https://stackoverflow.com/a/1079861
# WAY easier way to build debug and release builds
ifeq ($(DEBUG), 1)
BUILDDIR = build/debug
CXXFLAGS := -ggdb3 -Wpedantic -Wall -Wextra -Wno-unused-parameter $(DEBUG_CXXFLAGS) $(CXXFLAGS)
VARS += -DDEBUG=1
else
BUILDDIR = build/release
CXXFLAGS := -O2 $(CXXFLAGS)
endif
ifeq ($(LOG_FRAME), 1)
VARS += -DLOG_FRAME=1
endif
NAME = BurntEngine
TARGET = libengine.so.1
SRC = $(sort $(wildcard src/*.cpp))
OBJ = $(SRC:.cpp=.o)
LDFLAGS += -L$(BUILDDIR)/fmt -L$(BUILDDIR)/steam -lGameNetworkingSockets -lassimp -lfmt -lSDL3 -lvulkan -lfreetype -shared -fno-PIE -Wl,-soname,$(TARGET)
CXXFLAGS ?= -mtune=generic -march=native
CXXFLAGS += -funroll-all-loops -Iinclude -isystem/usr/include/freetype2 -fPIC -std=c++17 $(VARS)
all: fmt toml gamenetworkingsockets $(TARGET)
fmt:
ifeq ($(wildcard $(BUILDDIR)/fmt/libfmt.a),)
mkdir -p $(BUILDDIR)/fmt
make -C src/fmt BUILDDIR=$(BUILDDIR)/fmt
endif
toml:
ifeq ($(wildcard $(BUILDDIR)/toml++/toml.o),)
mkdir -p $(BUILDDIR)/toml++
make -C src/toml++ BUILDDIR=$(BUILDDIR)/toml++
endif
gamenetworkingsockets:
ifeq ($(wildcard $(BUILDDIR)/steam/libGameNetworkingSockets.so),)
mkdir -p $(BUILDDIR)/steam
mkdir -p steam/GameNetworkingSockets/build
cd steam/GameNetworkingSockets/build && cmake .. && make -j11
cp steam/GameNetworkingSockets/build/bin/libGameNetworkingSockets.so $(BUILDDIR)/steam/libGameNetworkingSockets.so
endif
$(TARGET): fmt toml gamenetworkingsockets $(OBJ)
mkdir -p $(BUILDDIR)
$(CXX) $(OBJ) $(BUILDDIR)/toml++/toml.o -o $(BUILDDIR)/$(TARGET) $(LDFLAGS)
dist: $(TARGET)
bsdtar -zcf $(NAME)-v$(VERSION).tar.gz LICENSE README.md -C $(BUILDDIR) $(TARGET)
clean:
rm -rf $(BUILDDIR)/$(TARGET) $(OBJ)
distclean:
rm -rf $(BUILDDIR) $(OBJ)
.PHONY: $(TARGET) fmt toml clean all