# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root

BUILT_SOURCES+= ctaocrypt/src/fips.c
BUILT_SOURCES+= ctaocrypt/src/fips_test.c
BUILT_SOURCES+= wolfcrypt/src/async.c
BUILT_SOURCES+= wolfcrypt/src/fips.c
BUILT_SOURCES+= wolfcrypt/src/fips_test.c
BUILT_SOURCES+= wolfcrypt/src/selftest.c
BUILT_SOURCES+= wolfcrypt/src/wolfcrypt_first.c
BUILT_SOURCES+= wolfcrypt/src/wolfcrypt_last.c

MAINTAINERCLEANFILES+= ctaocrypt/src/fips.c
MAINTAINERCLEANFILES+= ctaocrypt/src/fips_test.c
MAINTAINERCLEANFILES+= wolfcrypt/src/async.c
MAINTAINERCLEANFILES+= wolfcrypt/src/fips.c
MAINTAINERCLEANFILES+= wolfcrypt/src/fips_test.c
MAINTAINERCLEANFILES+= wolfcrypt/src/selftest.c
MAINTAINERCLEANFILES+= wolfcrypt/src/wolfcrypt_first.c
MAINTAINERCLEANFILES+= wolfcrypt/src/wolfcrypt_last.c

ctaocrypt/src/fips.c: Makefile
	touch $(srcdir)/$@

ctaocrypt/src/fips_test.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/async.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/fips.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/fips_test.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/selftest.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/wolfcrypt_first.c: Makefile
	touch $(srcdir)/$@

wolfcrypt/src/wolfcrypt_last.c: Makefile
	touch $(srcdir)/$@

if !BUILD_NO_LIBRARY
lib_LTLIBRARIES+= src/libwolfssl.la
endif
src_libwolfssl_la_SOURCES =
src_libwolfssl_la_LDFLAGS = ${AM_LDFLAGS} -no-undefined -version-info ${WOLFSSL_LIBRARY_VERSION}
src_libwolfssl_la_LIBADD = $(LIBM) $(LIB_ADD) $(LIB_STATIC_ADD)
src_libwolfssl_la_CFLAGS = -DBUILDING_WOLFSSL $(AM_CFLAGS)
src_libwolfssl_la_CPPFLAGS = -DBUILDING_WOLFSSL $(AM_CPPFLAGS)

# install the packaged IPP libraries
if BUILD_FAST_RSA

# Link needed IPP libraries
noinst_SCRIPTS+=IPP_links
IPP_links:
	@$(IPPLINK)

ippdir = $(libdir)
ipp_DATA = $(IPPLIBS)

include_HEADERS+=$(IPPHEADERS)
endif # BUILD_FAST_RSA

if BUILD_FIPS

if BUILD_FIPS_V1
# fips first  file
src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_first.c

src_libwolfssl_la_SOURCES += \
               ctaocrypt/src/hmac.c \
               ctaocrypt/src/random.c \
               ctaocrypt/src/sha256.c

if BUILD_RSA
src_libwolfssl_la_SOURCES += ctaocrypt/src/rsa.c
endif

if BUILD_AES
src_libwolfssl_la_SOURCES += ctaocrypt/src/aes.c
endif

if BUILD_DES3
src_libwolfssl_la_SOURCES += ctaocrypt/src/des3.c
endif

if BUILD_SHA
src_libwolfssl_la_SOURCES += ctaocrypt/src/sha.c
endif

if BUILD_SHA512
src_libwolfssl_la_SOURCES += ctaocrypt/src/sha512.c
endif

src_libwolfssl_la_SOURCES += ctaocrypt/src/fips.c
src_libwolfssl_la_SOURCES += ctaocrypt/src/fips_test.c

# fips last file
src_libwolfssl_la_SOURCES += ctaocrypt/src/wolfcrypt_last.c
endif

if BUILD_FIPS_V2
# FIPSv2 first file
src_libwolfssl_la_SOURCES += \
			   wolfcrypt/src/wolfcrypt_first.c

src_libwolfssl_la_SOURCES += \
               wolfcrypt/src/hmac.c \
               wolfcrypt/src/random.c \
               wolfcrypt/src/sha256.c

if BUILD_RSA
src_libwolfssl_la_SOURCES += wolfcrypt/src/rsa.c
endif

if BUILD_ECC
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
endif

if BUILD_AES
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
if BUILD_ARMASM
if BUILD_FIPS_READY
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-aes.c
endif
endif
endif

if BUILD_AESNI
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_asm.S
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_gcm_asm.S
endif
endif

if BUILD_DES3
src_libwolfssl_la_SOURCES += wolfcrypt/src/des3.c
endif

if BUILD_SHA
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha.c
endif

if BUILD_ARMASM
if BUILD_FIPS_READY
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha256.c
endif
endif
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256_asm.S
endif

if BUILD_SHA512
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
if BUILD_ARMASM
if BUILD_FIPS_READY
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512-asm.S
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-sha512-asm.S
endif
endif
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512_asm.S
endif
endif

if BUILD_SHA3
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
endif

if BUILD_DH
src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
endif

