summaryrefslogtreecommitdiff
path: root/Makefile
blob: 20824e63b2355b7204e92a3d14dd59a15808a677 (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
38
39
40
41
42
43
44
45
46
47
48
49
CC = cc

#CFLAGS  = -g3 -ggdb
CFLAGS  = -O2

CFLAGS += -pipe -fPIE -fdiagnostics-color -Wno-unknown-warning-option -Wpedantic
CFLAGS += -Wall -Werror-implicit-function-declaration -Wno-format-truncation
CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wsign-compare
CFLAGS += -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Werror=format-security
LDADD = -Wl,-z,now -Wl,-z,relro -pie -lssl -lcrypto -lpthread

BIN  = twind
OBJS = twind.o gemini.o log.o request.o mime.o util.o

INSTALL ?= install -p

PREFIX ?= /usr/local
SBIN ?= $(PREFIX)/sbin
MAN ?= $(PREFIX)/man
GEMINIDIR ?= /var/twind
CONFDIR ?= /etc/twind

UID = 4000

all: $(BIN)

install: all
	$(INSTALL) -d -m 755 -o root $(MAN)/man8
	$(INSTALL) -d -m 750 -o root $(CONFDIR)
	$(INSTALL) -d -m 755 -o root $(GEMINIDIR)
	$(INSTALL) -d -m 755 -o _twind -g _twind $(GEMINIDIR)/logs
	$(INSTALL) -m 644 -o root twind.8 $(MAN)/man8
	$(INSTALL) -m 755 -o root twind $(SBIN)

user:
	@useradd -d $(GEMINIDIR) -s /sbin/nologin -u $(UID) _twind

setuptls:
	@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)

$(BIN): $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)

.c.o:
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	rm -f $(BIN) $(OBJS)
generated by cgit on OpenBSD