Skip to content

Commit

Permalink
build: don't tie platform detection to architecture detection (dashpa…
Browse files Browse the repository at this point in the history
…y#53)

* build: don't tie platform detection to architecture detection

* build: add support for unknown 32-bit and 64-bit architectures

* build: don't continue silently, display error if unable to determine supported architecture

* build: make rng selection, FP_QNRES definition behavior match CMakeLists

* build: ensure that OPSYS is always defined, add android, [free/net]bsd
  • Loading branch information
kwvg committed Nov 20, 2022
1 parent 1011d11 commit 66ee820
Showing 1 changed file with 84 additions and 50 deletions.
134 changes: 84 additions & 50 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ AC_DEFINE([ARM], [3], [ARM 32-bit architecture.])
AC_DEFINE([X86], [4], [Intel x86-compatible 32-bit architecture.])
AC_DEFINE([X64], [5], [AMD64-compatible 64-bit architecture.])

dnl Relic: Generic options
AC_DEFINE([RELIC_NONE], [0], [Unknown or unrecognized parameter.])

dnl Relic: Arithmetic backends
AC_DEFINE([EASY], [1], [Easy C-only backend.])
AC_DEFINE([GMP], [2], [Backend based on GNU Multiple Precision library.])
Expand Down Expand Up @@ -209,9 +212,11 @@ dnl AC_DEFINE([RDRND], [2], [Intel RdRand instruction.])
dnl AC_DEFINE([UDEV], [3], [Operating system underlying generator.])
AC_DEFINE([WCGR], [4], [Use Windows' CryptGenRandom.])

AC_DEFINE([SINGLE], [0], [A multiple precision integer can store w words.])
AC_DEFINE([CARRY], [1], [A multiple precision integer can store the result of an addition.])
AC_DEFINE([DOUBLE], [2], [A multiple precision integer can store the result of a multiplication.])
dnl Relic (BN): Options for the multiple precision
AC_DEFINE([SINGLE], [1], [A multiple precision integer can store w words.])
AC_DEFINE([CARRY], [2], [A multiple precision integer can store the result of an addition.])
AC_DEFINE([DOUBLE], [3], [A multiple precision integer can store the result of a multiplication.])

AC_DEFINE([BASIC], [1], [Basic method.])
AC_DEFINE([PRIME], [1], [Prime curves.])
AC_DEFINE([TATEP], [1], [Tate pairing.])
Expand Down Expand Up @@ -330,25 +335,56 @@ AC_ARG_ENABLE([big_endian],
[use_big_endian=no])

if test x$use_big_endian = xyes; then
AC_DEFINE([BIGED], [0], [Define this symbol if big-endian support is enabled])
AC_DEFINE([BIGED], [1], [Define this symbol if big-endian support is enabled])
fi

use_pkgconfig=yes

case $host_cpu in
x86_64)
dnl Support for AMD64 (also known as x86_64 on some platforms) processors
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
;;
aarch*)
dnl Relic doesn't support aarch64 yet, set CPU_ARCH to none.
dnl Support for 64-bit ARM processors
CPU_ARCH="none"
AC_DEFINE([ARCH], [ARM], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
;;
i?86)
dnl Support for Intel x86 processors
CPU_ARCH="x86"
AC_DEFINE([ARCH], [X86], [Architecture.])
AC_DEFINE([WSIZE], [32], [Size of word in this architecture.])
;;
arm*)
dnl Support for 32-bit native ARM processors
CPU_ARCH="arm"
AC_DEFINE([ARCH], [ARM], [Architecture.])
AC_DEFINE([WSIZE], [32], [Size of word in this architecture.])
;;
*32*)
dnl Support for an undefined 32-bit architecture
CPU_ARCH="none"
AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.])
AC_DEFINE([WSIZE], [32], [Size of word in this architecture.])
;;
*64*)
dnl Support for an undefined 64-bit architecture
CPU_ARCH="none"
AC_DEFINE([ARCH], [RELIC_NONE], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
;;
*)
AC_MSG_ERROR([Unable to determine host architecture, may not be supported!])
;;
esac

case $host in
*darwin*)
case $host_cpu in
x86_64)
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
;;
aarch*)
CPU_ARCH="none"
AC_DEFINE([ARCH], [ARM], [Architecture.])
;;
esac
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.])
AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.])
AC_DEFINE([OPSYS], [MACOSX], [Detected operation system.])
AC_PATH_PROG([BREW],brew,)
if test x$BREW != x; then
Expand All @@ -370,41 +406,8 @@ case $host in
fi
fi
;;
*linux*)
AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.])
AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.])
AC_DEFINE([OPSYS], [LINUX], [Detected operation system.])
RELIC_CPPFLAGS="-D_GNU_SOURCE"
case $host_cpu in
x86_64)
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
;;
i?86)
CPU_ARCH="x86"
AC_DEFINE([ARCH], [X86], [Architecture.])
AC_DEFINE([WSIZE], [32], [Size of word in this architecture.])
;;
arm*)
CPU_ARCH="arm"
AC_DEFINE([ARCH], [ARM], [Architecture.])
AC_DEFINE([WSIZE], [32], [Size of word in this architecture.])
;;
aarch*)
dnl Relic doesn't support aarch64 yet, set CPU_ARCH to none.
CPU_ARCH="none"
AC_DEFINE([ARCH], [ARM], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
;;
esac
;;
*mingw*)
use_pkgconfig=no
CPU_ARCH="x64"
AC_DEFINE([ARCH], [X64], [Architecture.])
AC_DEFINE([WSIZE], [64], [Size of word in this architecture.])
AC_DEFINE([SEED], [WCGR], [Chosen random generator seeder.])
AC_DEFINE([OPSYS], [WINDOWS], [Detected operation system.])
LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"

Expand All @@ -416,6 +419,37 @@ case $host in
archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
postdeps_CXX=
;;
*linux*)
AC_DEFINE([OPSYS], [LINUX], [Detected operation system.])
RELIC_CPPFLAGS="-D_GNU_SOURCE"
;;
*android*)
AC_DEFINE([OPSYS], [DROID], [Detected operation system.])
;;
*freebsd*)
AC_DEFINE([OPSYS], [FREEBSD], [Detected operation system.])
;;
*netbsd*)
AC_DEFINE([OPSYS], [NETBSD], [Detected operation system.])
;;
*)
AC_DEFINE([OPSYS], [RELIC_NONE], [Detected operation system.])
;;
esac

case $host in
*darwin*)
dnl Relic: Don't define FP_QNRES on Darwin
AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.])
;;
*mingw*)
AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.])
AC_DEFINE([SEED], [WCGR], [Chosen random generator seeder.])
;;
*)
AC_DEFINE([FP_QNRES], [], [Use -1 as quadratic non-residue.])
AC_DEFINE([SEED], [UDEV], [Chosen random generator seeder.])
;;
esac

if test x$use_pkgconfig = xyes; then
Expand Down

0 comments on commit 66ee820

Please sign in to comment.