vieter/Makefile

80 lines
1.7 KiB
Makefile
Raw Normal View History

# =====CONFIG=====
SRC_DIR := src
SOURCES != find '$(SRC_DIR)' -iname '*.v'
LARCHIVE_VER := 3.5.2
LARCHIVE_DIR := libarchive-$(LARCHIVE_VER)
LARCHIVE_LIB := $(LARCHIVE_DIR)/libarchive/libarchive.so
V_RELEASE := weekly.2022.04
2022-01-27 19:24:35 +01:00
V_PATH ?= v-$(V_RELEASE)/v
# Custom V command for linking libarchive
# V := LDFLAGS=$(PWD)/$(LARCHIVE_LIB) v -cflags '-I$(PWD)/$(LARCHIVE_DIR) -I $(PWD)/$(LARCHIVE_DIR)'
2022-01-27 19:24:35 +01:00
V := $(V_PATH) -showcc
2022-01-13 12:35:05 +01:00
all: vieter
2022-01-12 18:54:13 +01:00
# =====COMPILATION=====
2022-01-13 12:35:05 +01:00
# Regular binary
vieter: $(SOURCES)
2022-01-13 12:35:05 +01:00
$(V) -g -o vieter $(SRC_DIR)
# Debug build using gcc
.PHONY: debug
debug: dvieter
dvieter: $(SOURCES)
$(V) -keepc -cg -cc gcc -o dvieter $(SRC_DIR)
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
pvieter: $(SOURCES)
$(V) -o pvieter -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=====
# Run the server in the default 'data' directory
.PHONY: run
2022-01-13 12:35:05 +01:00
run: vieter
2022-01-19 21:24:46 +01:00
API_KEY=test DOWNLOAD_DIR=data/downloads REPO_DIR=data/repo PKG_DIR=data/pkgs LOG_LEVEL=DEBUG ./vieter
2022-01-12 21:22:23 +01:00
.PHONY: run-prod
run-prod: prod
2022-01-14 18:32:00 +01:00
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG ./pvieter
2022-01-12 21:22:23 +01:00
# Same as run, but restart when the source code changes
.PHONY: watch
watch:
API_KEY=test REPO_DIR=data LOG_LEVEL=DEBUG $(V) watch run vieter
2022-01-12 18:54:13 +01:00
# =====OTHER=====
2022-01-13 14:33:06 +01:00
.PHONY: lint
lint:
$(V) fmt -verify $(SRC_DIR)
# Format the V codebase
.PHONY: fmt
fmt:
2022-01-13 14:33:06 +01:00
$(V) fmt -w $(SRC_DIR)
2022-01-09 23:02:55 +01:00
2022-01-14 21:02:34 +01:00
.PHONY: vet
vet:
$(V) vet -W $(SRC_DIR)
# Build & patch the V compiler
.PHONY: v
v: v-$(V_RELEASE)/v
v-$(V_RELEASE)/v:
curl -Lo - 'https://github.com/vlang/v/archive/refs/tags/$(V_RELEASE).tar.gz' | tar xzf -
2022-01-27 19:38:36 +01:00
cd patches && sh patch.sh '../v-$(V_RELEASE)'
2022-01-27 19:46:46 +01:00
make -C 'v-$(V_RELEASE)'
clean:
rm -rf '$(LARCHIVE_DIR)' 'data' 'vieter' 'dvieter' 'pvieter' 'vieter.c' 'v-$(V_RELEASE)'