aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile70
1 files changed, 70 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..72dff20
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,70 @@
+CC ?= cc
+CFLAGS ?= -O2 -g
+VERSION = 0.1.0-dev
+
+WARN = -Wall -Wextra -Wshadow -Wstrict-prototypes -Wmissing-prototypes \
+ -Wpointer-arith -Wvla -Wformat=2
+CPPFLAGS = -Isrc -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
+
+$(BUILD)/bokfd: $(BUILD)/src/bokfd.o $(CORE_OBJ) $(VENDOR_OBJ)
+ $(CC) $(CFLAGS) -o $@ $^ -lm
+
+$(BUILD)/bokfctl: $(BUILD)/clients/bokfctl.o $(BUILD)/src/util.o \
+ $(BUILD)/src/log.o $(BUILD)/vendor/yyjson.o \
+ $(BUILD)/vendor/sha256.o
+ $(CC) $(CFLAGS) -o $@ $^ -lm
+
+$(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
+
+$(BUILD)/test_core: $(BUILD)/tests/test_core.o $(CORE_OBJ) $(VENDOR_OBJ)
+ $(CC) $(CFLAGS) -o $@ $^ -lm
+
+test: $(BUILD)/test_core
+ $(BUILD)/test_core
+
+$(BUILD)/vendor/%.o: vendor/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -w -c $< -o $@
+
+$(BUILD)/src/%.o: src/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+$(BUILD)/clients/%.o: clients/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+$(BUILD)/tests/%.o: tests/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+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