Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ endif

ifdef CONFIG_LINUX
LOADABLE_EXTENSION=so
CFLAGS += -lm
# Link-time libraries, kept OUT of CFLAGS so they land AFTER the object/archive
# inputs on each link line. GNU ld with --as-needed (the Debian/Ubuntu default)
# drops a library placed before the inputs that reference it, which otherwise
# leaves sqrt/pow/ceil (libm) and pthread_* (libsqlite3, built threadsafe)
# undefined. See asg017/sqlite-vec#84 and #93.
LINK_LIBS += -lm -ldl -lpthread
endif

ifdef CONFIG_WINDOWS
Expand Down Expand Up @@ -99,7 +104,7 @@ $(TARGET_LOADABLE): sqlite-vec.c sqlite-vec.h $(prefix)
-Ivendor/ \
-O3 \
$(CFLAGS) \
$< -o $@
$< $(LINK_LIBS) -o $@

$(TARGET_STATIC): sqlite-vec.c sqlite-vec.h $(prefix) $(OBJS_DIR)
$(CC) -Ivendor/ $(CFLAGS) -DSQLITE_CORE -DSQLITE_VEC_STATIC \
Expand Down Expand Up @@ -145,8 +150,8 @@ $(TARGET_CLI): sqlite-vec.h $(LIBS_DIR)/sqlite-vec.a $(LIBS_DIR)/shell.a $(LIBS_
-DSQLITE_ENABLE_STMT_SCANSTATUS -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_EXTRA_INIT=core_init \
$(CFLAGS) \
-ldl -lm \
examples/sqlite3-cli/core_init.c $(LIBS_DIR)/shell.a $(LIBS_DIR)/sqlite3.a $(LIBS_DIR)/sqlite-vec.a -o $@
examples/sqlite3-cli/core_init.c $(LIBS_DIR)/shell.a $(LIBS_DIR)/sqlite3.a $(LIBS_DIR)/sqlite-vec.a \
$(LINK_LIBS) -o $@


sqlite-vec.h: sqlite-vec.h.tmpl VERSION
Expand Down Expand Up @@ -204,7 +209,7 @@ test-loadable-watch:
watchexec --exts c,py,Makefile --clear -- make test-loadable

test-unit:
$(CC) -DSQLITE_CORE -DSQLITE_VEC_TEST -DSQLITE_VEC_ENABLE_RESCORE -DSQLITE_VEC_ENABLE_DISKANN=1 tests/test-unit.c sqlite-vec.c vendor/sqlite3.c -I./ -Ivendor $(CFLAGS) -o $(prefix)/test-unit && $(prefix)/test-unit
$(CC) -DSQLITE_CORE -DSQLITE_VEC_TEST -DSQLITE_VEC_ENABLE_RESCORE -DSQLITE_VEC_ENABLE_DISKANN=1 tests/test-unit.c sqlite-vec.c vendor/sqlite3.c -I./ -Ivendor $(CFLAGS) $(LINK_LIBS) -o $(prefix)/test-unit && $(prefix)/test-unit

# Standalone sqlite3 CLI with vec0 compiled in. Useful for benchmarking,
# profiling (has debug symbols), and scripting without .load_extension.
Expand All @@ -219,7 +224,7 @@ cli: sqlite-vec.h $(prefix)
-Ivendor/ -I./ \
$(CFLAGS) \
vendor/sqlite3.c vendor/shell.c sqlite-vec.c examples/sqlite3-cli/core_init.c \
-ldl -lm -o $(prefix)/sqlite3
$(LINK_LIBS) -o $(prefix)/sqlite3

fuzz-build:
$(MAKE) -C tests/fuzz all
Expand Down