summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-09-12 18:48:02 -0400
committerJune McEnroe <june@causal.agency>2021-09-13 14:38:07 -0400
commit66e35b5797803b5b1b5a5a06d02678c324600d16 (patch)
tree1c1ff4b8bd6298baf3c762bf6221a94151244f28
parentCall sqlite3_initialize explicitly (diff)
downloadscooper-66e35b5797803b5b1b5a5a06d02678c324600d16.tar.gz
scooper-66e35b5797803b5b1b5a5a06d02678c324600d16.zip
Build with vendored sqlite3
-rw-r--r--Makefile24
-rwxr-xr-xconfigure6
-rw-r--r--server.h2
3 files changed, 25 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 271d28f..c6daf8e 100644
--- a/Makefile
+++ b/Makefile
@@ -5,14 +5,28 @@ MANDIR ?= ${PREFIX}/man
 CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -Wno-overlength-strings
 LDADD.kcgi = -lkcgi
 LDADD.kcgi-html = -lkcgihtml
-LDADD.sqlite3 = -lsqlite3
+
+CFLAGS.sqlite3 = -DSQLITE_ENABLE_FTS5 \
+	-DSQLITE_DQS=0 \
+	-DSQLITE_THREADSAFE=0 \
+	-DSQLITE_DEFAULT_MEMSTATUS=0 \
+	-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 \
+	-DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
+	-DSQLITE_MAX_EXPR_DEPTH=0 \
+	-DSQLITE_OMIT_DECLTYPE \
+	-DSQLITE_OMIT_DEPRECATED \
+	-DSQLITE_OMIT_PROGRESS_CALLBACK \
+	-DSQLITE_OMIT_SHARED_CACHE \
+	-DSQLITE_USE_ALLOCA \
+	-DSQLITE_OMIT_AUTOINIT \
+	-Wno-unused-parameter
 
 LITTERBOX = litterbox
 TEST_DB = litterbox.sqlite
 
 -include config.mk
 
-LDLIBS = ${LDADD.kcgi} ${LDADD.kcgi-html} ${LDADD.sqlite3}
+LDLIBS = -lm ${LDADD.kcgi} ${LDADD.kcgi-html}
 
 OBJS += contexts.o
 OBJS += css.o
@@ -21,6 +35,7 @@ OBJS += html.o
 OBJS += networks.o
 OBJS += search.o
 OBJS += server.o
+OBJS += sqlite3.o
 
 dev: tags all test
 
@@ -29,7 +44,10 @@ all: scooper
 scooper: ${OBJS}
 	${CC} ${STATIC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@
 
-${OBJS}: server.h
+${OBJS}: server.h sqlite3.h
+
+sqlite3.o: sqlite3.c
+	${CC} ${CFLAGS} ${CFLAGS.sqlite3} -c $< -o $@
 
 css.c: css.sh default.css color.css
 	sh css.sh default.css color.css > $@
diff --git a/configure b/configure
index c001b39..97cfafc 100755
--- a/configure
+++ b/configure
@@ -37,13 +37,13 @@ case "$(uname)" in
 	(FreeBSD|OpenBSD)
 		echo 'STATIC = -static'
 		PKG_CONFIG="${PKG_CONFIG} --static"
-		config kcgi kcgi-html sqlite3
+		config kcgi kcgi-html
 		;;
 	(Linux)
 		cflags -D_GNU_SOURCE
-		config kcgi kcgi-html sqlite3
+		config kcgi kcgi-html
 		;;
 	(*)
-		config kcgi kcgi-html sqlite3
+		config kcgi kcgi-html
 		;;
 esac
diff --git a/server.h b/server.h
index 8a5318d..223e44b 100644
--- a/server.h
+++ b/server.h
@@ -23,7 +23,7 @@
 
 #include <kcgi.h>
 #include <kcgihtml.h>
-#include <sqlite3.h>
+#include "sqlite3.h"
 
 // Why does it return (const unsigned char *)?
 #define sqlite3_column_text(...) (const char *)sqlite3_column_text(__VA_ARGS__)