
AM_CPPFLAGS += \
  -I$(srcdir)/src/ext/ \
  -I$(srcdir)/src/ext/equix/hashx/include/

EXTRA_DIST += src/ext/ext.md

EXTHEADERS = \
  src/ext/ht.h \
  src/ext/byteorder.h \
  src/ext/tinytest.h \
  src/ext/tor_readpassphrase.h \
  src/ext/strlcat.c \
  src/ext/strlcpy.c \
  src/ext/getdelim.c \
  src/ext/tinytest_macros.h \
  src/ext/tor_queue.h \
  src/ext/siphash.h \
  src/ext/compat_blake2.h \
  src/ext/timeouts/timeout.h \
  src/ext/timeouts/timeout-debug.h \
  src/ext/timeouts/timeout-bitops.c \
  src/ext/timeouts/timeout.c

noinst_HEADERS+= $(EXTHEADERS)

src_ext_ed25519_ref10_libed25519_ref10_a_CFLAGS=\
  @CFLAGS_CONSTTIME@

src_ext_ed25519_ref10_libed25519_ref10_a_SOURCES= \
	src/ext/ed25519/ref10/fe_0.c \
	src/ext/ed25519/ref10/fe_1.c \
	src/ext/ed25519/ref10/fe_add.c \
	src/ext/ed25519/ref10/fe_cmov.c \
	src/ext/ed25519/ref10/fe_copy.c \
	src/ext/ed25519/ref10/fe_frombytes.c \
	src/ext/ed25519/ref10/fe_invert.c \
	src/ext/ed25519/ref10/fe_isnegative.c \
	src/ext/ed25519/ref10/fe_isnonzero.c \
	src/ext/ed25519/ref10/fe_mul.c \
	src/ext/ed25519/ref10/fe_neg.c \
	src/ext/ed25519/ref10/fe_pow22523.c \
	src/ext/ed25519/ref10/fe_sq.c \
	src/ext/ed25519/ref10/fe_sq2.c \
	src/ext/ed25519/ref10/fe_sub.c \
	src/ext/ed25519/ref10/fe_tobytes.c \
	src/ext/ed25519/ref10/ge_add.c \
	src/ext/ed25519/ref10/ge_double_scalarmult.c \
	src/ext/ed25519/ref10/ge_frombytes.c \
	src/ext/ed25519/ref10/ge_madd.c \
	src/ext/ed25519/ref10/ge_msub.c \
	src/ext/ed25519/ref10/ge_p1p1_to_p2.c \
	src/ext/ed25519/ref10/ge_p1p1_to_p3.c \
	src/ext/ed25519/ref10/ge_p2_0.c \
	src/ext/ed25519/ref10/ge_p2_dbl.c \
	src/ext/ed25519/ref10/ge_p3_0.c \
	src/ext/ed25519/ref10/ge_p3_dbl.c \
	src/ext/ed25519/ref10/ge_p3_to_cached.c \
	src/ext/ed25519/ref10/ge_p3_to_p2.c \
	src/ext/ed25519/ref10/ge_p3_tobytes.c \
	src/ext/ed25519/ref10/ge_precomp_0.c \
	src/ext/ed25519/ref10/ge_scalarmult_base.c \
	src/ext/ed25519/ref10/ge_sub.c \
	src/ext/ed25519/ref10/ge_tobytes.c \
	src/ext/ed25519/ref10/keypair.c \
	src/ext/ed25519/ref10/open.c \
	src/ext/ed25519/ref10/sc_muladd.c \
	src/ext/ed25519/ref10/sc_reduce.c \
	src/ext/ed25519/ref10/sign.c \
	src/ext/ed25519/ref10/keyconv.c \
	src/ext/ed25519/ref10/blinding.c