if BUILD_CMAC
src_libwolfssl_la_SOURCES += wolfcrypt/src/cmac.c
endif

src_libwolfssl_la_SOURCES += wolfcrypt/src/fips.c \
                             wolfcrypt/src/fips_test.c

# fips last file
src_libwolfssl_la_SOURCES += wolfcrypt/src/wolfcrypt_last.c
endif

if BUILD_FIPS_RAND
src_libwolfssl_la_SOURCES += \
               wolfcrypt/src/wolfcrypt_first.c \
               wolfcrypt/src/hmac.c \
               wolfcrypt/src/random.c \
               wolfcrypt/src/sha256.c \
               wolfcrypt/src/sha256_asm.S \
               wolfcrypt/src/fips.c \
               wolfcrypt/src/fips_test.c \
               wolfcrypt/src/wolfcrypt_last.c
endif BUILD_FIPS_RAND

endif BUILD_FIPS

# For wolfRand, exclude everything else.
if !BUILD_FIPS_RAND

# For FIPSV2, exclude the wolfCrypt files included above.
# For wolfRand, exclude just a couple files.
# For old FIPS, keep the wolfCrypt versions of the
# CtaoCrypt files included above.
if !BUILD_FIPS_V2
src_libwolfssl_la_SOURCES += wolfcrypt/src/hmac.c
endif

# CAVP self test
if BUILD_SELFTEST
src_libwolfssl_la_SOURCES += wolfcrypt/src/selftest.c
endif

endif !BUILD_FIPS_RAND

src_libwolfssl_la_SOURCES += \
               wolfcrypt/src/hash.c \
               wolfcrypt/src/cpuid.c

if !BUILD_FIPS_RAND

if !BUILD_FIPS_V2
if BUILD_RNG
src_libwolfssl_la_SOURCES += wolfcrypt/src/random.c
endif
endif

if !BUILD_FIPS_V2
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha256.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256.c
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha256_asm.S
endif
endif
endif

if BUILD_AFALG
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_hash.c
endif

if BUILD_WOLFEVENT
src_libwolfssl_la_SOURCES += wolfcrypt/src/wolfevent.c
endif

if BUILD_ASYNCCRYPT
src_libwolfssl_la_SOURCES += wolfcrypt/src/async.c
endif

if !BUILD_USER_RSA
if BUILD_RSA
if BUILD_FAST_RSA
src_libwolfssl_la_SOURCES += wolfcrypt/user-crypto/src/rsa.c
else
if !BUILD_FIPS_V2
src_libwolfssl_la_SOURCES += wolfcrypt/src/rsa.c
endif
endif
endif
endif

if BUILD_RC2
src_libwolfssl_la_SOURCES += wolfcrypt/src/rc2.c
endif

if BUILD_SP
if BUILD_SP_C
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c32.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_c64.c
endif
if BUILD_SP_X86_64
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_x86_64.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_x86_64_asm.S
endif
if !BUILD_FIPS_V2
if BUILD_SP_ARM32
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm32.c
endif
endif
if BUILD_SP_ARM_THUMB
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_armthumb.c
endif
if !BUILD_FIPS_V2
if BUILD_SP_ARM64
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_arm64.c
endif
endif
if BUILD_SP_INT
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_int.c
endif
if BUILD_SP_ARM_CORTEX
src_libwolfssl_la_SOURCES += wolfcrypt/src/sp_cortexm.c
endif
endif

if !BUILD_FIPS_V2
if BUILD_AES
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes.c
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-aes.c
endif
if BUILD_AFALG
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_aes.c
endif
endif
endif

if !BUILD_FIPS_V2
if BUILD_CMAC
src_libwolfssl_la_SOURCES += wolfcrypt/src/cmac.c
endif
endif

if !BUILD_FIPS_V2
if BUILD_DES3
src_libwolfssl_la_SOURCES += wolfcrypt/src/des3.c
endif
endif

if !BUILD_FIPS_V2
if BUILD_SHA
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha.c
endif
endif

if !BUILD_FIPS_V2
if BUILD_SHA512
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-sha512-asm.S
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-sha512-asm.S
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512.c
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha512_asm.S
endif
endif
endif
endif

if !BUILD_FIPS_V2
if BUILD_SHA3
src_libwolfssl_la_SOURCES += wolfcrypt/src/sha3.c
endif
endif


endif !BUILD_FIPS_RAND

src_libwolfssl_la_SOURCES += \
               wolfcrypt/src/logging.c \
               wolfcrypt/src/wc_port.c \
               wolfcrypt/src/error.c

if !BUILD_FIPS_RAND
src_libwolfssl_la_SOURCES += \
               wolfcrypt/src/wc_encrypt.c \
               wolfcrypt/src/signature.c \
               wolfcrypt/src/wolfmath.c
endif !BUILD_FIPS_RAND

if BUILD_MEMORY
src_libwolfssl_la_SOURCES += wolfcrypt/src/memory.c
endif

if !BUILD_FIPS_RAND
if !BUILD_FIPS_V2
if BUILD_DH
src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
endif
endif

if BUILD_ASN
src_libwolfssl_la_SOURCES += wolfcrypt/src/asn.c
endif

