BIN(7) FreeBSD Miscellaneous Information Manual BIN(7)

bin
various utilities

Various tools primarily targeting Darwin, FreeBSD and OpenBSD. Some tools target Linux.

beef(1)
Befunge-93 interpreter
bibsort(1)
reformat bibliography
bit(1)
calculator
bri(1)
backlight brightness control
c(1)
run C statements
dtch(1)
detached sessions
ever(1)
watch files
fbatt(1)
framebuffer battery indicator
fbclock(1)
framebuffer clock
freecell(6)
patience game
glitch(1)
PNG glitcher
hilex(1)
syntax highlighter
htagml(1)
tags HTMLizer
modem(1)
fixed baud rate wrapper
mtags(1)
miscellaneous tags
nudge(1)
terminal vibrator
order(1)
operator precedence
pbd(1)
macOS pasteboard daemon
pngo(1)
PNG optimizer
psf2png(1)
PSF2 to PNG renderer
psfed(1)
PSF2 font editor
ptee(1)
tee for PTYs
relay(1)
IRC relay bot
scheme(1)
color scheme
shotty(1)
terminal capture
sup(1)
single-use passwords
title(1)
page titles
up(1)
upload file
when(1)
date calculator
xx(1)
hexdump

One piece of reused code.

png(3)
basic PNG output
April 26, 2021 Causal Agency

Makefile in git

PREFIX ?= ~/.local
MANDIR ?= ${PREFIX}/share/man

LIBS_PREFIX ?= /usr/local
CFLAGS += -I${LIBS_PREFIX}/include
LDFLAGS += -L${LIBS_PREFIX}/lib

CFLAGS += -Wall -Wextra -Wpedantic -Wno-gnu-case-range

BINS += beef
BINS += bibsort
BINS += bit
BINS += c
BINS += dtch
BINS += glitch
BINS += hilex
BINS += htagml
BINS += modem
BINS += mtags
BINS += nudge
BINS += order
BINS += pbd
BINS += pngo
BINS += psf2png
BINS += ptee
BINS += scheme
BINS += shotty
BINS += sup
BINS += title
BINS += up
BINS += when
BINS += xx

BSD += ever

GAMES += freecell

LINUX += bri
LINUX += fbatt
LINUX += fbclock
LINUX += psfed

TLS += relay
TLS += typer

MANS = ${BINS:%=man1/%.1}
MANS.BSD = ${BSD:%=man1/%.1}
MANS.GAMES = ${GAMES:%=man6/%.6}
MANS.LINUX = ${LINUX:%=man1/%.1}
MANS.TLS = ${TLS:%=man1/%.1}

LDLIBS.dtch = -lutil
LDLIBS.fbclock = -lz
LDLIBS.freecell = -lcurses
LDLIBS.glitch = -lz
LDLIBS.modem = -lutil
LDLIBS.pngo = -lz
LDLIBS.ptee = -lutil
LDLIBS.relay = -ltls
LDLIBS.scheme = -lm
LDLIBS.title = -lcurl
LDLIBS.typer = -ltls

ALL ?= meta any

-include config.mk

all: ${ALL}

meta: .gitignore tags

any: ${BINS}

bsd: ${BSD}

games: ${GAMES}

linux: ${LINUX}

tls: ${TLS}

IGNORE = *.o *.html
IGNORE += ${BINS} ${BSD} ${GAMES} ${LINUX} ${TLS}
IGNORE += scheme.h tags htmltags

.gitignore: Makefile
	echo config.mk '${IGNORE}' | tr ' ' '\n' | sort > $@

tags: *.[chly]
	ctags -w *.[chly]

clean:
	rm -f ${IGNORE}

install: ${ALL:%=install-%}

install-meta:
	install -d ${PREFIX}/bin ${MANDIR}/man1

install-any: install-meta ${BINS} ${MANS}
	install ${BINS} ${PREFIX}/bin
	install -m 644 ${MANS} ${MANDIR}/man1

install-bsd: install-meta ${BSD} ${MANS.BSD}
	install ${BSD} ${PREFIX}/bin
	install -m 644 ${MANS.BSD} ${MANDIR}/man1

install-games: install-meta ${GAMES} ${MANS.GAMES}
	install ${GAMES} ${PREFIX}/bin
	install -m 644 ${MANS.GAMES} ${MANDIR}/man6

install-linux: install-meta ${LINUX} ${MANS.LINUX}
	install ${LINUX} ${PREFIX}/bin
	install -m 644 ${MANS.LINUX} ${MANDIR}/man1

install-tls: install-meta ${TLS} ${MANS.TLS}
	install ${TLS} ${PREFIX}/bin
	install -m 644 ${MANS.TLS} ${MANDIR}/man1

