2022-01-12 18:18:23 +01:00
|
|
|
# =====CONFIG=====
|
2022-01-12 20:54:54 +01:00
|
|
|
SRC_DIR := src
|
|
|
|
SOURCES != find '$(SRC_DIR)' -iname '*.v'
|
|
|
|
|
2022-01-12 18:18:23 +01:00
|
|
|
LARCHIVE_VER := 3.5.2
|
|
|
|
LARCHIVE_DIR := libarchive-$(LARCHIVE_VER)
|
2022-01-12 20:54:54 +01:00
|
|
|
LARCHIVE_LIB := $(LARCHIVE_DIR)/libarchive/libarchive.so
|
2022-01-12 18:18:23 +01:00
|
|
|
|
|
|
|
# Custom V command for linking libarchive
|
2022-01-12 20:54:54 +01:00
|
|
|
# V := LDFLAGS=$(PWD)/$(LARCHIVE_LIB) v -cflags '-I$(PWD)/$(LARCHIVE_DIR) -I $(PWD)/$(LARCHIVE_DIR)'
|
|
|
|
V := v
|
2022-01-09 21:45:48 +01:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
# =====COMPILATION=====
|
2022-01-12 20:54:54 +01:00
|
|
|
.PHONY: debug
|
|
|
|
debug: vieter
|
|
|
|
vieter: $(SOURCES)
|
|
|
|
$(V) -cg -o vieter $(SRC_DIR)
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
.PHONY: prod
|
2022-01-12 20:54:54 +01:00
|
|
|
prod: vieter-prod
|
|
|
|
vieter-prod: $(SOURCES)
|
|
|
|
$(V) -o vieter-prod -prod $(SRC_DIR)
|
2022-01-12 18:54:13 +01:00
|
|
|
|
2022-01-12 21:50:17 +01:00
|
|
|
.PHONY: c
|
|
|
|
c:
|
|
|
|
$(V) -o vieter.c $(SRC_DIR)
|
|
|
|
|
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-12 21:22:23 +01:00
|
|
|
run: debug
|
2022-01-12 20:54:54 +01:00
|
|
|
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG ./vieter
|
2022-01-11 18:19:41 +01:00
|
|
|
|
2022-01-12 21:22:23 +01:00
|
|
|
.PHONY: run-prod
|
|
|
|
run-prod: prod
|
|
|
|
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG ./vieter-prod
|
|
|
|
|
2022-01-12 18:18:23 +01:00
|
|
|
# Same as run, but restart when the source code changes
|
2022-01-09 21:45:48 +01:00
|
|
|
.PHONY: watch
|
2022-01-12 20:54:54 +01:00
|
|
|
watch:
|
2022-01-12 18:18:23 +01:00
|
|
|
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter
|
2022-01-09 09:29:11 +01:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
# =====OTHER=====
|
2022-01-12 18:18:23 +01:00
|
|
|
# Format the V codebase
|
2022-01-09 09:29:11 +01:00
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
2022-01-12 20:54:54 +01:00
|
|
|
v fmt -w $(SRC_DIR)
|
2022-01-09 23:02:55 +01:00
|
|
|
|
|
|
|
# Pulls & builds my personal build of the v compiler, required for this project to function
|
|
|
|
.PHONY: customv
|
|
|
|
customv:
|
|
|
|
rm -rf v-jjr
|
|
|
|
git clone \
|
|
|
|
-b vweb-streaming \
|
|
|
|
--single-branch \
|
|
|
|
https://github.com/ChewingBever/v jjr-v
|
2022-01-09 23:03:51 +01:00
|
|
|
'$(MAKE)' -C jjr-v
|
2022-01-12 18:18:23 +01:00
|
|
|
|
2022-01-12 18:54:13 +01:00
|
|
|
|
|
|
|
# =====LIBARCHIVE=====
|
2022-01-12 18:18:23 +01:00
|
|
|
.PHONY: libarchive
|
|
|
|
libarchive: $(LARCHIVE_LIB)
|
|
|
|
$(LARCHIVE_LIB):
|
|
|
|
curl -o - "https://libarchive.org/downloads/libarchive-${LARCHIVE_VER}.tar.gz" | tar xzf -
|
2022-01-12 20:54:54 +01:00
|
|
|
cd "libarchive-${LARCHIVE_VER}" && cmake .
|
2022-01-12 18:18:23 +01:00
|
|
|
'$(MAKE)' -C "libarchive-${LARCHIVE_VER}"
|
|
|
|
|
|
|
|
clean:
|
2022-01-12 20:54:54 +01:00
|
|
|
rm -rf '$(LARCHIVE_DIR)' 'data' 'vieter' 'vieter-prod'
|