From f37ad399fe064056c438fb3f1103fe339e5fe9e5 Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Thu, 23 Jul 2020 16:28:38 -0400 Subject: Rewrite configure script for all platforms --- configure | 60 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 68fce73..d1f940d 100755 --- a/configure +++ b/configure @@ -1,26 +1,44 @@ #!/bin/sh set -eu -exec >config.mk - -if [ $# -gt 0 ]; then - echo 'warning: this script does not process arguments' >&2 -fi - -libs='libcrypto libtls ncursesw' +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:-}" +} -pkg-config --print-errors $libs -exec_prefix=$(pkg-config --variable=exec_prefix openssl) - -cat <config.mk -if [ "$(uname)" = 'Linux' ]; then - cat <<-EOF - CFLAGS += -D_GNU_SOURCE - EOF -fi +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 + config libcrypto libtls ncursesw + defvar OPENSSL_BIN openssl exec_prefix /bin/openssl + ;; + (*) + config libcrypto libtls ncursesw + defvar OPENSSL_BIN openssl exec_prefix /bin/openssl + ;; +esac -- cgit 1.4.1-2-gfad0