uninstall:
	rm -f ${BINS:%=${PREFIX}/bin/%} ${MANS:%=${MANDIR}/%}
	rm -f ${BSD:%=${PREFIX}/bin/%} ${MANS.BSD:%=${MANDIR}/%}
	rm -f ${GAMES:%=${PREFIX}/bin/%} ${MANS.GAMES:%=${MANDIR}/%}
	rm -f ${LINUX:%=${PREFIX}/bin/%} ${MANS.LINUX:%=${MANDIR}/%}
	rm -f ${TLS:%=${PREFIX}/bin/%} ${MANS.TLS:%=${MANDIR}/%}

.SUFFIXES: .pl

.c:
	${CC} ${CFLAGS} ${LDFLAGS} $< ${LDLIBS.$@} -o $@

.o:
	${CC} ${LDFLAGS} $< ${LDLIBS.$@} -o $@

.pl:
	cp -f $< $@
	chmod a+x $@

OBJS.hilex = c11.o hilex.o make.o mdoc.o sh.o

hilex: ${OBJS.hilex}
	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@

${OBJS.hilex}: hilex.h

fbatt.o fbclock.o: scheme.h

psf2png.o scheme.o: png.h

scheme.h: scheme
	./scheme -c > $@

include html.mk

html.mk in git

WEBROOT ?= /usr/local/www/causal.agency

HTMLS = index.html png.html
HTMLS += ${BINS:=.html}
HTMLS += ${BSD:=.html}
HTMLS += ${GAMES:=.html}
HTMLS += ${LINUX:=.html}
HTMLS += ${TLS:=.html}

html: ${HTMLS}
	@true

install-html: ${HTMLS}
	install -d ${WEBROOT}/bin
	install -C -m 644 ${HTMLS} ${WEBROOT}/bin

${HTMLS}: html.sh scheme hilex htagml htmltags

htmltags: *.[chly] mtags Makefile html.mk *.sh
	rm -f $@
	for f in *.[chly]; do ctags -aw -f $@ $$f; done
	./mtags -a -f $@ Makefile html.mk *.sh

index.html: README.7 Makefile html.mk html.sh
	sh html.sh README.7 Makefile html.mk html.sh > $@

.SUFFIXES: .html

.c.html:
	sh html.sh man1/${<:.c=.1} $< > $@

.h.html:
	sh html.sh man3/${<:.h=.3} $< > $@

.y.html:
	sh html.sh man1/${<:.y=.1} $< > $@

.sh.html:
	sh html.sh man1/${<:.sh=.1} $< > $@

.pl.html:
	sh html.sh man1/${<:.pl=.1} $< > $@

freecell.html: freecell.c man6/freecell.6
	sh html.sh man6/freecell.6 freecell.c > $@

html.sh in git

#!/bin/sh
set -eu

readonly GitURL='https://git.causal.agency/src/tree/bin'

man=$1
shift
title=${man##*/}
title=${title%.[1-9]}

cat <<EOF
<!DOCTYPE html>
<meta charset="UTF-8">
<title>${title}</title>
<style>
html { line-height: 1.25em; font-family: monospace; }
body { max-width: 80ch; margin: 1em auto; padding: 0 1ch; }

table.head, table.foot { width: 100%; }
td.head-rtitle, td.foot-os { text-align: right; }
td.head-vol { text-align: center; }
div.Pp { margin: 1ex 0ex; }
div.Nd, div.Bf, div.Op { display: inline; }
span.Pa, span.Ad { font-style: italic; }
span.Ms { font-weight: bold; }
dl.Bl-diag > dt { font-weight: bold; }
code.Nm, code.Fl, code.Cm, code.Ic, code.In, code.Fd, code.Fn,
code.Cd { font-weight: bold; font-family: inherit; }

table { border-collapse: collapse; }
table.Nm code.Nm { padding-right: 1ch; }
table.foot { margin-top: 1em; }

ul.index { padding: 0; }
ul.index li { display: inline; list-style-type: none; }
pre { -moz-tab-size: 4; tab-size: 4; }

$(./scheme -st)
html { background-color: var(--ansi16); color: var(--ansi17); }
a { color: var(--ansi4); }
a:visited { color: var(--ansi5); }
a.permalink, a.tag { color: var(--ansi3); text-decoration: none; }
a.permalink > code:target, *:target > a.permalink,
a.tag:target { color: var(--ansi11); }
pre .Ke { color: var(--ansi7); }
pre .Ma { color: var(--ansi2); }
pre .Co { color: var(--ansi4); }
pre .St { color: var(--ansi6); }
pre .Fo { color: var(--ansi14); }
pre .Su { color: var(--ansi1); }
</style>
EOF

opts=fragment
[ "${man}" = "README.7" ] && opts=${opts},man=%N.html
mandoc -T html -O ${opts} "${man}"

for src; do
	cat <<-EOF
	<p>
	<a href="${GitURL}/${src}">${src} in git</a>
	EOF
	./htagml -x -f htmltags "${src}"
	./hilex -t -f html "${src}" | ./htagml -ip -f htmltags "${src}"
done