#!/bin/sh

# Cleanup script for llamaR package
# Removes compiled objects, shared libraries, and generated files

# Remove compiled objects and libraries. llamaR statically links libggml.a from
# ggmlR, so stale .o files left in any src subdirectory (models/, jinja/, mtmd/,
# mtmd/models/) would relink against the OLD libggml.a. Recurse the whole src
# tree so a fixed directory list never goes stale.
find src -type f \( -name '*.o' -o -name '*.so' -o -name '*.dll' -o -name '*.dylib' -o -name '*.a' \) -delete

# Remove generated Makevars (created by configure)
rm -f src/Makevars
rm -f src/Makevars.win

# Remove R CMD check directories
rm -rf ..Rcheck
rm -rf llamaR.Rcheck

# Remove build artifacts
rm -f src/symbols.rds

# Remove installed copy and stale install lock
rm -rf /home/yuri/R/x86_64-pc-linux-gnu-library/4.3/llamaR
rm -rf /home/yuri/R/x86_64-pc-linux-gnu-library/4.3/00LOCK-llamaR