endif !BUILD_FIPS_RAND

if BUILD_CODING
src_libwolfssl_la_SOURCES += wolfcrypt/src/coding.c
endif

if !BUILD_FIPS_RAND

if BUILD_POLY1305
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-poly1305.c
endif
src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305.c
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305_asm.S
endif
endif

if BUILD_RC4
src_libwolfssl_la_SOURCES += wolfcrypt/src/arc4.c
endif

if BUILD_MD4
src_libwolfssl_la_SOURCES += wolfcrypt/src/md4.c
endif

if BUILD_MD5
src_libwolfssl_la_SOURCES += wolfcrypt/src/md5.c
endif

if BUILD_PWDBASED
src_libwolfssl_la_SOURCES += wolfcrypt/src/pwdbased.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs12.c
endif

if BUILD_DSA
src_libwolfssl_la_SOURCES += wolfcrypt/src/dsa.c
endif

if !BUILD_FIPS_V2
if BUILD_AESNI
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_asm.S
src_libwolfssl_la_SOURCES += wolfcrypt/src/aes_gcm_asm.S
endif
endif

if BUILD_CAMELLIA
src_libwolfssl_la_SOURCES += wolfcrypt/src/camellia.c
endif

if BUILD_MD2
src_libwolfssl_la_SOURCES += wolfcrypt/src/md2.c
endif

if BUILD_RIPEMD
src_libwolfssl_la_SOURCES += wolfcrypt/src/ripemd.c
endif

if BUILD_BLAKE2
src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2b.c
endif
if BUILD_BLAKE2S
src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2s.c
endif

if BUILD_HC128
src_libwolfssl_la_SOURCES += wolfcrypt/src/hc128.c
endif

if BUILD_RABBIT
src_libwolfssl_la_SOURCES += wolfcrypt/src/rabbit.c
endif

if BUILD_CHACHA
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-chacha.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha.c
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha_asm.S
endif
endif
if BUILD_POLY1305
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha20_poly1305.c
endif
endif

if !BUILD_INLINE
src_libwolfssl_la_SOURCES += wolfcrypt/src/misc.c
endif

if BUILD_FASTMATH
src_libwolfssl_la_SOURCES += wolfcrypt/src/tfm.c
endif

if BUILD_SLOWMATH
src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
endif

if !BUILD_FIPS_V2
if BUILD_ECC
src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
endif
if BUILD_ECCSI
src_libwolfssl_la_SOURCES += wolfcrypt/src/eccsi.c
endif
if BUILD_SAKKE
src_libwolfssl_la_SOURCES += wolfcrypt/src/sakke.c
endif
endif

if BUILD_CURVE25519
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve25519.c
endif

if BUILD_ED25519
src_libwolfssl_la_SOURCES += wolfcrypt/src/ed25519.c
endif

if BUILD_FEMATH
if BUILD_CURVE25519_SMALL
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_low_mem.c
else
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_x25519_asm.S
else
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-curve25519.S
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-curve25519.S
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_operations.c
endif
endif
endif
endif

if BUILD_GEMATH
if BUILD_ED25519_SMALL
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_low_mem.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_operations.c
if !BUILD_FEMATH
if BUILD_INTELASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_x25519_asm.S
else
if BUILD_ARMASM
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/arm/armv8-curve25519.S
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_operations.c
endif
endif
endif
endif
endif

if BUILD_CURVE448
src_libwolfssl_la_SOURCES += wolfcrypt/src/curve448.c
endif

if BUILD_ED448
src_libwolfssl_la_SOURCES += wolfcrypt/src/ed448.c
endif

if BUILD_FE448
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_448.c
endif

if BUILD_GE448
src_libwolfssl_la_SOURCES += wolfcrypt/src/ge_448.c
if !BUILD_FE448
src_libwolfssl_la_SOURCES += wolfcrypt/src/fe_448.c
endif
endif

if BUILD_LIBZ
src_libwolfssl_la_SOURCES += wolfcrypt/src/compress.c
endif

if BUILD_PKCS7
src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs7.c
endif

if BUILD_SRP
src_libwolfssl_la_SOURCES += wolfcrypt/src/srp.c
endif

if BUILD_IDEA
src_libwolfssl_la_SOURCES += wolfcrypt/src/idea.c
endif

if BUILD_AFALG
src_libwolfssl_la_SOURCES += wolfcrypt/src/port/af_alg/wc_afalg.c
endif

if !BUILD_CRYPTONLY
# ssl files
src_libwolfssl_la_SOURCES += \
               src/internal.c \
               src/wolfio.c \
               src/keys.c \
               src/ssl.c \
               src/tls.c

if BUILD_TLS13
src_libwolfssl_la_SOURCES += src/tls13.c
endif

if BUILD_OCSP
src_libwolfssl_la_SOURCES += src/ocsp.c
endif

if BUILD_CRL
src_libwolfssl_la_SOURCES += src/crl.c
endif

if BUILD_SNIFFER
src_libwolfssl_la_SOURCES += src/sniffer.c
endif

endif !BUILD_CRYPTONLY

endif !BUILD_FIPS_RAND
