diff options
author | June McEnroe <june@causal.agency> | 2020-03-01 19:20:23 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-03-01 21:14:52 -0500 |
commit | c876c88c2ac74255fa402c441343e8314d1fff8f (patch) | |
tree | e6420b0a64c4e8ef9709d129b3ce2a11b484602a | |
parent | Advertise STS policy (diff) | |
download | pounce-c876c88c2ac74255fa402c441343e8314d1fff8f.tar.gz pounce-c876c88c2ac74255fa402c441343e8314d1fff8f.zip |
Replace .mk files with configure script
Copied and expanded from catgirl.
-rw-r--r-- | Darwin.mk | 2 | ||||
-rw-r--r-- | Linux.mk | 6 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | README.7 | 51 | ||||
-rw-r--r-- | bounce.c | 4 | ||||
-rw-r--r-- | bounce.h | 4 | ||||
-rwxr-xr-x | configure | 43 |
7 files changed, 80 insertions, 37 deletions
diff --git a/Darwin.mk b/Darwin.mk deleted file mode 100644 index 42ba483..0000000 --- a/Darwin.mk +++ /dev/null @@ -1,2 +0,0 @@ -LIBRESSL_PREFIX = /usr/local/opt/libressl -LDLIBS := ${LDLIBS:-lcrypt=} diff --git a/Linux.mk b/Linux.mk deleted file mode 100644 index fff0c8a..0000000 --- a/Linux.mk +++ /dev/null @@ -1,6 +0,0 @@ -CFLAGS += -D_GNU_SOURCE -D'CERTBOT_PATH="/etc/letsencrypt"' -LDLIBS_calico = -lcrypto - -MANDIR = ${PREFIX}/share/man -RCS = -DIRS = diff --git a/Makefile b/Makefile index de08e06..597534e 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,8 @@ PREFIX = /usr/local -MANDIR = ${PREFIX}/man +MANDIR = ${PREFIX}/share/man ETCDIR = ${PREFIX}/etc -LIBRESSL_PREFIX = /usr/local -LIBRESSL_BIN_PREFIX = ${LIBRESSL_PREFIX:%=%/bin} CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -CFLAGS += ${LIBRESSL_PREFIX:%=-I%/include} -CFLAGS += ${LIBRESSL_BIN_PREFIX:%=-D'LIBRESSL_BIN_PREFIX="%/"'} -LDFLAGS += ${LIBRESSL_PREFIX:%=-L%/lib} LDLIBS = -lcrypt -lcrypto -ltls BINS = calico pounce diff --git a/README.7 b/README.7 index 1508628..225a7a7 100644 --- a/README.7 +++ b/README.7 @@ -1,4 +1,4 @@ -.Dd January 17, 2020 +.Dd March 1, 2020 .Dt README 7 .Os "Causal Agency" . @@ -15,24 +15,6 @@ and the IRCv3.2 .Sy server-time extension to communicate with clients. . -.Pp -.Nm -requires LibreSSL -.Pq Fl ltls -and targets -.Fx . -It can also be built -on Darwin or GNU/Linux -by copying the appropriate file to -.Pa config.mk -and modifying as needed. -On -.Fx , -processes are sandboxed with -.Xr capsicum 4 . -On other systems, -who knows what might happen? -. .Sh RATIONALE As a former .Xr znc 1 @@ -58,6 +40,37 @@ extension, all events can be accurately replayed, rather than being limited to messages. . +.Sh INSTALLING +.Nm +requires LibreSSL +.Pq Fl ltls +and primarily targets +.Fx , +as well as macOS and Linux. +On +.Fx , +processes are sandboxed with +.Xr capsicum 4 . +On other systems, +who knows what might happen? +. +.Bd -literal -offset indent +\&./configure +make all +sudo make install PREFIX=/usr/local +.Ed +. +.Pp +If your system installs LibreSSL +in a non-standard path, set +.Ev PKG_CONFIG_PATH +for +.Nm ./configure . +For example, +.Bd -literal -offset indent +PKG_CONFIG_PATH=/opt/libressl/lib/pkgconfig ./configure +.Ed +. .Sh FILES .Bl -tag -width "dispatch.c" -compact .It Pa bounce.h diff --git a/bounce.c b/bounce.c index efcc59d..604830a 100644 --- a/bounce.c +++ b/bounce.c @@ -58,7 +58,7 @@ static void genKey(const char *path) { char subj[256]; snprintf(subj, sizeof(subj), "/CN=%.*s", (int)strcspn(name, "."), name); execlp( - LIBRESSL_BIN_PREFIX "openssl", "openssl", "req", + OPENSSL_BIN, "openssl", "req", "-x509", "-new", "-newkey", "rsa:4096", "-sha256", "-days", "3650", "-nodes", "-subj", subj, "-keyout", path, NULL @@ -97,7 +97,7 @@ static void genCert(const char *path, const char *ca) { close(rw[1]); redir(STDIN_FILENO, rw[0]); execlp( - LIBRESSL_BIN_PREFIX "openssl", "openssl", "x509", + OPENSSL_BIN, "openssl", "x509", "-CA", ca, "-CAcreateserial", "-days", "3650", NULL ); diff --git a/bounce.h b/bounce.h index ffbd24b..a5dc836 100644 --- a/bounce.h +++ b/bounce.h @@ -27,8 +27,8 @@ #define CERTBOT_PATH "/usr/local/etc/letsencrypt" #endif -#ifndef LIBRESSL_BIN_PREFIX -#define LIBRESSL_BIN_PREFIX +#ifndef OPENSSL_BIN +#define OPENSSL_BIN "openssl" #endif #define SOURCE_URL "https://git.causal.agency/pounce" diff --git a/configure b/configure new file mode 100755 index 0000000..7d1e424 --- /dev/null +++ b/configure @@ -0,0 +1,43 @@ +#!/bin/sh +set -eu + +case "$(uname)" in + (FreeBSD) + if ! pkg info -e libressl; then + echo 'LibreSSL required' + exit 1 + fi + prefix=$(pkg query '%p' libressl) + cat >config.mk <<-EOF + MANDIR = \${PREFIX}/man + CFLAGS += -I${prefix}/include + CFLAGS += -D'OPENSSL_BIN="${prefix}/bin/openssl"' + LDFLAGS += -L${prefix}/lib + EOF + exit + ;; +esac + +libs='libcrypto libtls' +pkg-config --print-errors $libs + +cat >config.mk <<EOF +CFLAGS += $(pkg-config --cflags $libs) +CFLAGS += -D'OPENSSL_BIN="$(pkg-config --variable=prefix openssl)/bin/openssl"' +LDFLAGS += $(pkg-config --libs-only-L $libs) +LDLIBS = -lcrypt $(pkg-config --libs-only-l $libs) +EOF + +case "$(uname)" in + (Darwin) + echo 'LDLIBS := ${LDLIBS:-lcrypt=}' >>config.mk + ;; + (Linux) + cat >>config.mk <<-EOF + CFLAGS += -D_GNU_SOURCE -D'CERTBOT_PATH="/etc/letsencrypt"' + LDLIBS_calico = $(pkg-config --libs-only-l libcrypto) + RCS = + DIRS = + EOF + ;; +esac |