INCLUDE(FindArch.cmake) INCLUDE(AsmOp.cmake) TARGET_ARCHITECTURE(ARCH) SET(CHACHASRC ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/chacha.c ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/ref.c) SET(POLYSRC ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/poly1305.c) SET(SIPHASHSRC ${CMAKE_CURRENT_SOURCE_DIR}/siphash/siphash.c ${CMAKE_CURRENT_SOURCE_DIR}/siphash/ref.c) SET(BLAKE2SRC ${CMAKE_CURRENT_SOURCE_DIR}/blake2/blake2.c ${CMAKE_CURRENT_SOURCE_DIR}/blake2/ref.c) SET(CURVESRC ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/ref.c ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/curve25519.c) # For now we support only x86_64 architecture with optimizations IF("${ARCH}" STREQUAL "x86_64") SET(ASM_CODE "vpaddq %ymm0, %ymm0, %ymm0") ASM_OP(HAVE_AVX2 "avx2") SET(ASM_CODE "vpaddq %xmm0, %xmm0, %xmm0") ASM_OP(HAVE_AVX "avx") SET(ASM_CODE "pmuludq %xmm0, %xmm0") ASM_OP(HAVE_SSE2 "sse2") SET(ASM_CODE "lddqu 0(%esi), %xmm0") ASM_OP(HAVE_SSE3 "sse3") SET(ASM_CODE "pshufb %xmm0, %xmm0") ASM_OP(HAVE_SSSE3 "ssse3") SET(ASM_CODE "pblendw \$0, %xmm0, %xmm0") ASM_OP(HAVE_SSE41 "sse41") SET(ASM_CODE " .macro TEST1 op \\op %eax, %eax .endm TEST1 xorl ") ASM_OP(HAVE_SLASHMACRO "slash macro convention") SET(ASM_CODE " .macro TEST1 op $0 %eax, %eax .endm TEST1 xorl ") ASM_OP(HAVE_DOLLARMACRO "dollar macro convention") if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/ref-64.c) SET(CURVESRC ${CURVESRC} ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/curve25519-donna-c64.c) else() SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/ref-32.c) SET(CURVESRC ${CURVESRC} ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/curve25519-donna.c) endif() SET(BLAKE2SRC ${BLAKE2SRC} ${CMAKE_CURRENT_SOURCE_DIR}/blake2/x86-64.S) ELSEIF("${ARCH}" STREQUAL "i386") SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/ref-32.c) SET(CURVESRC ${CURVESRC} ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/curve25519-donna.c) SET(BLAKE2SRC ${BLAKE2SRC} ${CMAKE_CURRENT_SOURCE_DIR}/blake2/x86-32.S) ELSE() SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/ref-32.c) ENDIF() IF(HAVE_AVX2) SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx2.S) SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/avx2.S) ENDIF(HAVE_AVX2) IF(HAVE_AVX) SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/avx.S) SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/avx.S) SET(CURVESRC ${CURVESRC} ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/avx.S ${CMAKE_CURRENT_SOURCE_DIR}/curve25519/avx.c) SET(BLAKE2SRC ${BLAKE2SRC} ${CMAKE_CURRENT_SOURCE_DIR}/blake2/avx.S) ENDIF(HAVE_AVX) IF(HAVE_SSE2) SET(CHACHASRC ${CHACHASRC} ${CMAKE_CURRENT_SOURCE_DIR}/chacha20/sse2.S) SET(POLYSRC ${POLYSRC} ${CMAKE_CURRENT_SOURCE_DIR}/poly1305/sse2.S) ENDIF(HAVE_SSE2) IF(HAVE_SSE41) SET(SIPHASHSRC ${SIPHASHSRC} ${CMAKE_CURRENT_SOURCE_DIR}/siphash/sse41.S) ENDIF(HAVE_SSE41) CONFIGURE_FILE(platform_config.h.in platform_config.h) INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") SET(LIBCRYPTOBOXSRC ${CMAKE_CURRENT_SOURCE_DIR}/cryptobox.c) SET(RSPAMD_CRYPTOBOX ${LIBCRYPTOBOXSRC} ${CHACHASRC} ${POLYSRC} ${SIPHASHSRC} ${CURVESRC} ${BLAKE2SRC} PARENT_SCOPE)