Blame


1 f224a3fe 2021-08-24 xhr CC = cc
2 f224a3fe 2021-08-24 xhr
3 f224a3fe 2021-08-24 xhr #CFLAGS = -g3 -ggdb
4 f224a3fe 2021-08-24 xhr CFLAGS = -O2
5 f224a3fe 2021-08-24 xhr
6 f224a3fe 2021-08-24 xhr CFLAGS += -pipe -fPIE -fdiagnostics-color -Wno-unknown-warning-option -Wpedantic
7 f224a3fe 2021-08-24 xhr CFLAGS += -Wall -Werror-implicit-function-declaration -Wno-format-truncation
8 f224a3fe 2021-08-24 xhr CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
9 f224a3fe 2021-08-24 xhr CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
10 f224a3fe 2021-08-24 xhr CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Werror=format-security
11 f224a3fe 2021-08-24 xhr LDADD = -Wl,-z,now -Wl,-z,relro -pie -lssl -lcrypto -lpthread
12 f224a3fe 2021-08-24 xhr
13 f224a3fe 2021-08-24 xhr BIN = twind
14 f224a3fe 2021-08-24 xhr OBJS = twind.o gemini.o log.o request.o mime.o util.o
15 f224a3fe 2021-08-24 xhr
16 f224a3fe 2021-08-24 xhr INSTALL ?= install -p
17 f224a3fe 2021-08-24 xhr
18 f224a3fe 2021-08-24 xhr PREFIX ?= /usr/local
19 f224a3fe 2021-08-24 xhr SBIN ?= $(PREFIX)/sbin
20 f224a3fe 2021-08-24 xhr MAN ?= $(PREFIX)/man
21 f224a3fe 2021-08-24 xhr GEMINIDIR ?= /var/twind
22 f224a3fe 2021-08-24 xhr CONFDIR ?= /etc/twind
23 f224a3fe 2021-08-24 xhr
24 f224a3fe 2021-08-24 xhr UID = 4000
25 f224a3fe 2021-08-24 xhr
26 f224a3fe 2021-08-24 xhr all: $(BIN)
27 f224a3fe 2021-08-24 xhr
28 f224a3fe 2021-08-24 xhr install: all
29 f224a3fe 2021-08-24 xhr $(INSTALL) -d -m 755 -o root $(MAN)/man8
30 f224a3fe 2021-08-24 xhr $(INSTALL) -d -m 750 -o root $(CONFDIR)
31 f224a3fe 2021-08-24 xhr $(INSTALL) -d -m 755 -o root $(GEMINIDIR)
32 f224a3fe 2021-08-24 xhr $(INSTALL) -d -m 755 -o _twind -g _twind $(GEMINIDIR)/logs
33 f224a3fe 2021-08-24 xhr $(INSTALL) -m 644 -o root twind.8 $(MAN)/man8
34 f224a3fe 2021-08-24 xhr $(INSTALL) -m 755 -o root twind $(SBIN)
35 f224a3fe 2021-08-24 xhr
36 f224a3fe 2021-08-24 xhr user:
37 f224a3fe 2021-08-24 xhr @useradd -d $(GEMINIDIR) -s /sbin/nologin -u $(UID) _twind
38 f224a3fe 2021-08-24 xhr
39 f224a3fe 2021-08-24 xhr setuptls:
40 f224a3fe 2021-08-24 xhr @openssl req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes -keyout $(CONFDIR)/twind.key.pem -new -subj /CN=$(HN) -out $(CONFDIR)/twind.cert.pem -addext subjectAltName=DNS:$(HN)
41 f224a3fe 2021-08-24 xhr
42 f224a3fe 2021-08-24 xhr $(BIN): $(OBJS)
43 f224a3fe 2021-08-24 xhr $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
44 f224a3fe 2021-08-24 xhr
45 f224a3fe 2021-08-24 xhr .c.o:
46 f224a3fe 2021-08-24 xhr $(CC) $(CFLAGS) -o $@ -c $<
47 f224a3fe 2021-08-24 xhr
48 f224a3fe 2021-08-24 xhr clean:
49 f224a3fe 2021-08-24 xhr rm -f $(BIN) $(OBJS)