2021-01-04 03:48:29 +01:00
|
|
|
# Binaries
|
|
|
|
ECHO=echo
|
|
|
|
KODEV=kodev
|
|
|
|
MKDIR=mkdir -p
|
|
|
|
COPY=cp
|
|
|
|
RM=rm -f
|
|
|
|
SPP=spp
|
2021-01-16 21:59:22 +01:00
|
|
|
CD=cd
|
2022-02-20 01:12:52 +01:00
|
|
|
AWK=awk
|
|
|
|
GREP=grep
|
|
|
|
SORT=sort
|
2021-01-04 03:48:29 +01:00
|
|
|
|
2020-05-17 18:05:00 +02:00
|
|
|
# Config
|
|
|
|
chroot_dir=kore_chroot/
|
|
|
|
mirror=http://dl-cdn.alpinelinux.org/alpine/
|
|
|
|
arch=aarch64
|
|
|
|
version=2.10.5-r0
|
2020-08-13 19:59:33 +02:00
|
|
|
certbot_email=--register-unsafely-without-email
|
|
|
|
#certbot_email=-m you@cock.li
|
2021-01-04 03:48:29 +01:00
|
|
|
user=robin
|
|
|
|
port=8888
|
|
|
|
domain=test.monster:$(port)
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2022-09-03 01:06:38 +02:00
|
|
|
SPPFLAGS=-D port=$(port) -D kore_chroot=$(chroot_dir) -D chuser=$(user) -D domain=$(domain)
|
2022-02-20 01:12:52 +01:00
|
|
|
# squelch prints, flip to print verbose information
|
2021-01-04 03:48:29 +01:00
|
|
|
Q=@
|
|
|
|
#Q=
|
|
|
|
|
|
|
|
# Probably don't change stuff past here if you're just using smr
|
|
|
|
lua_in_files=$(shell find src/lua/*.in -type f)
|
|
|
|
lua_files=$(shell find src/lua/*.lua -type f) $(shell find src/lua/endpoints -type f) $(lua_in_files:%.in=%)
|
2020-05-17 18:05:00 +02:00
|
|
|
src_files=$(shell find src -type f) $(shell find conf -type f)
|
|
|
|
sql_files=$(shell find src/sql -type f)
|
2020-12-21 05:22:22 +01:00
|
|
|
test_files=$(shell find spec -type f)
|
|
|
|
built_tests=$(test_files:%=$(chroot_dir)%)
|
2020-05-17 18:05:00 +02:00
|
|
|
built_files=$(lua_files:src/lua/%.lua=$(chroot_dir)%.lua)
|
2021-01-04 03:48:29 +01:00
|
|
|
in_page_files=$(shell find src/pages/*.in -type f)
|
|
|
|
in_part_files=$(shell find src/pages/parts/*.in -type f)
|
|
|
|
page_files=$(in_page_files:%.in=%)
|
|
|
|
part_files=$(in_part_files:%.in=%) $(shell find src/pages/parts/*.etlua -type f)
|
2020-05-17 18:05:00 +02:00
|
|
|
built_pages=$(page_files:src/pages/%.etlua=$(chroot_dir)pages/%.etlua)
|
|
|
|
built_sql=$(sql_files:src/sql/%.sql=$(chroot_dir)sql/%.sql)
|
2020-12-21 05:22:22 +01:00
|
|
|
built=$(built_files) $(built_sql) $(built_pages) $(built_tests)
|
2021-10-11 02:54:15 +02:00
|
|
|
asset_in_files=$(wildcard assets/*.in -type f)
|
|
|
|
asset_files=$(asset_in_files:%.in=%)
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2022-02-20 01:12:52 +01:00
|
|
|
help: ## Print this help
|
|
|
|
$(Q)$(GREP) -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | $(SORT) | $(AWK) 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'
|
|
|
|
|
|
|
|
all: $(chroot_dir) smr.so $(built_files) $(built_pages) $(built_sql) ## Build and run smr in a chroot
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[running] $@"
|
|
|
|
$(Q)$(KODEV) run
|
|
|
|
|
|
|
|
conf/smr.conf : conf/smr.conf.in Makefile
|
|
|
|
$(Q)$(ECHO) "[preprocess] $@"
|
2022-09-03 01:06:38 +02:00
|
|
|
$(Q)$(SPP) -o $@ $(SPPFLAGS) $<
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2020-08-13 19:59:33 +02:00
|
|
|
apk-tools-static-$(version).apk:
|
|
|
|
# wget -q $(mirror)latest-stable/main/$(arch)/apk-tools-static-$(version).apk
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2022-02-20 01:12:52 +01:00
|
|
|
clean: ## clean up all the files generated by this makefile
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[clean] $@"
|
|
|
|
$(Q)$(KODEV) clean
|
|
|
|
$(Q)$(RM) $(page_files)
|
|
|
|
$(Q)$(RM) conf/smr.conf
|
|
|
|
$(Q)$(RM) src/pages/parts/story_breif.etlua
|
|
|
|
$(Q)$(RM) src/lua/config.lua
|
2021-10-11 02:54:15 +02:00
|
|
|
$(Q)$(RM) $(asset_files)
|
2021-01-04 03:48:29 +01:00
|
|
|
|
2022-02-20 01:12:52 +01:00
|
|
|
cloc: ## calculate source lines of code in smr
|
2021-08-27 03:05:18 +02:00
|
|
|
cloc --force-lang="HTML",etlua.in src assets
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2020-08-13 19:59:33 +02:00
|
|
|
$(chroot_dir): apk-tools-static-$(version).apk
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(MKDIR) $(chroot_dir)
|
|
|
|
$(Q)$(MKDIR) $(chroot_dir)/pages
|
|
|
|
$(Q)$(MKDIR) $(chroot_dir)/sql
|
|
|
|
$(Q)$(MKDIR) $(chroot_dir)/data
|
2021-02-03 04:41:22 +01:00
|
|
|
$(Q)$(MKDIR) $(chroot_dir)/data/archive
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(MKDIR) $(chroot_dir)/endpoints
|
2020-05-17 18:05:00 +02:00
|
|
|
|
|
|
|
code : $(built_files)
|
|
|
|
|
|
|
|
$(built_files): $(chroot_dir)%.lua : src/lua/%.lua
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[copy] $@"
|
|
|
|
$(Q)$(COPY) $^ $@
|
2020-05-17 18:05:00 +02:00
|
|
|
|
|
|
|
$(built_pages): $(chroot_dir)pages/%.etlua : src/pages/%.etlua
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[copy] $@"
|
|
|
|
$(Q)$(COPY) $^ $@
|
|
|
|
|
|
|
|
src/lua/config.lua : src/lua/config.lua.in Makefile
|
|
|
|
$(Q)$(ECHO) "[preprocess] $@"
|
2022-09-03 01:06:38 +02:00
|
|
|
$(Q)$(SPP) $(SPPFLAGS) -o $@ $<
|
2021-01-04 03:48:29 +01:00
|
|
|
|
|
|
|
$(page_files) : % : %.in $(part_files)
|
|
|
|
$(Q)$(ECHO) "[preprocess] $@"
|
2022-09-03 01:06:38 +02:00
|
|
|
$(Q)$(SPP) $(SPPFLAGS) -o $@ $<
|
2021-01-04 03:48:29 +01:00
|
|
|
|
|
|
|
src/pages/parts/story_breif.etlua : src/pages/parts/story_breif.etlua.in
|
|
|
|
$(Q)$(ECHO) "[preprocess] $@"
|
2022-09-03 01:06:38 +02:00
|
|
|
$(Q)$(SPP) $(SPPFLAGS) -o $@ $<
|
2020-05-17 18:05:00 +02:00
|
|
|
|
|
|
|
$(built_sql): $(chroot_dir)sql/%.sql : src/sql/%.sql
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[copy] $@"
|
|
|
|
$(Q)$(COPY) $^ $@
|
2020-05-17 18:05:00 +02:00
|
|
|
|
2020-12-21 05:22:22 +01:00
|
|
|
$(built_tests) : $(chroot_dir)% : %
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[copy] $@"
|
|
|
|
$(Q)$(COPY) $^ $@
|
2020-12-21 05:22:22 +01:00
|
|
|
|
2021-10-11 02:54:15 +02:00
|
|
|
$(asset_files) : % : %.in
|
|
|
|
$(Q)$(ECHO) "[preprocess] $@"
|
2022-09-03 01:06:38 +02:00
|
|
|
$(Q)$(SPP) $(SPPFLAGS) -o $@ $<
|
2021-10-11 02:54:15 +02:00
|
|
|
|
|
|
|
smr.so : $(src_files) conf/smr.conf conf/build.conf $(asset_files)
|
2021-01-04 03:48:29 +01:00
|
|
|
$(Q)$(ECHO) "[build] $@"
|
|
|
|
$(Q)$(KODEV) build
|
2020-12-21 05:22:22 +01:00
|
|
|
|
2022-02-20 01:12:52 +01:00
|
|
|
test : $(built) ## run the unit tests
|
|
|
|
$(Q)$(CD) kore_chroot && busted -v --no-keep-going #--exclude-tags slow
|
2021-09-12 19:37:12 +02:00
|
|
|
|
2022-02-20 01:12:52 +01:00
|
|
|
cov : $(built) ## code coverage (based on unit tests)
|
2021-09-12 19:37:12 +02:00
|
|
|
$(Q)$(RM) kore_chroot/luacov.stats.out
|
2022-02-20 01:12:52 +01:00
|
|
|
$(Q)$(CD) kore_chroot && busted -v -c --no-keep-going #--exclude-tags slow
|
2022-09-03 01:22:08 +02:00
|
|
|
$(Q)$(CD) kore_chroot && luacov endpoints/
|
|
|
|
$(Q)$(ECHO) "open kore_chroot/luacov.report.out to view coverage results."
|