lua != which lua
luac != which luac
sh != which sh
extens = $(wildcard ext/*.lua)
extens_names ?= $(basename $(notdir $(extens)))
build = build
executable = cortav
prefix = $(HOME)/.local
bin_prefix = $(prefix)/bin
share_prefix = $(prefix)/share/$(executable)
$(build)/$(executable): sirsem.lua cortav.lua $(extens) cli.lua | $(build)/
@echo ' ยป building with extensions $(extens_names)'
echo '#!$(lua)' > $@
luac -o - $^ >> $@
chmod +x $@
$(build)/cortav.html: cortav.ct $(build)/$(executable) | $(build)/
./cortav $< -o $@ -m render:format html -y html:fossil-uv
.PHONY: syncdoc
syncdoc: $(build)/cortav.html
fossil uv add $<
fossil uv sync
.PHONY: clean
clean:
rm -f $(build)/cortav $(build)/cortav.html $(build)/velartrill-cortav-view.desktop $(build)/cortav-view.sh
$(build)/%.sh: desk/%.sh
echo >$@ "#!$(sh)"
echo >>$@ 'cortav_exec="$(bin_prefix)/$(executable)"'
cat $< >> $@
chmod +x $@
$(build)/velartrill-cortav-view.desktop: desk/cortav-view.desktop.tpl
cp $< $@
echo "Exec=$(bin_prefix)/cortav-view.sh" >>$@
%/:
mkdir -p $@
.PHONY: install
install: $(build)/cortav $(build)/cortav-view.sh $(build)/velartrill-cortav-view.desktop | $(bin_prefix)/
install $(build)/$(executable) $(bin_prefix)
install $(build)/cortav-view.sh $(bin_prefix)
xdg-mime install desk/velartrill-cortav.xml
xdg-desktop-menu install $(build)/velartrill-cortav-view.desktop
xdg-mime default velartrill-cortav-view.desktop text/x-cortav
.PHONY: excise
excise: $(build)/velartrill-cortav-view.desktop
xdg-mime uninstall desk/velartrill-cortav.xml
xdg-desktop-menu uninstall $(build)/velartrill-cortav-view.desktop
rm $(bin_prefix)/$(executable)
rm $(bin_prefix)/cortav-view.sh
.PHONY: wipe
wipe: excise clean