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

View File

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

View File

@ -1,17 +1,49 @@
# Checks for libraries. # Checks for libraries.
AC_DEFUN([ADD_EXTERNAL_LIB], AC_DEFUN([ADD_EXTERNAL_LIB],[
[AC_ARG_WITH(
[openssl-dir], AC_MSG_CHECKING([whether to use OpenSSL])
AS_HELP_STRING([--with-openssl-dir=dir],[openssl dir used locally (default /usr).]), # define the --with-openssl option
[AC_DEFINE_UNQUOTED(OPENSSLDIR, [$withval], [OPENSSL DIR used locally]) AC_ARG_WITH([openssl],
AC_SUBST(OPENSSL_DIR, [$withval])], [AS_HELP_STRING(
[AC_SUBST(OPENSSL_DIR, /usr)] [--without-openssl],
)] [disable OpenSSL; use --with-openssl=dir to specify OpenSSL dir (default /usr or /usr/local/opt/openssl on macOS)]
[AC_ARG_WITH( )],
[m4ri-dir], [with_openssl=$withval],
AS_HELP_STRING([--with-m4ri-dir=dir],[m4ri dir used locally (default /usr).]), [with_openssl=default]
[AC_DEFINE_UNQUOTED(M4RIDIR, [$withval], [M4RI DIR used locally]) )
AC_SUBST(M4RI_DIR, [$withval])], # 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)] [AC_SUBST(M4RI_DIR, /usr)]
)] )
) ])

View File

@ -23,7 +23,7 @@ AC_DEFUN([ARG_ENABL_SET_WRAP],
AC_DEFUN([CONFIG_FEATURE_FLAGS], 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 # The parameters are
# 1) Flag-name # 1) Flag-name
@ -31,7 +31,6 @@ AC_DEFUN([CONFIG_FEATURE_FLAGS],
# 3) Compilation param name # 3) Compilation param name
# 4) Compilation directory # 4) Compilation directory
ARG_DISBL_SET_WRAP([aes-ni], [aes_ni], [USE_AES_NI]) 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])) AS_IF([test "x${enable_shared}" = "xyes" ], AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]))
AM_CONDITIONAL([ENABLE_SHARED],[test "x${enable_shared}" = "xyes"]) 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 ##### 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-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([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-picnic], [sig_picnic], ARG_DISBL_SET_WRAP([sig-qtesla], [sig_qtesla], [ENABLE_SIG_QTESLA], [src/sig/qtesla])
[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_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([config]) AC_CONFIG_MACRO_DIRS([config])
# Detect the host CPU and x86 features that are available.
DETECT_HOST_AND_CPU
# Set paths to external libraries. # Set paths to external libraries.
ADD_EXTERNAL_LIB ADD_EXTERNAL_LIB
@ -42,9 +45,6 @@ AC_GENERAL_CHECKS
# DOXYGEN SUPPORT # DOXYGEN SUPPORT
CONFIG_DOXYGEN CONFIG_DOXYGEN
# Detect the host CPU and x86 features that are availble.
DETECT_HOST_AND_CPU
# Configure the list of supported features # Configure the list of supported features
CONFIG_FEATURES CONFIG_FEATURES

View File

@ -30,6 +30,6 @@ hacks=(
CFLAGS=-D_ARM_ # Several files aren't using the right define 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
make -j check LDFLAGS="-L${PREFIX}/lib -static" make -j check LDFLAGS="-L${PREFIX}/lib -static"