diff options
author | bptato <nincsnevem662@gmail.com> | 2024-10-08 22:35:27 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-10-08 23:08:36 +0200 |
commit | bb58b0de4f0320fe3043059f8958322e6a402f42 (patch) | |
tree | 7d0904112a39660ddfd04e91d506b513645b4b90 /bonus/Makefile | |
parent | 4482f8c5e7ded15c201a9c7e98ba1533b19638ca (diff) | |
download | chawan-bb58b0de4f0320fe3043059f8958322e6a402f42.tar.gz |
bonus: add stbir2, readme, makefile
Diffstat (limited to 'bonus/Makefile')
-rw-r--r-- | bonus/Makefile | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/bonus/Makefile b/bonus/Makefile new file mode 100644 index 00000000..6365e7c0 --- /dev/null +++ b/bonus/Makefile @@ -0,0 +1,68 @@ +#TODO curse XDG +CHA_CGI_DIR ?= "$$HOME/cgi-bin" + +prefix = /usr/local + +bindir = $(DESTDIR)$(prefix)/bin + +.PHONY: none +none: + @echo "Run make install-{file} to install a script." + +stbir2_url=https://raw.githubusercontent.com/nothings/stb/master/stb_image_resize2.h + +stbir2/stb_image_resize2.h: + @printf 'stb_image_resize2.h not found.\n' + @printf 'Should I download it from $(stbir2_url)? (y/n) ' + @read -r res; if test "$$res" = "y"; then \ + cd stbir2; cha -d "$(stbir2_url)" >stb_image_resize2.h; \ + else exit 1; \ + fi + +.PHONY: install-stbir2 +install-stbir2: stbir2/stbir2.nim stbir2/stb_image_resize2.h stbir2/stb_image_resize2.c + mkdir -p $(CHA_CGI_DIR) + nim c -d:release -d:lto -o:$(CHA_CGI_DIR)/resize stbir2/stbir2.nim + +.PHONY: install-git.cgi +install-git.cgi: git.cgi + mkdir -p $(CHA_CGI_DIR) + cp git.cgi $(CHA_CGI_DIR) + ./addurimethod git git.cgi +#TODO this will almost never work unless the user is root... + ln -s $(CHA_CGI_DIR)/git.cgi $(bindir)/gitcha + +.PHONY: install-filei.cgi +install-filei.cgi: filei.cgi + mkdir -p $(CHA_CGI_DIR) + cp filei.cgi $(CHA_CGI_DIR) + +.PHONY: install-libfetch.c +install-libfetch-http.c: $(CHA_CGI_DIR)/libfetch-http + $(CC) -Wall -O2 -g -std=c89 $< -lfetch -o $@ + ./addurimethod http libfetch-http + ./addurimethod https libfetch-http + +install-magnet.cgi: magnet.cgi + mkdir -p $(CHA_CGI_DIR) + cp magnet.cgi $(CHA_CGI_DIR) + ./addurimethod magnet magnet.cgi + +install-trans.cgi: trans.cgi + mkdir -p $(CHA_CGI_DIR) + cp trans.cgi $(CHA_CGI_DIR) + @echo + @echo 'Add this to your config.toml:' + @echo + @echo '[page]' + @echo "gT = '''" + @echo 'async () => {' + @echo ' if (!pager.currentSelection) {' + @echo ' pager.alert("No selection to translate.");' + @echo ' return;' + @echo ' }' + @echo ' const text = await pager.getSelectionText(pager.currentSelection);' + @echo ' pager.cursorToggleSelection();' + @echo ' pager.load(`cgi-bin:trans.cgi?${encodeURIComponent(text)}\n`);' + @echo '}' + @echo "'''" |