2022-01-12 18:18:23 +01:00
|
|
|
# =====CONFIG=====
|
2022-01-12 20:54:54 +01:00
|
|
|
SRC_DIR := src
|
2023-01-12 12:26:12 +01:00
|
|
|
SRCS != find '$(SRC_DIR)' -iname '*.v'
|
2022-01-12 20:54:54 +01:00
|
|
|
|
2022-04-15 10:59:05 +02:00
|
|
|
V_PATH ?= v
|
2022-12-22 23:10:10 +01:00
|
|
|
V := $(V_PATH) -showcc -gc boehm -W -d use_openssl -skip-unused
|
2022-01-09 21:45:48 +01:00
|
|
|
|
2022-01-13 12:35:05 +01:00
|
|
|
all: vieter
|
2022-01-12 18:54:13 +01:00
|
|
|
|
2022-04-14 23:15:19 +02:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
# =====COMPILATION=====
|
2023-01-12 12:26:12 +01:00
|
|
|
.PHONY: libvieter
|
|
|
|
libvieter:
|
|
|
|
CFLAGS='-O3' make -C '$(SRC_DIR)/libvieter'
|
|
|
|
|
2022-01-13 12:35:05 +01:00
|
|
|
# Regular binary
|
2023-01-12 12:26:12 +01:00
|
|
|
vieter: $(SOURCES) libvieter
|
2022-01-13 12:35:05 +01:00
|
|
|
$(V) -g -o vieter $(SRC_DIR)
|
|
|
|
|
|
|
|
# Debug build using gcc
|
2022-02-22 08:14:20 +01:00
|
|
|
# The debug build can't use the boehm garbage collector, as that is
|
|
|
|
# multi-threaded and causes issues when running vieter inside gdb.
|
2022-01-13 12:35:05 +01:00
|
|
|
.PHONY: debug
|
|
|
|
debug: dvieter
|
2023-01-12 12:26:12 +01:00
|
|
|
dvieter: $(SOURCES) libvieter
|
2022-02-21 22:22:36 +01:00
|
|
|
$(V_PATH) -showcc -keepc -cg -o dvieter $(SRC_DIR)
|
|
|
|
|
2022-02-22 08:14:20 +01:00
|
|
|
# Run the debug build inside gdb
|
2022-02-21 22:22:36 +01:00
|
|
|
.PHONY: gdb
|
|
|
|
gdb: dvieter
|
2022-04-15 11:38:06 +02:00
|
|
|
gdb --args ./dvieter -f vieter.toml server
|
2022-01-12 18:54:13 +01:00
|
|
|
|
2022-01-13 12:35:05 +01:00
|
|
|
# Optimised production build
|
2022-01-12 18:54:13 +01:00
|
|
|
.PHONY: prod
|
2022-01-13 12:35:05 +01:00
|
|
|
prod: pvieter
|
2023-01-12 12:26:12 +01:00
|
|
|
pvieter: $(SOURCES) libvieter
|
2022-01-13 12:35:05 +01:00
|
|
|
$(V) -o pvieter -prod $(SRC_DIR)
|
2022-01-12 18:54:13 +01:00
|
|
|
|
2022-01-27 21:47:25 +01:00
|
|
|
# Only generate C code
|
2022-01-12 21:50:17 +01:00
|
|
|
.PHONY: c
|
2023-01-12 12:26:12 +01:00
|
|
|
c: $(SOURCES) libvieter
|
2022-01-12 21:50:17 +01:00
|
|
|
$(V) -o vieter.c $(SRC_DIR)
|
|
|
|
|
2022-04-14 23:15:19 +02:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
# =====EXECUTION=====
|
2022-01-12 18:18:23 +01:00
|
|
|
# Run the server in the default 'data' directory
|
|
|
|
.PHONY: run
|
2022-01-13 12:35:05 +01:00
|
|
|
run: vieter
|
2022-04-14 23:15:19 +02:00
|
|
|
./vieter -f vieter.toml server
|
2022-01-11 18:19:41 +01:00
|
|
|
|
2022-01-12 21:22:23 +01:00
|
|
|
.PHONY: run-prod
|
|
|
|
run-prod: prod
|
2022-04-06 18:17:33 +02:00
|
|
|
./pvieter -f vieter.toml server
|
2022-01-09 09:29:11 +01:00
|
|
|
|
2022-04-14 23:15:19 +02:00
|
|
|
|
2022-04-30 23:24:07 +02:00
|
|
|
# =====DOCS=====
|
|
|
|
.PHONY: docs
|
|
|
|
docs:
|
|
|
|
rm -rf 'docs/public'
|
|
|
|
cd docs && hugo
|
|
|
|
|
|
|
|
.PHONY: api-docs
|
|
|
|
api-docs:
|
|
|
|
rm -rf '$(SRC_DIR)/_docs'
|
|
|
|
cd '$(SRC_DIR)' && v doc -all -f html -m -readme .
|
|
|
|
|
2022-06-01 13:59:52 +02:00
|
|
|
.PHONY: man
|
|
|
|
man: vieter
|
|
|
|
rm -rf man
|
|
|
|
./vieter man man
|
|
|
|
|
2022-04-30 23:24:07 +02:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
# =====OTHER=====
|
2023-01-12 12:26:12 +01:00
|
|
|
# Linting
|
2022-01-13 14:33:06 +01:00
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
$(V) fmt -verify $(SRC_DIR)
|
2022-04-30 16:41:12 +02:00
|
|
|
$(V) vet -W $(SRC_DIR)
|
|
|
|
$(V_PATH) missdoc -p $(SRC_DIR)
|
|
|
|
@ [ $$($(V_PATH) missdoc -p $(SRC_DIR) | wc -l) = 0 ]
|
2022-01-13 14:33:06 +01:00
|
|
|
|
2023-01-12 12:26:12 +01:00
|
|
|
|
|
|
|
# Formatting
|
2022-01-09 09:29:11 +01:00
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
2022-01-13 14:33:06 +01:00
|
|
|
$(V) fmt -w $(SRC_DIR)
|
2022-01-09 23:02:55 +01:00
|
|
|
|
2023-01-12 12:26:12 +01:00
|
|
|
|
|
|
|
# Testing
|
2022-04-10 16:17:50 +02:00
|
|
|
.PHONY: test
|
2023-01-18 18:10:47 +01:00
|
|
|
test: libvieter
|
2023-01-12 12:26:12 +01:00
|
|
|
$(V) -g test $(SRC_DIR)
|
|
|
|
|
2022-04-10 16:17:50 +02:00
|
|
|
|
2023-01-12 12:26:12 +01:00
|
|
|
# Cleaning
|
2022-04-29 10:34:12 +02:00
|
|
|
.PHONY: clean
|
2022-01-12 18:18:23 +01:00
|
|
|
clean:
|
2022-06-22 09:33:48 +02:00
|
|
|
rm -rf 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'pkg' 'src/vieter' *.pkg.tar.zst 'suvieter' 'afvieter' '$(SRC_DIR)/_docs' 'docs/public'
|
2023-01-12 12:26:12 +01:00
|
|
|
make -C '$(SRC_DIR)/libvieter' clean
|
2022-04-14 23:15:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
# =====EXPERIMENTAL=====
|
|
|
|
.PHONY: autofree
|
|
|
|
autofree: afvieter
|
|
|
|
afvieter: $(SOURCES)
|
2022-11-02 18:25:49 +01:00
|
|
|
$(V) -showcc -autofree -o afvieter $(SRC_DIR)
|
2022-04-14 23:15:19 +02:00
|
|
|
|
|
|
|
.PHONY: skip-unused
|
|
|
|
skip-unused: suvieter
|
|
|
|
suvieter: $(SOURCES)
|
2022-11-02 18:25:49 +01:00
|
|
|
$(V) -skip-unused -o suvieter $(SRC_DIR)
|