2020-02-06 23:49:27 -05:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
2020-07-23 16:28:38 -04: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 16:06:01 -04:00
|
|
|
|
2020-07-23 16:28:38 -04:00
|
|
|
exec >config.mk
|
2020-02-11 19:03:39 -05:00
|
|
|
|
2020-07-23 16:40:46 -04: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 16:28:38 -04:00
|
|
|
case "$(uname)" in
|
|
|
|
(FreeBSD)
|
|
|
|
ldlibs -lncursesw
|
|
|
|
config libtls
|
2020-08-06 16:12:45 -04:00
|
|
|
defstr OPENSSL_BIN /usr/bin/openssl
|
2020-07-23 16:28:38 -04:00
|
|
|
;;
|
|
|
|
(OpenBSD)
|
|
|
|
ldlibs -lncursesw -ltls
|
|
|
|
defstr OPENSSL_BIN /usr/bin/openssl
|
|
|
|
;;
|
|
|
|
(Linux)
|
|
|
|
cflags -Wno-pedantic -D_GNU_SOURCE
|
2020-07-30 13:37:54 -04:00
|
|
|
config libtls ncursesw
|
2020-07-23 16:28:38 -04:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
2020-07-30 13:36:17 -04:00
|
|
|
(Darwin)
|
|
|
|
cflags -D__STDC_WANT_LIB_EXT1__=1
|
|
|
|
cflags "-D'explicit_bzero(b,l)=memset_s((b),(l),0,(l))'"
|
2020-07-30 13:37:54 -04:00
|
|
|
config libtls ncursesw
|
2020-07-30 13:36:17 -04:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
2020-07-23 16:28:38 -04:00
|
|
|
(*)
|
2020-07-30 13:37:54 -04:00
|
|
|
config libtls ncursesw
|
2020-07-23 16:28:38 -04:00
|
|
|
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl
|
|
|
|
;;
|
|
|
|
esac
|