Consolidate configure options for OpenSSL

This commit is contained in:
Douglas Stebila 2019-07-05 15:12:32 -04:00
parent 745e630dae
commit 5d97502e9c
7 changed files with 62 additions and 36 deletions

View File

@ -9,7 +9,7 @@ matrix:
env:
- CC_OVERRIDE=gcc
- ENABLE_SIG_PICNIC=0
- USE_OPENSSL=1
- WITH_OPENSSL=1
- CHECK_STYLE=true
addons:
apt:
@ -67,7 +67,7 @@ matrix:
compiler: gcc
env:
- CC_OVERRIDE=gcc-6
- USE_OPENSSL=1
- WITH_OPENSSL=1
addons:
apt:
sources:
@ -84,8 +84,7 @@ matrix:
env:
- CC_OVERRIDE=clang
- AES_NI=0
- USE_OPENSSL=1
- OPENSSL_DIR=/usr/local/opt/openssl # openssl is a keg-only package
- WITH_OPENSSL=1
before_install:
- brew update
- brew install doxygen graphviz

View File

@ -33,11 +33,10 @@ source $(dirname $0)/defs.sh
# construct configure arguments
enable_disable_str=
if [[ ${USE_OPENSSL} == 1 ]];then
enable_disable_str=" --enable-openssl"
if [[ ! -z "${OPENSSL_DIR// }" ]];then
enable_disable_str+=" --with-openssl-dir=${OPENSSL_DIR}"
fi
if [[ ${WITH_OPENSSL} == 1 ]];then
enable_disable_str=" --with-openssl"
else
enable_disable_str=" --without-openssl"
fi
if [[ ${AES_NI} == 0 ]];then

View File

