Skip to contentSkip to conversation

package/cryptopp: add a target build configuration

PATCH In review Kamel Bouhara 2 participants 2 messages Jul 28, 2020 – Jan 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package/cryptopp: add a target build configuration

Currently only a host build is supported for cryptopp, this add a new configuration and build support for the make target.

---
Changes in v3:
- Added explicit configuration with LDCONF=/bin/true to make sure symlink will exist on both target and host.
- Improved patch commit description

Changes in v2:
- Fixed indentations issue
- Removed unrequired Config.in.host
- Added a depends on !BR2_STATIC_LIBS to build only in dynamic configuration.
- Fixed inconsistency between TARGET_INSTALL and STAGING_INSTALL

---
 package/Config.in                             |  1 +
 ...ied-SONAME-to-shared-object-for-Linu.patch | 30 +++++++++++++++++++
 package/cryptopp/Config.in                    |  8 +++++
 package/cryptopp/cryptopp.mk                  | 26 +++++++++++++++-
 4 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100644 package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch
 create mode 100644 package/cryptopp/Config.in
package/Config.in +1 -0
index 9c4843be07..014f57a54a 100644
@@ -1279,6 +1279,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"
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +30 -0
new file mode 100644
index 0000000000..11f3090767
@@ -0,0 +1,30 @@
+From 78eb43f50978ffd780cf31b1cea6736dadc6b155 Mon Sep 17 00:00:00 2001
+From: Kamel Bouhara <[email protected]>
+Date: Mon, 6 Jul 2020 17:10:55 +0200
+Subject: [PATCH] Add fully-qualified SONAME to shared object for Linux
+
+From: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
+
+Add SONAME libcryptopp.so.8 required for library runtime and application
+linking.
+
+Signed-off-by: Kamel Bouhara <[email protected]>
+---
+ GNUmakefile | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/GNUmakefile b/GNUmakefile
+index e7b7b3a6..730e2a6f 100755
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -1256,6 +1256,7 @@ ifneq ($(wildcard libcryptopp.so$(SOLIB_VERSION_SUFFIX)),)
+ 	$(CHMOD) 0755 $(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.26.2
+
package/cryptopp/Config.in new file +8 -0
new file mode 100644
index 0000000000..4ead5339ab
@@ -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
package/cryptopp/cryptopp.mk +25 -1
index f1d19386ab..e77287467d 100644
@@ -31,7 +31,31 @@ define HOST_CRYPTOPP_BUILD_CMDS
 endef
 
 define HOST_CRYPTOPP_INSTALL_CMDS
-	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(HOST_DIR) install-lib
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(HOST_DIR)" LDCONFIG=/bin/true install-lib
 endef
 
+define CRYPTOPP_EXTRACT_CMDS
+	$(UNZIP) $(CRYPTOPP_DL_DIR)/$(CRYPTOPP_SOURCE) -d $(@D)
+endef
+
+CRYPTOPP_CXXFLAGS = $(TARGET_CFLAGS) -fPIC
+
+CRYPTOPP_MAKE_OPTS = \
+	$(TARGET_CONFIGURE_OPTS) \
+	CXXFLAGS="$(CRYPTOPP_CXXFLAGS)"
+
+define CRYPTOPP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(CRYPTOPP_MAKE_OPTS) shared
+endef
+
+define CRYPTOPP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(TARGET_DIR)" LDCONFIG=/bin/true install-lib
+endef
+
+define CRYPTOPP_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(STAGING_DIR)" libcryptopp.pc
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(STAGING_DIR)" LDCONFIG=/bin/true install-lib
+endef
+
+$(eval $(generic-package))
 $(eval $(host-generic-package))

--
2.27.0

#1 lore raw

Hello Kamel,

I finally applied, but with a good number of changes, see below.

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch line 4

Quoted 10 lines · On Tue, 28 Jul 2020 11:53:46 +0200 Kamel Bouhara <[email protected]>…
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +4 -0
new file mode 100644
index 0000000000..11f3090767
@@ -0,0 +1,30 @@
+From 78eb43f50978ffd780cf31b1cea6736dadc6b155 Mon Sep 17 00:00:00 2001
+From: Kamel Bouhara <[email protected]>
+Date: Mon, 6 Jul 2020 17:10:55 +0200
+Subject: [PATCH] Add fully-qualified SONAME to shared object for Linux

That's not really what the patch does. What it does is create a symlink that matches with the SONAME of the library. The question is: how was it working before. Answer: because of the ldconfig call that creates such symlinks. But of course, we don't call ldconfig when cross-compiling, hence the need for your change.

So, I improved the commit log, also changed the GNUmakefile-cross file, and submitted that upstream:

https://github.com/weidai11/cryptopp/pull/1101

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch

Quoted 3 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -1
 define HOST_CRYPTOPP_INSTALL_CMDS
-	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX=$(HOST_DIR) install-lib
+	$(HOST_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(HOST_DIR)" LDCONFIG=/bin/true install-lib

These are unrelated changes, so I dropped them.

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch

Quoted 11 lines

endef

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +9 -0
+define CRYPTOPP_EXTRACT_CMDS
+	$(UNZIP) $(CRYPTOPP_DL_DIR)/$(CRYPTOPP_SOURCE) -d $(@D)
+endef
+
+CRYPTOPP_CXXFLAGS = $(TARGET_CFLAGS) -fPIC
+
+CRYPTOPP_MAKE_OPTS = \
+	$(TARGET_CONFIGURE_OPTS) \
+	CXXFLAGS="$(CRYPTOPP_CXXFLAGS)"

You were missing the logic to handle gcc < 4.9 that exists for the host package, and that we also need for the target package.

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch

Quoted 7 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +7 -0
+
+define CRYPTOPP_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(CRYPTOPP_MAKE_OPTS) shared
+endef
+
+define CRYPTOPP_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(TARGET_DIR)" LDCONFIG=/bin/true install-lib

PREFIX=$(TARGET_DIR) is wrong. It should have been PREFIX=/usr DESTDIR=$(TARGET_DIR)

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch

Quoted 4 lines
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +4 -0
+endef
+
+define CRYPTOPP_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(STAGING_DIR)" libcryptopp.pc

Building the libcryptopp.pc file is really a build step, so I moved this to the build step.

package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch

Quoted 1 line
package/cryptopp/0001-Add-fully-qualified-SONAME-to-shared-object-for-Linu.patch new file +1 -0
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) PREFIX="$(STAGING_DIR)" LDCONFIG=/bin/true install-lib

Same as above, PREFIX=$(STAGING_DIR) is wrong, it should be PREFIX=/usr DESTDIR=$(STAGING_DIR)

Applied with those changes. Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot