summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-10-18 15:47:55 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-10-18 16:13:11 +0800
commitc7e7ed24f507a245921662f2165975ee38ea7737 (patch)
tree576118afa0f2029ae78e5869107f31a95d12f3ad
downloadvlm-test-c7e7ed24f507a245921662f2165975ee38ea7737.tar.gz
Initial commit (Makefile, gitignore, blank main).
-rw-r--r--.gitignore8
-rw-r--r--Makefile86
-rw-r--r--README.txt13
-rw-r--r--main.c4
4 files changed, 111 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8081c66
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+bjournd
+
+*.o
+*.gguf
+
+deps/
+
+**/*.swp
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9f46bb8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,86 @@
+CC = cc
+CXX = c++
+CFLAGS = -march=native -O2 -std=c11 -Wall -Wextra
+CXXFLAGS = -march=native -O2 -O2 -Wall -Wextra
+INCLUDES = -I. -Ideps/include
+
+TARGET = bjournd
+SRC = main.c
+OBJS = $(SRC:.c=.o)
+
+LLAMA_TAG = 0.7.0
+LLAMA_URL = https://github.com/ggml-org/llama.cpp/archive/refs/tags/v$(LLAMA_TAG).tar.gz
+LLAMA_TAR = deps/llama-$(LLAMA_TAG).tar.gz
+LLAMA_SRC_DIR = deps/llama.cpp-src
+LLAMA_BUILD = $(LLAMA_SRC_DIR)/build
+
+STATIC_LIBS = deps/lib/libllama.a \
+ deps/lib/libggml.a \
+ deps/lib/libggml-cpu.a \
+
+# System flags required for static linking llama on OpenBSD
+SYS_LIBS = -static -pthread -lm -lc++ -lc++abi
+
+.PHONY: all clean distclean install install-user uninstall
+
+all: $(TARGET)
+
+# Link order: libllama -> libggml-cpu -> libggml -> libggml-base
+$(TARGET): deps/lib/libllama.a $(OBJS)
+ $(CXX) $(CXXFLAGS) $(OBJS) \
+ -Wl,--start-group \
+ deps/lib/libllama.a \
+ deps/lib/libggml-cpu.a \
+ deps/lib/libggml.a \
+ deps/lib/libggml-base.a \
+ -Wl,--end-group \
+ $(SYS_LIBS) -o $@
+
+# BSD suffix rule: compiles any .c file into .o
+.c.o:
+ $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
+
+# Download llama source and build statically
+deps/lib/libllama.a deps/lib/libggml.a deps/lib/libggml-cpu.a:
+ @command -v cmake >/dev/null 2>&1 || { echo >&2 "===> Error: cmake is required but not installed. Aborting."; exit 1; }
+ @mkdir -p deps/lib deps/include
+ @echo "===> Downloading llama.cpp $(LLAMA_TAG) source..."
+ ftp -o $(LLAMA_TAR) $(LLAMA_URL)
+
+ @echo "===> Extracting source archive..."
+ tar -xzf $(LLAMA_TAR) -C deps
+ rm -rf $(LLAMA_SRC_DIR)
+ mv deps/llama.cpp-$(LLAMA_TAG) $(LLAMA_SRC_DIR)
+ rm -f $(LLAMA_TAR)
+
+ @echo "===> Compiling llama static archives..."
+ cmake -S $(LLAMA_SRC_DIR) -B $(LLAMA_BUILD) \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DBUILD_SHARED_LIBS=OFF \
+ -DLLAMA_BUILD_MTMD=ON \
+ -DGGML_OPENMP=OFF \
+ -DGGML_VULKAN=OFF \
+ -DLLAMA_BUILD_APP=OFF \
+ -DLLAMA_BUILD_COMMON=OFF \
+ -DLLAMA_BUILD_TESTS=OFF \
+ -DLLAMA_BUILD_UI=OFF \
+ -DLLAMA_BUILD_EXAMPLES=OFF \
+ -DLLAMA_BUILD_SERVER=OFF \
+ -DLLAMA_BUILD_TOOLS=OFF
+
+ cmake --build $(LLAMA_BUILD) --config Release -j$$(sysctl -n hw.ncpu)
+
+ @echo "===> Installing .a files and headers into deps/..."
+ find $(LLAMA_BUILD) -type f -name "*.a" -exec cp {} deps/lib/ \;
+ cp -R $(LLAMA_SRC_DIR)/include/* deps/include/
+ cp -R $(LLAMA_SRC_DIR)/ggml/include/* deps/include/
+
+ @echo "===> Cleaning up build directory..."
+ rm -rf $(LLAMA_SRC_DIR)
+
+clean:
+ rm -f $(TARGET) $(OBJS)
+
+distclean: clean
+ rm -rf deps
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..732ea87
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,13 @@
+ffplay "rtsp://user:pass@192.168.0.8:554/stream1"
+
+extract frames:
+
+ ffmpeg -ss 00:01:30 -i clip.mp4 -vf "fps=1,scale=-2:336" \
+ -frames:v 8 frame_%03d.jpg
+
+llama-cli:
+
+ llama-mtmd-cli -m model.gguf --mmproj mmproj.gguf \
+ --no-mmproj-offload -ngl 0 --device none -c 4096 \
+ $(for f in frame_*.jpg; do echo --image $f; done) \
+ -p "These are consecutive frames from a video. Describe what happens."
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..31dbf45
--- /dev/null
+++ b/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}