Rewrite configure script for all platforms

master
C. McEnroe 2020-07-23 16:28:38 -04:00
parent 5873d8b5a7
commit f37ad399fe
3 changed files with 44 additions and 35 deletions

View File

@ -1,9 +1,6 @@
PREFIX ?= /usr/local PREFIX ?= /usr/local
MANDIR ?= ${PREFIX}/share/man MANDIR ?= ${PREFIX}/share/man
CFLAGS += -I${PREFIX}/include
LDFLAGS += -L${PREFIX}/lib
CEXTS = gnu-case-range gnu-conditional-omitted-operand CEXTS = gnu-case-range gnu-conditional-omitted-operand
CFLAGS += -std=c11 -Wall -Wextra -Wpedantic ${CEXTS:%=-Wno-%} CFLAGS += -std=c11 -Wall -Wextra -Wpedantic ${CEXTS:%=-Wno-%}
LDLIBS = -lncursesw -ltls LDLIBS = -lncursesw -ltls

View File

@ -1,4 +1,4 @@
.Dd July 8, 2020 .Dd July 23, 2020
.Dt README 7 .Dt README 7
.Os "Causal Agency" .Os "Causal Agency"
.\" To view this file, run: man ./README.7 .\" To view this file, run: man ./README.7
@ -86,17 +86,11 @@ requires LibreSSL
.Pq Fl ltls .Pq Fl ltls
and ncurses and ncurses
.Pq Fl lncursesw . .Pq Fl lncursesw .
It primarily targets It targets
.Fx , .Fx ,
.Ox .Ox ,
and macOS, macOS
as well as Linux. and Linux.
The
.Pa configure
step is not necessary on
.Fx
or
.Ox .
On On
.Ox , .Ox ,
additionally set additionally set

60
configure vendored
View File

@ -1,26 +1,44 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
cflags() {
echo "CFLAGS += $*"
}
ldlibs() {
echo "LDLIBS ${o:-}= $*"
o=+
}
config() {
pkg-config --print-errors "$@"
cflags $(pkg-config --cflags "$@")
ldlibs $(pkg-config --libs "$@")
}
defstr() {
cflags "-D'$1=\"$2\"'"
}
defvar() {
defstr "$1" "$(pkg-config --variable=$3 $2)${4:-}"
}
exec >config.mk exec >config.mk
if [ $# -gt 0 ]; then case "$(uname)" in
echo 'warning: this script does not process arguments' >&2 (FreeBSD)
fi ldlibs -lncursesw
config libtls
libs='libcrypto libtls ncursesw' defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
;;
pkg-config --print-errors $libs (OpenBSD)
exec_prefix=$(pkg-config --variable=exec_prefix openssl) ldlibs -lncursesw -ltls
defstr OPENSSL_BIN /usr/bin/openssl
cat <<EOF ;;
CFLAGS += $(pkg-config --cflags $libs) (Linux)
CFLAGS += -D'OPENSSL_BIN="${exec_prefix}/bin/openssl"' cflags -Wno-pedantic -D_GNU_SOURCE
LDFLAGS += $(pkg-config --libs-only-L $libs) config libcrypto libtls ncursesw
LDLIBS = $(pkg-config --libs-only-l $libs) defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
EOF ;;
(*)
if [ "$(uname)" = 'Linux' ]; then config libcrypto libtls ncursesw
cat <<-EOF defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
CFLAGS += -D_GNU_SOURCE ;;
EOF esac
fi