aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 93275cb8f9a4163f6e5a4d7e304494dc66181404 (plain)
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
CFLAGS += -std=c89 -Wall -pedantic -Wno-parentheses
LDLIBS += -lsqlite3
C = $(shell ls *.c)
H = $(shell ls *.h)
TPL = $(shell ls t/*.t | sed 's/$$/c/')

.SUFFIXES: .t .tc

all: cforum README

clean:
	rm cforum
	rm $(TPL)

cforum: $(C) $(H) $(TPL)
	$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o cforum $(C)

README: $(C) $(H) $(TPL)
	<README >.README awk '/^	/ {if(!i++){print;system($$0"|sed s/^/\\	/")}next} {i=0;print}'
	mv .README README

.t.tc: mktpl/mktpl
	<$< mktpl/mktpl >$@

db:
	touch db
	chown :www db
	chmod g+w db
	sqlite3 db "CREATE TABLE settings(key, value, PRIMARY KEY (key));"
	sqlite3 db "INSERT INTO settings values('name', 'C Forum');"
	sqlite3 db "CREATE TABLE users(name, full, hash NOT NULL, created INT NOT NULL, PRIMARY KEY (name));"
	sqlite3 db "INSERT INTO users values('john', 'John Ankarström', '123', 1462134896);"
	sqlite3 db "CREATE TABLE posts(parent INT, user INT NOT NULL, created INT NOT NULL, edited INT, subject NOT NULL, text NOT NULL, FOREIGN KEY (user) REFERENCES users(oid));"
	sqlite3 db "INSERT INTO posts values(NULL, 1, 1462137896, NULL, 'Hello World!', 'This is the first post.');"
	sqlite3 db "INSERT INTO posts values(1, 1, 1462138896, NULL, 'Re: Hello World!', 'This is the second post!');"
	sqlite3 db "CREATE TABLE atts(post INT NOT NULL, name NOT NULL, description, mime NOT NULL, data BLOB, FOREIGN KEY (post) REFERENCES posts(oid));"
	sqlite3 db "$$(printf "INSERT INTO atts values(1, 'example', 'Some example shell code.', 'text/plain', '#!/bin/sh\necho Hello World!');")"