Files
bantam-cpp/Makefile
T

64 lines
2.5 KiB
Makefile
Raw Normal View History

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
# paths) for HTTP and interactive line editing. JSON is handled by the vendored
# single-header nlohmann/json.hpp (no extra dependency).
# If your headers/libs live in a non-standard prefix, override, e.g.:
# make CPPFLAGS="-I/opt/include" LDLIBS="-L/opt/lib -lcurl -lreadline"
CXX = c++
2026-10-14 00:50:06 +03:00
CXXFLAGS = -std=c++20 -Wall -Wextra -Wpedantic -O1 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
2026-10-14 00:01:03 +03:00
CPPFLAGS = -I/usr/local/include -I.
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)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o bantam $(OBJS) $(LDLIBS)
main.o: main.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c main.cpp
config.o: config.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c config.cpp
util.o: util.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c util.cpp
json.o: json.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c json.cpp
llm.o: llm.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c llm.cpp
tools.o: tools.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c tools.cpp
session.o: session.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c session.cpp
render.o: render.cpp bantam.hpp nlohmann/json.hpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c render.cpp
editor.o: editor.cpp bantam.hpp nlohmann/json.hpp
$(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:
$(MAKE) CXXFLAGS="$(CXXFLAGS) -g -O0 -fsanitize=address,undefined -B$(ASANDIR) -Wl,-rpath,$(ASANDIR)" bantam