From bf4cf9de833e2d571d98d1ca935ea08a3468e463 Mon Sep 17 00:00:00 2001 From: Kamel Bouhara Date: Tue, 28 Jul 2020 11:53:46 +0200 Subject: [PATCH] package/cryptopp: add a target variant So far, cryptopp only had a host variant, but some use-cases require this library on the target, so this adjusts the cryptopp package accordingly. One patch (submitted upstream) is needed to have the proper symlink corresponding to the SONAME of the shared library. Signed-off-by: Kamel Bouhara Signed-off-by: Thomas Petazzoni --- package/Config.in | 1 + ...e-add-missing-shared-library-symlink.patch | 62 +++++++++++++++++++ package/cryptopp/Config.in | 8 +++ package/cryptopp/cryptopp.mk | 31 ++++++++++ 4 files changed, 102 insertions(+) create mode 100644 package/cryptopp/0001-GNUmakefile-add-missing-shared-library-symlink.patch create mode 100644 package/cryptopp/Config.in diff --git a/package/Config.in b/package/Config.in index 3a0cc0c585..b424d20de4 100644 --- a/package/Config.in +++ b/package/Config.in @@ -1397,6 +1397,7 @@ menu "Crypto" source "package/botan/Config.in" source "package/ca-certificates/Config.in" source "package/cryptodev/Config.in" + source "package/cryptopp/Config.in" source "package/gcr/Config.in" source "package/gnutls/Config.in" source "package/libargon2/Config.in" diff --git a/package/cryptopp/0001-GNUmakefile-add-missing-shared-library-symlink.patch b/package/cryptopp/0001-GNUmakefile-add-missing-shared-library-symlink.patch new file mode 100644 index 0000000000..5f87414d53 --- /dev/null +++ b/package/cryptopp/0001-GNUmakefile-add-missing-shared-library-symlink.patch @@ -0,0 +1,62 @@ +From e4c2e3bc8174f24cf63923619f5d06d85b84ae1d Mon Sep 17 00:00:00 2001 +From: Kamel Bouhara +Date: Fri, 7 Jan 2022 22:59:23 +0100 +Subject: [PATCH] GNUmakefile: add missing shared library symlink + +The GNUmakefile install-lib target currently installs the following +symlink: + + libcryptopp.so -> libcryptopp.so.8.6.0 + +However, it does not create the following symlink: + + libcryptopp.so.8 -> libcryptopp.so.8.6.0 + +This symlink is necessary at runtime because libcryptopp.so.8 is the +SONAME of the cryptopp library, and therefore this is what the dynamic +loader will search when starting a program that is linked against +cryptopp. + +For native compilation, the 'ldconfig' invocation that immediately +follows will create that symlink, so everything works. + +For cross-compilation however, ldconfig can't be used, and therefore +LDCONFIG is passed as /bin/true, and therefore it doesn't create the +symlink. So instead, create it directly inside the GNUmakefile, +without relying on ldconfig. + +Upstream: https://github.com/weidai11/cryptopp/pull/1101 +Signed-off-by: Kamel Bouhara +Signed-off-by: Thomas Petazzoni +--- + GNUmakefile | 1 + + GNUmakefile-cross | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/GNUmakefile b/GNUmakefile +index 23273edb..3b55e420 100644 +--- a/GNUmakefile ++++ b/GNUmakefile +@@ -1412,6 +1412,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),) + $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX) + ifeq ($(HAS_SOLIB_VERSION),1) + -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so ++ -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX) + $(LDCONF) $(DESTDIR)$(LIBDIR) + endif + endif +diff --git a/GNUmakefile-cross b/GNUmakefile-cross +index 9847f04b..a2b87e4a 100644 +--- a/GNUmakefile-cross ++++ b/GNUmakefile-cross +@@ -856,6 +856,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),) + $(CHMOD) u=rwx,go=rx $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_VERSION_SUFFIX) + ifeq ($(HAS_SOLIB_VERSION),1) + -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so ++ -$(LN) libcryptopp.so$(SOLIB_VERSION_SUFFIX) $(DESTDIR)$(LIBDIR)/libcryptopp.so$(SOLIB_COMPAT_SUFFIX) + $(LDCONF) $(DESTDIR)$(LIBDIR) + endif + endif +-- +2.33.1 + diff --git a/package/cryptopp/Config.in b/package/cryptopp/Config.in new file mode 100644 index 0000000000..4ead5339ab --- /dev/null +++ b/package/cryptopp/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_CRYPTOPP + bool "cryptopp" + depends on !BR2_STATIC_LIBS + help + A free C++ class library of cryptographic schemes + +comment "cryptopp needs a toolchain w/ dynamic library" + depends on BR2_STATIC_LIBS diff --git a/package/cryptopp/cryptopp.mk b/package/cryptopp/cryptopp.mk index 6711a37fbc..5e6eb9644d 100644 --- a/package/cryptopp/cryptopp.mk +++ b/package/cryptopp/cryptopp.mk @@ -36,4 +36,35 @@ define HOST_CRYPTOPP_INSTALL_CMDS $(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(HOST_DIR) install-lib endef +define CRYPTOPP_EXTRACT_CMDS + $(UNZIP) $(CRYPTOPP_DL_DIR)/$(CRYPTOPP_SOURCE) -d $(@D) +endef + +CRYPTOPP_CXXFLAGS = $(TARGET_CXXFLAGS) -fPIC + +# _mm256_broadcastsi128_si256 has been added only in gcc 4.9 +ifneq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_9),y) +CRYPTOPP_CXXFLAGS += -DCRYPTOPP_DISABLE_AVX2 +endif + +CRYPTOPP_MAKE_OPTS = \ + $(TARGET_CONFIGURE_OPTS) \ + CXXFLAGS="$(CRYPTOPP_CXXFLAGS)" + +define CRYPTOPP_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(CRYPTOPP_MAKE_OPTS) \ + PREFIX=/usr shared libcryptopp.pc +endef + +define CRYPTOPP_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=/usr DESTDIR=$(TARGET_DIR) \ + LDCONFIG=/bin/true install-lib +endef + +define CRYPTOPP_INSTALL_STAGING_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=/usr DESTDIR=$(STAGING_DIR) \ + LDCONFIG=/bin/true install-lib +endef + +$(eval $(generic-package)) $(eval $(host-generic-package))