blob: b55fca385103db4fe9d6f016e37d563af0709737 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
CC ?= cc
CFLAGS ?= -O2 -g
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null \
|| echo 0.1.0-dev)
WARN = -Wall -Wextra -Wshadow -Wstrict-prototypes -Wmissing-prototypes \
-Wpointer-arith -Wvla -Wformat=2
DEPFLAGS = -MMD -MP
CPPFLAGS = -Isrc -Iclients -Ivendor -Ivendor/argon2
DEFS = -D_GNU_SOURCE -DARGON2_NO_THREADS -DBOKF_VERSION=\"$(VERSION)\"
BUILD ?= build
VENDOR_SRC = vendor/sqlite3.c vendor/yyjson.c vendor/sha256.c \
vendor/argon2/argon2.c vendor/argon2/core.c \
vendor/argon2/encoding.c vendor/argon2/ref.c \
vendor/argon2/thread.c vendor/argon2/blake2/blake2b.c
CORE_SRC = src/util.c src/log.c src/config.c src/db.c src/auth.c \
src/sessions.c src/audit.c src/protocol.c src/commands.c \
src/seed.c src/ledger.c src/reports.c src/sru.c src/sie.c \
src/formula.c src/pdf.c src/invoice.c src/secret.c src/smtp.c
VENDOR_OBJ = $(patsubst %.c,$(BUILD)/%.o,$(VENDOR_SRC))
CORE_OBJ = $(patsubst %.c,$(BUILD)/%.o,$(CORE_SRC))
all: $(BUILD)/bokfd $(BUILD)/bokfctl $(BUILD)/bokftui
backend: $(BUILD)/bokfd $(BUILD)/bokfctl
SSL_LIBS = -lssl -lcrypto
$(BUILD)/bokfd: $(BUILD)/src/bokfd.o $(CORE_OBJ) $(VENDOR_OBJ)
$(CC) $(CFLAGS) -o $@ $^ -lm $(SSL_LIBS)
$(BUILD)/bokfctl: $(BUILD)/clients/bokfctl.o $(BUILD)/clients/client.o \
$(BUILD)/src/util.o $(BUILD)/src/log.o $(BUILD)/vendor/yyjson.o \
$(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm $(SSL_LIBS)
$(BUILD)/bokftui: $(BUILD)/clients/bokftui.o $(BUILD)/clients/tui.o \
$(BUILD)/clients/client.o \
$(BUILD)/src/util.o $(BUILD)/src/log.o $(BUILD)/src/formula.o \
$(BUILD)/vendor/yyjson.o $(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm -lncursesw $(SSL_LIBS)
$(BUILD)/test_core: $(BUILD)/tests/test_core.o $(BUILD)/clients/client.o \
$(CORE_OBJ) $(VENDOR_OBJ)
$(CC) $(CFLAGS) -o $@ $^ -lm $(SSL_LIBS)
$(BUILD)/test_tui: $(BUILD)/tests/test_tui.o $(BUILD)/clients/tui.o \
$(BUILD)/src/util.o $(BUILD)/src/log.o $(BUILD)/vendor/yyjson.o \
$(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm -lncursesw
$(BUILD)/test_pdf: $(BUILD)/tests/pdf_check.o $(BUILD)/src/pdf.o \
$(BUILD)/src/util.o $(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm
$(BUILD)/test_invoice: $(BUILD)/tests/invoice_check.o $(BUILD)/src/invoice.o \
$(BUILD)/src/pdf.o $(BUILD)/src/util.o \
$(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm -lssl -lcrypto
$(BUILD)/test_smtp: $(BUILD)/tests/smtp_check.o $(BUILD)/src/smtp.o \
$(BUILD)/src/util.o $(BUILD)/src/log.o \
$(BUILD)/vendor/sha256.o
$(CC) $(CFLAGS) -o $@ $^ -lm -lssl -lcrypto
test: check $(BUILD)/test_core $(BUILD)/test_tui $(BUILD)/test_pdf \
$(BUILD)/test_invoice $(BUILD)/test_smtp
$(BUILD)/test_core
$(BUILD)/test_tui
$(BUILD)/test_pdf
$(BUILD)/test_invoice
$(BUILD)/test_smtp
test-core: $(BUILD)/test_core
$(BUILD)/test_core
check:
sh scripts/check-consistency.sh
test-pty: all
python3 scripts/tui-golden.py
SAN_CFLAGS = -O1 -g -fno-omit-frame-pointer
test-asan:
$(MAKE) BUILD=build-asan CFLAGS="$(SAN_CFLAGS) -fsanitize=address" test-core
test-ubsan:
$(MAKE) BUILD=build-ubsan CFLAGS="$(SAN_CFLAGS) -fsanitize=undefined" test-core
$(BUILD)/vendor/%.o: vendor/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(CPPFLAGS) $(DEFS) -w -c $< -o $@
$(BUILD)/src/%.o: src/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
$(BUILD)/clients/%.o: clients/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
$(BUILD)/tests/%.o: tests/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
-include $(VENDOR_OBJ:.o=.d) $(CORE_OBJ:.o=.d) $(BUILD)/src/bokfd.d \
$(BUILD)/clients/bokfctl.d $(BUILD)/clients/bokftui.d \
$(BUILD)/clients/tui.d $(BUILD)/clients/client.d \
$(BUILD)/tests/test_core.d $(BUILD)/tests/test_tui.d
install: all
install -d $(DESTDIR)/usr/local/bin $(DESTDIR)/usr/local/share/bokf
install -m 0755 $(BUILD)/bokfd $(BUILD)/bokfctl $(BUILD)/bokftui \
$(DESTDIR)/usr/local/bin/
install -m 0644 data/bas_k2.csv data/bas_k3.csv $(DESTDIR)/usr/local/share/bokf/
clean:
rm -rf $(BUILD) build-asan build-ubsan
.PHONY: all backend test test-core test-pty check test-asan test-ubsan \
install clean
|