From 245b0cbb43e4f7745db1ef6a9082692be6a89053 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 20 May 2020 21:40:11 -0400 Subject: Rewrite build and install like pounce 1.3 man pages are no longer compressed! --- .gitignore | 6 +++--- Makefile | 44 ++++++++++++++++++++++++++++---------------- README.7 | 23 ++++++++++++----------- configure | 30 ++++++++---------------------- rc.d/litterbox | 51 --------------------------------------------------- rc.d/litterbox.in | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 103 deletions(-) delete mode 100644 rc.d/litterbox create mode 100644 rc.d/litterbox.in diff --git a/.gitignore b/.gitignore index 55b8a36..da7d199 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ *.o .test -/litterbox -/scoop -/unscoop config.mk +litterbox +scoop tags +unscoop diff --git a/Makefile b/Makefile index 96bd125..85eadc2 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,18 @@ -PREFIX = /usr/local -MANDIR = ${PREFIX}/share/man -ETCDIR = ${PREFIX}/etc +PREFIX ?= /usr/local +MANDIR ?= ${PREFIX}/share/man +ETCDIR ?= ${PREFIX}/etc + +CFLAGS += -I${PREFIX}/include +LDFLAGS += -L${PREFIX}/lib CFLAGS += -std=c11 -Wall -Wextra -Wpedantic LDLIBS = -lsqlite3 -LDLIBS.litterbox = -ltls +LDLIBS.litterbox = -lsqlite3 -ltls BINS = litterbox scoop unscoop MANS = ${BINS:=.1} -RCS = +RCS = rc.d/litterbox +INSTALLS = install-rcs -include config.mk @@ -20,10 +24,10 @@ dev: tags all test all: ${BINS} litterbox: ${OBJS.litterbox} - ${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS} ${LDLIBS.$@} -o $@ + ${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@ .o: - ${CC} ${LDFLAGS} $< ${LDLIBS} ${LDLIBS.$@} -o $@ + ${CC} ${LDFLAGS} $< ${LDLIBS} -o $@ ${BINS:=.o}: database.h @@ -33,19 +37,27 @@ test: .test set -e; for format in ${FORMATS}; do ./unscoop -n -f $$format; done touch .test +.SUFFIXES: .in + +.in: + sed -e 's|%%PREFIX%%|${PREFIX}|g' $< > $@ + tags: *.c *.h ctags -w *.c *.h clean: - rm -f .test tags ${BINS} ${OBJS.litterbox} ${BINS:=.o} + rm -f .test tags ${BINS} ${RCS} ${OBJS.litterbox} ${BINS:=.o} + +install: ${BINS} ${MANS} ${INSTALLS} + install -d ${DESTDIR}${PREFIX}/bin ${DESTDIR}${MANDIR}/man1 + install ${BINS} ${DESTDIR}${PREFIX}/bin + install -m 644 ${MANS} ${DESTDIR}${MANDIR}/man1 -install: ${BINS} ${MANS} - install -d ${PREFIX}/bin ${MANDIR}/man1 - install ${BINS} ${PREFIX}/bin - for man in ${MANS}; do gzip -c $$man > ${MANDIR}/man1/$$man.gz; done - if [ -n '${RCS}' ]; then install -d ${ETCDIR}/rc.d; fi - if [ -n '${RCS}' ]; then install ${RCS} ${ETCDIR}/rc.d; fi +install-rcs: ${RCS} + install -d ${DESTDIR}${ETCDIR}/rc.d + install ${RCS} ${DESTDIR}${ETCDIR}/rc.d uninstall: - rm -f ${BINS:%=${PREFIX}/bin/%} ${MANS:%=${MANDIR}/man1/%.gz} - if [ -n '${RCS}' ]; then rm -f ${RCS:%=${ETCDIR}/%}; fi + rm -f ${BINS:%=${DESTDIR}${PREFIX}/bin/%} + rm -f ${MANS:%=${DESTDIR}${MANDIR}/man1/%} + rm -f ${RCS:%=${DESTDIR}${ETCDIR}/%} diff --git a/README.7 b/README.7 index 3b76e5d..affd36a 100644 --- a/README.7 +++ b/README.7 @@ -19,29 +19,30 @@ as a logging bot. . .Pp .Nm -requires LibreSSL +targets +.Fx +and requires LibreSSL .Pq Fl ltls and SQLite .Pq Fl lsqlite3 . -It primarily targets -.Fx , -as well as macOS and Linux. -. .Bd -literal -offset indent -\&./configure make all sudo make install PREFIX=/usr/local .Ed . .Pp -If your system installs LibreSSL +On other systems, +such as macOS and Linux, +the build is configured using +.Xr pkg-config 1 . +If LibreSSL is installed in a non-standard path, set -.Ev PKG_CONFIG_PATH -for -.Nm ./configure . -For example, +.Ev PKG_CONFIG_PATH appropriately. +For example: .Bd -literal -offset indent PKG_CONFIG_PATH=/opt/libressl/lib/pkgconfig ./configure +make all +sudo make install PREFIX=/usr/local .Ed . .Sh FILES diff --git a/configure b/configure index 5e442ba..eafde4b 100755 --- a/configure +++ b/configure @@ -3,33 +3,19 @@ set -eu exec >config.mk -case "$(uname)" in - (FreeBSD) - if ! pkg info -e libressl || ! pkg info -e sqlite3; then - echo 'LibreSSL & SQLite3 required' >&2 - exit 1 - fi - prefix=$(pkg query '%p' sqlite3) - cat <<-EOF - CFLAGS += -I${prefix}/include - CFLAGS += -D'SQLITE3_BIN="${prefix}/bin/sqlite3"' - LDFLAGS += -L${prefix}/lib - RCS = rc.d/litterbox - EOF - exit - ;; - (Linux) - echo 'CFLAGS += -D_GNU_SOURCE' - ;; -esac - libs='libtls sqlite3' pkg-config --print-errors $libs cat < ${name} profile: ${profile}" - /usr/local/etc/rc.d/${name} "$1" "${profile}" || exit "$?" - done - exit - fi -fi - -child_flags=$litterbox_flags -child_user=$litterbox_user -unset litterbox_flags litterbox_user -command_args="\ - -r -P ${pidfile} -T ${name}${profile:+/${profile}} \ - ${child_user:+-u ${child_user}} \ - -- ${child_command} ${child_flags}" - -run_rc_command "$1" diff --git a/rc.d/litterbox.in b/rc.d/litterbox.in new file mode 100644 index 0000000..cc48092 --- /dev/null +++ b/rc.d/litterbox.in @@ -0,0 +1,51 @@ +#!/bin/sh + +# PROVIDE: litterbox +# REQUIRE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +name='litterbox' +rcvar='litterbox_enable' + +load_rc_config "${name}" + +: ${litterbox_enable:='NO'} + +command='/usr/sbin/daemon' +pidprefix="/var/run/${name}" +pidfile="${pidprefix}.pid" + +child_command='%%PREFIX%%/bin/litterbox' + +if [ -n "$2" ]; then + profile=$2 + if [ -n "${litterbox_profiles}" ]; then + pidfile="${pidprefix}.${profile}.pid" + eval litterbox_enable="\${litterbox_${profile}_enable:-${litterbox_enable}}" + eval litterbox_flags="\${litterbox_${profile}_flags:-${litterbox_flags}}" + eval litterbox_user="\${litterbox_${profile}_user:-${litterbox_user}}" + eval litterbox_env="\${litterbox_${profile}_env:-${litterbox_env}}" + else + echo "$0: extra argument ignored" + fi +else + if [ -n "${litterbox_profiles}" -a -n "$1" ]; then + for profile in ${litterbox_profiles}; do + echo "===> ${name} profile: ${profile}" + %%PREFIX%%/etc/rc.d/${name} "$1" "${profile}" || exit "$?" + done + exit + fi +fi + +child_flags=$litterbox_flags +child_user=$litterbox_user +unset litterbox_flags litterbox_user +command_args="\ + -r -P ${pidfile} -T ${name}${profile:+/${profile}} \ + ${child_user:+-u ${child_user}} \ + -- ${child_command} ${child_flags}" + +run_rc_command "$1" -- cgit 1.4.1