| 1 |
#!/bin/sh |
| 2 |
set -eu |
| 3 |
|
| 4 |
: ${PKG_CONFIG:=pkg-config} |
| 5 |
|
| 6 |
cflags() { |
| 7 |
echo "CFLAGS += $*" |
| 8 |
} |
| 9 |
defstr() { |
| 10 |
cflags "-D'$1=\"$2\"'" |
| 11 |
} |
| 12 |
defvar() { |
| 13 |
defstr "$1" "$(${PKG_CONFIG} --variable=$3 $2)${4:-}" |
| 14 |
} |
| 15 |
ldadd() { |
| 16 |
lib=$1; shift |
| 17 |
echo "LDADD.${lib} = $*" |
| 18 |
} |
| 19 |
config() { |
| 20 |
${PKG_CONFIG} --print-errors "$@" |
| 21 |
cflags $(${PKG_CONFIG} --cflags "$@") |
| 22 |
for lib; do ldadd $lib $(${PKG_CONFIG} --libs $lib); done |
| 23 |
} |
| 24 |
|
| 25 |
exec >config.mk |
| 26 |
|
| 27 |
for opt; do |
| 28 |
case "${opt}" in |
| 29 |
(--prefix=*) echo "PREFIX = ${opt#*=}" ;; |
| 30 |
(--bindir=*) echo "BINDIR = ${opt#*=}" ;; |
| 31 |
(--mandir=*) echo "MANDIR = ${opt#*=}" ;; |
| 32 |
(--enable-sandman) echo 'BINS += sandman' ;; |
| 33 |
(*) echo "warning: unsupported option ${opt}" >&2 ;; |
| 34 |
esac |
| 35 |
done |
| 36 |
|
| 37 |
case "$(uname)" in |
| 38 |
(FreeBSD) |
| 39 |
config libtls |
| 40 |
defstr OPENSSL_BIN /usr/bin/openssl |
| 41 |
;; |
| 42 |
(OpenBSD) |
| 43 |
defstr OPENSSL_BIN /usr/bin/openssl |
| 44 |
;; |
| 45 |
(Linux) |
| 46 |
cflags -Wno-pedantic -D_GNU_SOURCE |
| 47 |
config libtls ncursesw |
| 48 |
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl |
| 49 |
echo 'OBJS += compat_readpassphrase.o' |
| 50 |
;; |
| 51 |
(Darwin) |
| 52 |
cflags -D__STDC_WANT_LIB_EXT1__=1 |
| 53 |
cflags "-D'explicit_bzero(b,l)=memset_s((b),(l),0,(l))'" |
| 54 |
config libtls ncursesw |
| 55 |
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl |
| 56 |
;; |
| 57 |
(*) |
| 58 |
config libtls ncursesw |
| 59 |
defvar OPENSSL_BIN openssl exec_prefix /bin/openssl |
| 60 |
;; |
| 61 |
esac |