.SUFFIXES: .scm .c
.PHONY: check-sqlite

OL=ol
maybe_sqlitec!=$(OL) -e '(if (has? *features* (quote sqlite)) "`pkg-config --cflags sqlite3`" "")'
maybe_sqlitel!=$(OL) -e '(if (has? *features* (quote sqlite)) "`pkg-config --libs sqlite3`" "")'
maybe_lutil!=[ `uname -s` = 'OpenBSD' ] && echo "-lutil" || true
CFLAGS:=$(maybe_sqlitec) -I. -DPRIM_CUSTOM
LDFLAGS:=$(maybe_sqlitel) -static -lpthread -lm $(maybe_lutil) # -lcrypto

all: rs
rs: rs.o ovm.h mod.c
	$(CC) rs.o $(CFLAGS) mod.c -o $@ $(LDFLAGS)
.scm.c:
	$(OL) -x c -o $@ $<
clean:
	rm -f rs rs.c *.o
ovm.h:
	curl -Lo ovm.h https://gitlab.com/owl-lisp/owl/-/raw/master/c/ovm.h