ED25519_REF10_HDRS = \
	src/ext/ed25519/ref10/api.h \
	src/ext/ed25519/ref10/base.h \
	src/ext/ed25519/ref10/base2.h \
	src/ext/ed25519/ref10/crypto_hash_sha512.h \
	src/ext/ed25519/ref10/crypto_int32.h \
	src/ext/ed25519/ref10/crypto_int64.h \
	src/ext/ed25519/ref10/crypto_sign.h \
	src/ext/ed25519/ref10/crypto_uint32.h \
	src/ext/ed25519/ref10/crypto_uint64.h \
	src/ext/ed25519/ref10/crypto_verify_32.h \
	src/ext/ed25519/ref10/d.h \
	src/ext/ed25519/ref10/d2.h \
	src/ext/ed25519/ref10/ed25519_ref10.h \
	src/ext/ed25519/ref10/fe.h \
	src/ext/ed25519/ref10/ge.h \
	src/ext/ed25519/ref10/ge_add.h \
	src/ext/ed25519/ref10/ge_madd.h \
	src/ext/ed25519/ref10/ge_msub.h \
	src/ext/ed25519/ref10/ge_p2_dbl.h \
	src/ext/ed25519/ref10/ge_sub.h \
	src/ext/ed25519/ref10/pow22523.h \
	src/ext/ed25519/ref10/pow225521.h \
	src/ext/ed25519/ref10/randombytes.h \
	src/ext/ed25519/ref10/sc.h \
	src/ext/ed25519/ref10/sqrtm1.h

noinst_HEADERS += $(ED25519_REF10_HDRS)

LIBED25519_REF10=src/ext/ed25519/ref10/libed25519_ref10.a
noinst_LIBRARIES += $(LIBED25519_REF10)

src_ext_ed25519_donna_libed25519_donna_a_CFLAGS=\
  @CFLAGS_CONSTTIME@ \
  -DED25519_CUSTOMRANDOM \
  -DED25519_CUSTOMHASH \
  -DED25519_SUFFIX=_donna

src_ext_ed25519_donna_libed25519_donna_a_SOURCES= \
	src/ext/ed25519/donna/ed25519_tor.c

ED25519_DONNA_HDRS = \
	src/ext/ed25519/donna/curve25519-donna-32bit.h \
	src/ext/ed25519/donna/curve25519-donna-64bit.h \
	src/ext/ed25519/donna/curve25519-donna-helpers.h \
	src/ext/ed25519/donna/curve25519-donna-sse2.h \
	src/ext/ed25519/donna/ed25519-donna-32bit-sse2.h \
	src/ext/ed25519/donna/ed25519-donna-32bit-tables.h \
	src/ext/ed25519/donna/ed25519-donna-64bit-sse2.h \
	src/ext/ed25519/donna/ed25519-donna-64bit-tables.h \
	src/ext/ed25519/donna/ed25519-donna-64bit-x86-32bit.h \
	src/ext/ed25519/donna/ed25519-donna-64bit-x86.h \
	src/ext/ed25519/donna/ed25519-donna-basepoint-table.h \
	src/ext/ed25519/donna/ed25519-donna-batchverify.h \
	src/ext/ed25519/donna/ed25519-donna.h \
	src/ext/ed25519/donna/ed25519-donna-impl-base.h \
	src/ext/ed25519/donna/ed25519-donna-impl-sse2.h \
	src/ext/ed25519/donna/ed25519-donna-portable.h \
	src/ext/ed25519/donna/ed25519-donna-portable-identify.h \
	src/ext/ed25519/donna/ed25519_donna_tor.h \
	src/ext/ed25519/donna/ed25519.h \
	src/ext/ed25519/donna/ed25519-hash-custom.h \
	src/ext/ed25519/donna/ed25519-hash.h \
	src/ext/ed25519/donna/ed25519-randombytes-custom.h \
	src/ext/ed25519/donna/ed25519-randombytes.h \
	src/ext/ed25519/donna/modm-donna-32bit.h \
	src/ext/ed25519/donna/modm-donna-64bit.h \
	src/ext/ed25519/donna/regression.h \
	src/ext/ed25519/donna/test-ticks.h \
	src/ext/ed25519/donna/test-internals.c

noinst_HEADERS += $(ED25519_DONNA_HDRS)

LIBED25519_DONNA=src/ext/ed25519/donna/libed25519_donna.a
noinst_LIBRARIES += $(LIBED25519_DONNA)

src_ext_equix_libhashx_a_CPPFLAGS = \
	-I$(srcdir)/src/ext/equix/hashx/include/ \
	-I$(srcdir)/src/ext/equix/hashx/src/ \
	-DHASHX_SIZE=@HASHX_SIZE@ \
	-DEQUIX_STATIC=1 -DHASHX_STATIC=1

