From 2eeee6aa48d249ce8f5afeebcac4789123b3ab1b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 3 Feb 2020 19:28:45 -0800 Subject: [PATCH] configure: Add submodule dependency for libpbc. --- .gitmodules | 7 ++++++ configure.ac | 58 ++++++++++++++++++++++++++++++++++++++++++++++- deps/pbc | 1 + tools/buildpbc.sh | 46 +++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 160000 deps/pbc create mode 100755 tools/buildpbc.sh diff --git a/.gitmodules b/.gitmodules index 8c65e8d57..cacb2f450 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,3 +8,10 @@ path = deps/gecko-dev url = https://github.com/mozilla/gecko-dev.git branch = esr45 +[submodule "pbc"] + path = pbc + url = https://github.com/blynn/pbc.git + branch = master +[submodule "deps/pbc"] + path = deps/pbc + url = https://github.com/blynn/pbc.git diff --git a/configure.ac b/configure.ac index c9cc9c8a4..25e4d5c5c 100644 --- a/configure.ac +++ b/configure.ac @@ -1476,6 +1476,61 @@ AC_CHECK_LIB([gmp], [__gmp_version], AM_CONDITIONAL([GMP], [test "x$have_gmp" = "xyes" ]) +dnl +dnl +dnl libpbc support +dnl +dnl + +AC_SUBST(PBC_CPPFLAGS, []) +AC_SUBST(PBC_LDFLAGS, []) +AC_SUBST(PBC_LIBS, []) + +AC_ARG_WITH(pbc-includes, +AC_HELP_STRING([--with-pbc-includes=[[[DIR]]]], [Path to libpbc include directory]), +[ + PBC_CPPFLAGS="-isystem $withval" +], []) + +AC_ARG_WITH(pbc-libs, +AC_HELP_STRING([--with-pbc-libs=[[[DIR]]]], [Path to libpbc library directory]), +[ + PBC_LDFLAGS="-L$withval" +], []) + +AC_MSG_CHECKING([whether you asked to use the Pairing-Based Cryptography library included here]) +AC_ARG_WITH(included-pbc, +AC_HELP_STRING([--with-included-pbc], [Use the libpbc sources from included submodule]), +[ + AC_MSG_RESULT([yes]) + have_pbc="yes" + with_included_pbc="yes" + AC_DEFINE(HAVE_PBC, 1, [Define to 1 if libpbc is available.]) + + PBC_CPPFLAGS="-isystem $PWD/deps/pbc/include" + PBC_LDFLAGS="-L$PWD/deps/pbc/" + PBC_LIBS="$PWD/deps/pbc/libpbc.a" + + bash tools/buildpbc.sh + AS_IF([ test $? != 0 ], + [ + AC_MSG_ERROR([Failed to build Pairing-Based Cryptography library included submodule]) + ]) +], [ + with_included_pbc="no" + AC_CHECK_LIB([pbc], [pbc_set_memory_functions], + [ + have_pbc="yes" + AC_DEFINE(HAVE_PBC, 1, [Define to 1 if libpbc is available.]) + PBC_LIBS="-lpbc" + ], [ + have_pbc="no" + AC_MSG_WARN([Unable to find Pairing-Based Cryptography (libpbc) on this system.]) + ]) +]) + +AM_CONDITIONAL([PBC], [test "x$have_pbc" = "xyes" ]) + dnl dnl dnl ImageMagick support @@ -2087,9 +2142,10 @@ echo "Ziplinks (libz) support ........... $have_zlib" echo "LZ4 support ....................... $have_lz4" echo "Snappy support .................... $have_snappy" echo "GNU MP support .................... $have_gmp" +echo "Crypto support .................... $have_crypto" echo "Sodium support .................... $have_sodium" echo "SSL support ....................... $have_ssl" -echo "Crypto support .................... $have_crypto" +echo "PBC support ....................... $have_pbc" echo "Magic support ..................... $have_magic" echo "ImageMagick support ............... $have_imagemagick" echo "LLVM library support .............. $have_libllvm" diff --git a/deps/pbc b/deps/pbc new file mode 160000 index 000000000..fbf458903 --- /dev/null +++ b/deps/pbc @@ -0,0 +1 @@ +Subproject commit fbf4589036ce4f662e2d06905862c9e816cf9d08 diff --git a/tools/buildpbc.sh b/tools/buildpbc.sh new file mode 100755 index 000000000..8cdfa43b5 --- /dev/null +++ b/tools/buildpbc.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +run () +{ + COMMAND=$1 + # check for empty commands + if test -z "$COMMAND" ; then + echo -e "\033[1;5;31mERROR\033[0m No command specified!" + return 1 + fi + + shift; + OPTIONS="$@" + # print a message + if test -n "$OPTIONS" ; then + echo -ne "\033[1m$COMMAND $OPTIONS\033[0m ... " + else + echo -ne "\033[1m$COMMAND\033[0m ... " + fi + + # run or die + $COMMAND $OPTIONS ; RESULT=$? + if test $RESULT -ne 0 ; then + echo -e "\033[1;5;31mERROR\033[0m $COMMAND failed. (exit code = $RESULT)" + exit 1 + fi + + echo -e "\033[0;32myes\033[0m" + return 0 +} + + +echo "*** Building The PBC Library... " + +USERDIR=$PWD # Save current dir and return to it later + +run git submodule update --init deps/pbc + +run cd deps/pbc +run git fetch --tags +run git checkout master +NJOBS=`nproc` +run bash ./setup +run bash ./configure +run make -j$NJOBS +run cd $USERDIR # Return to user's original directory