Browse Source

Fixing autoconf/autoheader usage

Enabling autoheader to actually work and adding initial check function
structure for detecting whether we're on z/OS with GSKSSL or on a system
which has OpenSSL.
master
David Lanzendörfer 10 months ago
parent
commit
a8f01c15f9
3 changed files with 177 additions and 63 deletions
  1. +88
    -0
      ax_check_gskssl.m4
  2. +4
    -3
      configure.ac
  3. +85
    -60
      include/netpgp/config.h.in

+ 88
- 0
ax_check_gskssl.m4 View File

@ -0,0 +1,88 @@
AU_ALIAS([CHECK_SSL], [AX_CHECK_GSKSSL])
AC_DEFUN([AX_CHECK_GSKSSL], [
found=false
AC_ARG_WITH(gskssl,
AS_HELP_STRING([--with-gskssl=DIR],
[root of the OpenSSL directory]),
[
case "$withval" in
"" | y | ye | yes | n | no)
AC_MSG_ERROR([Invalid --with-gskssl value])
;;
*) ssldirs="$withval"
;;
esac
], [
# if pkg-config is installed and gskssl has installed a .pc file,
# then use that information and don't search ssldirs
AC_PATH_PROG(PKG_CONFIG, pkg-config)
if test x"$PKG_CONFIG" != x""; then
GSKSSL_LDFLAGS=`$PKG_CONFIG gskssl --libs-only-L 2>/dev/null`
if test $? = 0; then
GSKSSL_LIBS=`$PKG_CONFIG gskssl --libs-only-l 2>/dev/null`
GSKSSL_INCLUDES=`$PKG_CONFIG gskssl --cflags-only-I 2>/dev/null`
found=true
fi
fi
# no such luck; use some default ssldirs
if ! $found; then
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
fi
]
)
# note that we #include <gskssl/foo.h>, so the OpenSSL headers have to be in
# an 'gskssl' subdirectory
if ! $found; then
GSKSSL_INCLUDES=
for ssldir in $ssldirs; do
AC_MSG_CHECKING([for gskssl/ssl.h in $ssldir])
if test -f "$ssldir/include/gskssl/ssl.h"; then
GSKSSL_INCLUDES="-I$ssldir/include"
GSKSSL_LDFLAGS="-L$ssldir/lib"
GSKSSL_LIBS="-lssl -lcrypto"
found=true
AC_MSG_RESULT([yes])
break
else
AC_MSG_RESULT([no])
fi
done
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
# it will just work!
fi
# try the preprocessor and linker with our new flags,
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
echo "Trying link with GSKSSL_LDFLAGS=$GSKSSL_LDFLAGS;" \
"GSKSSL_LIBS=$GSKSSL_LIBS; GSKSSL_INCLUDES=$GSKSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
LDFLAGS="$LDFLAGS $GSKSSL_LDFLAGS"
LIBS="$GSKSSL_LIBS $LIBS"
CPPFLAGS="$GSKSSL_INCLUDES $CPPFLAGS"
AC_LINK_IFELSE(
AC_LANG_PROGRAM([#include <gskssl/ssl.h>], [SSL_new(NULL)]),
[
AC_MSG_RESULT([yes])
$1
], [
AC_MSG_RESULT([no])
$2
])
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
AC_SUBST([GSKSSL_INCLUDES])
AC_SUBST([GSKSSL_LIBS])
AC_SUBST([GSKSSL_LDFLAGS])
])

+ 4
- 3
configure.ac View File

@ -10,7 +10,7 @@ AS_SHELL_SANITIZE
AC_CONFIG_SRCDIR([src/netpgp.c])
AC_CONFIG_AUX_DIR([buildaux])
AC_CONFIG_HEADER([src/config.h])
AC_CONFIG_HEADER([include/netpgp/config.h])
AM_INIT_AUTOMAKE([-Wall foreign])
AM_MAINTAINER_MODE
@ -75,9 +75,10 @@ AC_TYPE_UINT8_T
# check for openssl
m4_include([ax_check_openssl.m4])
m4_include([ax_check_gskssl.m4])
AX_CHECK_OPENSSL([LIBS="$LIBS $OPENSSL_LDFLAGS $OPENSSL_LIBS" INCLUDES="$INCLUDES $OPENSSL_INCLUDES"],
[AC_MSG_ERROR([Missing OpenSSL])])
AX_CHECK_OPENSSL([LIBS="$LIBS $OPENSSL_LDFLAGS $OPENSSL_LIBS" INCLUDES="$INCLUDES $OPENSSL_INCLUDES"])
AX_CHECK_GSKSSL([LIBS="$LIBS $OPENSSL_LDFLAGS $OPENSSL_LIBS" INCLUDES="$INCLUDES $OPENSSL_INCLUDES"])
CPPFLAGS="$CPPFLAGS $INCLUDES"


include/netpgp/config.h → include/netpgp/config.h.in View File


Loading…
Cancel
Save