2020-02-07 04:49:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
|
2020-07-23 20:28:38 +00:00
|
|
|
cflags() {
|
|
|
|
echo "CFLAGS += $*"
|
|
|
|
}
|
|
|
|
defstr() {
|
|
|
|
cflags "-D'$1=\"$2\"'"
|
|
|
|
}
|
|
|
|
defvar() {
|
|
|
|
defstr "$1" "$(pkg-config --variable=$3 $2)${4:-}"
|
|
|
|
}
|
2021-05-04 16:09:46 +00:00
|
|
|
ldadd() {
|
|
|
|
lib=$1; shift
|
|
|
|
echo "LDADD.${lib} = $*"
|
|
|
|
}
|
|
|
|
config() {
|
|
|
|
pkg-config --print-errors "$@"
|
|
|
|
cflags $(pkg-config --cflags "$@")
|
|
|
|
for lib; do ldadd $lib $(pkg-config --libs $lib); done
|
|
|
|
}
|
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
|
|
|
|
;;
|
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
|