mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Update GNUmakefile-cross for feature tests (GH #741)
This commit is contained in:
parent
07209942a4
commit
92ae496c80
@ -541,7 +541,7 @@ ifeq ($(IS_ARMV8),1)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
SHA3_FLAG = -march=armv8.4-a+crypto
|
||||
endif
|
||||
|
||||
|
||||
# ASIMD_FLAG
|
||||
endif
|
||||
|
||||
|
@ -3,6 +3,14 @@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# If needed
|
||||
TMPDIR ?= /tmp
|
||||
# Used for ARMv7 and NEON.
|
||||
FP_ABI ?= hard
|
||||
# Used for feature tests
|
||||
TOUT ?= a.out
|
||||
TOUT := $(strip $(TOUT))
|
||||
|
||||
# Default CXXFLAGS if none were provided
|
||||
CXXFLAGS ?= -DNDEBUG -g2 -O3 -fPIC -pipe
|
||||
|
||||
@ -22,32 +30,11 @@ INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL)
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# Attempt to determine host machine, fallback to "this" machine.
|
||||
# The host machine is the one the package runs on. Most people
|
||||
# call this the "target", but not Autotools.
|
||||
HOSTX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | cut -f 1 -d '-')
|
||||
ifeq ($(HOSTX),)
|
||||
HOSTX := $(shell uname -m 2>/dev/null)
|
||||
endif
|
||||
|
||||
IS_i686 := $(shell echo "$HOSTX" | $(EGREP) -v 64 | $(EGREP) -i -c 'i.86')
|
||||
IS_x86_64 := $(shell echo "$HOSTX" | $(EGREP) -i -c 'x86_64|amd64')
|
||||
IS_ARM32 := $(shell echo "$(HOSTX)" | $(EGREP) -i -c -E 'arm|armhf|arm7l|eabihf')
|
||||
IS_ARMv8 := $(shell echo "$HOSTX" | $(EGREP) -i -c 'aarch32|aarch64')
|
||||
|
||||
GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -v -E '(llvm|clang)' | $(EGREP) -i -c -E '(gcc|g\+\+)')
|
||||
CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -i -c -E '(llvm|clang)')
|
||||
|
||||
IS_IOS ?= 0
|
||||
IS_ANDROID ?= 0
|
||||
IS_ARM_EMBEDDED ?= 0
|
||||
IS_NEON ?= 0
|
||||
|
||||
# Fixup ARM
|
||||
ifeq ($(IS_ARMv8),1)
|
||||
IS_ARM32 := 0
|
||||
endif
|
||||
|
||||
# Can be used by Android and Embeeded cross-compiles. Disable by default because
|
||||
# Android and embedded users typically don't run this configuration.
|
||||
HAS_SOLIB_VERSION ?= 0
|
||||
@ -83,14 +70,14 @@ endif
|
||||
|
||||
# We honor ARFLAGS, but the "v" option used by default causes a noisy make
|
||||
ifeq ($(ARFLAGS),rv)
|
||||
ARFLAGS = r
|
||||
ARFLAGS = r
|
||||
endif
|
||||
|
||||
# Sadly, we can't actually use GCC_PRAGMA_AWARE because of GCC bug 53431.
|
||||
# Its a shame because GCC has so much to offer by the way of analysis.
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
|
||||
ifneq ($(CLANG_COMPILER),0)
|
||||
CXXFLAGS += -Wall
|
||||
CXXFLAGS += -Wall
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
@ -147,6 +134,355 @@ ifeq ($(IS_ARM_EMBEDDED),1)
|
||||
CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
##### Compiler and Platform #####
|
||||
###########################################################
|
||||
|
||||
# Wait until CXXFLAGS have been set by setenv scripts
|
||||
|
||||
GCC_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -v -E '(llvm|clang)' | $(EGREP) -i -c -E '(gcc|g\+\+)')
|
||||
CLANG_COMPILER := $(shell $(CXX) --version 2>/dev/null | $(EGREP) -i -c -E '(llvm|clang)')
|
||||
|
||||
HOSTX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null | cut -f 1 -d '-')
|
||||
ifeq ($(HOSTX),)
|
||||
HOSTX := $(shell uname -m 2>/dev/null)
|
||||
endif
|
||||
|
||||
ifeq ($(CLANG_COMPILER),1)
|
||||
IS_X86 := $(shell echo $(CXXFLAGS) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'i.86')
|
||||
IS_X64 := $(shell echo $(CXXFLAGS) | $(EGREP) -i -c -E 'x86_64|amd64')
|
||||
IS_ARM32 := $(shell echo $(CXXFLAGS) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'arm|armhf|arm7l|eabihf')
|
||||
IS_ARMV8 := $(shell echo $(CXXFLAGS) | $(EGREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
|
||||
else
|
||||
IS_X86 := $(shell echo $(HOSTX) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'i.86')
|
||||
IS_X64 := $(shell echo $(HOSTX) | $(EGREP) -i -c -E 'x86_64|amd64')
|
||||
IS_ARM32 := $(shell echo $(HOSTX) | $(EGREP) -v 64 | $(EGREP) -i -c -E 'arm|armhf|arm7l|eabihf')
|
||||
IS_ARMV8 := $(shell echo $(HOSTX) | $(EGREP) -i -c -E 'aarch32|aarch64|arm64|armv8')
|
||||
endif
|
||||
|
||||
$(info Here's what we think is happening... IS_X86: $(IS_X86), IS_X64: $(IS_X64), IS_ARM32: $(IS_ARM32), IS_ARMV8: $(IS_ARMV8))
|
||||
|
||||
###########################################################
|
||||
##### Test Program #####
|
||||
###########################################################
|
||||
|
||||
# Hack to skip CPU feature tests for some recipes
|
||||
DETECT_FEATURES ?= 1
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),-DCRYPTOPP_DISABLE_ASM)
|
||||
DETECT_FEATURES := 0
|
||||
else ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
|
||||
DETECT_FEATURES := 0
|
||||
else ifeq ($(findstring distclean,$(MAKECMDGOALS)),distclean)
|
||||
DETECT_FEATURES := 0
|
||||
else ifeq ($(findstring distclean,$(MAKECMDGOALS)),trim)
|
||||
DETECT_FEATURES := 0
|
||||
endif
|
||||
|
||||
# Strip out -Wall, -Wextra and friends for feature testing
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
TCXXFLAGS := $(filter-out -Wall -Wextra -Werror -Wunused -Wconversion, $(CXXFLAGS))
|
||||
ifneq ($(strip $(TCXXFLAGS)),)
|
||||
$(info Using testing flags: $(TCXXFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
# For the previous messages
|
||||
$(info )
|
||||
|
||||
###########################################################
|
||||
##### X86/X32/X64 Options #####
|
||||
###########################################################
|
||||
|
||||
ifneq ($(IS_X86)$(IS_X64),00)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
SSE2_FLAG = -msse2
|
||||
SSE3_FLAG = -msse3
|
||||
SSSE3_FLAG = -mssse3
|
||||
SSE41_FLAG = -msse4.1
|
||||
SSE42_FLAG = -msse4.2
|
||||
CLMUL_FLAG = -mpclmul
|
||||
AESNI_FLAG = -maes
|
||||
AVX_FLAG = -mavx
|
||||
AVX2_FLAG = -mavx2
|
||||
SHANI_FLAG = -msha
|
||||
|
||||
TPROG = TestPrograms/test_x86_sse2.cxx
|
||||
TOPT = $(SSE2_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
CHACHA_FLAG = $(SSE2_FLAG)
|
||||
else
|
||||
SSE2_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_ssse3.cxx
|
||||
TOPT = $(SSSE3_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
ARIA_FLAG = $(SSSE3_FLAG)
|
||||
CHAM_FLAG = $(SSSE3_FLAG)
|
||||
LEA_FLAG = $(SSSE3_FLAG)
|
||||
SIMECK_FLAG = $(SSSE3_FLAG)
|
||||
SIMON64_FLAG = $(SSSE3_FLAG)
|
||||
SIMON128_FLAG = $(SSSE3_FLAG)
|
||||
SPECK64_FLAG = $(SSSE3_FLAG)
|
||||
SPECK128_FLAG = $(SSSE3_FLAG)
|
||||
else
|
||||
SSSE3_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_sse41.cxx
|
||||
TOPT = $(SSE41_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
BLAKE2B_FLAG = $(SSE41_FLAG)
|
||||
BLAKE2S_FLAG = $(SSE41_FLAG)
|
||||
SIMON64_FLAG = $(SSE41_FLAG)
|
||||
SPECK64_FLAG = $(SSE41_FLAG)
|
||||
else
|
||||
SSE41_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_sse42.cxx
|
||||
TOPT = $(SSE42_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
CRC_FLAG = $(SSE42_FLAG)
|
||||
else
|
||||
SSE42_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_clmul.cxx
|
||||
TOPT = $(CLMUL_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
GCM_FLAG = $(SSSE3_FLAG) $(CLMUL_FLAG)
|
||||
else
|
||||
CLMUL_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_aes.cxx
|
||||
TOPT = $(AESNI_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
AES_FLAG = $(SSE41_FLAG) $(AESNI_FLAG)
|
||||
SM4_FLAG = $(SSSE3_FLAG) $(AESNI_FLAG)
|
||||
else
|
||||
AESNI_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_avx.cxx
|
||||
TOPT = $(AVX_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
# XXX_FLAG = $(AVX_FLAG)
|
||||
else
|
||||
AVX_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_avx2.cxx
|
||||
TOPT = $(AVX2_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
CHACHA_AVX2_FLAG = $(AVX2_FLAG)
|
||||
else
|
||||
AVX2_FLAG =
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_x86_sha.cxx
|
||||
TOPT = $(SHANI_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
SHA_FLAG = $(SSE42_FLAG) $(SHANI_FLAG)
|
||||
else
|
||||
SHANI_FLAG =
|
||||
endif
|
||||
|
||||
ifeq ($(SSE2_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
|
||||
else ifeq ($(SSE3_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_SSE3
|
||||
else ifeq ($(SSSE3_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_SSSE3
|
||||
else ifeq ($(SSE41_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
|
||||
else ifeq ($(SSE42_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_SSE4
|
||||
endif
|
||||
|
||||
# Unusual GCC/Clang on Macports. It assembles AES, but not CLMUL.
|
||||
# test_x86_clmul.s:15: no such instruction: 'pclmulqdq $0, %xmm1,%xmm0'
|
||||
ifeq ($(CLMUL_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_CLMUL
|
||||
endif
|
||||
ifeq ($(AESNI_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_AESNI
|
||||
endif
|
||||
|
||||
ifneq ($(SSE42_FLAG),)
|
||||
ifeq ($(AVX_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_AVX
|
||||
else ifeq ($(AVX2_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_AVX2
|
||||
else ifeq ($(SHANI_FLAG),)
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_SHANI
|
||||
endif
|
||||
endif
|
||||
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# IS_X86, IS_X32 and IS_X64
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
##### ARM A-32, Aach64 and NEON #####
|
||||
###########################################################
|
||||
|
||||
ifneq ($(IS_ARM32)$(IS_ARMV8),00)
|
||||
ifeq ($(DETECT_FEATURES),1)
|
||||
|
||||
ifeq ($(IS_ARM32),1)
|
||||
|
||||
ifneq ($(IS_IOS)$(IS_ANDROID),00)
|
||||
NEON_FLAG =
|
||||
else
|
||||
NEON_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_neon.cxx
|
||||
TOPT = $(NEON_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
ARIA_FLAG = $(NEON_FLAG)
|
||||
AES_FLAG = $(NEON_FLAG)
|
||||
CRC_FLAG = $(NEON_FLAG)
|
||||
GCM_FLAG = $(NEON_FLAG)
|
||||
BLAKE2B_FLAG = $(NEON_FLAG)
|
||||
BLAKE2S_FLAG = $(NEON_FLAG)
|
||||
CHACHA_FLAG = $(NEON_FLAG)
|
||||
CHAM_FLAG = $(NEON_FLAG)
|
||||
LEA_FLAG = $(NEON_FLAG)
|
||||
SHA_FLAG = $(NEON_FLAG)
|
||||
SIMECK_FLAG = $(NEON_FLAG)
|
||||
SIMON64_FLAG = $(NEON_FLAG)
|
||||
SIMON128_FLAG = $(NEON_FLAG)
|
||||
SPECK64_FLAG = $(NEON_FLAG)
|
||||
SPECK128_FLAG = $(NEON_FLAG)
|
||||
SM4_FLAG = $(NEON_FLAG)
|
||||
else
|
||||
NEON_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_NEON
|
||||
endif
|
||||
|
||||
# IS_NEON
|
||||
endif
|
||||
|
||||
ifeq ($(IS_ARMV8),1)
|
||||
|
||||
ifeq ($(IS_IOS),1)
|
||||
ASIMD_FLAG =
|
||||
CRC_FLAG =
|
||||
AES_FLAG =
|
||||
PMUL_FLAG =
|
||||
SHA_FLAG =
|
||||
else
|
||||
ASIMD_FLAG = -march=armv8.1-a
|
||||
CRC_FLAG = -march=armv8.1-a+crc
|
||||
AES_FLAG = -march=armv8.1-a+crypto
|
||||
PMULL_FLAG = -march=armv8.1-a+crypto
|
||||
SHA_FLAG = -march=armv8.1-a+crypto
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_acle.cxx
|
||||
TOPT = $(ASIMD_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(TCXXFLAGS) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
ACLE_FLAG += -DCRYPTOPP_ARM_ACLE_AVAILABLE=1
|
||||
else
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_ACLE_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_asimd.cxx
|
||||
TOPT = $(ASIMD_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
ARIA_FLAG = $(ASIMD_FLAG)
|
||||
BLAKE2B_FLAG = $(ASIMD_FLAG)
|
||||
BLAKE2S_FLAG = $(ASIMD_FLAG)
|
||||
CHACHA_FLAG = $(ASIMD_FLAG)
|
||||
CHAM_FLAG = $(ASIMD_FLAG)
|
||||
LEA_FLAG = $(ASIMD_FLAG)
|
||||
NEON_FLAG = $(ASIMD_FLAG)
|
||||
SIMECK_FLAG = $(ASIMD_FLAG)
|
||||
SIMON64_FLAG = $(ASIMD_FLAG)
|
||||
SIMON128_FLAG = $(ASIMD_FLAG)
|
||||
SPECK64_FLAG = $(ASIMD_FLAG)
|
||||
SPECK128_FLAG = $(ASIMD_FLAG)
|
||||
SM4_FLAG = $(ASIMD_FLAG)
|
||||
else
|
||||
ASIMD_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_crc.cxx
|
||||
TOPT = $(CRC_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifneq ($(strip $(HAVE_OPT)),0)
|
||||
CRC_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_CRC32_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_aes.cxx
|
||||
TOPT = $(AES_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifneq ($(strip $(HAVE_OPT)),0)
|
||||
AES_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_AES_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_pmull.cxx
|
||||
TOPT = $(PMULL_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifneq ($(strip $(HAVE_OPT)),0)
|
||||
PMULL_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_PMULL_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_sha.cxx
|
||||
TOPT = $(SHA_FLAG)
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifneq ($(strip $(HAVE_OPT)),0)
|
||||
SHA_FLAG =
|
||||
CXXFLAGS += -DCRYPTOPP_ARM_SHA_AVAILABLE=0
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_sm3.cxx
|
||||
TOPT = -march=armv8.4-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
SM3_FLAG = -march=armv8.4-a+crypto
|
||||
SM4_FLAG = -march=armv8.4-a+crypto
|
||||
endif
|
||||
|
||||
TPROG = TestPrograms/test_arm_sha3.cxx
|
||||
TOPT = -march=armv8.4-a+crypto
|
||||
HAVE_OPT = $(shell $(CXX) $(CXXFLAGS) $(ACLE_FLAG) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT) 2>&1 | tr ' ' '\n' | wc -l)
|
||||
ifeq ($(strip $(HAVE_OPT)),0)
|
||||
SHA3_FLAG = -march=armv8.4-a+crypto
|
||||
SHA512_FLAG = -march=armv8.4-a+crypto
|
||||
endif
|
||||
|
||||
# IS_ARMV8
|
||||
endif
|
||||
|
||||
# DETECT_FEATURES
|
||||
endif
|
||||
|
||||
# IS_ARM32, IS_ARMV8, IS_NEON
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
##### Common #####
|
||||
###########################################################
|
||||
@ -234,147 +570,23 @@ ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
|
||||
endif # MAKECMDGOALS
|
||||
endif # Dead code stripping
|
||||
|
||||
# Pickup ARMv7 and NEON. Do it after Android, iOS and Embedded flags have been set.
|
||||
ifeq ($(IS_ARM32),1)
|
||||
IS_ARMv7 := $(shell $(CXX) $(CXXFLAGS) -dM -E pch.cpp 2>&1 | $(EGREP) -i -c '__ARM_ARCH 7')
|
||||
ifeq ($(IS_ARMv7),1)
|
||||
IS_NEON := 1
|
||||
else
|
||||
IS_NEON := $(shell $(CXX) $(CXXFLAGS) -dM -E pch.cpp 2>&1 | $(EGREP) -i -c -E '\<__ARM_NEON\>')
|
||||
endif
|
||||
endif
|
||||
|
||||
# ARMv7-a
|
||||
ifeq ($(IS_ARMv7),1)
|
||||
ifeq ($(findstring -march=armv7-a,$(CXXFLAGS)),)
|
||||
NEON_FLAG = -march=armv7-a
|
||||
GCM_FLAG = -march=armv7-a
|
||||
ARIA_FLAG = -march=armv7-a
|
||||
BLAKE2_FLAG = -march=armv7-a
|
||||
CHACHA_FLAG = -march=armv7-a
|
||||
LEA_FLAG = -march=armv7-a
|
||||
endif
|
||||
endif
|
||||
|
||||
# NEON
|
||||
ifeq ($(IS_NEON),1)
|
||||
ifeq ($(findstring -mfpu=neon,$(CXXFLAGS)),)
|
||||
NEON_FLAG += -mfpu=neon
|
||||
GCM_FLAG += -mfpu=neon
|
||||
ARIA_FLAG += -mfpu=neon
|
||||
BLAKE2_FLAG += -mfpu=neon
|
||||
CHACHA_FLAG += -mfpu=neon
|
||||
LEA_FLAG += -mfpu=neon
|
||||
SIMECK_FLAG += -mfpu=neon
|
||||
SIMON64_FLAG += -mfpu=neon
|
||||
SIMON128_FLAG += -mfpu=neon
|
||||
SPECK64_FLAG += -mfpu=neon
|
||||
SPECK128_FLAG += -mfpu=neon
|
||||
ifeq ($(IS_ANDROID),1)
|
||||
ifeq ($(findstring -mfloat-abi=softfp,$(CXXFLAGS)),)
|
||||
NEON_FLAG += -mfloat-abi=softfp
|
||||
GCM_FLAG += -mfloat-abi=softfp
|
||||
ARIA_FLAG += -mfloat-abi=softfp
|
||||
BLAKE2_FLAG += -mfloat-abi=softfp
|
||||
CHACHA_FLAG += -mfloat-abi=softfp
|
||||
LEA_FLAG += -mfloat-abi=softfp
|
||||
SIMECK_FLAG += -mfloat-abi=softfp
|
||||
SIMON64_FLAG += -mfloat-abi=softfp
|
||||
SIMON128_FLAG += -mfloat-abi=softfp
|
||||
SPECK64_FLAG += -mfloat-abi=softfp
|
||||
SPECK128_FLAG += -mfloat-abi=softfp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# ARMv8-a
|
||||
ifneq ($(IS_ARMv8),0)
|
||||
IS_NEON := $(shell $(CXX) $(CXXFLAGS) -march=armv8-a -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __ARM_NEON)
|
||||
ifeq ($(IS_NEON),1)
|
||||
ARIA_FLAG = -march=armv8-a
|
||||
BLAKE2_FLAG = -march=armv8-a
|
||||
CHACHA_FLAG = -march=armv8-a
|
||||
LEA_FLAG = -march=armv8-a
|
||||
NEON_FLAG = -march=armv8-a
|
||||
SIMECK_FLAG = -march=armv8-a
|
||||
SIMON64_FLAG = -march=armv8-a
|
||||
SIMON128_FLAG = -march=armv8-a
|
||||
SPECK64_FLAG = -march=armv8-a
|
||||
SPECK128_FLAG = -march=armv8-a
|
||||
endif
|
||||
HAVE_CRC := $(shell $(CXX) $(CXXFLAGS) -march=armv8-a+crc -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __ARM_FEATURE_CRC32)
|
||||
ifeq ($(HAVE_CRC),1)
|
||||
CRC_FLAG = -march=armv8-a+crc
|
||||
endif
|
||||
HAVE_CRYPTO := $(shell $(CXX) $(CXXFLAGS) -march=armv8-a+crypto -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __ARM_FEATURE_CRYPTO)
|
||||
ifeq ($(HAVE_CRYPTO),1)
|
||||
AES_FLAG = -march=armv8-a+crypto
|
||||
GCM_FLAG = -march=armv8-a+crypto
|
||||
SHA_FLAG = -march=armv8-a+crypto
|
||||
endif
|
||||
HAVE_CRYPTO := $(shell $(CXX) $(CXXFLAGS) -march=armv8.4-a+crypto -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __ARM_FEATURE_CRYPTO)
|
||||
ifeq ($(HAVE_CRYPTO),1)
|
||||
SM4_FLAG = -march=armv8.4-a+crypto
|
||||
endif
|
||||
endif
|
||||
|
||||
# i686 and x86_64
|
||||
ifneq ($(IS_i686)$(IS_x86_64),00)
|
||||
# SSE2 is a core feature of x86_64
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
||||
SSE_FLAG = -msse2
|
||||
CHACHA_FLAG = -msse2
|
||||
endif
|
||||
HAVE_SSSE3 = $(shell $(CXX) $(CXXFLAGS) -mssse3 -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __SSSE3__)
|
||||
ifeq ($(HAVE_SSSE3),1)
|
||||
ARIA_FLAG = -mssse3
|
||||
CHAM_FLAG = -mssse3
|
||||
LEA_FLAG = -mssse3
|
||||
SSSE3_FLAG = -mssse3
|
||||
SIMECK_FLAG = -mssse3
|
||||
SIMON128_FLAG = -mssse3
|
||||
SPECK128_FLAG = -mssse3
|
||||
endif
|
||||
HAVE_SSE4 = $(shell $(CXX) $(CXXFLAGS) -msse4.1 -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __SSE4_1__)
|
||||
ifeq ($(HAVE_SSE4),1)
|
||||
SIMON64_FLAG = -msse4.1
|
||||
SPECK64_FLAG = -msse4.1
|
||||
endif
|
||||
HAVE_SSE4 = $(shell $(CXX) $(CXXFLAGS) -msse4.2 -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __SSE4_2__)
|
||||
ifeq ($(HAVE_SSE4),1)
|
||||
BLAKE2_FLAG = -msse4.2
|
||||
CRC_FLAG = -msse4.2
|
||||
endif
|
||||
HAVE_CLMUL = $(shell $(CXX) $(CXXFLAGS) -mssse3 -mpclmul -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __PCLMUL__ )
|
||||
ifeq ($(HAVE_CLMUL),1)
|
||||
GCM_FLAG = -mssse3 -mpclmul
|
||||
endif
|
||||
HAVE_AES = $(shell $(CXX) $(CXXFLAGS) -msse4.1 -maes -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __AES__)
|
||||
ifeq ($(HAVE_AES),1)
|
||||
AES_FLAG = -msse4.1 -maes
|
||||
SM4_FLAG = -mssse3 -maes
|
||||
endif
|
||||
HAVE_SHA = $(shell $(CXX) $(CXXFLAGS) -msse4.2 -msha -dM -E pch.cpp 2>&1 | $(EGREP) -i -c __SHA__)
|
||||
ifeq ($(HAVE_SHA),1)
|
||||
SHA_FLAG = -msse4.2 -msha
|
||||
endif
|
||||
endif
|
||||
|
||||
###########################################################
|
||||
##### Source and object files #####
|
||||
###########################################################
|
||||
|
||||
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
|
||||
SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(sort $(wildcard *.cpp)))
|
||||
SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp cryptlib_bds.cpp,$(sort $(wildcard *.cpp)))
|
||||
# For Makefile.am; resource.h is Windows
|
||||
INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
|
||||
|
||||
# Cryptogams AES for ARMv4 and above. We couple to ARMv7.
|
||||
# Avoid iOS. It cannot consume the assembly.
|
||||
ifeq ($(IS_ARM32),1)
|
||||
CRYPTOGAMS_AES_FLAG = -march=armv7-a
|
||||
CRYPTOGAMS_AES_FLAG += -Wa,--noexecstack
|
||||
SRCS += aes_armv4.S
|
||||
ifneq ($(IS_IOS),1)
|
||||
CRYPTOGAMS_AES_FLAG = -march=armv7-a
|
||||
CRYPTOGAMS_AES_FLAG += -Wa,--noexecstack
|
||||
SRCS += aes_armv4.S
|
||||
endif
|
||||
endif
|
||||
|
||||
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
|
||||
@ -564,32 +776,44 @@ ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
|
||||
-include GNUmakefile.deps
|
||||
endif # Dependencies
|
||||
|
||||
# Cryptogams ARM asm implementation.
|
||||
aes_armv4.o : aes_armv4.S
|
||||
$(CXX) $(strip $(CXXFLAGS) -fpermissive $(CRYPTOGAMS_AES_FLAG) -c) $<
|
||||
|
||||
cpu-features.o: cpu-features.h cpu-features.c
|
||||
$(CXX) $(strip $(CXXFLAGS) -fpermissive -c) cpu-features.c
|
||||
|
||||
# Cryptogams ARM asm implementation.
|
||||
aes_armv4.o : aes_armv4.S
|
||||
$(CXX) $(strip $(CXXFLAGS) $(CRYPTOGAMS_AES_FLAG) -c) $<
|
||||
|
||||
# SSE4.2 or NEON available
|
||||
# SSSE3 or NEON available
|
||||
aria_simd.o : aria_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(ARIA_FLAG) -c) $<
|
||||
|
||||
# SSE4.2 or ARMv8a available
|
||||
blake2_simd.o : blake2-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(BLAKE2_FLAG) -c) $<
|
||||
# SSE, NEON or POWER7 available
|
||||
blake2s_simd.o : blake2s_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(BLAKE2S_FLAG) -c) $<
|
||||
|
||||
# SSE, NEON or POWER8 available
|
||||
blake2b_simd.o : blake2b_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(BLAKE2B_FLAG) -c) $<
|
||||
|
||||
# SSE2 or NEON available
|
||||
chacha_simd.o : chacha_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(CHACHA_FLAG) -c) $<
|
||||
|
||||
# AVX2 available
|
||||
chacha_avx.o : chacha_avx.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(CHACHA_AVX2_FLAG) -c) $<
|
||||
|
||||
# SSSE3 available
|
||||
cham_simd.o : cham_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(CHAM_FLAG) -c) $<
|
||||
|
||||
# Power9 available
|
||||
darn.o : darn.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(DARN_FLAG) -c) $<
|
||||
|
||||
# SSE2 on i586
|
||||
cpu.o : cpu.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(CPU_FLAG) -c) $<
|
||||
sse_simd.o : sse_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SSE2_FLAG) -c) $<
|
||||
|
||||
# SSE4.2 or ARMv8a available
|
||||
crc_simd.o : crc_simd.cpp
|
||||
@ -599,7 +823,7 @@ crc_simd.o : crc_simd.cpp
|
||||
gcm_simd.o : gcm_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(GCM_FLAG) -c) $<
|
||||
|
||||
# SSSE3 or ARMv8a available
|
||||
# SSSE3 available
|
||||
lea_simd.o : lea_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(LEA_FLAG) -c) $<
|
||||
|
||||
@ -639,6 +863,10 @@ speck64_simd.o : speck64_simd.cpp
|
||||
speck128_simd.o : speck128_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
|
||||
|
||||
# ARMv8.4 available
|
||||
sm3_simd.o : sm3_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SM3_FLAG) -c) $<
|
||||
|
||||
# AESNI available
|
||||
sm4_simd.o : sm4_simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SM4_FLAG) -c) $<
|
||||
@ -649,4 +877,3 @@ sm4_simd.o : sm4_simd.cpp
|
||||
.PHONY: dep deps depend
|
||||
dep deps depend GNUmakefile.deps:
|
||||
$(CXX) $(strip $(CXXFLAGS) -DCRYPTOPP_DISABLE_ASM) -MM *.cpp > GNUmakefile.deps
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user