PROLOG = swipl PACKAGE = $(shell $(PROLOG) -s pack.pl -g "name(N) , writeln(N)" -t halt) VERSION = $(shell $(PROLOG) -s pack.pl -g "version(V), writeln(V)" -t halt) ZIPPACK = $(PACKAGE)-$(VERSION).zip LIBROOT = $(shell $(PROLOG) -q -g "absolute_file_name(library(.), V), writeln(V)" -t halt) LIBRARY = $(shell find $(LIBROOT) -type f -name '*.pl') SOURCES = $(shell find prolog -type f -name '*.pl') EXTRAS = pack.pl README.md LICENSE Makefile ETAGS = etags --language=prolog .PHONY: all check install lint pack clean packinstall packremove pack all: check hutpl lint: @$(PROLOG) -q -g "use_module(library(diagnostics))" -t halt -- prolog/*/*.pl check: lint pack: $(ZIPPACK) $(ZIPPACK): $(SOURCES) $(EXTRAS) zip -r $@ $^ TAGS: $(SOURCES) $(LIBRARY) @$(ETAGS) $^ packinstall: $(ZIPPACK) @$(PROLOG) -g "pack_install('$(ZIPPACK)')" -t halt packremove: $(PROLOG) -g "pack_remove($(PACKAGE))" -t halt install: true clean: rm $(ZIPPACK) hutpl: $(SOURCES) $(PROLOG) --undefined=error -O -o $@ -c prolog/$(PACKAGE)/main.pl upload: pack hutpl ./hutpl git artifact upload $(shell ./hutpl git repo eshel sourcehut.pl | jq .id) "v$(VERSION)" $(ZIPPACK)