blob: 12a6f9283e6b402349de6896a67c68cabcc41426 (
plain) (
blame)
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
|
# libhl2hake.so — 32-bit Source Engine plugin.
#
# make release build (build/release, -O2)
# make debug build/debug with -O0 -g (symbolise crash addresses)
# make clean
#
# Needs a 32-bit multilib toolchain (g++-multilib on Debian/Ubuntu).
CXX ?= g++
OUT := libhl2hake.so
SRC := $(wildcard src/*.cpp)
ODIR ?= build/release
OPT ?= -O2
CXXFLAGS := -m32 -std=c++17 -Wall -Wextra -Werror -fPIC \
-fvisibility=hidden -fno-omit-frame-pointer -pthread \
-MMD -MP $(OPT)
LDFLAGS := -m32 -shared -pthread -Wl,--no-undefined
LDLIBS := -ldl
OBJ := $(patsubst src/%.cpp,$(ODIR)/%.o,$(SRC))
DEP := $(OBJ:.o=.d)
all: check $(OUT)
@file $(OUT)
@test -f assets/LiberationSans-Regular.ttf || \
echo "warning: assets/ is missing next to the .so; the overlay falls back to system fonts" >&2
# Objects, dependency files and headers are handled by make itself; this only
# keeps the debug build in its own directory.
debug:
@$(MAKE) --no-print-directory ODIR=build/debug OPT="-O0 -g"
# Always relink. Both configs write the same output file, so without this a
# plain `make` after `make debug` would keep the debug binary (the .so is newer
# than the release objects). Linking is sub-second.
.PHONY: FORCE
FORCE:
$(OUT): $(OBJ) FORCE
$(CXX) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS)
$(ODIR)/%.o: src/%.cpp | $(ODIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(ODIR):
@mkdir -p $@
# Fail once with a usable message instead of a wall of compiler errors.
.PHONY: check
check:
@printf 'int main(){return 0;}\n' | \
$(CXX) -m32 -x c++ - -o /dev/null 2>/dev/null || \
{ echo "error: $(CXX) cannot build 32-bit binaries; install g++-multilib" >&2; exit 1; }
.PHONY: all debug clean
clean:
rm -rf build $(OUT)
-include $(DEP)
|