From 63e2b0b663602738b3423e33543c1714314d7573 Mon Sep 17 00:00:00 2001 From: Robin Malley Date: Sun, 20 Feb 2022 00:12:52 +0000 Subject: [PATCH] Make makefile self documenting --- Makefile | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e8722f2..49f8a1b 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ COPY=cp RM=rm -f SPP=spp CD=cd +AWK=awk +GREP=grep +SORT=sort # Config chroot_dir=kore_chroot/ @@ -18,7 +21,7 @@ user=robin port=8888 domain=test.monster:$(port) -#squelch prints +# squelch prints, flip to print verbose information Q=@ #Q= @@ -40,7 +43,10 @@ built=$(built_files) $(built_sql) $(built_pages) $(built_tests) asset_in_files=$(wildcard assets/*.in -type f) asset_files=$(asset_in_files:%.in=%) -all: $(chroot_dir) smr.so $(built_files) $(built_pages) $(built_sql) +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 $(Q)$(ECHO) "[running] $@" $(Q)$(KODEV) run @@ -51,7 +57,7 @@ conf/smr.conf : conf/smr.conf.in Makefile apk-tools-static-$(version).apk: # wget -q $(mirror)latest-stable/main/$(arch)/apk-tools-static-$(version).apk -clean: +clean: ## clean up all the files generated by this makefile $(Q)$(ECHO) "[clean] $@" $(Q)$(KODEV) clean $(Q)$(RM) $(page_files) @@ -60,7 +66,7 @@ clean: $(Q)$(RM) src/lua/config.lua $(Q)$(RM) $(asset_files) -cloc: +cloc: ## calculate source lines of code in smr cloc --force-lang="HTML",etlua.in src assets $(chroot_dir): apk-tools-static-$(version).apk @@ -134,11 +140,11 @@ smr.so : $(src_files) conf/smr.conf conf/build.conf $(asset_files) $(Q)$(ECHO) "[build] $@" $(Q)$(KODEV) build -test : $(built) - $(Q)$(CD) kore_chroot && busted -v --exclude-tags slow +test : $(built) ## run the unit tests + $(Q)$(CD) kore_chroot && busted -v --no-keep-going #--exclude-tags slow -cov : $(built) +cov : $(built) ## code coverage (based on unit tests) $(Q)$(RM) kore_chroot/luacov.stats.out - $(Q)$(CD) kore_chroot && busted -v -c --exclude-tags slow + $(Q)$(CD) kore_chroot && busted -v -c --no-keep-going #--exclude-tags slow $(Q)$(CD) kore_chroot && luacov $(built) $(Q)$($ECHO) "open kore_chroot/luacov.report.out to view coverage results."