db: reorder some update statements
[rb-79.git] / Makefile
blobeee07b99ce508dce76c0db19d7a06b6a13734483
1 .SUFFIXES:
2 .SUFFIXES: .o .c
4 CFLAGS ?=
5 LDFLAGS ?=
7 PREFIX ?= /usr
8 BINDIR ?= $(PREFIX)/bin
9 SHAREDIR ?= $(PREFIX)/share
10 MANDIR ?= $(SHAREDIR)/man
12 CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE
14 # Do you want logging?
15 CFLAGS += -DWRITE_LOGS=1
17 # fcgi - grumble grumble no pkg-config entry
18 LDFLAGS += -lfcgi
20 # libmagic - grumble grumble no pkg-config entry
21 LDFLAGS += -lmagic
23 # sqlite3
24 CFLAGS += $(shell pkg-config --cflags sqlite3)
25 LDFLAGS += $(shell pkg-config --libs sqlite3)
27 # libpcre2
28 CFLAGS += $(shell pkg-config --cflags libpcre2-8)
29 LDFLAGS += $(shell pkg-config --libs libpcre2-8)
31 # libsodium
32 CFLAGS += $(shell pkg-config --cflags libsodium)
33 LDFLAGS += $(shell pkg-config --libs libsodium)
35 # gmime - one of these day's I'll do it without fscking glib
36 CFLAGS += $(shell pkg-config --cflags gmime-2.6)
37 LDFLAGS += $(shell pkg-config --libs gmime-2.6)
39 # Debug
40 # CFLAGS += -g -O0 -pedantic -Wall -Wextra -Werror
42 # The `-O3' makes it go three times faster
43 # CFLAGS += -O3 -pedantic -Wall -Wextra -Werror
45 # If this is `foodb', then you'd better have db-foodb.c ready
46 DB_TYPE = sqlite3
48 default: all
49 all: \
50 rb79-ban-ip \
51 rb79-delete-post \
52 rb79-moderate-post \
53 rb79-server \
54 rb79-view-thread
56 SERVER_OFILES = \
57 db-$(DB_TYPE).o \
58 locks.o \
59 multipart.o \
60 preconditions.o \
61 rb79-server.o \
62 sanitize-comment.o \
63 sanitize-file.o \
64 tripcodes.o \
65 util.o \
66 write-thread.o
68 config.h: config.def.h
69 cp config.def.h config.h
71 %.o: %.c config.h rb79.h macros.h unicode-transforms.h
72 $(CC) $(CFLAGS) -c -o $@ $<
74 rb79-server: $(SERVER_OFILES)
75 $(CC) -o $@ $^ $(LDFLAGS)
77 rb79-ban-ip: db-$(DB_TYPE).o locks.o rb79-ban-ip.o util.o \
78 write-thread.o
79 $(CC) -o $@ $^ $(LDFLAGS)
81 rb79-delete-post: db-$(DB_TYPE).o locks.o rb79-delete-post.o util.o \
82 write-thread.o
83 $(CC) -o $@ $^ $(LDFLAGS)
85 rb79-moderate-post: db-$(DB_TYPE).o locks.o rb79-moderate-post.o \
86 util.o write-thread.o
87 $(CC) -o $@ $^ $(LDFLAGS)
89 rb79-view-thread: db-$(DB_TYPE).o locks.o rb79-view-thread.o util.o \
90 write-thread.o
91 $(CC) -o $@ $^ $(LDFLAGS)
94 .PHONY: clean
95 clean:
96 find -name '*.o' -delete
97 rm -f rb79-server
98 rm -f rb79-ban-ip
99 rm -f rb79-delete-post
100 rm -f rb79-moderate-post
101 rm -f rb79-view-thread
103 .PHONY: install
104 install: all
105 mkdir -p $(DESTDIR)$(BINDIR)
106 cp -f rb79-server $(DESTDIR)$(BINDIR)/
107 cp -f tools/rb79-describe-file.sh $(DESTDIR)$(BINDIR)/rb79-describe-file
108 cp -f rb79-ban-ip $(DESTDIR)$(BINDIR)/
109 cp -f rb79-delete-post $(DESTDIR)$(BINDIR)/
110 cp -f rb79-moderate-post $(DESTDIR)$(BINDIR)/
111 cp -f rb79-view-thread $(DESTDIR)$(BINDIR)/
112 mkdir -p $(DESTDIR)$(MANDIR)
113 cp -f rb79.1 $(DESTDIR)$(MANDIR)/
114 cp -f rb79-ban-ip.1 $(DESTDIR)$(MANDIR)/
115 cp -f rb79-delete-post.1 $(DESTDIR)$(MANDIR)/
116 cp -f rb79-moderate-post.1 $(DESTDIR)$(MANDIR)/
117 cp -f rb79-server.1 $(DESTDIR)$(MANDIR)/
118 cp -f rb79-view-thread.1 $(DESTDIR)$(MANDIR)/
120 .PHONY: uninstall
121 uninstall:
122 cd $(DESTDIR)$(BINDIR) && rm -f rb79-server
123 cd $(DESTDIR)$(BINDIR) && rm -f rb79-describe-file
124 cd $(DESTDIR)$(BINDIR) && rm -f rb79-ban-ip
125 cd $(DESTDIR)$(BINDIR) && rm -f rb79-delete-post
126 cd $(DESTDIR)$(BINDIR) && rm -f rb79-moderate-post
127 cd $(DESTDIR)$(BINDIR) && rm -f rb79-view-thread
128 cd $(DESTDIR)$(MANDIR) && rm -f rb79.1
129 cd $(DESTDIR)$(MANDIR) && rm -f rb79-ban-ip.1
130 cd $(DESTDIR)$(MANDIR) && rm -f rb79-delete-post.1
131 cd $(DESTDIR)$(MANDIR) && rm -f rb79-moderate-post.1
132 cd $(DESTDIR)$(MANDIR) && rm -f rb79-server.1
133 cd $(DESTDIR)$(MANDIR) && rm -f rb79-view-thread.1