userscript: make "No. 123" links smarter
[rb-79.git] / Makefile
blob9354145e9d3c898ef03084aa816f4b6696e90853
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 test -f config.h || cp config.def.h config.h
70 touch config.h
72 %.o: %.c config.h rb79.h macros.h unicode-transforms.h
73 $(CC) $(CFLAGS) -c -o $@ $<
75 rb79-server: $(SERVER_OFILES)
76 $(CC) -o $@ $^ $(LDFLAGS)
78 rb79-ban-ip: db-$(DB_TYPE).o locks.o rb79-ban-ip.o util.o \
79 write-thread.o
80 $(CC) -o $@ $^ $(LDFLAGS)
82 rb79-delete-post: db-$(DB_TYPE).o locks.o rb79-delete-post.o util.o \
83 write-thread.o
84 $(CC) -o $@ $^ $(LDFLAGS)
86 rb79-moderate-post: db-$(DB_TYPE).o locks.o rb79-moderate-post.o \
87 util.o write-thread.o
88 $(CC) -o $@ $^ $(LDFLAGS)
90 rb79-view-thread: db-$(DB_TYPE).o locks.o rb79-view-thread.o util.o \
91 write-thread.o
92 $(CC) -o $@ $^ $(LDFLAGS)
95 .PHONY: clean
96 clean:
97 find -name '*.o' -delete
98 rm -f rb79-server
99 rm -f rb79-ban-ip
100 rm -f rb79-delete-post
101 rm -f rb79-moderate-post
102 rm -f rb79-view-thread
104 .PHONY: install
105 install: all
106 mkdir -p $(DESTDIR)$(BINDIR)
107 cp -f rb79-server $(DESTDIR)$(BINDIR)/
108 cp -f tools/rb79-describe-file.sh $(DESTDIR)$(BINDIR)/rb79-describe-file
109 cp -f rb79-ban-ip $(DESTDIR)$(BINDIR)/
110 cp -f rb79-delete-post $(DESTDIR)$(BINDIR)/
111 cp -f rb79-moderate-post $(DESTDIR)$(BINDIR)/
112 cp -f rb79-view-thread $(DESTDIR)$(BINDIR)/
113 mkdir -p $(DESTDIR)$(MANDIR)/man1
114 cp -f rb79.1 $(DESTDIR)$(MANDIR)/man1/
115 cp -f rb79-ban-ip.1 $(DESTDIR)$(MANDIR)/man1/
116 cp -f rb79-delete-post.1 $(DESTDIR)$(MANDIR)/man1/
117 cp -f rb79-moderate-post.1 $(DESTDIR)$(MANDIR)/man1/
118 cp -f rb79-server.1 $(DESTDIR)$(MANDIR)/man1/
119 cp -f rb79-view-thread.1 $(DESTDIR)$(MANDIR)/man1/
121 .PHONY: uninstall
122 uninstall:
123 cd $(DESTDIR)$(BINDIR) && rm -f rb79-server
124 cd $(DESTDIR)$(BINDIR) && rm -f rb79-describe-file
125 cd $(DESTDIR)$(BINDIR) && rm -f rb79-ban-ip
126 cd $(DESTDIR)$(BINDIR) && rm -f rb79-delete-post
127 cd $(DESTDIR)$(BINDIR) && rm -f rb79-moderate-post
128 cd $(DESTDIR)$(BINDIR) && rm -f rb79-view-thread
129 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79.1
130 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79-ban-ip.1
131 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79-delete-post.1
132 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79-moderate-post.1
133 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79-server.1
134 cd $(DESTDIR)$(MANDIR) && rm -f man1/rb79-view-thread.1