2020-02-07 04:49:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
2021-11-19 21:52:24 +00:00
|
|
|
: ${PKG_CONFIG:=pkg-config}
|
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
cflags() {
|
|
|
|
echo "CFLAGS += $*"
|
|
|
|
}
|
|
|
|
defstr() {
|
|
|
|
cflags "-D'$1=\"$2\"'"
|
|
|
|
}
|
|
|
|
defvar() {
|
2021-11-19 21:52:24 +00:00
|
|
|
defstr "$1" "$(${PKG_CONFIG} --variable=$3 $2)${4:-}"
|
2020-07-23 20:28:38 +00:00
|
|
|
}
|
2021-05-04 16:09:46 +00:00
|
|
|
ldadd() {
|
|
|
|
lib=$1; shift
|
|
|
|
echo "LDADD.${lib} = $*"
|
|
|
|
}
|
|
|
|
config() {
|
2021-11-19 21:52:24 +00:00
|
|
|
${PKG_CONFIG} --print-errors "$@"
|
|
|
|
cflags $(${PKG_CONFIG} --cflags "$@")
|
|
|
|
for lib; do ldadd $lib $(${PKG_CONFIG} --libs $lib); done
|
2021-05-04 16:09:46 +00:00
|
|
|
}
|
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#*=}" ;;
|
2021-05-04 16:09:46 +00:00
|
|
|
(--bindir=*) echo "BINDIR = ${opt#*=}" ;;
|
2020-07-23 20:40:46 +00:00
|
|
|
(--mandir=*) echo "MANDIR = ${opt#*=}" ;;
|
|
|
|
(*) echo "warning: unsupported option ${opt}" >&2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
case "$(uname)" in
|
|
|
|
(FreeBSD)
|
|
|
|
config libtls
|
2020-08-06 20:12:45 +00:00
|
|
|
defstr OPENSSL_BIN /usr/bin/openssl
|
2020-07-23 20:28:38 +00:00
|
|
|
;;
|
|
|
|
(OpenBSD)
|
|
|
|
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
|
2022-02-12 18:30:15 +00:00
|
|
|
echo 'OBJS += compat_readpassphrase.o'
|
2020-07-23 20:28:38 +00:00
|
|
|
;;
|
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
|