2020-02-07 04:49:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
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:-}"
|
|
|
|
}
|
2020-06-11 20:06:01 +00:00
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
exec >config.mk
|
2020-02-12 00:03:39 +00:00
|
|
|
|
2020-07-23 20:40:46 +00:00
|
|
|
for opt; do
|
|
|
|
case "${opt}" in
|
|
|
|
(--prefix=*) echo "PREFIX = ${opt#*=}" ;;
|
|
|
|
(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
|
|
|
|
(*) echo "warning: unsupported option ${opt}" >&2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
case "$(uname)" in
|
|
|
|
(FreeBSD)
|
|
|
|
ldlibs -lncursesw
|
|
|
|
config libtls
|
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
|
|
|
(OpenBSD)
|
|
|
|
ldlibs -lncursesw -ltls
|
|
|
|
defstr OPENSSL_BIN /usr/bin/openssl
|
|
|
|
;;
|
|
|
|
(Linux)
|
|
|
|
cflags -Wno-pedantic -D_GNU_SOURCE
|
2020-07-30 17:37:54 +00:00
|
|
|
config libtls ncursesw
|
2020-07-23 20:28:38 +00:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
2020-07-30 17:36:17 +00:00
|
|
|
(Darwin)
|
|
|
|
cflags -D__STDC_WANT_LIB_EXT1__=1
|
|
|
|
cflags "-D'explicit_bzero(b,l)=memset_s((b),(l),0,(l))'"
|
2020-07-30 17:37:54 +00:00
|
|
|
config libtls ncursesw
|
2020-07-30 17:36:17 +00:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
2020-07-23 20:28:38 +00:00
|
|
|
(*)
|
2020-07-30 17:37:54 +00:00
|
|
|
config libtls ncursesw
|
2020-07-23 20:28:38 +00:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
|
|
|
esac
|