2018-01-25 23:39:24 +00:00
|
|
|
# https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
|
2018-02-05 13:54:13 +00:00
|
|
|
# and https://www.gnu.org/prep/standards/standards.html
|
|
|
|
|
2018-01-25 23:39:24 +00:00
|
|
|
SHELL = /bin/sh
|
|
|
|
|
2017-05-27 02:20:38 +00:00
|
|
|
# Default CXXFLAGS if none were provided
|
|
|
|
CXXFLAGS ?= -DNDEBUG -g2 -O3 -fPIC -pipe
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-31 06:43:42 +00:00
|
|
|
AR ?= ar
|
|
|
|
ARFLAGS ?= cr
|
2015-11-05 06:59:46 +00:00
|
|
|
RANLIB ?= ranlib
|
2015-12-31 06:43:42 +00:00
|
|
|
CP ?= cp
|
|
|
|
MV ?= mv
|
|
|
|
CHMOD ?= chmod
|
2018-02-05 13:54:13 +00:00
|
|
|
MKDIR ?= mkdir -p
|
2015-12-31 06:43:42 +00:00
|
|
|
EGREP ?= egrep
|
2018-02-05 13:54:13 +00:00
|
|
|
|
2015-12-26 18:57:04 +00:00
|
|
|
LN ?= ln -sf
|
2017-12-16 14:07:23 +00:00
|
|
|
LDCONF ?= /sbin/ldconfig -n
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2018-02-05 13:54:13 +00:00
|
|
|
INSTALL = install
|
|
|
|
INSTALL_PROGRAM = $(INSTALL)
|
|
|
|
INSTALL_DATA = $(INSTALL) -m 644
|
|
|
|
|
2018-01-29 01:23:48 +00:00
|
|
|
# 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_ARM := $(shell echo "$HOSTX" | $(EGREP) -i -c 'arm')
|
|
|
|
IS_ARMv8 := $(shell echo "$HOSTX" | $(EGREP) -i -c 'aarch32|aarch64')
|
2017-12-30 23:38:40 +00:00
|
|
|
|
2017-09-13 21:16:57 +00:00
|
|
|
CLANG_COMPILER := $(shell $(CXX) --version 2>&1 | $(EGREP) -i -c "clang")
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
IS_IOS ?= 0
|
|
|
|
IS_ANDROID ?= 0
|
|
|
|
IS_ARM_EMBEDDED ?= 0
|
2017-09-18 00:07:53 +00:00
|
|
|
IS_NEON ?= 0
|
|
|
|
|
|
|
|
# Fixup ARM
|
|
|
|
ifeq ($(IS_ARMv8),1)
|
|
|
|
IS_ARM := 0
|
|
|
|
endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
2016-01-05 20:05:29 +00:00
|
|
|
# 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
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
# Default prefix for make install
|
|
|
|
ifeq ($(PREFIX),)
|
|
|
|
PREFIX = /usr/local
|
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-31 06:43:42 +00:00
|
|
|
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
|
|
|
|
ifeq ($(DATADIR),)
|
|
|
|
DATADIR := $(PREFIX)/share
|
|
|
|
endif
|
|
|
|
ifeq ($(LIBDIR),)
|
|
|
|
LIBDIR := $(PREFIX)/lib
|
|
|
|
endif
|
|
|
|
ifeq ($(BINDIR),)
|
|
|
|
BINDIR := $(PREFIX)/bin
|
|
|
|
endif
|
|
|
|
ifeq ($(INCLUDEDIR),)
|
|
|
|
INCLUDEDIR := $(PREFIX)/include
|
|
|
|
endif
|
|
|
|
|
|
|
|
# We honor ARFLAGS, but the "v" option used by default causes a noisy make
|
|
|
|
ifeq ($(ARFLAGS),rv)
|
|
|
|
ARFLAGS = r
|
|
|
|
endif
|
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
# 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)
|
2016-09-24 04:05:24 +00:00
|
|
|
CXXFLAGS += -Wall
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# iOS cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/iOS_(Command_Line).
|
|
|
|
ifeq ($(IS_IOS),1)
|
2015-11-05 06:59:46 +00:00
|
|
|
CXX = clang++
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(IOS_FLAGS) -arch $(IOS_ARCH)
|
2018-04-26 10:56:26 +00:00
|
|
|
CXXFLAGS += -isysroot "$(IOS_SYSROOT)" -stdlib=libc++
|
2015-06-08 11:50:22 +00:00
|
|
|
|
|
|
|
AR = libtool
|
|
|
|
ARFLAGS = -static -o
|
2015-12-08 19:55:58 +00:00
|
|
|
RANLIB = ranlib
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# Android cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/Android_(Command_Line).
|
|
|
|
ifeq ($(IS_ANDROID),1)
|
|
|
|
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-android.sh'
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(AOSP_FLAGS) -DANDROID --sysroot=$(AOSP_SYSROOT)
|
2018-01-28 20:29:14 +00:00
|
|
|
CXXFLAGS += -Wa,--noexecstack -I$(AOSP_STL_INC) -I$(AOSP_SYS_ARCH_INC)
|
2018-01-21 14:05:34 +00:00
|
|
|
LDFLAGS += --sysroot=$(AOSP_LD_SYSROOT)
|
2015-12-08 19:55:58 +00:00
|
|
|
|
|
|
|
# c++config.h shows up in odd places at times.
|
|
|
|
ifneq ($(AOSP_BITS_INC),)
|
|
|
|
CXXFLAGS += -I$(AOSP_BITS_INC)
|
|
|
|
endif
|
|
|
|
|
2017-09-13 11:16:41 +00:00
|
|
|
# STL headers
|
2015-12-08 19:55:58 +00:00
|
|
|
LDLIBS += $(AOSP_STL_LIB)
|
2017-09-13 11:16:41 +00:00
|
|
|
|
|
|
|
# Source files copied into PWD for Android cpu-features
|
|
|
|
# setenv-android.sh does the copying. Its a dirty compile.
|
|
|
|
AOSP_CPU_OBJ = cpu-features.o
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# ARM embedded cross-compile configuration.
|
2015-06-08 11:50:22 +00:00
|
|
|
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line)
|
|
|
|
# and http://www.cryptopp.com/wiki/ARM_Embedded_(Bare Metal).
|
|
|
|
ifeq ($(IS_ARM_EMBEDDED),1)
|
|
|
|
# CPP, CXX, AR, RANLIB, LD, etc are set in 'setenv-embedded.sh'
|
2015-12-08 19:55:58 +00:00
|
|
|
CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT)
|
2015-06-08 11:50:22 +00:00
|
|
|
endif
|
|
|
|
|
2017-05-27 02:20:38 +00:00
|
|
|
# No ASM for Travis testing
|
|
|
|
ifeq ($(findstring no-asm,$(MAKECMDGOALS)),no-asm)
|
|
|
|
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -DCRYPTOPP_DISABLE_ASM
|
|
|
|
endif # CXXFLAGS
|
|
|
|
endif # No ASM
|
|
|
|
|
|
|
|
# Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'.
|
|
|
|
ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
|
|
|
|
ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -fsanitize=undefined
|
|
|
|
endif # CXXFLAGS
|
|
|
|
ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -DCRYPTOPP_COVERAGE
|
|
|
|
endif # CXXFLAGS
|
|
|
|
endif # UBsan
|
|
|
|
|
|
|
|
# Address Sanitizer (Asan) testing. Issue 'make asan'.
|
|
|
|
ifeq ($(findstring asan,$(MAKECMDGOALS)),asan)
|
|
|
|
ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -fsanitize=address
|
|
|
|
endif # CXXFLAGS
|
|
|
|
ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -DCRYPTOPP_COVERAGE
|
|
|
|
endif # CXXFLAGS
|
|
|
|
ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -fno-omit-frame-pointer
|
|
|
|
endif # CXXFLAGS
|
|
|
|
endif # Asan
|
|
|
|
|
|
|
|
# LD gold linker testing. Triggered by 'LD=ld.gold'.
|
|
|
|
ifeq ($(findstring ld.gold,$(LD)),ld.gold)
|
|
|
|
ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),)
|
|
|
|
ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf")
|
|
|
|
ifneq ($(ELF_FORMAT),0)
|
|
|
|
LDFLAGS += -fuse-ld=gold
|
|
|
|
endif # ELF/ELF64
|
|
|
|
endif # CXXFLAGS
|
|
|
|
endif # Gold
|
|
|
|
|
|
|
|
# Valgrind testing. Issue 'make valgrind'.
|
|
|
|
ifneq ($(filter valgrind,$(MAKECMDGOALS)),)
|
|
|
|
# Tune flags; see http://valgrind.org/docs/manual/quick-start.html
|
|
|
|
CXXFLAGS := $(CXXFLAGS:-g%=-g3)
|
|
|
|
CXXFLAGS := $(CXXFLAGS:-O%=-O1)
|
|
|
|
CXXFLAGS := $(CXXFLAGS:-xO%=-xO1)
|
|
|
|
ifeq ($(findstring -DCRYPTOPP_VALGRIND,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -DCRYPTOPP_VALGRIND
|
|
|
|
endif # -DCRYPTOPP_VALGRIND
|
|
|
|
endif # Valgrind
|
|
|
|
|
|
|
|
# Debug testing on GNU systems. Triggered by -DDEBUG.
|
|
|
|
# Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268
|
|
|
|
ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),)
|
|
|
|
USING_GLIBCXX := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__GLIBCXX__")
|
|
|
|
ifneq ($(USING_GLIBCXX),0)
|
|
|
|
ifeq ($(HAS_NEWLIB),0)
|
|
|
|
ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -D_GLIBCXX_DEBUG
|
|
|
|
endif # CXXFLAGS
|
|
|
|
endif # HAS_NEWLIB
|
|
|
|
endif # USING_GLIBCXX
|
|
|
|
endif # GNU Debug build
|
|
|
|
|
2016-01-05 01:23:19 +00:00
|
|
|
# Dead code stripping. Issue 'make lean'.
|
|
|
|
ifeq ($(findstring lean,$(MAKECMDGOALS)),lean)
|
|
|
|
ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -ffunction-sections
|
|
|
|
endif # CXXFLAGS
|
|
|
|
ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),)
|
|
|
|
CXXFLAGS += -fdata-sections
|
|
|
|
endif # CXXFLAGS
|
2017-05-27 02:23:35 +00:00
|
|
|
ifneq ($(IS_IOS),0)
|
2016-01-05 01:23:19 +00:00
|
|
|
ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),)
|
|
|
|
LDFLAGS += -Wl,-dead_strip
|
|
|
|
endif # CXXFLAGS
|
|
|
|
else # BSD, Linux and Unix
|
|
|
|
ifeq ($(findstring -Wl,--gc-sections,$(LDFLAGS)),)
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
|
|
|
endif # LDFLAGS
|
|
|
|
endif # MAKECMDGOALS
|
|
|
|
endif # Dead code stripping
|
|
|
|
|
2017-09-18 00:07:53 +00:00
|
|
|
# Pickup ARMv7 and NEON. Do it after Android, iOS and Embedded flags have been set.
|
|
|
|
ifeq ($(IS_ARM),1)
|
|
|
|
IS_ARMv7 := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -dM -E - 2>/dev/null | $(EGREP) -i -c '__ARM_ARCH 7')
|
|
|
|
ifeq ($(IS_ARMv7),1)
|
|
|
|
IS_NEON := 1
|
|
|
|
else
|
|
|
|
IS_NEON := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -dM -E - 2>/dev/null | $(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
|
2018-06-23 07:54:51 +00:00
|
|
|
LEA_FLAG = -march=armv7-a
|
2017-09-18 00:07:53 +00:00
|
|
|
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
|
2018-06-23 07:54:51 +00:00
|
|
|
LEA_FLAG += -mfpu=neon
|
2018-02-19 04:23:50 +00:00
|
|
|
SIMON_FLAG += -mfpu=neon
|
|
|
|
SPECK_FLAG += -mfpu=neon
|
2017-09-18 00:07:53 +00:00
|
|
|
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
|
2018-06-23 07:54:51 +00:00
|
|
|
LEA_FLAG += -mfloat-abi=softfp
|
2018-02-19 04:23:50 +00:00
|
|
|
SIMON_FLAG += -mfloat-abi=softfp
|
|
|
|
SPECK_FLAG += -mfloat-abi=softfp
|
2017-09-18 00:07:53 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-09-13 21:16:57 +00:00
|
|
|
# ARMv8-a
|
2017-09-18 00:07:53 +00:00
|
|
|
ifneq ($(IS_ARMv8),0)
|
|
|
|
IS_NEON := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -march=armv8-a -dM -E - 2>/dev/null | $(EGREP) -i -c __ARM_NEON)
|
|
|
|
ifeq ($(IS_NEON),1)
|
2017-09-13 21:16:57 +00:00
|
|
|
ARIA_FLAG = -march=armv8-a
|
|
|
|
BLAKE2_FLAG = -march=armv8-a
|
2018-06-23 07:54:51 +00:00
|
|
|
LEA_FLAG = -march=armv8-a
|
2017-09-13 21:16:57 +00:00
|
|
|
NEON_FLAG = -march=armv8-a
|
2018-02-19 04:23:50 +00:00
|
|
|
SIMON_FLAG = -march=armv8-a
|
|
|
|
SPECK_FLAG = -march=armv8-a
|
2017-09-13 21:16:57 +00:00
|
|
|
endif
|
|
|
|
HAVE_CRC := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -march=armv8-a+crc -dM -E - 2>/dev/null | $(EGREP) -i -c __ARM_FEATURE_CRC32)
|
|
|
|
ifeq ($(HAVE_CRC),1)
|
|
|
|
CRC_FLAG = -march=armv8-a+crc
|
|
|
|
endif
|
|
|
|
HAVE_CRYPTO := $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -march=armv8-a+crypto -dM -E - 2>/dev/null | $(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
|
|
|
|
endif
|
|
|
|
|
2017-09-17 19:33:41 +00:00
|
|
|
# i686 and x86_64
|
|
|
|
ifneq ($(IS_i686)$(IS_x86_64),00)
|
|
|
|
HAVE_SSSE3 = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -mssse3 -dM -E - 2>/dev/null | $(EGREP) -i -c __SSSE3__)
|
|
|
|
ifeq ($(HAVE_SSSE3),1)
|
|
|
|
ARIA_FLAG = -mssse3
|
2018-06-19 22:03:28 +00:00
|
|
|
CHAM_FLAG = -mssse3
|
2018-06-22 20:26:27 +00:00
|
|
|
LEA_FLAG = -mssse3
|
2017-09-17 19:33:41 +00:00
|
|
|
SSSE3_FLAG = -mssse3
|
2018-02-19 04:23:50 +00:00
|
|
|
SIMON_FLAG = -mssse3
|
|
|
|
SPECK_FLAG = -mssse3
|
2018-01-27 17:23:44 +00:00
|
|
|
endif
|
|
|
|
HAVE_SSE4 = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -msse4.1 -dM -E - 2>/dev/null | $(EGREP) -i -c __SSE4_1__)
|
|
|
|
ifeq ($(HAVE_SSE4),1)
|
2018-02-19 04:23:50 +00:00
|
|
|
SIMON_FLAG = -msse4.1
|
|
|
|
SPECK_FLAG = -msse4.1
|
2017-09-17 19:33:41 +00:00
|
|
|
endif
|
|
|
|
HAVE_SSE4 = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -msse4.2 -dM -E - 2>/dev/null | $(EGREP) -i -c __SSE4_2__)
|
|
|
|
ifeq ($(HAVE_SSE4),1)
|
|
|
|
BLAKE2_FLAG = -msse4.2
|
|
|
|
CRC_FLAG = -msse4.2
|
|
|
|
endif
|
|
|
|
HAVE_CLMUL = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -mssse3 -mpclmul -dM -E - 2>/dev/null | $(EGREP) -i -c __PCLMUL__ )
|
|
|
|
ifeq ($(HAVE_CLMUL),1)
|
|
|
|
GCM_FLAG = -mssse3 -mpclmul
|
|
|
|
endif
|
|
|
|
HAVE_AES = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -msse4.1 -maes -dM -E - 2>/dev/null | $(EGREP) -i -c __AES__)
|
|
|
|
ifeq ($(HAVE_AES),1)
|
|
|
|
AES_FLAG = -msse4.1 -maes
|
|
|
|
endif
|
|
|
|
HAVE_SHA = $(shell echo | $(CXX) -x c++ $(CXXFLAGS) -msse4.2 -msha -dM -E - 2>/dev/null | $(EGREP) -i -c __SHA__)
|
|
|
|
ifeq ($(HAVE_SHA),1)
|
|
|
|
SHA_FLAG = -msse4.2 -msha
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-11-05 01:20:45 +00:00
|
|
|
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
|
2017-05-27 02:20:38 +00:00
|
|
|
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)))
|
2016-11-05 01:20:45 +00:00
|
|
|
|
2017-11-01 22:25:44 +00:00
|
|
|
# For Makefile.am; resource.h is Windows
|
|
|
|
INCL := $(filter-out resource.h,$(sort $(wildcard *.h)))
|
|
|
|
|
2016-11-05 01:20:45 +00:00
|
|
|
# List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems.
|
2015-11-05 06:59:46 +00:00
|
|
|
OBJS := $(SRCS:.cpp=.o)
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2016-11-05 01:20:45 +00:00
|
|
|
# List test.cpp first to tame C++ static initialization problems.
|
Add interface to TweetNaCl library (#566)
TweetNaCl is a compact reimplementation of the NaCl library by Daniel J. Bernstein, Bernard van Gastel, Wesley Janssen, Tanja Lange, Peter Schwabe and Sjaak Smetsers. The library is less than 20 KB in size and provides 25 of the NaCl library functions.
The compact library uses curve25519, XSalsa20, Poly1305 and SHA-512 as default primitives, and includes both x25519 key exchange and ed25519 signatures. The complete list of functions can be found in TweetNaCl: A crypto library in 100 tweets (20140917), Table 1, page 5.
Crypto++ retained the function names and signatures but switched to data types provided by <stdint.h> to promote interoperability with Crypto++ and avoid size problems on platforms like Cygwin. For example, NaCl typdef'd u64 as an unsigned long long, but Cygwin, MinGW and MSYS are LP64 systems (not LLP64 systems). In addition, Crypto++ was missing NaCl's signed 64-bit integer i64.
Crypto++ enforces the 0-key restriction due to small points. The TweetNaCl library allowed the 0-keys to small points. Also see RFC 7748, Elliptic Curves for Security, Section 6.
TweetNaCl is well written but not well optimized. It runs 2x to 3x slower than optimized routines from libsodium. However, the library is still 2x to 4x faster than the algorithms NaCl was designed to replace.
The Crypto++ wrapper for TweetNaCl requires OS features. That is, NO_OS_DEPENDENCE cannot be defined. It is due to TweetNaCl's internal function randombytes. Crypto++ used DefaultAutoSeededRNG within randombytes, so OS integration must be enabled. You can use another generator like RDRAND to avoid the restriction.
2018-01-18 03:02:09 +00:00
|
|
|
TESTSRCS := adhoc.cpp test.cpp bench1.cpp bench2.cpp validat0.cpp validat1.cpp validat2.cpp validat3.cpp validat4.cpp datatest.cpp regtest1.cpp regtest2.cpp regtest3.cpp fipsalgt.cpp dlltest.cpp
|
2017-11-01 22:25:44 +00:00
|
|
|
TESTINCL := bench.h factory.h validate.h
|
2015-12-08 19:55:58 +00:00
|
|
|
TESTOBJS := $(TESTSRCS:.cpp=.o)
|
2015-11-05 06:59:46 +00:00
|
|
|
LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# For Shared Objects, Diff, Dist/Zip rules
|
|
|
|
LIB_VER := $(shell $(EGREP) "define CRYPTOPP_VERSION" config.h | cut -d" " -f 3)
|
|
|
|
LIB_MAJOR := $(shell echo $(LIB_VER) | cut -c 1)
|
|
|
|
LIB_MINOR := $(shell echo $(LIB_VER) | cut -c 2)
|
|
|
|
LIB_PATCH := $(shell echo $(LIB_VER) | cut -c 3)
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
ifeq ($(strip $(LIB_PATCH)),)
|
|
|
|
LIB_PATCH := 0
|
|
|
|
endif
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
|
|
|
# Full version suffix for shared library
|
|
|
|
SOLIB_VERSION_SUFFIX=.$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)
|
2018-02-20 15:05:52 +00:00
|
|
|
# Different patchlevels and minors are compatible since 6.1
|
|
|
|
SOLIB_COMPAT_SUFFIX=.$(LIB_MAJOR)
|
2015-12-26 18:57:04 +00:00
|
|
|
SOLIB_FLAGS=-Wl,-soname,libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
endif # HAS_SOLIB_VERSION
|
|
|
|
|
2018-01-27 18:05:23 +00:00
|
|
|
# Default builds program with static library only
|
|
|
|
.PHONY: default
|
|
|
|
default: cryptest.exe
|
|
|
|
|
2015-12-29 00:30:01 +00:00
|
|
|
.PHONY: all
|
2018-01-27 18:05:23 +00:00
|
|
|
all: static dynamic cryptest.exe
|
2015-07-31 18:24:49 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
ifneq ($(IS_IOS),0)
|
2015-11-05 06:59:46 +00:00
|
|
|
static: libcryptopp.a
|
|
|
|
shared dynamic dylib: libcryptopp.dylib
|
|
|
|
else
|
2015-06-08 11:50:22 +00:00
|
|
|
static: libcryptopp.a
|
2015-12-26 18:57:04 +00:00
|
|
|
shared dynamic: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2018-01-27 18:05:23 +00:00
|
|
|
.PHONY: test check
|
|
|
|
test check: cryptest.exe
|
2015-06-08 11:50:22 +00:00
|
|
|
./cryptest.exe v
|
|
|
|
|
2016-01-05 01:23:19 +00:00
|
|
|
# CXXFLAGS are tuned earlier. Applications must use linker flags
|
|
|
|
# -Wl,--gc-sections (Linux and Unix) or -Wl,-dead_strip (OS X)
|
|
|
|
.PHONY: lean
|
|
|
|
lean: static dynamic cryptest.exe
|
|
|
|
|
2015-07-31 18:24:49 +00:00
|
|
|
.PHONY: clean
|
2015-06-08 11:50:22 +00:00
|
|
|
clean:
|
2017-09-13 22:58:07 +00:00
|
|
|
-$(RM) adhoc.cpp.o adhoc.cpp.proto.o $(LIBOBJS) $(AOSP_CPU_OBJ) $(TESTOBJS) $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTIMPORTOBJS) $(DLLTESTOBJS)
|
2017-03-09 09:01:36 +00:00
|
|
|
@-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a
|
|
|
|
@-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
|
|
|
@-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct rdrand-???.o
|
2017-11-05 08:42:39 +00:00
|
|
|
@-$(RM) *.la *.lo *.gcov *.gcno *.gcda *.stackdump core core-*
|
2017-03-09 09:01:36 +00:00
|
|
|
@-$(RM) /tmp/adhoc.exe
|
|
|
|
@-$(RM) -r /tmp/cryptopp_test/
|
|
|
|
@-$(RM) -r *.exe.dSYM/
|
|
|
|
@-$(RM) -r *.dylib.dSYM/
|
|
|
|
@-$(RM) -r cov-int/
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
.PHONY: distclean
|
|
|
|
distclean: clean
|
2017-11-01 22:30:49 +00:00
|
|
|
-$(RM) adhoc.cpp adhoc.cpp.copied GNUmakefile.deps benchmarks.html cryptest.txt cryptest-*.txt
|
2017-09-26 05:05:15 +00:00
|
|
|
@-$(RM) cryptopp.tgz *.o *.bc *.ii *~
|
2017-11-01 16:11:04 +00:00
|
|
|
@-$(RM) -r $(SRCS:.cpp=.obj) cryptlib.lib cryptest.exe *.suo *.sdf *.pdb Win32/ x64/ ipch/
|
2017-11-05 08:38:19 +00:00
|
|
|
@-$(RM) -f configure.ac configure configure.in Makefile.am Makefile.in Makefile
|
|
|
|
@-$(RM) -f config.guess config.status config.sub depcomp install-sh compile
|
2017-11-06 12:27:37 +00:00
|
|
|
@-$(RM) -f stamp-h1 ar-lib *.m4 local.* lt*.sh missing libtool* libcryptopp.pc*
|
2017-11-05 08:42:39 +00:00
|
|
|
@-$(RM) -rf m4/ auto*.cache/ .deps/ .libs/
|
2017-03-09 09:01:36 +00:00
|
|
|
@-$(RM) -r TestCoverage/
|
|
|
|
@-$(RM) cryptopp$(LIB_VER)\.*
|
|
|
|
@-$(RM) CryptoPPRef.zip
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2018-05-06 04:10:38 +00:00
|
|
|
# Install cryptest.exe, libcryptopp.a and libcryptopp.so.
|
|
|
|
# The library install was broken-out into its own recipe at GH #653.
|
2015-07-31 18:24:49 +00:00
|
|
|
.PHONY: install
|
2018-05-06 04:10:38 +00:00
|
|
|
install: cryptest.exe install-lib
|
2018-02-05 13:54:13 +00:00
|
|
|
@-$(MKDIR) $(DESTDIR)$(BINDIR)
|
|
|
|
$(INSTALL_PROGRAM) cryptest.exe $(DESTDIR)$(BINDIR)
|
|
|
|
@-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestData
|
|
|
|
@-$(MKDIR) $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
|
|
|
|
$(INSTALL_DATA) TestData/*.dat $(DESTDIR)$(DATADIR)/cryptopp/TestData
|
|
|
|
$(INSTALL_DATA) TestVectors/*.txt $(DESTDIR)$(DATADIR)/cryptopp/TestVectors
|
2018-05-06 04:10:38 +00:00
|
|
|
|
|
|
|
# A recipe to install only the library, and not cryptest.exe. Also
|
|
|
|
# see https://github.com/weidai11/cryptopp/issues/653.
|
|
|
|
.PHONY: install-lib
|
|
|
|
install-lib:
|
|
|
|
@-$(MKDIR) $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
$(INSTALL_DATA) *.h $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
2015-12-27 18:13:16 +00:00
|
|
|
ifneq ($(wildcard libcryptopp.a),)
|
2018-02-05 13:54:13 +00:00
|
|
|
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL_DATA) libcryptopp.a $(DESTDIR)$(LIBDIR)
|
2015-12-27 18:13:16 +00:00
|
|
|
endif
|
|
|
|
ifneq ($(wildcard libcryptopp.dylib),)
|
2018-02-05 13:54:13 +00:00
|
|
|
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
|
2018-02-05 14:03:21 +00:00
|
|
|
$(INSTALL_PROGRAM) libcryptopp.dylib $(DESTDIR)$(LIBDIR)
|
2015-12-27 18:13:16 +00:00
|
|
|
endif
|
|
|
|
ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
|
2018-02-05 13:54:13 +00:00
|
|
|
@-$(MKDIR) $(DESTDIR)$(LIBDIR)
|
2018-02-05 14:03:21 +00:00
|
|
|
$(INSTALL_PROGRAM) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
2017-12-16 14:07:23 +00:00
|
|
|
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so
|
|
|
|
$(LDCONF) $(DESTDIR)$(LIBDIR)
|
2015-12-26 18:57:04 +00:00
|
|
|
endif
|
2015-11-05 06:59:46 +00:00
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
.PHONY: remove uninstall
|
|
|
|
remove uninstall:
|
2015-12-31 06:43:42 +00:00
|
|
|
-$(RM) -r $(DESTDIR)$(INCLUDEDIR)/cryptopp
|
|
|
|
-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.a
|
|
|
|
-$(RM) $(DESTDIR)$(BINDIR)/cryptest.exe
|
2017-03-09 09:01:36 +00:00
|
|
|
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.dylib
|
|
|
|
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
|
|
|
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
@-$(RM) $(DESTDIR)$(LIBDIR)/libcryptopp.so
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2017-09-13 11:16:41 +00:00
|
|
|
libcryptopp.a: $(LIBOBJS) $(AOSP_CPU_OBJ)
|
|
|
|
$(AR) $(ARFLAGS) $@ $(LIBOBJS) $(AOSP_CPU_OBJ)
|
2015-06-08 11:50:22 +00:00
|
|
|
$(RANLIB) $@
|
|
|
|
|
2015-12-31 21:05:14 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
2015-12-26 18:57:04 +00:00
|
|
|
.PHONY: libcryptopp.so
|
2015-12-27 18:13:16 +00:00
|
|
|
libcryptopp.so: libcryptopp.so$(SOLIB_VERSION_SUFFIX)
|
2015-12-31 21:05:14 +00:00
|
|
|
endif
|
2015-12-26 18:57:04 +00:00
|
|
|
|
2015-12-27 18:13:16 +00:00
|
|
|
libcryptopp.so$(SOLIB_VERSION_SUFFIX): $(LIBOBJS)
|
2016-10-26 22:26:07 +00:00
|
|
|
$(CXX) -shared $(SOLIB_FLAGS) -o $@ $(strip $(CXXFLAGS)) -Wl,--exclude-libs,ALL $(LIBOBJS) $(LDFLAGS) $(LDLIBS)
|
2015-12-26 18:57:04 +00:00
|
|
|
ifeq ($(HAS_SOLIB_VERSION),1)
|
|
|
|
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so
|
|
|
|
-$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) libcryptopp.so$(SOLIB_COMPAT_SUFFIX)
|
|
|
|
endif
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
libcryptopp.dylib: $(LIBOBJS)
|
2016-10-26 22:26:07 +00:00
|
|
|
$(CXX) -dynamiclib -o $@ $(strip $(CXXFLAGS)) -install_name "$@" -current_version "$(LIB_MAJOR).$(LIB_MINOR).$(LIB_PATCH)" -compatibility_version "$(LIB_MAJOR).$(LIB_MINOR)" -headerpad_max_install_names $(LDFLAGS) $(LIBOBJS)
|
2015-12-08 19:55:58 +00:00
|
|
|
|
|
|
|
cryptest.exe: libcryptopp.a $(TESTOBJS)
|
2016-10-26 22:26:07 +00:00
|
|
|
$(CXX) -o $@ $(strip $(CXXFLAGS)) $(TESTOBJS) ./libcryptopp.a $(LDFLAGS) $(LDLIBS)
|
2015-06-08 11:50:22 +00:00
|
|
|
|
2015-12-08 19:55:58 +00:00
|
|
|
# Used to generate list of source files for Autotools, CMakeList and Android.mk
|
|
|
|
.PHONY: sources
|
|
|
|
sources:
|
2016-11-05 01:20:45 +00:00
|
|
|
$(info Library sources: $(filter-out $(TESTSRCS),$(SRCS)))
|
2015-12-08 19:55:58 +00:00
|
|
|
$(info )
|
2017-11-01 22:25:44 +00:00
|
|
|
$(info Library headers: $(filter-out $(TESTINCL),$(INCL)))
|
|
|
|
$(info )
|
2015-12-08 19:55:58 +00:00
|
|
|
$(info Test sources: $(TESTSRCS))
|
2017-11-01 22:25:44 +00:00
|
|
|
$(info )
|
|
|
|
$(info Test headers: $(TESTINCL))
|
2015-12-08 19:55:58 +00:00
|
|
|
|
2015-06-08 11:50:22 +00:00
|
|
|
adhoc.cpp: adhoc.cpp.proto
|
|
|
|
ifeq ($(wildcard adhoc.cpp),)
|
|
|
|
cp adhoc.cpp.proto adhoc.cpp
|
|
|
|
else
|
|
|
|
touch adhoc.cpp
|
|
|
|
endif
|
|
|
|
|
2015-11-18 20:35:35 +00:00
|
|
|
# Include dependencies, if present. You must issue `make deps` to create them.
|
|
|
|
ifeq ($(wildcard GNUmakefile.deps),GNUmakefile.deps)
|
|
|
|
-include GNUmakefile.deps
|
|
|
|
endif # Dependencies
|
|
|
|
|
2017-09-13 11:16:41 +00:00
|
|
|
cpu-features.o: cpu-features.h cpu-features.c
|
2017-09-13 21:16:57 +00:00
|
|
|
$(CXX) $(strip $(CXXFLAGS) -fpermissive -c) cpu-features.c
|
|
|
|
|
|
|
|
# SSE4.2 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) $<
|
|
|
|
|
2018-06-19 22:03:28 +00:00
|
|
|
# SSSE3 available
|
|
|
|
cham-simd.o : cham-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(CHAM_FLAG) -c) $<
|
|
|
|
|
2017-09-13 21:16:57 +00:00
|
|
|
# SSE2 on i586
|
|
|
|
cpu.o : cpu.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(CPU_FLAG) -c) $<
|
|
|
|
|
|
|
|
# SSE4.2 or ARMv8a available
|
|
|
|
crc-simd.o : crc-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(CRC_FLAG) -c) $<
|
|
|
|
|
|
|
|
# PCLMUL or ARMv7a/ARMv8a available
|
|
|
|
gcm-simd.o : gcm-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(GCM_FLAG) -c) $<
|
|
|
|
|
2018-06-23 07:54:51 +00:00
|
|
|
# SSSE3 or ARMv8a available
|
2018-06-22 20:26:27 +00:00
|
|
|
lea-simd.o : lea-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(LEA_FLAG) -c) $<
|
|
|
|
|
2017-09-13 21:16:57 +00:00
|
|
|
# NEON available
|
|
|
|
neon-simd.o : neon-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(NEON_FLAG) -c) $<
|
|
|
|
|
|
|
|
# AESNI or ARMv7a/ARMv8a available
|
|
|
|
rijndael-simd.o : rijndael-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(AES_FLAG) -c) $<
|
|
|
|
|
|
|
|
# SSE4.2/SHA-NI or ARMv8a available
|
|
|
|
sha-simd.o : sha-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
|
|
|
|
|
|
|
|
# SSE4.2/SHA-NI or ARMv8a available
|
|
|
|
shacal2-simd.o : shacal2-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(SHA_FLAG) -c) $<
|
2017-09-13 11:16:41 +00:00
|
|
|
|
2018-02-19 04:23:50 +00:00
|
|
|
# SSSE3 or NEON available
|
|
|
|
simon-simd.o : simon-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(SIMON_FLAG) -c) $<
|
|
|
|
|
|
|
|
# SSSE3 or NEON available
|
|
|
|
speck-simd.o : speck-simd.cpp
|
|
|
|
$(CXX) $(strip $(CXXFLAGS) $(SPECK_FLAG) -c) $<
|
|
|
|
|
2015-06-08 11:50:22 +00:00
|
|
|
%.o : %.cpp
|
2017-09-13 21:16:57 +00:00
|
|
|
$(CXX) $(strip $(CXXFLAGS) -c) $<
|
2015-07-20 10:55:42 +00:00
|
|
|
|
2015-11-05 06:59:46 +00:00
|
|
|
GNUmakefile.deps:
|
2017-09-13 21:16:57 +00:00
|
|
|
$(CXX) $(strip $(CXXFLAGS) -MM) *.cpp > GNUmakefile.deps
|