2026-10-14 00:01:03 +03:00
|
|
|
# Bantam (C++20 port) — POSIX-compatible Makefile.
|
|
|
|
|
# Targets: Linux, FreeBSD, macOS, Haiku (any POSIX make: bmake, gmake, smake).
|
|
|
|
|
# Dependencies: libcurl and GNU readline (found via standard include/lib
|
2026-10-14 08:36:39 +03:00
|
|
|
# paths) for HTTP and interactive line editing. JSON is handled natively in
|
|
|
|
|
# json.cpp (no extra or vendored dependency).
|
2026-10-14 00:01:03 +03:00
|
|
|
# If your headers/libs live in a non-standard prefix, override, e.g.:
|
|
|
|
|
# make CPPFLAGS="-I/opt/include" LDLIBS="-L/opt/lib -lcurl -lreadline"
|
2026-10-14 00:56:19 +03:00
|
|
|
#
|
|
|
|
|
# 32-bit build: make 32bit
|
2026-10-14 08:36:39 +03:00
|
|
|
# Or: make CXXFLAGS="-std=c++20 -O2 -m32" LDFLAGS="-m32"
|
2026-10-14 00:56:19 +03:00
|
|
|
# Large file support on 32-bit: make CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
|
2026-10-14 00:01:03 +03:00
|
|
|
|
|
|
|
|
CXX = c++
|
2026-10-14 08:36:39 +03:00
|
|
|
STRIP = strip
|
|
|
|
|
CXXFLAGS = -std=c++20 -s -Wall -Wextra -Wpedantic -O2 -march=native -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
|
2026-10-14 10:21:46 +03:00
|
|
|
CPPFLAGS = -I/usr/local/include -I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_XOPEN_SOURCE=700
|
2026-10-14 08:36:39 +03:00
|
|
|
LDFLAGS = -s
|
2026-10-14 00:01:03 +03:00
|
|
|
LDLIBS = -L/usr/local/lib -lcurl -lreadline
|
|
|
|
|
|
|
|
|
|
# Location of the AddressSanitizer/UBSan runtime libraries plus a replacement
|
|
|
|
|
# libasan_preinit.o (so the runtime initializes before main()). On a normal
|
|
|
|
|
# system these ship with the compiler; override with
|
|
|
|
|
# make debug ASANDIR= (empty) — the gcc driver finds them automatically.
|
|
|
|
|
ASANDIR = /tmp/asanlib
|
|
|
|
|
|
|
|
|
|
OBJS = main.o config.o util.o json.o llm.o tools.o session.o render.o editor.o
|
|
|
|
|
|
|
|
|
|
bantam: $(OBJS)
|
2026-10-14 08:36:39 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -o bantam $(OBJS) $(LDLIBS)
|
|
|
|
|
$(STRIP) bantam
|
2026-10-14 00:01:03 +03:00
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
main.o: main.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c main.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
config.o: config.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c config.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
util.o: util.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c util.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
json.o: json.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c json.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
llm.o: llm.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c llm.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
tools.o: tools.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c tools.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
session.o: session.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c session.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
render.o: render.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c render.cpp
|
|
|
|
|
|
2026-10-14 08:36:39 +03:00
|
|
|
editor.o: editor.cpp bantam.hpp
|
2026-10-14 00:01:03 +03:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c editor.cpp
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
rm -f $(OBJS) bantam bantam_asan
|
|
|
|
|
|
|
|
|
|
install: bantam
|
|
|
|
|
install -m 0755 bantam $(DESTDIR)/usr/local/bin/bantam
|
|
|
|
|
|
|
|
|
|
# Debug build with AddressSanitizer + UndefinedBehaviorSanitizer.
|
|
|
|
|
# Rebuilds ./bantam — run `make clean && make` afterwards to restore the
|
|
|
|
|
# optimized build. ASANDIR points the gcc driver (-B) at the runtime libs and
|
|
|
|
|
# the replacement libasan_preinit.o, and sets an rpath so they load at run time.
|
|
|
|
|
debug:
|
2026-10-14 08:36:39 +03:00
|
|
|
$(MAKE) CXXFLAGS="-std=c++20 -Wall -Wextra -Wpedantic -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE -g -O0 -fsanitize=address,undefined -B$(ASANDIR) -Wl,-rpath,$(ASANDIR)" LDFLAGS="" STRIP=":" bantam
|
2026-10-14 00:56:19 +03:00
|
|
|
|
|
|
|
|
# 32-bit build target
|
|
|
|
|
# Usage: make 32bit
|
|
|
|
|
# This builds a 32-bit binary with large file support enabled.
|
|
|
|
|
32bit:
|
2026-10-14 08:36:39 +03:00
|
|
|
$(MAKE) CXXFLAGS="$(CXXFLAGS) -m32" LDFLAGS="$(LDFLAGS) -m32" bantam
|
2026-10-14 00:56:19 +03:00
|
|
|
|
2026-10-14 10:21:46 +03:00
|
|
|
.PHONY: clean install debug 32bit
|