about summary refs log tree commit diff
path: root/Makefile
blob: 7fd2bde3e23d036754f832a51b56f8e63c5e712e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
PREFIX ?= ~/.local
BINDIR ?= ${PREFIX}/bin
MANDIR ?= ${PREFIX}/man

CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -Wno-overlength-strings
LDADD.kcgi = -lkcgi
LDADD.kcgi-html = -lkcgihtml

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 = -lm ${LDADD.dl} ${LDADD.kcgi} ${LDADD.kcgi-html}

OBJS += contexts.o
OBJS += css.o
OBJS += events.o
OBJS += html.o
OBJS += networks.o
OBJS += search.o
OBJS += server.o
OBJS += sqlite3.o

dev: tags all test

all: scooper

scooper: ${OBJS}
	${CC} ${STATIC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@

contexts.o events.o html.o networks.o search.o server.o: server.h sqlite3.h

sqlite3.o: sqlite3.c sqlite3.h
	${CC} ${CFLAGS} ${CFLAGS.sqlite3} -c $< -o $@

css.c: css.sh default.css color.css
	sh css.sh default.css color.css > $@

test: .test

.test: scooper
	${LITTERBOX} -i -d ${TEST_DB}
	./scooper -c ${TEST_DB}
	rm ${TEST_DB} ${TEST_DB}-*
	touch $@

tags: *.[ch]
	ctags -w *.[ch]

clean:
	rm -f scooper ${OBJS} css.c .test tags

install: scooper scooper.1
	install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR}/man1
	install scooper ${DESTDIR}${BINDIR}
	install -m 644 scooper.1 ${DESTDIR}${MANDIR}/man1

uninstall:
	rm -f ${DESTDIR}${BINDIR}/scooper ${DESTDIR}${MANDIR}/man1/scooper.1