blob: d35176b426cb978cd63cb6768a26584b1d911140 (
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
|
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/sie.c src/formula.c
VENDOR_OBJ = $(patsubst %.c,$(BUILD)/%.o,$(VENDOR_SRC))
CORE_OBJ = $(patsubst %.c,$(BUILD)/%.o,$(CORE_SRC))
all: $(BUILD)/bokfd $(BUILD)/bokfctl $(BUILD)/bokftui
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/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)
test: $(BUILD)/test_core
$(BUILD)/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/client.d $(BUILD)/tests/test_core.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)
.PHONY: all test install clean
|