From a466e9abd9d847a4cffd570ffec3874ed172572c Mon Sep 17 00:00:00 2001 From: Shravan Mishra Date: Thu, 23 Feb 2017 12:51:14 -0500 Subject: [PATCH] Enable openssl and gmp dir to be specified --- configure.ac | 33 ++++++++++++++++++++++++++++++--- m4/macros/with.m4 | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 m4/macros/with.m4 diff --git a/configure.ac b/configure.ac index c11b253a1..5f98b649c 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_PROG_MKDIR_P AM_PROG_AS AM_INIT_AUTOMAKE([subdir-objects]) m4_include(m4/macros/enable-disable.m4) +m4_include(m4/macros/with.m4) LT_INIT([disable-shared]) AC_CHECK_SIZEOF([size_t]) # Checks for libraries. @@ -74,18 +75,44 @@ AM_CONDITIONAL([sidhiqc], [test "x$sidhiqc" = xtrue]) AM_CONDITIONAL([USE_SIDH_IQC], [test "x$sidhiqc" = xtrue]) + AM_CPPFLAGS="-g -std=gnu11 -Wpedantic -Wall -Wextra -DCONSTANT_TIME" AC_CANONICAL_HOST # Check for which host we are on and setup a few things # specifically based on the host case $host_os in darwin* ) - OPENSSL_DIR=/usr/local/opt/openssl - GMP_DIR=/usr/local/opt/ + AC_ARG_WITH( + [openssl-dir], + AS_HELP_STRING([--with-openssl-dir=dir],[openssl dir used locally (default /usr/local/opt/openssl).]), + [AC_DEFINE_UNQUOTED(OPENSSLDIR, [$withval], [OPENSSL DIR used locally]) + AC_SUBST(OPENSSL_DIR, [$withval])], + [AC_SUBST(OPENSSL_DIR, /usr/local/opt/openssl)] + ) + AC_ARG_WITH( + [gmp-dir], + AS_HELP_STRING([--with-gmp-dir=dir],[gmp dir used locally (default /usr/local/opt/).]), + [AC_DEFINE_UNQUOTED(GMPDIR, [$withval], [GMP DIR used locally]) + AC_SUBST(GMP_DIR, [$withval])], + [AC_SUBST(GMP_DIR, /usr/local/opt/)] + ) AM_CONDITIONAL([ON_DARWIN], [test xtrue = xtrue]) ;; linux*) - OPENSSL_DIR=/usr + 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( + [gmp-dir], + AS_HELP_STRING([--with-gmp-dir=dir],[gmp dir used locally (default /usr).]), + [AC_DEFINE_UNQUOTED(GMPDIR, [$withval], [GMP DIR used locally]) + AC_SUBST(GMP_DIR, [$withval])], + [AC_SUBST(GMP_DIR, /usr)] + ) if test x"${ac_cv_sizeof_size_t}" = x"8";then AM_CPPFLAGS=${AM_CPPFLAGS}" -DSIDH_ASM -march=x86-64" fi diff --git a/m4/macros/with.m4 b/m4/macros/with.m4 new file mode 100644 index 000000000..3852af0a1 --- /dev/null +++ b/m4/macros/with.m4 @@ -0,0 +1,24 @@ +# ARG_WITH_SUBST(option, default, help) +# ----------------------------------- +# Create a --with-$1 option with helptext, AC_SUBST($1) to $withval/default +AC_DEFUN([ARG_WITH_SUBST], + [AC_ARG_WITH( + [$1], + AS_HELP_STRING([--with-$1=arg], [$3 (default: $2).]), + [AC_SUBST(patsubst([$1], [-], [_]), ["$withval"])], + [AC_SUBST(patsubst([$1], [-], [_]), ["$2"])] + )] +) + +# ARG_WITH_SET(option, default, help) +# ----------------------------------- +# Create a --with-$1 option with helptext, set a variable $1 to $withval/default +AC_DEFUN([ARG_WITH_SET], + [AC_ARG_WITH( + [$1], + AS_HELP_STRING([--with-$1=arg], [$3 (default: $2).]), + patsubst([$1], [-], [_])="$withval", + patsubst([$1], [-], [_])=$2 + )] +) +