The repository formerly known as dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. PREFIX = ~/.local
  2. MANDIR = $(PREFIX)/share/man
  3. GFX = cocoa
  4. CFLAGS += -Wall -Wextra -Wpedantic
  5. LDLIBS = -lm -lutil -lz
  6. LDLIBS_cocoa = $(LDLIBS) -framework Cocoa
  7. LDLIBS_fb = $(LDLIBS)
  8. LDLIBS_x11 = $(LDLIBS) -lX11
  9. BINS += aes
  10. BINS += dtch
  11. BINS += glitch
  12. BINS += hi
  13. BINS += hnel
  14. BINS += modem
  15. BINS += pbd
  16. BINS += pngo
  17. BINS += psf2png
  18. BINS += scheme
  19. BINS += ttpre
  20. BINS += up
  21. BINS += wake
  22. BINS += xx
  23. LINKS += atch
  24. LINKS += open
  25. LINKS += pbcopy
  26. LINKS += pbpaste
  27. BINS_BSD += beef
  28. BINS_BSD += wat
  29. BINS_LINUX += bri
  30. BINS_LINUX += fbatt
  31. BINS_LINUX += fbclock
  32. BINS_LINUX += psfed
  33. BINS_GFX += brot
  34. BINS_GFX += gfxx
  35. BINS_ALL = $(BINS) $(BINS_BSD) $(BINS_LINUX) $(BINS_GFX)
  36. MAN1_ALL = $(BINS_ALL:%=man1/%.1)
  37. any: .gitignore tags $(BINS) $(LINKS)
  38. bsd: any $(BINS_BSD)
  39. linux: any $(BINS_LINUX)
  40. gfx: any $(BINS_GFX)
  41. .o:
  42. $(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
  43. scheme.h: scheme
  44. ./scheme -c > scheme.h
  45. brot.o gfxx.o gfx-cocoa.o gfx-fb.o gfx-x11.o: gfx.h
  46. fbatt.o fbclock.o: scheme.h
  47. gfxx.o psf2png.o scheme.o: png.h
  48. GFX_OBJ = gfx-$(GFX).o
  49. brot: brot.o $(GFX_OBJ)
  50. $(CC) $(LDFLAGS) $@.o $(GFX_OBJ) $(LDLIBS_$(GFX)) -o $@
  51. gfxx: gfxx.o $(GFX_OBJ)
  52. $(CC) $(LDFLAGS) $@.o $(GFX_OBJ) $(LDLIBS_$(GFX)) -o $@
  53. hi: hi.c
  54. $(CC) $(CFLAGS) $(LDFLAGS) hi.c $(LDLIBS) -o $@
  55. ./hi -c
  56. atch: dtch
  57. ln -f dtch atch
  58. open pbcopy pbpaste: pbd
  59. ln -f pbd $@
  60. .gitignore: Makefile
  61. echo $(BINS_ALL) $(LINKS) tags scheme.h scheme.png '*.o' '*.html' \
  62. | tr ' ' '\n' | sort > .gitignore
  63. tags: *.h *.c
  64. ctags -w *.h *.c
  65. scheme.png: scheme
  66. ./scheme -gt > scheme.png
  67. HTMLS = $(BINS_ALL:%=%.html)
  68. WEBROOT = /usr/local/www/causal.agency
  69. GITEA_URL = https://code.causal.agency/june/src/src/branch/master/bin
  70. html: $(HTMLS)
  71. $(HTMLS): ttpre hi
  72. .SUFFIXES: .html
  73. .c.html:
  74. @echo '<!DOCTYPE html>' > $@
  75. @echo '<title>$(<:%.c=%)</title>' >> $@
  76. @echo '<code><a href="$(GITEA_URL)/$<">$< in git</a></code>' >> $@
  77. man -P cat ./man1/$(<:%.c=%.1) | ./ttpre >> $@
  78. ./hi -f html -o inline,tab=4 $< >> $@
  79. .sh.html:
  80. @echo '<!DOCTYPE html>' > $@
  81. @echo '<title>$(<:%.sh=%)</title>' >> $@
  82. @echo '<code><a href="$(GITEA_URL)/$<">$< in git</a></code>' >> $@
  83. man -P cat ./man1/$(<:%.sh=%.1) | ./ttpre >> $@
  84. ./hi -f html -o inline,tab=4 $< >> $@
  85. clean:
  86. rm -f $(BINS_ALL) $(LINKS) tags scheme.h scheme.png *.o *.html
  87. README: bin.7
  88. mandoc bin.7 | col -bx > README
  89. setuid: bri
  90. chown root bri
  91. chmod u+s bri
  92. link:
  93. install -d $(PREFIX)/bin $(MANDIR)/man1
  94. ln -fs $(BINS_ALL:%=$(PWD)/%) $(LINKS:%=$(PWD)/%) $(PREFIX)/bin
  95. ln -fs $(MAN1_ALL:%=$(PWD)/%) $(MANDIR)/man1
  96. unlink:
  97. rm -f $(BINS_ALL:%=$(PREFIX)/bin/%) $(LINKS:%=$(PREFIX)/bin/%)
  98. rm -f $(MAN1_ALL:%=$(MANDIR)/%)
  99. install-html: $(HTMLS)
  100. install -d $(WEBROOT)/bin
  101. install -C -m 644 $(HTMLS) $(WEBROOT)/bin