# 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)