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 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. GFX = cocoa
  2. LIBRESSL_PREFIX = /usr/local
  3. PREFIX = ~/.local
  4. MANDIR = ${PREFIX}/share/man
  5. CFLAGS += -Wall -Wextra -Wpedantic
  6. LDLIBS = -lm -lutil -lz
  7. CFLAGS_tls = ${CFLAGS} -I${LIBRESSL_PREFIX}/include
  8. LDFLAGS_tls = ${LDFLAGS} -L${LIBRESSL_PREFIX}/lib
  9. LDLIBS_tls = ${LDLIBS} -ltls
  10. GFX_OBJ = gfx-${GFX}.o
  11. LDLIBS_cocoa = ${LDLIBS} -framework Cocoa
  12. LDLIBS_fb = ${LDLIBS}
  13. LDLIBS_x11 = ${LDLIBS} -lX11
  14. -include config.mk
  15. BINS_ANY += aes
  16. BINS_ANY += bit
  17. BINS_ANY += dtch
  18. BINS_ANY += glitch
  19. BINS_ANY += hi
  20. BINS_ANY += hnel
  21. BINS_ANY += modem
  22. BINS_ANY += order
  23. BINS_ANY += pbd
  24. BINS_ANY += pngo
  25. BINS_ANY += psf2png
  26. BINS_ANY += ptee
  27. BINS_ANY += scheme
  28. BINS_ANY += setopt
  29. BINS_ANY += shotty
  30. BINS_ANY += ttpre
  31. BINS_ANY += up
  32. BINS_ANY += wake
  33. BINS_ANY += when
  34. BINS_ANY += xx
  35. LINKS_ANY += open
  36. LINKS_ANY += pbcopy
  37. LINKS_ANY += pbpaste
  38. BINS_BSD += beef
  39. BINS_BSD += wat
  40. BINS_GFX += brot
  41. BINS_GFX += gfxx
  42. BINS_LINUX += bri
  43. BINS_LINUX += fbatt
  44. BINS_LINUX += fbclock
  45. BINS_LINUX += psfed
  46. BINS_TLS += relay
  47. BINS = ${BINS_ANY} ${BINS_BSD} ${BINS_GFX} ${BINS_LINUX} ${BINS_TLS}
  48. MANS = ${BINS:%=man1/%.1}
  49. LINKS = ${LINKS_ANY}
  50. # Groups
  51. any: meta ${BINS_ANY} ${LINKS_ANY}
  52. bsd: meta ${BINS_BSD}
  53. gfx: meta ${BINS_GFX}
  54. linux: meta ${BINS_LINUX}
  55. tls: meta ${BINS_TLS}
  56. meta: tags .gitignore
  57. # Binaries
  58. brot: brot.o ${GFX_OBJ}
  59. ${CC} ${LDFLAGS} $@.o ${GFX_OBJ} ${LDLIBS_${GFX}} -o $@
  60. gfxx: gfxx.o ${GFX_OBJ}
  61. ${CC} ${LDFLAGS} $@.o ${GFX_OBJ} ${LDLIBS_${GFX}} -o $@
  62. hi: hi.c
  63. ${CC} ${CFLAGS} ${LDFLAGS} hi.c ${LDLIBS} -o $@
  64. ./hi -c
  65. open pbcopy pbpaste: pbd
  66. ln -f pbd $@
  67. relay: relay.c
  68. ${CC} ${CFLAGS_tls} ${LDFLAGS_tls} $@.c ${LDLIBS_tls} -o $@
  69. # Headers
  70. brot.o gfxx.o gfx-cocoa.o gfx-fb.o gfx-x11.o: gfx.h
  71. fbatt.o fbclock.o: scheme.h
  72. gfxx.o psf2png.o scheme.o: png.h
  73. scheme.h: scheme
  74. ./scheme -c > scheme.h
  75. .o:
  76. ${CC} ${LDFLAGS} $< ${LDLIBS} -o $@
  77. # HTML
  78. HTMLS = index.html ${BINS:%=%.html} png.html
  79. WEBROOT = /usr/local/www/causal.agency
  80. html: ${HTMLS}
  81. @true
  82. ${HTMLS}: html.sh hi ttpre
  83. .SUFFIXES: .html
  84. .c.html:
  85. sh html.sh $< man1/${<:.c=.1} > $@
  86. .h.html:
  87. sh html.sh $< man3/${<:.h=.3} > $@
  88. .sh.html:
  89. sh html.sh $< man1/${<:.sh=.1} > $@
  90. .y.html:
  91. sh html.sh $< man1/${<:.y=.1} > $@
  92. index.html: Makefile bin.7
  93. sh html.sh Makefile bin.7 \
  94. | sed -E 's,([a-z0-9-]+)[(][1-9][)],<a href="\1.html">&</a>,' \
  95. > index.html
  96. # Meta
  97. README: bin.7
  98. mandoc bin.7 | col -bx > README
  99. scheme.png: scheme
  100. ./scheme -gt > scheme.png
  101. tags: *.h *.c
  102. ctags -w *.h *.c
  103. IGNORE = '*.o' '*.html' scheme.h scheme.png tags ${BINS} ${LINKS}
  104. .gitignore: Makefile
  105. echo config.mk ${IGNORE} | tr ' ' '\n' | sort > .gitignore
  106. clean:
  107. rm -f ${IGNORE}
  108. # Install
  109. link:
  110. install -d ${PREFIX}/bin ${MANDIR}/man1
  111. ln -fs ${BINS:%=${PWD}/%} ${LINKS:%=${PWD}/%} ${PREFIX}/bin
  112. ln -fs ${MANS:%=${PWD}/%} ${MANDIR}/man1
  113. unlink:
  114. rm -f ${BINS:%=${PREFIX}/bin/%} ${LINKS:%=${PREFIX}/bin/%}
  115. rm -f ${MANS:%=${MANDIR}/%}
  116. install-html: ${HTMLS}
  117. install -d ${WEBROOT}/bin
  118. install -C -m 644 ${HTMLS} ${WEBROOT}/bin
  119. setuid: bri
  120. chown root bri
  121. chmod u+s bri