@ -134,7 +134,7 @@ Run the build system:
(If on macOS you encounter an error like `Can't exec "libtoolize": No such file or directory at ...`, try running with `LIBTOOLIZE=glibtoolize autoreconf -i`.)
You can enable/disable various algorithms at compile-time, tell liboqs to use OpenSSL for certain crypto algorithms, and more; see `./configure --help`. (In particular, on macOS, you might want to point liboqs to brew's version of OpenSSL, via the command: `./configure --enable-openssl --with-openssl-dir=/usr/local/opt/openssl`.)
You can enable/disable various algorithms at compile-time, tell liboqs to use OpenSSL for certain crypto algorithms, and more; see `./configure --help`.
### Build results

View File

@ -1,17 +1,49 @@
# Checks for libraries.
AC_DEFUN([ADD_EXTERNAL_LIB],
[AC_ARG_WITH(
[openssl-dir],
AS_HELP_STRING([--with-openssl-dir=dir],[openssl dir used locally (default /usr).]),
[AC_DEFINE_UNQUOTED(OPENSSLDIR, [$withval], [OPENSSL DIR used locally])
AC_SUBST(OPENSSL_DIR, [$withval])],
[AC_SUBST(OPENSSL_DIR, /usr)]
)]
[AC_ARG_WITH(
[m4ri-dir],
AS_HELP_STRING([--with-m4ri-dir=dir],[m4ri dir used locally (default /usr).]),
[AC_DEFINE_UNQUOTED(M4RIDIR, [$withval], [M4RI DIR used locally])
AC_SUBST(M4RI_DIR, [$withval])],
AC_DEFUN([ADD_EXTERNAL_LIB],[
AC_MSG_CHECKING([whether to use OpenSSL])
# define the --with-openssl option
AC_ARG_WITH([openssl],
[AS_HELP_STRING(
[--without-openssl],
[disable OpenSSL; use --with-openssl=dir to specify OpenSSL dir (default /usr or /usr/local/opt/openssl on macOS)]
)],
[with_openssl=$withval],
[with_openssl=default]
)
# platform-specific default directory
AS_IF(
[test "x${with_openssl}" = "xdefault"],
[AM_COND_IF(ON_DARWIN,
[with_openssl=/usr/local/opt/openssl],
[with_openssl=/usr]
)]
)
AS_IF(
[test "x${with_openssl}" = "xno"],
[AC_MSG_RESULT([no])],
[
AC_MSG_RESULT([${with_openssl}])
# set OPENSSL_DIR based on value provided
AC_SUBST([OPENSSL_DIR], [${with_openssl}])
]
)
# define automake conditional USE_OPENSSL
AM_CONDITIONAL(USE_OPENSSL, [test "x${with_openssl}" != "xno"])
# define C macro USE_OPENSSL
AM_COND_IF(USE_OPENSSL,
[AC_DEFINE(USE_OPENSSL, 1, [Defined to 1 if using OpenSSL in liboqs])]
)
AC_ARG_WITH([m4ri-dir],
[AS_HELP_STRING(
[--with-m4ri-dir=dir],
[m4ri dir used locally (default /usr)]
)],
[
AC_DEFINE_UNQUOTED(M4RIDIR, [$withval], [M4RI DIR used locally])
AC_SUBST(M4RI_DIR, [$withval])
],
[AC_SUBST(M4RI_DIR, /usr)]
)]
)
)
])

View File

@ -23,7 +23,7 @@ AC_DEFUN([ARG_ENABL_SET_WRAP],
AC_DEFUN([CONFIG_FEATURE_FLAGS],
[
#The flags are organizes according to features then cryptosystems.
# The flags are organized according to features then cryptosystems.
# The parameters are
# 1) Flag-name
@ -31,7 +31,6 @@ AC_DEFUN([CONFIG_FEATURE_FLAGS],
# 3) Compilation param name
# 4) Compilation directory
ARG_DISBL_SET_WRAP([aes-ni], [aes_ni], [USE_AES_NI])
ARG_ENABL_SET_WRAP([openssl], [openssl], [USE_OPENSSL])
AS_IF([test "x${enable_shared}" = "xyes" ], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]))
AM_CONDITIONAL([ENABLE_SHARED],[test "x${enable_shared}" = "xyes"])
@ -53,11 +52,8 @@ AC_DEFUN([CONFIG_FEATURE_FLAGS],
##### OQS_COPY_FROM_PQCLEAN_FRAGMENT_ARG_DISBL_SET_WRAP_END
ARG_DISBL_SET_WRAP([kem-frodokem], [kem_frodokem], [ENABLE_KEM_FRODOKEM], [src/kem/frodokem])
ARG_DISBL_SET_WRAP([kem-sike], [kem_sike], [ENABLE_KEM_SIKE], [src/kem/sike])
ARG_DISBL_SET_WRAP([sig-picnic], [sig_picnic],
[ENABLE_SIG_PICNIC], [src/sig/picnic])
ARG_DISBL_SET_WRAP([sig-qtesla], [sig_qtesla],
[ENABLE_SIG_QTESLA], [src/sig/qtesla])
ARG_DISBL_SET_WRAP([sig-picnic], [sig_picnic], [ENABLE_SIG_PICNIC], [src/sig/picnic])
ARG_DISBL_SET_WRAP([sig-qtesla], [sig_qtesla], [ENABLE_SIG_QTESLA], [src/sig/qtesla])
]
)

View File

@ -25,6 +25,9 @@ AC_DEFINE([OQS_MASTER_BRANCH],[],[liboqs branch])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([config])
# Detect the host CPU and x86 features that are available.
DETECT_HOST_AND_CPU
# Set paths to external libraries.
ADD_EXTERNAL_LIB
@ -42,9 +45,6 @@ AC_GENERAL_CHECKS
# DOXYGEN SUPPORT
CONFIG_DOXYGEN
# Detect the host CPU and x86 features that are availble.
DETECT_HOST_AND_CPU
# Configure the list of supported features
CONFIG_FEATURES

View File

@ -30,6 +30,6 @@ hacks=(
CFLAGS=-D_ARM_ # Several files aren't using the right define
)
./configure --disable-shared --enable-static --host="${CHOST}" --build="$CBUILD" CC="${CHOST}-gcc" --with-openssl-dir="${PREFIX}" "${hacks[@]}"
./configure --disable-shared --enable-static --host="${CHOST}" --build="$CBUILD" CC="${CHOST}-gcc" --with-openssl="${PREFIX}" "${hacks[@]}"
make -j
make -j check LDFLAGS="-L${PREFIX}/lib -static"