src_ext_equix_libhashx_a_SOURCES = \
	src/ext/equix/hashx/src/blake2.c \
	src/ext/equix/hashx/src/compiler.c \
	src/ext/equix/hashx/src/compiler_a64.c \
	src/ext/equix/hashx/src/compiler_x86.c \
	src/ext/equix/hashx/src/context.c \
	src/ext/equix/hashx/src/hashx.c \
	src/ext/equix/hashx/src/program.c \
	src/ext/equix/hashx/src/program_exec.c \
	src/ext/equix/hashx/src/siphash.c \
	src/ext/equix/hashx/src/siphash_rng.c \
	src/ext/equix/hashx/src/virtual_memory.c

src_ext_equix_libequix_a_CPPFLAGS = \
	-I$(srcdir)/src/ext/equix/include/ \
	-I$(srcdir)/src/ext/equix/src/ \
	$(src_ext_equix_libhashx_a_CPPFLAGS)

src_ext_equix_libequix_a_SOURCES = \
	src/ext/equix/src/context.c \
	src/ext/equix/src/equix.c \
	src/ext/equix/src/solver.c

EQUIX_HDRS = \
	src/ext/equix/hashx/include/hashx.h \
	src/ext/equix/hashx/src/blake2.h \
	src/ext/equix/hashx/src/compiler.h \
	src/ext/equix/hashx/src/context.h \
	src/ext/equix/hashx/src/force_inline.h \
	src/ext/equix/hashx/src/hashx_endian.h \
	src/ext/equix/hashx/src/instruction.h \
	src/ext/equix/hashx/src/program.h \
	src/ext/equix/hashx/src/siphash_rng.h \
	src/ext/equix/hashx/src/siphash.h \
	src/ext/equix/hashx/src/unreachable.h \
	src/ext/equix/hashx/src/virtual_memory.h \
	src/ext/equix/include/equix.h \
	src/ext/equix/src/context.h \
	src/ext/equix/src/solver_heap.h \
	src/ext/equix/src/solver.h

EQUIX_LIBS = \
    src/ext/equix/libhashx.a \
    src/ext/equix/libequix.a

noinst_HEADERS += $(EQUIX_HDRS)
noinst_LIBRARIES += $(EQUIX_LIBS)

if BUILD_KECCAK_TINY
src_ext_keccak_tiny_libkeccak_tiny_a_CFLAGS=\
  @CFLAGS_CONSTTIME@

src_ext_keccak_tiny_libkeccak_tiny_a_SOURCES= \
	src/ext/keccak-tiny/keccak-tiny-unrolled.c

LIBKECCAK_TINY_HDRS = \
	src/ext/keccak-tiny/keccak-tiny.h

noinst_HEADERS += $(LIBKECCAK_TINY_HDRS)

LIBKECCAK_TINY=src/ext/keccak-tiny/libkeccak-tiny.a
noinst_LIBRARIES += $(LIBKECCAK_TINY)
endif

src_ext_polyval_libpolyval_a_CFLAGS=\
  @CFLAGS_CONSTTIME@
src_ext_polyval_libpolyval_a_SOURCES= \
   src/ext/polyval/polyval.c

POLYVAL_HDRS = \
   src/ext/polyval/polyval.h \
   src/ext/polyval/pclmul.c \
   src/ext/polyval/ctmul64.c \
   src/ext/polyval/ctmul.c

noinst_HEADERS += $(POLYVAL_HDRS)
LIBPOLYVAL=src/ext/polyval/libpolyval.a
noinst_LIBRARIES += $(LIBPOLYVAL)

EXTRA_DIST += \
	src/ext/timeouts/bench/bench-add.lua 		\
	src/ext/timeouts/bench/bench-aux.lua		\
	src/ext/timeouts/bench/bench.c			\
	src/ext/timeouts/bench/bench-del.lua		\
	src/ext/timeouts/bench/bench-expire.lua		\
	src/ext/timeouts/bench/bench.h			\
	src/ext/timeouts/bench/bench-heap.c		\
	src/ext/timeouts/bench/bench-llrb.c		\
	src/ext/timeouts/bench/bench.plt		\
	src/ext/timeouts/bench/bench-wheel.c		\
	src/ext/timeouts/bench/Rules.mk			\
	src/ext/timeouts/lua/Rules.mk			\
	src/ext/timeouts/lua/timeout-lua.c		\
	src/ext/timeouts/Makefile			\
	src/ext/timeouts/Rules.shrc			\
	src/ext/timeouts/test-timeout.c
